bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] frexp, tests: work around ICC bug with -zero


From: Eric Blake
Subject: [PATCH 1/2] frexp, tests: work around ICC bug with -zero
Date: Thu, 4 Nov 2010 16:34:32 -0600

* 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 <address@hidden>
---

Refactors everything so that future compiler workarounds necessary
to get at -0.0 can be limited to a single test file (.m4 files may
need more efforts, though).  Tested that all of these tests still
pass with gcc; there are still some ICC failures, but I think they
are due to NaN issues and not -0.0 issues (at any rate, I'll probably
have more patches coming up later).

 ChangeLog                      |   59 +++++++++++++++++++++++++++++++++
 m4/frexp.m4                    |   18 ++++++++--
 modules/ceilf-tests            |    1 +
 modules/ceill-tests            |    1 +
 modules/floorf-tests           |    1 +
 modules/floorl-tests           |    1 +
 modules/frexp-nolibm-tests     |    2 +
 modules/frexp-tests            |    1 +
 modules/frexpl-nolibm-tests    |    2 +
 modules/frexpl-tests           |    1 +
 modules/isnan-tests            |    1 +
 modules/isnand-nolibm-tests    |    1 +
 modules/isnand-tests           |    1 +
 modules/isnanf-nolibm-tests    |    1 +
 modules/isnanf-tests           |    1 +
 modules/isnanl-nolibm-tests    |    1 +
 modules/isnanl-tests           |    1 +
 modules/ldexpl-tests           |    1 +
 modules/round-tests            |    1 +
 modules/roundf-tests           |    1 +
 modules/roundl-tests           |    1 +
 modules/signbit-tests          |    1 +
 modules/snprintf-posix-tests   |    1 +
 modules/sprintf-posix-tests    |    1 +
 modules/strtod-tests           |    1 +
 modules/trunc-tests            |    1 +
 modules/truncf-tests           |    1 +
 modules/truncl-tests           |    1 +
 modules/vasnprintf-posix-tests |    1 +
 modules/vasprintf-posix-tests  |    1 +
 modules/vsnprintf-posix-tests  |    1 +
 modules/vsprintf-posix-tests   |    1 +
 tests/minus-zero.h             |   70 ++++++++++++++++++++++++++++++++++++++++
 tests/test-ceilf1.c            |    7 +---
 tests/test-ceill.c             |   19 +----------
 tests/test-floorf1.c           |    7 +---
 tests/test-floorl.c            |   19 +----------
 tests/test-frexp.c             |    7 +---
 tests/test-frexpl.c            |   19 +----------
 tests/test-isnan.c             |   29 ++---------------
 tests/test-isnand.h            |    7 +---
 tests/test-isnanf.h            |    7 +---
 tests/test-isnanl.h            |   19 +----------
 tests/test-ldexpl.c            |   19 +----------
 tests/test-round1.c            |    7 +---
 tests/test-roundf1.c           |    7 +---
 tests/test-roundl.c            |   19 +----------
 tests/test-signbit.c           |   35 ++++----------------
 tests/test-snprintf-posix.h    |   33 ++++---------------
 tests/test-sprintf-posix.h     |   33 ++++---------------
 tests/test-strtod.c            |   13 +++----
 tests/test-trunc1.c            |    7 +---
 tests/test-truncf1.c           |    7 +---
 tests/test-truncl.c            |   19 +----------
 tests/test-vasnprintf-posix.c  |   33 ++++---------------
 tests/test-vasprintf-posix.c   |   33 ++++---------------
 56 files changed, 251 insertions(+), 333 deletions(-)
 create mode 100644 tests/minus-zero.h

diff --git a/ChangeLog b/ChangeLog
index 68c0a75..9aca76a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,62 @@
+2010-11-04  Eric Blake  <address@hidden>
+
+       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.
+
 2010-11-03  Eric Blake  <address@hidden>

        tests: fix compiler warnings
diff --git a/m4/frexp.m4 b/m4/frexp.m4
index 530fdbc..bb9c439 100644
--- a/m4/frexp.m4
+++ b/m4/frexp.m4
@@ -104,12 +104,24 @@ AC_DEFUN([gl_FUNC_FREXP_WORKS],
 #include <float.h>
 #include <math.h>
 #include <string.h>
+/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
+   ICC 10.0 has a bug when optimizing the expression -zero.
+   The expression -DBL_MIN * DBL_MIN does not work when cross-compiling
+   to PowerPC on MacOS X 10.5.  */
+#if defined __hpux || defined __sgi || defined __ICC
+static double
+compute_minus_zero (void)
+{
+  return -DBL_MIN * DBL_MIN;
+}
+# define minus_zero compute_minus_zero ()
+#else
+double minus_zero = -0.0;
+#endif
 int main()
 {
   int i;
   volatile double x;
-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -zero instead.  */
   double zero = 0.0;
   /* Test on denormalized numbers.  */
   for (i = 1, x = 1.0; i >= DBL_MIN_EXP; i--, x *= 0.5)
@@ -132,7 +144,7 @@ int main()
       return 1;
   }
   /* Test on negative zero.  */
-  x = -zero;
+  x = minus_zero;
   {
     int exp;
     double y = frexp (x, &exp);
diff --git a/modules/ceilf-tests b/modules/ceilf-tests
index 09c9c78..040fd1b 100644
--- a/modules/ceilf-tests
+++ b/modules/ceilf-tests
@@ -1,6 +1,7 @@
 Files:
 tests/test-ceilf1.c
 tests/test-ceilf2.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/modules/ceill-tests b/modules/ceill-tests
index 48b9be3..09ae4f3 100644
--- a/modules/ceill-tests
+++ b/modules/ceill-tests
@@ -1,5 +1,6 @@
 Files:
 tests/test-ceill.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/modules/floorf-tests b/modules/floorf-tests
index 64b4e3c..3e9c045 100644
--- a/modules/floorf-tests
+++ b/modules/floorf-tests
@@ -1,6 +1,7 @@
 Files:
 tests/test-floorf1.c
 tests/test-floorf2.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/modules/floorl-tests b/modules/floorl-tests
index f7dd7bb..5273fb5 100644
--- a/modules/floorl-tests
+++ b/modules/floorl-tests
@@ -1,5 +1,6 @@
 Files:
 tests/test-floorl.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/modules/frexp-nolibm-tests b/modules/frexp-nolibm-tests
index 2d761c0..82ee57c 100644
--- a/modules/frexp-nolibm-tests
+++ b/modules/frexp-nolibm-tests
@@ -1,5 +1,7 @@
 Files:
 tests/test-frexp.c
+tests/minus-zero.h
+tests/nan.h
 tests/signature.h
 tests/macros.h

diff --git a/modules/frexp-tests b/modules/frexp-tests
index 32a9eca..3f669f9 100644
--- a/modules/frexp-tests
+++ b/modules/frexp-tests
@@ -1,5 +1,6 @@
 Files:
 tests/test-frexp.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/modules/frexpl-nolibm-tests b/modules/frexpl-nolibm-tests
index d9f6d4d..1648d95 100644
--- a/modules/frexpl-nolibm-tests
+++ b/modules/frexpl-nolibm-tests
@@ -1,5 +1,7 @@
 Files:
 tests/test-frexpl.c
+tests/minus-zero.h
+tests/nan.h
 tests/signature.h
 tests/macros.h

diff --git a/modules/frexpl-tests b/modules/frexpl-tests
index 4eb2e4b..a944634 100644
--- a/modules/frexpl-tests
+++ b/modules/frexpl-tests
@@ -1,5 +1,6 @@
 Files:
 tests/test-frexpl.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/modules/isnan-tests b/modules/isnan-tests
index a63b7cf..1bc2b72 100644
--- a/modules/isnan-tests
+++ b/modules/isnan-tests
@@ -1,5 +1,6 @@
 Files:
 tests/test-isnan.c
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h

diff --git a/modules/isnand-nolibm-tests b/modules/isnand-nolibm-tests
index 2ce8b6c..ee6f880 100644
--- a/modules/isnand-nolibm-tests
+++ b/modules/isnand-nolibm-tests
@@ -1,6 +1,7 @@
 Files:
 tests/test-isnand-nolibm.c
 tests/test-isnand.h
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h

diff --git a/modules/isnand-tests b/modules/isnand-tests
index b9964cc..a23ba4d 100644
--- a/modules/isnand-tests
+++ b/modules/isnand-tests
@@ -1,6 +1,7 @@
 Files:
 tests/test-isnand.c
 tests/test-isnand.h
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h

diff --git a/modules/isnanf-nolibm-tests b/modules/isnanf-nolibm-tests
index 6aab7e0..ff89c1d 100644
--- a/modules/isnanf-nolibm-tests
+++ b/modules/isnanf-nolibm-tests
@@ -1,6 +1,7 @@
 Files:
 tests/test-isnanf-nolibm.c
 tests/test-isnanf.h
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h

diff --git a/modules/isnanf-tests b/modules/isnanf-tests
index 2c09485..ba301df 100644
--- a/modules/isnanf-tests
+++ b/modules/isnanf-tests
@@ -1,6 +1,7 @@
 Files:
 tests/test-isnanf.c
 tests/test-isnanf.h
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h

diff --git a/modules/isnanl-nolibm-tests b/modules/isnanl-nolibm-tests
index 6d2f08e..78427b4 100644
--- a/modules/isnanl-nolibm-tests
+++ b/modules/isnanl-nolibm-tests
@@ -1,6 +1,7 @@
 Files:
 tests/test-isnanl-nolibm.c
 tests/test-isnanl.h
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h

diff --git a/modules/isnanl-tests b/modules/isnanl-tests
index 5cff0dd..68411fe 100644
--- a/modules/isnanl-tests
+++ b/modules/isnanl-tests
@@ -1,6 +1,7 @@
 Files:
 tests/test-isnanl.c
 tests/test-isnanl.h
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h

diff --git a/modules/ldexpl-tests b/modules/ldexpl-tests
index 3c4f251..223175f 100644
--- a/modules/ldexpl-tests
+++ b/modules/ldexpl-tests
@@ -1,5 +1,6 @@
 Files:
 tests/test-ldexpl.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/modules/round-tests b/modules/round-tests
index b52890c..9e154c8 100644
--- a/modules/round-tests
+++ b/modules/round-tests
@@ -1,6 +1,7 @@
 Files:
 tests/test-round1.c
 tests/test-round2.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/modules/roundf-tests b/modules/roundf-tests
index 8d99ab9..7ee4178 100644
--- a/modules/roundf-tests
+++ b/modules/roundf-tests
@@ -2,6 +2,7 @@ Files:
 tests/test-roundf1.c
 tests/test-round2.c
 tests/test-roundf2.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/modules/roundl-tests b/modules/roundl-tests
index bd1b5c9..f9bd467 100644
--- a/modules/roundl-tests
+++ b/modules/roundl-tests
@@ -1,5 +1,6 @@
 Files:
 tests/test-roundl.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/modules/signbit-tests b/modules/signbit-tests
index 10d7d7b..b824765 100644
--- a/modules/signbit-tests
+++ b/modules/signbit-tests
@@ -1,5 +1,6 @@
 Files:
 tests/test-signbit.c
+tests/minus-zero.h
 tests/macros.h
 m4/exponentf.m4
 m4/exponentd.m4
diff --git a/modules/snprintf-posix-tests b/modules/snprintf-posix-tests
index 4448cf5..9a5c3ab 100644
--- a/modules/snprintf-posix-tests
+++ b/modules/snprintf-posix-tests
@@ -2,6 +2,7 @@ Files:
 tests/test-snprintf-posix.c
 tests/test-snprintf-posix.h
 tests/test-snprintf.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/modules/sprintf-posix-tests b/modules/sprintf-posix-tests
index f6e4ce0..333c584 100644
--- a/modules/sprintf-posix-tests
+++ b/modules/sprintf-posix-tests
@@ -1,6 +1,7 @@
 Files:
 tests/test-sprintf-posix.c
 tests/test-sprintf-posix.h
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/modules/strtod-tests b/modules/strtod-tests
index bea7825..38aebe8 100644
--- a/modules/strtod-tests
+++ b/modules/strtod-tests
@@ -1,6 +1,7 @@
 Files:
 tests/test-strtod.c
 tests/signature.h
+tests/minus-zero.h
 tests/macros.h

 Depends-on:
diff --git a/modules/trunc-tests b/modules/trunc-tests
index ce1e979..6c254e0 100644
--- a/modules/trunc-tests
+++ b/modules/trunc-tests
@@ -1,6 +1,7 @@
 Files:
 tests/test-trunc1.c
 tests/test-trunc2.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/modules/truncf-tests b/modules/truncf-tests
index 746950d..27b93f2 100644
--- a/modules/truncf-tests
+++ b/modules/truncf-tests
@@ -1,6 +1,7 @@
 Files:
 tests/test-truncf1.c
 tests/test-truncf2.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/modules/truncl-tests b/modules/truncl-tests
index 6056a64..01bcf73 100644
--- a/modules/truncl-tests
+++ b/modules/truncl-tests
@@ -1,5 +1,6 @@
 Files:
 tests/test-truncl.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/modules/vasnprintf-posix-tests b/modules/vasnprintf-posix-tests
index 5320d88..e281d26 100644
--- a/modules/vasnprintf-posix-tests
+++ b/modules/vasnprintf-posix-tests
@@ -2,6 +2,7 @@ Files:
 tests/test-vasnprintf-posix.c
 tests/test-vasnprintf-posix2.sh
 tests/test-vasnprintf-posix2.c
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h
 m4/locale-fr.m4
diff --git a/modules/vasprintf-posix-tests b/modules/vasprintf-posix-tests
index 4be9c2b..8702bdc 100644
--- a/modules/vasprintf-posix-tests
+++ b/modules/vasprintf-posix-tests
@@ -1,5 +1,6 @@
 Files:
 tests/test-vasprintf-posix.c
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h

diff --git a/modules/vsnprintf-posix-tests b/modules/vsnprintf-posix-tests
index 530e57c..687d28d 100644
--- a/modules/vsnprintf-posix-tests
+++ b/modules/vsnprintf-posix-tests
@@ -2,6 +2,7 @@ Files:
 tests/test-vsnprintf-posix.c
 tests/test-snprintf-posix.h
 tests/test-vsnprintf.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/modules/vsprintf-posix-tests b/modules/vsprintf-posix-tests
index 7b5412f..2f04f87 100644
--- a/modules/vsprintf-posix-tests
+++ b/modules/vsprintf-posix-tests
@@ -1,6 +1,7 @@
 Files:
 tests/test-vsprintf-posix.c
 tests/test-sprintf-posix.h
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
diff --git a/tests/minus-zero.h b/tests/minus-zero.h
new file mode 100644
index 0000000..65bd1b4
--- /dev/null
+++ b/tests/minus-zero.h
@@ -0,0 +1,70 @@
+/* Macros for floating-point negative zero.
+   Copyright (C) 2010 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <float.h>
+
+/* minus_zerof represents the value -0.0f.  */
+
+/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f.
+   ICC 10.0 has a bug when optimizing the expression -zero.
+   The expression -FLT_MIN * FLT_MIN does not work when cross-compiling
+   to PowerPC on MacOS X 10.5.  */
+#if defined __hpux || defined __sgi || defined __ICC
+static float
+compute_minus_zerof (void)
+{
+  return -FLT_MIN * FLT_MIN;
+}
+# define minus_zerof compute_minus_zerof ()
+#else
+float minus_zerof = -0.0f;
+#endif
+
+
+/* minus_zerod represents the value -0.0.  */
+
+/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
+   ICC 10.0 has a bug when optimizing the expression -zero.
+   The expression -DBL_MIN * DBL_MIN does not work when cross-compiling
+   to PowerPC on MacOS X 10.5.  */
+#if defined __hpux || defined __sgi || defined __ICC
+static double
+compute_minus_zerod (void)
+{
+  return -DBL_MIN * DBL_MIN;
+}
+# define minus_zerod compute_minus_zerod ()
+#else
+double minus_zerod = -0.0;
+#endif
+
+/* minus_zerol represents the value -0.0L.  */
+
+/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L.
+   IRIX cc can't put -0.0L into .data, but can compute at runtime.
+   ICC 10.0 has a bug when optimizing the expression -zero.
+   The expression -LDBL_MIN * LDBL_MIN does not work when cross-compiling
+   to PowerPC on MacOS X 10.5.  */
+#if defined __hpux || defined __sgi || defined __ICC
+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
diff --git a/tests/test-ceilf1.c b/tests/test-ceilf1.c
index ff6db5e..86bb49e 100644
--- a/tests/test-ceilf1.c
+++ b/tests/test-ceilf1.c
@@ -24,19 +24,16 @@
 SIGNATURE_CHECK (ceilf, float, (float));

 #include "isnanf-nolibm.h"
+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f.
-   So we use -zero instead.  */
-float zero = 0.0f;
-
 int
 main ()
 {
   /* Zero.  */
   ASSERT (ceilf (0.0f) == 0.0f);
-  ASSERT (ceilf (-zero) == 0.0f);
+  ASSERT (ceilf (minus_zerof) == 0.0f);
   /* Positive numbers.  */
   ASSERT (ceilf (0.3f) == 1.0f);
   ASSERT (ceilf (0.7f) == 1.0f);
diff --git a/tests/test-ceill.c b/tests/test-ceill.c
index ec3c6b9..cac45b7 100644
--- a/tests/test-ceill.c
+++ b/tests/test-ceill.c
@@ -27,25 +27,10 @@ SIGNATURE_CHECK (ceill, long double, (long double));

 #include "fpucw.h"
 #include "isnanl-nolibm.h"
+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

-/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
-   So we use minus_zero 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_zero (void)
-{
-  return -LDBL_MIN * LDBL_MIN;
-}
-# define minus_zero compute_minus_zero ()
-#else
-long double minus_zero = -0.0L;
-#endif
-
 int
 main ()
 {
@@ -55,7 +40,7 @@ main ()

   /* Zero.  */
   ASSERT (ceill (0.0L) == 0.0L);
-  ASSERT (ceill (minus_zero) == 0.0L);
+  ASSERT (ceill (minus_zerol) == 0.0L);
   /* Positive numbers.  */
   ASSERT (ceill (0.3L) == 1.0L);
   ASSERT (ceill (0.7L) == 1.0L);
diff --git a/tests/test-floorf1.c b/tests/test-floorf1.c
index 389f42b..39261d8 100644
--- a/tests/test-floorf1.c
+++ b/tests/test-floorf1.c
@@ -24,19 +24,16 @@
 SIGNATURE_CHECK (floorf, float, (float));

 #include "isnanf-nolibm.h"
+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f.
-   So we use -zero instead.  */
-float zero = 0.0f;
-
 int
 main ()
 {
   /* Zero.  */
   ASSERT (floorf (0.0f) == 0.0f);
-  ASSERT (floorf (-zero) == 0.0f);
+  ASSERT (floorf (minus_zerof) == 0.0f);
   /* Positive numbers.  */
   ASSERT (floorf (0.3f) == 0.0f);
   ASSERT (floorf (0.7f) == 0.0f);
diff --git a/tests/test-floorl.c b/tests/test-floorl.c
index 5bbcaac..84717f8 100644
--- a/tests/test-floorl.c
+++ b/tests/test-floorl.c
@@ -27,25 +27,10 @@ SIGNATURE_CHECK (floorl, long double, (long double));

 #include "fpucw.h"
 #include "isnanl-nolibm.h"
+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

-/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
-   So we use minus_zero 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_zero (void)
-{
-  return -LDBL_MIN * LDBL_MIN;
-}
-# define minus_zero compute_minus_zero ()
-#else
-long double minus_zero = -0.0L;
-#endif
-
 int
 main ()
 {
@@ -55,7 +40,7 @@ main ()

   /* Zero.  */
   ASSERT (floorl (0.0L) == 0.0L);
-  ASSERT (floorl (minus_zero) == 0.0L);
+  ASSERT (floorl (minus_zerol) == 0.0L);
   /* Positive numbers.  */
   ASSERT (floorl (0.3L) == 0.0L);
   ASSERT (floorl (0.7L) == 0.0L);
diff --git a/tests/test-frexp.c b/tests/test-frexp.c
index d5ab7e5..b0f1a4e 100644
--- a/tests/test-frexp.c
+++ b/tests/test-frexp.c
@@ -26,6 +26,7 @@ SIGNATURE_CHECK (frexp, double, (double, int *));
 #include <float.h>

 #include "isnand-nolibm.h"
+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

@@ -34,10 +35,6 @@ SIGNATURE_CHECK (frexp, double, (double, int *));
 #undef exp
 #define exp exponent

-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -zero instead.  */
-double zero = 0.0;
-
 static double
 my_ldexp (double x, int d)
 {
@@ -96,7 +93,7 @@ main ()
   { /* Negative zero.  */
     int exp = -9999;
     double mantissa;
-    x = -zero;
+    x = minus_zerod;
     mantissa = frexp (x, &exp);
     ASSERT (exp == 0);
     ASSERT (mantissa == x);
diff --git a/tests/test-frexpl.c b/tests/test-frexpl.c
index 8d9d41d..831dffe 100644
--- a/tests/test-frexpl.c
+++ b/tests/test-frexpl.c
@@ -27,6 +27,7 @@ SIGNATURE_CHECK (frexpl, long double, (long double, int *));

 #include "fpucw.h"
 #include "isnanl-nolibm.h"
+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

@@ -48,22 +49,6 @@ SIGNATURE_CHECK (frexpl, long double, (long double, int *));
 # define MIN_NORMAL_EXP LDBL_MIN_EXP
 #endif

-/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
-   So we use minus_zero 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_zero (void)
-{
-  return -LDBL_MIN * LDBL_MIN;
-}
-# define minus_zero compute_minus_zero ()
-#else
-long double minus_zero = -0.0L;
-#endif
-
 static long double
 my_ldexp (long double x, int d)
 {
@@ -120,7 +105,7 @@ main ()
   { /* Negative zero.  */
     int exp = -9999;
     long double mantissa;
-    x = minus_zero;
+    x = minus_zerol;
     mantissa = frexpl (x, &exp);
     ASSERT (exp == 0);
     ASSERT (mantissa == x);
diff --git a/tests/test-isnan.c b/tests/test-isnan.c
index d1d05dc..104aa6f 100644
--- a/tests/test-isnan.c
+++ b/tests/test-isnan.c
@@ -29,33 +29,10 @@
 #include <float.h>
 #include <limits.h>

+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f.
-   So we use -zero instead.  */
-float zerof = 0.0f;
-
-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -zero 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
-
 static void
 test_float (void)
 {
@@ -67,7 +44,7 @@ test_float (void)
   ASSERT (!isnan (-2.718e30f));
   ASSERT (!isnan (-2.718e-30f));
   ASSERT (!isnan (0.0f));
-  ASSERT (!isnan (-zerof));
+  ASSERT (!isnan (minus_zerof));
   /* Infinite values.  */
   ASSERT (!isnan (1.0f / 0.0f));
   ASSERT (!isnan (-1.0f / 0.0f));
@@ -107,7 +84,7 @@ test_double (void)
   ASSERT (!isnan (-2.718e30));
   ASSERT (!isnan (-2.718e-30));
   ASSERT (!isnan (0.0));
-  ASSERT (!isnan (-zerod));
+  ASSERT (!isnan (minus_zerod));
   /* Infinite values.  */
   ASSERT (!isnan (1.0 / 0.0));
   ASSERT (!isnan (-1.0 / 0.0));
diff --git a/tests/test-isnand.h b/tests/test-isnand.h
index f986621..3756aaf 100644
--- a/tests/test-isnand.h
+++ b/tests/test-isnand.h
@@ -18,13 +18,10 @@

 #include <limits.h>

+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -zero instead.  */
-double zero = 0.0;
-
 int
 main ()
 {
@@ -36,7 +33,7 @@ main ()
   ASSERT (!isnand (-2.718e30));
   ASSERT (!isnand (-2.718e-30));
   ASSERT (!isnand (0.0));
-  ASSERT (!isnand (-zero));
+  ASSERT (!isnand (minus_zerod));
   /* Infinite values.  */
   ASSERT (!isnand (1.0 / 0.0));
   ASSERT (!isnand (-1.0 / 0.0));
diff --git a/tests/test-isnanf.h b/tests/test-isnanf.h
index d071b2c..b40f2e1 100644
--- a/tests/test-isnanf.h
+++ b/tests/test-isnanf.h
@@ -18,13 +18,10 @@

 #include <limits.h>

+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f.
-   So we use -zero instead.  */
-float zero = 0.0f;
-
 int
 main ()
 {
@@ -36,7 +33,7 @@ main ()
   ASSERT (!isnanf (-2.718e30f));
   ASSERT (!isnanf (-2.718e-30f));
   ASSERT (!isnanf (0.0f));
-  ASSERT (!isnanf (-zero));
+  ASSERT (!isnanf (minus_zerof));
   /* Infinite values.  */
   ASSERT (!isnanf (1.0f / 0.0f));
   ASSERT (!isnanf (-1.0f / 0.0f));
diff --git a/tests/test-isnanl.h b/tests/test-isnanl.h
index 1665cf4..0831ab3 100644
--- a/tests/test-isnanl.h
+++ b/tests/test-isnanl.h
@@ -19,25 +19,10 @@
 #include <float.h>
 #include <limits.h>

+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

-/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
-   So we use minus_zero 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_zero (void)
-{
-  return -LDBL_MIN * LDBL_MIN;
-}
-# define minus_zero compute_minus_zero ()
-#else
-long double minus_zero = -0.0L;
-#endif
-
 int
 main ()
 {
@@ -54,7 +39,7 @@ main ()
   ASSERT (!isnanl (-2.718e30L));
   ASSERT (!isnanl (-2.718e-30L));
   ASSERT (!isnanl (0.0L));
-  ASSERT (!isnanl (minus_zero));
+  ASSERT (!isnanl (minus_zerol));
   /* Infinite values.  */
   ASSERT (!isnanl (1.0L / 0.0L));
   ASSERT (!isnanl (-1.0L / 0.0L));
diff --git a/tests/test-ldexpl.c b/tests/test-ldexpl.c
index f3b4e6f..b520609 100644
--- a/tests/test-ldexpl.c
+++ b/tests/test-ldexpl.c
@@ -27,25 +27,10 @@ SIGNATURE_CHECK (ldexpl, long double, (long double, int));

 #include "fpucw.h"
 #include "isnanl-nolibm.h"
+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

-/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
-   So we use minus_zero 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_zero (void)
-{
-  return -LDBL_MIN * LDBL_MIN;
-}
-# define minus_zero compute_minus_zero ()
-#else
-long double minus_zero = -0.0L;
-#endif
-
 int
 main ()
 {
@@ -85,7 +70,7 @@ main ()
   }

   { /* Negative zero.  */
-    x = minus_zero;
+    x = minus_zerol;
     y = ldexpl (x, 0); ASSERT (y == x); ASSERT (signbit (x));
     y = ldexpl (x, 5); ASSERT (y == x); ASSERT (signbit (x));
     y = ldexpl (x, -5); ASSERT (y == x); ASSERT (signbit (x));
diff --git a/tests/test-round1.c b/tests/test-round1.c
index 5e20d1b..86fd1de 100644
--- a/tests/test-round1.c
+++ b/tests/test-round1.c
@@ -26,19 +26,16 @@
 SIGNATURE_CHECK (round, double, (double));

 #include "isnand-nolibm.h"
+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -zero instead.  */
-double zero = 0.0;
-
 int
 main ()
 {
   /* Zero.  */
   ASSERT (round (0.0) == 0.0);
-  ASSERT (round (-zero) == 0.0);
+  ASSERT (round (minus_zerod) == 0.0);
   /* Positive numbers.  */
   ASSERT (round (0.3) == 0.0);
   ASSERT (round (0.5) == 1.0);
diff --git a/tests/test-roundf1.c b/tests/test-roundf1.c
index 62c580e..33609bb 100644
--- a/tests/test-roundf1.c
+++ b/tests/test-roundf1.c
@@ -26,19 +26,16 @@
 SIGNATURE_CHECK (roundf, float, (float));

 #include "isnanf-nolibm.h"
+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f.
-   So we use -zero instead.  */
-float zero = 0.0f;
-
 int
 main ()
 {
   /* Zero.  */
   ASSERT (roundf (0.0f) == 0.0f);
-  ASSERT (roundf (-zero) == 0.0f);
+  ASSERT (roundf (minus_zerof) == 0.0f);
   /* Positive numbers.  */
   ASSERT (roundf (0.3f) == 0.0f);
   ASSERT (roundf (0.5f) == 1.0f);
diff --git a/tests/test-roundl.c b/tests/test-roundl.c
index fca60f0..f06db8a 100644
--- a/tests/test-roundl.c
+++ b/tests/test-roundl.c
@@ -29,25 +29,10 @@ SIGNATURE_CHECK (roundl, long double, (long double));

 #include "fpucw.h"
 #include "isnanl-nolibm.h"
+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

-/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
-   So we use minus_zero 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_zero (void)
-{
-  return -LDBL_MIN * LDBL_MIN;
-}
-# define minus_zero compute_minus_zero ()
-#else
-long double minus_zero = -0.0L;
-#endif
-
 int
 main ()
 {
@@ -57,7 +42,7 @@ main ()

   /* Zero.  */
   ASSERT (roundl (0.0L) == 0.0L);
-  ASSERT (roundl (minus_zero) == 0.0L);
+  ASSERT (roundl (minus_zerol) == 0.0L);
   /* Positive numbers.  */
   ASSERT (roundl (0.3L) == 0.0L);
   ASSERT (roundl (0.5L) == 1.0L);
diff --git a/tests/test-signbit.c b/tests/test-signbit.c
index 9581190..c763157 100644
--- a/tests/test-signbit.c
+++ b/tests/test-signbit.c
@@ -28,34 +28,13 @@
 #include <float.h>
 #include <limits.h>

+#include "minus-zero.h"
 #include "macros.h"

 float zerof = 0.0f;
 double zerod = 0.0;
 long double zerol = 0.0L;

-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f.
-   So we use -zerof instead.  */
-
-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -zerod instead.  */
-
-/* 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
-
 static void
 test_signbitf ()
 {
@@ -68,10 +47,10 @@ test_signbitf ()
   ASSERT (signbit (-2.718e-30f));
   /* Zeros.  */
   ASSERT (!signbit (0.0f));
-  if (1.0f / -zerof < 0)
-    ASSERT (signbit (-zerof));
+  if (1.0f / minus_zerof < 0)
+    ASSERT (signbit (minus_zerof));
   else
-    ASSERT (!signbit (-zerof));
+    ASSERT (!signbit (minus_zerof));
   /* Infinite values.  */
   ASSERT (!signbit (1.0f / 0.0f));
   ASSERT (signbit (-1.0f / 0.0f));
@@ -113,10 +92,10 @@ test_signbitd ()
   ASSERT (signbit (-2.718e-30));
   /* Zeros.  */
   ASSERT (!signbit (0.0));
-  if (1.0 / -zerod < 0)
-    ASSERT (signbit (-zerod));
+  if (1.0 / minus_zerod < 0)
+    ASSERT (signbit (minus_zerod));
   else
-    ASSERT (!signbit (-zerod));
+    ASSERT (!signbit (minus_zerod));
   /* Infinite values.  */
   ASSERT (!signbit (1.0 / 0.0));
   ASSERT (signbit (-1.0 / 0.0));
diff --git a/tests/test-snprintf-posix.h b/tests/test-snprintf-posix.h
index b796d5b..f55e49e 100644
--- a/tests/test-snprintf-posix.h
+++ b/tests/test-snprintf-posix.h
@@ -16,6 +16,7 @@

 /* Written by Bruno Haible <address@hidden>, 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
@@ -192,7 +173,7 @@ test_function (int (*my_snprintf) (char *, size_t, const 
char *, ...))
   { /* Negative zero.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%a %d", -zerod, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%a %d", minus_zerod, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0x0p+0 33") == 0);
     ASSERT (retval == strlen (result));
@@ -901,7 +882,7 @@ test_function (int (*my_snprintf) (char *, size_t, const 
char *, ...))
   { /* Negative zero.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%f %d", -zerod, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%f %d", minus_zerod, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
     ASSERT (retval == strlen (result));
@@ -1415,7 +1396,7 @@ test_function (int (*my_snprintf) (char *, size_t, const 
char *, ...))
   { /* Negative zero.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%F %d", -zerod, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%F %d", minus_zerod, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
     ASSERT (retval == strlen (result));
@@ -1738,7 +1719,7 @@ test_function (int (*my_snprintf) (char *, size_t, const 
char *, ...))
   { /* Negative zero.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%e %d", -zerod, 33, 44, 55);
+      my_snprintf (result, sizeof (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);
@@ -2403,7 +2384,7 @@ test_function (int (*my_snprintf) (char *, size_t, const 
char *, ...))
   { /* Negative zero.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%g %d", -zerod, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%g %d", minus_zerod, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0 33") == 0);
     ASSERT (retval == strlen (result));
diff --git a/tests/test-sprintf-posix.h b/tests/test-sprintf-posix.h
index a50e57c..3abe27e 100644
--- a/tests/test-sprintf-posix.h
+++ b/tests/test-sprintf-posix.h
@@ -16,6 +16,7 @@

 /* Written by Bruno Haible <address@hidden>, 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));
diff --git a/tests/test-strtod.c b/tests/test-strtod.c
index e1d04af..2617610 100644
--- a/tests/test-strtod.c
+++ b/tests/test-strtod.c
@@ -28,15 +28,12 @@ SIGNATURE_CHECK (strtod, double, (char const *, char **));
 #include <string.h>

 #include "isnand-nolibm.h"
+#include "minus-zero.h"
 #include "macros.h"

 /* Avoid requiring -lm just for fabs.  */
 #define FABS(d) ((d) < 0.0 ? -(d) : (d))

-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -zero instead.  */
-double zero = 0.0;
-
 int
 main (void)
 {
@@ -312,7 +309,7 @@ main (void)
     errno = 0;
     result = strtod (input, &ptr);
     ASSERT (result == 0.0);
-    ASSERT (!!signbit (result) == !!signbit (-zero)); /* IRIX 6.5, OSF/1 4.0 */
+    ASSERT (!!signbit (result) == !!signbit (minus_zerod)); /* IRIX 6.5, OSF/1 
4.0 */
     ASSERT (ptr == input + 2);
     ASSERT (errno == 0);
   }
@@ -407,7 +404,7 @@ main (void)
     errno = 0;
     result = strtod (input, &ptr);
     ASSERT (result == 0.0);
-    ASSERT (!!signbit (result) == !!signbit (-zero)); /* MacOS X 10.3, FreeBSD 
6.2, IRIX 6.5, OSF/1 4.0 */
+    ASSERT (!!signbit (result) == !!signbit (minus_zerod)); /* MacOS X 10.3, 
FreeBSD 6.2, IRIX 6.5, OSF/1 4.0 */
     ASSERT (ptr == input + 2);          /* glibc-2.3.6, MacOS X 10.3, FreeBSD 
6.2, AIX 7.1 */
     ASSERT (errno == 0);
   }
@@ -553,7 +550,7 @@ main (void)
        0 on negative underflow, even though quality of implementation
        demands preserving the sign.  Disable this test until fixed
        glibc is more prevalent.  */
-    ASSERT (!!signbit (result) == !!signbit (-zero)); /* glibc-2.3.6, mingw */
+    ASSERT (!!signbit (result) == !!signbit (minus_zerod)); /* glibc-2.3.6, 
mingw */
 #endif
     ASSERT (ptr == input + 10);
     ASSERT (errno == ERANGE);
@@ -972,7 +969,7 @@ main (void)
         errno = 0;
         result = strtod (input, &ptr);
         ASSERT (result == 0.0);
-        ASSERT (!!signbit (result) == !!signbit (-zero)); /* IRIX 6.5, OSF/1 
4.0 */
+        ASSERT (!!signbit (result) == !!signbit (minus_zerod)); /* IRIX 6.5, 
OSF/1 4.0 */
         ASSERT (ptr == input + m);
         ASSERT (errno == 0);
       }
diff --git a/tests/test-trunc1.c b/tests/test-trunc1.c
index 65b027a..69530b8 100644
--- a/tests/test-trunc1.c
+++ b/tests/test-trunc1.c
@@ -24,19 +24,16 @@
 SIGNATURE_CHECK (trunc, double, (double));

 #include "isnand-nolibm.h"
+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -zero instead.  */
-double zero = 0.0;
-
 int
 main ()
 {
   /* Zero.  */
   ASSERT (trunc (0.0) == 0.0);
-  ASSERT (trunc (-zero) == 0.0);
+  ASSERT (trunc (minus_zerod) == 0.0);
   /* Positive numbers.  */
   ASSERT (trunc (0.3) == 0.0);
   ASSERT (trunc (0.7) == 0.0);
diff --git a/tests/test-truncf1.c b/tests/test-truncf1.c
index 8b125a8..b5f48dd 100644
--- a/tests/test-truncf1.c
+++ b/tests/test-truncf1.c
@@ -24,19 +24,16 @@
 SIGNATURE_CHECK (truncf, float, (float));

 #include "isnanf-nolibm.h"
+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f.
-   So we use -zero instead.  */
-float zero = 0.0f;
-
 int
 main ()
 {
   /* Zero.  */
   ASSERT (truncf (0.0f) == 0.0f);
-  ASSERT (truncf (-zero) == 0.0f);
+  ASSERT (truncf (minus_zerof) == 0.0f);
   /* Positive numbers.  */
   ASSERT (truncf (0.3f) == 0.0f);
   ASSERT (truncf (0.7f) == 0.0f);
diff --git a/tests/test-truncl.c b/tests/test-truncl.c
index 4879075..ab1f444 100644
--- a/tests/test-truncl.c
+++ b/tests/test-truncl.c
@@ -27,25 +27,10 @@ SIGNATURE_CHECK (truncl, long double, (long double));

 #include "fpucw.h"
 #include "isnanl-nolibm.h"
+#include "minus-zero.h"
 #include "nan.h"
 #include "macros.h"

-/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
-   So we use minus_zero 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_zero (void)
-{
-  return -LDBL_MIN * LDBL_MIN;
-}
-# define minus_zero compute_minus_zero ()
-#else
-long double minus_zero = -0.0L;
-#endif
-
 int
 main ()
 {
@@ -55,7 +40,7 @@ main ()

   /* Zero.  */
   ASSERT (truncl (0.0L) == 0.0L);
-  ASSERT (truncl (minus_zero) == 0.0L);
+  ASSERT (truncl (minus_zerol) == 0.0L);
   /* Positive numbers.  */
   ASSERT (truncl (0.3L) == 0.0L);
   ASSERT (truncl (0.7L) == 0.0L);
diff --git a/tests/test-vasnprintf-posix.c b/tests/test-vasnprintf-posix.c
index 3a9879f..66b4eb4 100644
--- a/tests/test-vasnprintf-posix.c
+++ b/tests/test-vasnprintf-posix.c
@@ -29,6 +29,7 @@
 #include <string.h>

 #include "macros.h"
+#include "minus-zero.h"
 #include "nan.h"

 /* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0.  */
@@ -36,30 +37,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
@@ -225,7 +206,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, 
const char *, ...))
   { /* Negative zero.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%a %d", -zerod, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%a %d", minus_zerod, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0x0p+0 33") == 0);
@@ -1052,7 +1033,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, 
const char *, ...))
   { /* Negative zero.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%f %d", -zerod, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%f %d", minus_zerod, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
@@ -1662,7 +1643,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, 
const char *, ...))
   { /* Negative zero.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%F %d", -zerod, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%F %d", minus_zerod, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
@@ -2039,7 +2020,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, 
const char *, ...))
   { /* Negative zero.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%e %d", -zerod, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%e %d", minus_zerod, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000e+00 33") == 0
@@ -2806,7 +2787,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, 
const char *, ...))
   { /* Negative zero.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%g %d", -zerod, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%g %d", minus_zerod, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0 33") == 0);
diff --git a/tests/test-vasprintf-posix.c b/tests/test-vasprintf-posix.c
index ef19df8..cd48493 100644
--- a/tests/test-vasprintf-posix.c
+++ b/tests/test-vasprintf-posix.c
@@ -28,6 +28,7 @@
 #include <string.h>

 #include "macros.h"
+#include "minus-zero.h"
 #include "nan.h"

 /* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0.  */
@@ -35,30 +36,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
@@ -205,7 +186,7 @@ test_function (int (*my_asprintf) (char **, const char *, 
...))
   { /* Negative zero.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%a %d", -zerod, 33, 44, 55);
+      my_asprintf (&result, "%a %d", minus_zerod, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0x0p+0 33") == 0);
@@ -1032,7 +1013,7 @@ test_function (int (*my_asprintf) (char **, const char *, 
...))
   { /* Negative zero.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%f %d", -zerod, 33, 44, 55);
+      my_asprintf (&result, "%f %d", minus_zerod, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
@@ -1642,7 +1623,7 @@ test_function (int (*my_asprintf) (char **, const char *, 
...))
   { /* Negative zero.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%F %d", -zerod, 33, 44, 55);
+      my_asprintf (&result, "%F %d", minus_zerod, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
@@ -2019,7 +2000,7 @@ test_function (int (*my_asprintf) (char **, const char *, 
...))
   { /* Negative zero.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%e %d", -zerod, 33, 44, 55);
+      my_asprintf (&result, "%e %d", minus_zerod, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000e+00 33") == 0
@@ -2786,7 +2767,7 @@ test_function (int (*my_asprintf) (char **, const char *, 
...))
   { /* Negative zero.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%g %d", -zerod, 33, 44, 55);
+      my_asprintf (&result, "%g %d", minus_zerod, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0 33") == 0);
-- 
1.7.3.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]