This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Refactor tst-strtod-round.c for type-generic-ness
- 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" <libc-alpha at sourceware dot org>
- Date: Tue, 24 May 2016 20:49:45 +0000
- Subject: Re: [PATCH] Refactor tst-strtod-round.c for type-generic-ness
- Authentication-results: sourceware.org; auth=none
- References: <e35f4861-8872-f318-2a0d-78834725b4da at linux dot vnet dot ibm dot com>
On Tue, 24 May 2016, Paul E. Murphy wrote:
> I've left tst-strtod.h alone as the additional work needed to make
> it more type-generic is thus far unique.
It's not necessary for this patch, but note that GEN_TEST_STRTOD_FOREACH,
despite its name and comment, could actually be used as a general facility
for "generate some text for each floating-point type in succession". It
could be used in the definition of STRUCT_FOREACH_FLOAT if you wanted, for
example (maybe it would need to take variable arguments and pass them
through to mfunc) - and in that of STRTOD_TEST_FOREACH, and others. It's
the pieces relating to having expected results for every format, and
related to IBM long double being special, that are harder to do in a
generic way like that.
In any case, I think defining RND_* macros for each type, and IS_RND_OK,
_RND_OKld etc., is making things overly complicated and increasing the
number of bits of per-type code needed unnecessarily. Suppose you passed
the mode to test_in_one_mode. Then you can use ROUNDING_TESTS (FTYPE,
mode) in GEN_ONE_TEST to test whether rounding works for the type being
tested, rather than calling it in do_test (as in the checked-in code) or
in data initializers (as in your present code). The only reason
ROUNDING_TESTS might not be suitable is the case of IBM long double - but
the obvious way to address that is a conditional #undef and #define of
ROUNDING_TESTS_long_double in the IBM long double case.
> +/* Declare a member element for each floating point type
> + with a suffix matching FSUF above. */
Saying "above" seems wrong when FSUF is now commented in tst-strtod.h, not
in this file.
> +/* Declare a member element for each floating point type
> + of type with a suffix matching FSUF above. */
Likewise.
> +/* This macro is used in conjunction with the output from the
> + gen-tst-strtod-round utility to select the appropriately
> + rounded long double value for a given format. Note that
> + the literal suffix must be appended before the token is
> + potentially expanded, so we can fixup such mangling later on. */
> +#define TEST(s, \
> + fx, fd, fn, fz, fu, \
> + dx, dd, dn, dz, du, \
> + ld64ix, ld64id, ld64in, ld64iz, ld64iu, \
> + ld64mx, ld64md, ld64mn, ld64mz, ld64mu, \
> + ld106x, ld106d, ld106n, ld106z, ld106u, \
> + ld113x, ld113d, ld113n, ld113z, ld113u) \
> + { \
> + s, \
> + { fx, dx, LDC (ld53x, ld64ix, ld64mx, ld106x, ld113x) }, \
I think you mean dx as the first argument of LDC here.
--
Joseph S. Myers
joseph@codesourcery.com