This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCHv3 01/11] Begin refactor of libm-test.inc
- From: Joseph Myers <joseph at codesourcery dot com>
- To: "Paul E. Murphy" <murphyp at linux dot vnet dot ibm dot com>
- Cc: <libc-alpha at sourceware dot org>
- Date: Thu, 26 May 2016 22:45:15 +0000
- Subject: Re: [PATCHv3 01/11] Begin refactor of libm-test.inc
- Authentication-results: sourceware.org; auth=none
- References: <cover dot 1464297421 dot git dot murphyp at linux dot vnet dot ibm dot com> <c48cd38f893b8f563319b1270b7cfbc710ab93c1 dot 1464297421 dot git dot murphyp at linux dot vnet dot ibm dot com>
On Thu, 26 May 2016, Paul E. Murphy wrote:
> +/* Maximum character buffer to store a stringitized FLOAT value. */
> +# define FSTR_MAX (128)
No space after '#', as this isn't inside a preprocessor conditional.
OK with that change, *but* please note:
> @@ -428,8 +432,12 @@ print_float (FLOAT f)
> else if (isnan (f))
> printf ("qNaN\n");
> else
> - printf ("% .*" PRINTF_EXPR " % .*" PRINTF_XEXPR "\n",
> - TYPE_DECIMAL_DIG - 1, f, TYPE_HEX_DIG - 1, f);
> + {
> + char fstrn[FSTR_MAX], fstrx[FSTR_MAX];
> + FTOSTR (fstrn, FSTR_MAX, "% .*" PRINTF_EXPR, TYPE_DECIMAL_DIG - 1, f);
> + FTOSTR (fstrx, FSTR_MAX, "% .*" PRINTF_XEXPR, TYPE_HEX_DIG - 1, f);
> + printf ("%s %s\n", fstrn, fstrx);
> + }
This won't actually work for strfromf128, only snprintf. strfrom
functions don't take printf flags (' ') here, or '*' as precision. So
there is more work to do to adapt this to generate strings in a way that
will actually work for float128.
> @@ -851,10 +865,17 @@ check_float_internal (const char *test_name, FLOAT computed, FLOAT expected,
> print_float (expected);
> if (print_diff)
> {
> - printf (" difference: % .*" PRINTF_EXPR " % .*" PRINTF_XEXPR
> - "\n", TYPE_DECIMAL_DIG - 1, diff, TYPE_HEX_DIG - 1, diff);
> - printf (" ulp : % .4" PRINTF_NEXPR "\n", ulps);
> - printf (" max.ulp : % .4" PRINTF_NEXPR "\n", max_ulp);
> + char dstrn[FSTR_MAX], dstrx[FSTR_MAX];
> + char ustrn[FSTR_MAX], mustrn[FSTR_MAX];
> + FTOSTR (dstrn, FSTR_MAX, "% .*" PRINTF_EXPR,
> + TYPE_DECIMAL_DIG - 1, diff);
> + FTOSTR (dstrx, FSTR_MAX, "% .*" PRINTF_XEXPR,
> + TYPE_HEX_DIG - 1, diff);
> + FTOSTR (ustrn, FSTR_MAX, "% .4" PRINTF_NEXPR, ulps);
> + FTOSTR (mustrn, FSTR_MAX, "% .4" PRINTF_NEXPR, max_ulp);
Again, using printf ' ' flag isn't valid for strfrom functions.
--
Joseph S. Myers
joseph@codesourcery.com