This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] benchtests: Improve readability of JSON output
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: Will Newton <will dot newton at linaro dot org>, libc-alpha <libc-alpha at sourceware dot org>
- Date: Thu, 24 Apr 2014 10:38:35 +0000
- Subject: Re: [PATCH] benchtests: Improve readability of JSON output
- Authentication-results: sourceware.org; auth=none
- References: <1396949290-21346-1-git-send-email-will dot newton at linaro dot org> <5343C311 dot 1030101 at redhat dot com> <CANu=DmjuuVwD4iVC7+fA+7jmO_CCSuHXHAuRyCA-CLqHnGbE9Q at mail dot gmail dot com> <5343CE68 dot 1080208 at redhat dot com> <CANu=DmhKGALfv4Zy5zXv6Zhzm+qKS4URfO109jnLnthS+ee5mQ at mail dot gmail dot com> <Pine dot LNX dot 4 dot 64 dot 1404231421590 dot 13425 at digraph dot polyomino dot org dot uk> <5358BEF5 dot 2030708 at redhat dot com>
On Thu, 24 Apr 2014, Florian Weimer wrote:
> On 04/23/2014 04:26 PM, Joseph S. Myers wrote:
>
> > > > It's a pity that we don't have (on GNU/Linux at least) a canonical
> > > > library
> > > > to get gdtoa-type functionality from.
> > >
> > > I think the "a" specifier would work but JSON does not support hex
> > > formats.
> >
> > You can also use DECIMAL_DIG as the precision with "g" (presuming you are
> > in round-to-nearest mode for both output and input) (or FLT_DECIMAL_DIG,
> > DBL_DECIMAL_DIG, LDBL_DECIMAL_DIG, given C11). Is there something making
> > that unsuitable?
>
> What about the locale sensitivity?
Well, you can temporarily set the C locale for the current thread with
uselocale, just as you can set and restore the rounding mode with
fesetround. Would it be better to have snprintf_l (see discussion Jun /
Aug 2013; it appears Apple libc has such a function)? I'm not sure if we
have any clearly defined general principle for which (locale-dependent)
functions have *_l variants and which require you to use uselocale if you
want to call them with a locale other than the thread default.
Given snprintf_l *and* a GCC implementation of the TS 18661-1 FENV_ROUND
pragma *and* glibc defining snprintf_l to be affected by constant rounding
directions, this would reduce to a single function call in the scope of
"#pragma STDC FENV_ROUND FE_TONEAREST" (with a previous computation of a
locale_t value for the C locale to specify in that function call).
--
Joseph S. Myers
joseph@codesourcery.com