diff options
author | Eric Blake <eblake@redhat.com> | 2010-11-04 12:29:27 -0600 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2010-11-04 17:03:58 -0600 |
commit | 74f73e82d45826c2ba8e533ff3ec75fcf9e17361 (patch) | |
tree | 4eec22158bae54aced730780424b1a549f870d9b /tests/test-sprintf-posix.h | |
parent | 37059fdaaacaaa2e4c03f1768f919186f5f263c4 (diff) | |
download | gnulib-74f73e82d45826c2ba8e533ff3ec75fcf9e17361.tar.gz |
frexp, tests: work around ICC bug with -zero
* m4/frexp.m4 (gl_FUNC_FREXP_WORKS): Compute -0.0 in a way that
works with more compilers.
* tests/minus-zero.h: New file.
* modules/ceilf-tests (Files): Include it.
* modules/ceill-tests (Files): Likewise.
* modules/floorf-tests (Files): Likewise.
* modules/floorl-tests (Files): Likewise.
* modules/frexp-nolibm-tests (Files): Likewise.
* modules/frexp-tests (Files): Likewise.
* modules/frexpl-nolibm-tests (Files): Likewise.
* modules/frexpl-tests (Files): Likewise.
* modules/isnan-tests (Files): Likewise.
* modules/isnand-nolibm-tests (Files): Likewise.
* modules/isnand-tests (Files): Likewise.
* modules/isnanf-nolibm-tests (Files): Likewise.
* modules/isnanf-tests (Files): Likewise.
* modules/isnanl-nolibm-tests (Files): Likewise.
* modules/isnanl-tests (Files): Likewise.
* modules/round-tests (Files): Likewise.
* modules/roundf-tests (Files): Likewise.
* modules/roundl-tests (Files): Likewise.
* modules/ldexpl-tests (Files): Likewise.
* modules/signbit-tests (Files): Likewise.
* modules/snprintf-posix-tests (Files): Likewise.
* modules/sprintf-posix-tests (Files): Likewise.
* modules/strtod-tests (Files): Likewise.
* modules/trunc-tests (Files): Likewise.
* modules/truncf-tests (Files): Likewise.
* modules/truncl-tests (Files): Likewise.
* modules/vsnprintf-posix-tests (Files): Likewise.
* modules/vsprintf-posix-tests (Files): Likewise.
* modules/vasnprintf-posix-tests (Files): Likewise.
* modules/vasprintf-posix-tests (Files): Likewise.
* tests/test-ceilf1.c (main): Use it.
* tests/test-ceill.c (main): Likewise.
* tests/test-floorf1.c (main): Likewise.
* tests/test-floorl.c (main): Likewise.
* tests/test-frexp.c (main): Likewise.
* tests/test-frexpl.c (main): Likewise.
* tests/test-isnan.c (main): Likewise.
* tests/test-isnand.h (main): Likewise.
* tests/test-isnanf.h (main): Likewise.
* tests/test-isnanl.h (main): Likewise.
* tests/test-ldexpl.c (main): Likewise.
* tests/test-round.c (main): Likewise.
* tests/test-roundf.c (main): Likewise.
* tests/test-roundl.c (main): Likewise.
* tests/test-signbit.c (test_signbitf, test_signbitd)
(test_signbitl): Likewise.
* tests/test-snprintf-posix.h (test_function): Likewise.
* tests/test-sprintf-posix.h (test_function): Likewise.
* tests/test-strtod.c (main): Likewise.
* tests/test-trunc1.c (main): Likewise.
* tests/test-truncf1.c (main): Likewise.
* tests/test-truncl.c (main): Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'tests/test-sprintf-posix.h')
-rw-r--r-- | tests/test-sprintf-posix.h | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/tests/test-sprintf-posix.h b/tests/test-sprintf-posix.h index a50e57ca4d..3abe27e60e 100644 --- a/tests/test-sprintf-posix.h +++ b/tests/test-sprintf-posix.h @@ -16,6 +16,7 @@ /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ +#include "minus-zero.h" #include "nan.h" /* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */ @@ -23,30 +24,10 @@ static int have_minus_zero () { static double plus_zero = 0.0; - double minus_zero = - plus_zero; + double minus_zero = minus_zerod; return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0; } -/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. - So we use -zerod instead. */ -double zerod = 0.0; - -/* On HP-UX 10.20, negating 0.0L does not yield -0.0L. - So we use minus_zerol instead. - IRIX cc can't put -0.0L into .data, but can compute at runtime. - Note that the expression -LDBL_MIN * LDBL_MIN does not work on other - platforms, such as when cross-compiling to PowerPC on MacOS X 10.5. */ -#if defined __hpux || defined __sgi -static long double -compute_minus_zerol (void) -{ - return -LDBL_MIN * LDBL_MIN; -} -# define minus_zerol compute_minus_zerol () -#else -long double minus_zerol = -0.0L; -#endif - /* Representation of an 80-bit 'long double' as an initializer for a sequence of 'unsigned int' words. */ #ifdef WORDS_BIGENDIAN @@ -178,7 +159,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* Negative zero. */ char result[1000]; int retval = - my_sprintf (result, "%a %d", -zerod, 33, 44, 55); + my_sprintf (result, "%a %d", minus_zerod, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0x0p+0 33") == 0); ASSERT (retval == strlen (result)); @@ -887,7 +868,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* Negative zero. */ char result[1000]; int retval = - my_sprintf (result, "%f %d", -zerod, 33, 44, 55); + my_sprintf (result, "%f %d", minus_zerod, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); @@ -1401,7 +1382,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* Negative zero. */ char result[1000]; int retval = - my_sprintf (result, "%F %d", -zerod, 33, 44, 55); + my_sprintf (result, "%F %d", minus_zerod, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); @@ -1724,7 +1705,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* Negative zero. */ char result[1000]; int retval = - my_sprintf (result, "%e %d", -zerod, 33, 44, 55); + my_sprintf (result, "%e %d", minus_zerod, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000e+00 33") == 0 || strcmp (result, "-0.000000e+000 33") == 0); @@ -2389,7 +2370,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* Negative zero. */ char result[1000]; int retval = - my_sprintf (result, "%g %d", -zerod, 33, 44, 55); + my_sprintf (result, "%g %d", minus_zerod, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0 33") == 0); ASSERT (retval == strlen (result)); |