[PATCH] benchtests: Improve readability of JSON output
Joseph S. Myers
joseph@codesourcery.com
Thu Apr 24 10:38:00 GMT 2014
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
More information about the Libc-alpha
mailing list