frexp, tests: work around ICC bug with -zero
authorEric Blake <eblake@redhat.com>
Thu, 4 Nov 2010 18:29:27 +0000 (12:29 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 4 Nov 2010 23:03:58 +0000 (17:03 -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 <eblake@redhat.com>
56 files changed:
ChangeLog
m4/frexp.m4
modules/ceilf-tests
modules/ceill-tests
modules/floorf-tests
modules/floorl-tests
modules/frexp-nolibm-tests
modules/frexp-tests
modules/frexpl-nolibm-tests
modules/frexpl-tests
modules/isnan-tests
modules/isnand-nolibm-tests
modules/isnand-tests
modules/isnanf-nolibm-tests
modules/isnanf-tests
modules/isnanl-nolibm-tests
modules/isnanl-tests
modules/ldexpl-tests
modules/round-tests
modules/roundf-tests
modules/roundl-tests
modules/signbit-tests
modules/snprintf-posix-tests
modules/sprintf-posix-tests
modules/strtod-tests
modules/trunc-tests
modules/truncf-tests
modules/truncl-tests
modules/vasnprintf-posix-tests
modules/vasprintf-posix-tests
modules/vsnprintf-posix-tests
modules/vsprintf-posix-tests
tests/minus-zero.h [new file with mode: 0644]
tests/test-ceilf1.c
tests/test-ceill.c
tests/test-floorf1.c
tests/test-floorl.c
tests/test-frexp.c
tests/test-frexpl.c
tests/test-isnan.c
tests/test-isnand.h
tests/test-isnanf.h
tests/test-isnanl.h
tests/test-ldexpl.c
tests/test-round1.c
tests/test-roundf1.c
tests/test-roundl.c
tests/test-signbit.c
tests/test-snprintf-posix.h
tests/test-sprintf-posix.h
tests/test-strtod.c
tests/test-trunc1.c
tests/test-truncf1.c
tests/test-truncl.c
tests/test-vasnprintf-posix.c
tests/test-vasprintf-posix.c

index 0ef0c276baeb1100b3adfc1fbf00f0038d646dae..3106ba7780f0cd6242a86d8d60310d3d4a5a079f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,62 @@
 2010-11-04  Eric Blake  <eblake@redhat.com>
 
+       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.
+
        isnanl: work around icc bug
        * lib/isnan.c (FUNC): Compute run-time NaN under ICC as well.
 
index 530fdbcee55b0b0532440dff39600e9639926c16..bb9c4390d9154b5d700e2cdf9ad6387a960a636c 100644 (file)
@@ -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);
index 09c9c7816bbef30cbef4e58b856bad9dba985a07..040fd1bbf5f38730e4482acb5ad1b85f5086c9ba 100644 (file)
@@ -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
index 48b9be301b87d28364c809510206434596a9a82f..09ae4f32d432a029b3002f2ab0f9d12808abe9b8 100644 (file)
@@ -1,5 +1,6 @@
 Files:
 tests/test-ceill.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
index 64b4e3c31eea8139fa095b7a91d0663c1c42d8be..3e9c045ef0076bfaf2e9901016706d0d5f69195e 100644 (file)
@@ -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
index f7dd7bb80fdb5e43bd08575f6efd6ece1ffb6041..5273fb5a8826677131d3642790824c734b51f492 100644 (file)
@@ -1,5 +1,6 @@
 Files:
 tests/test-floorl.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
index 2d761c063d5809114a8f48c88347fe2caf04b248..82ee57c879705f32e9238487dbb3176807c7a9ed 100644 (file)
@@ -1,5 +1,7 @@
 Files:
 tests/test-frexp.c
+tests/minus-zero.h
+tests/nan.h
 tests/signature.h
 tests/macros.h
 
index 32a9ecae18311c91bb599bced93630732163b63e..3f669f9353726c0512bd393467e7b74df8f16f03 100644 (file)
@@ -1,5 +1,6 @@
 Files:
 tests/test-frexp.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
index d9f6d4da46c63fea13bb9bf2fc0138bf3b55937c..1648d95ab444454afc24e4b80b9aba0ce1d800cf 100644 (file)
@@ -1,5 +1,7 @@
 Files:
 tests/test-frexpl.c
+tests/minus-zero.h
+tests/nan.h
 tests/signature.h
 tests/macros.h
 
index 4eb2e4bd98be19627e5fe9c6939bfb604c12afd5..a944634af22845e31c5d64fb9d0a4368a6ab1c98 100644 (file)
@@ -1,5 +1,6 @@
 Files:
 tests/test-frexpl.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
index a63b7cfd1575be24132b041f157d1e57c81ea6fc..1bc2b7217ad73f217326a3beb22345b7556e9168 100644 (file)
@@ -1,5 +1,6 @@
 Files:
 tests/test-isnan.c
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h
 
index 2ce8b6c5a7fa75365bc920268736e2ef44694b85..ee6f880d2f0b0c3427494f27f77ec981183f9a67 100644 (file)
@@ -1,6 +1,7 @@
 Files:
 tests/test-isnand-nolibm.c
 tests/test-isnand.h
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h
 
index b9964ccae7f27eed2e00eeaee4ea2316b3bfb910..a23ba4db67a5c29dcc267d471dccd54df867eaf0 100644 (file)
@@ -1,6 +1,7 @@
 Files:
 tests/test-isnand.c
 tests/test-isnand.h
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h
 
index 6aab7e072735309e638ff11344d7d8d1447095ba..ff89c1d6cbcff54efa1d0f4b6ad08b6d4d4c44a3 100644 (file)
@@ -1,6 +1,7 @@
 Files:
 tests/test-isnanf-nolibm.c
 tests/test-isnanf.h
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h
 
index 2c09485f7f5ae3d2087e52588ed2cad096cac531..ba301df11ef0776fbdd885c42404134c4df11a2f 100644 (file)
@@ -1,6 +1,7 @@
 Files:
 tests/test-isnanf.c
 tests/test-isnanf.h
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h
 
index 6d2f08e43b374a2da3f65d4e88e57cf652cc1c10..78427b43680f5131675ef7347e73b67ef2717688 100644 (file)
@@ -1,6 +1,7 @@
 Files:
 tests/test-isnanl-nolibm.c
 tests/test-isnanl.h
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h
 
index 5cff0dd732b895347278f9392e2701de67c94dea..68411fec1d6dfe407a437af095e43a8dd6604465 100644 (file)
@@ -1,6 +1,7 @@
 Files:
 tests/test-isnanl.c
 tests/test-isnanl.h
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h
 
index 3c4f251cb190cc9085a1044304556b9ec5cb9d71..223175f6114d786d12b677ced74a40d57fef3034 100644 (file)
@@ -1,5 +1,6 @@
 Files:
 tests/test-ldexpl.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
index b52890cd4b5d656e8c718578e05102cab7ad7da2..9e154c8cc1b4fbefe140be287a6f2be63fbb7ef7 100644 (file)
@@ -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
index 8d99ab91a283834db0845a24ee9172704f54c3c9..7ee4178f3efe7ef5f96ba7a180cc5da84aafbabc 100644 (file)
@@ -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
index bd1b5c90b64c55b6093816280931e98c905dbce3..f9bd46727ee3dfd099a7325378e957b6f4de00cb 100644 (file)
@@ -1,5 +1,6 @@
 Files:
 tests/test-roundl.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
index 10d7d7b51ef5435d686d32f8bd0b05105050b415..b8247652f2a99a89a84e313d2ff88b7d4776b653 100644 (file)
@@ -1,5 +1,6 @@
 Files:
 tests/test-signbit.c
+tests/minus-zero.h
 tests/macros.h
 m4/exponentf.m4
 m4/exponentd.m4
index 4448cf521c1e5f27ceac04d4fd915cc59630d896..9a5c3ab7cbd499815fd4c59ee50911df7684a6b8 100644 (file)
@@ -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
index f6e4ce0f565c0d020f3478d790a2839cf7893899..333c5844be1c37618289c40fe7d9b371cbe81934 100644 (file)
@@ -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
index bea7825e777725a1ca2e182abaf6ec750f64784c..38aebe802ec3ec717d5066bb9df59e7850b8d0e7 100644 (file)
@@ -1,6 +1,7 @@
 Files:
 tests/test-strtod.c
 tests/signature.h
+tests/minus-zero.h
 tests/macros.h
 
 Depends-on:
index ce1e9799649bc14594d258957a09e35d70f5a4e7..6c254e0692a8db04c1281e06008ec0caec5c7f13 100644 (file)
@@ -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
index 746950d14bf7cd27cf9a142fd77405543cd7cc6d..27b93f2a2a8b4bf4814a4d23b35f950b4031b5f2 100644 (file)
@@ -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
index 6056a642e5e141afbd9b70cdb968ce4c3d04efa3..01bcf73921c524f2a488117f24f81c9828aac891 100644 (file)
@@ -1,5 +1,6 @@
 Files:
 tests/test-truncl.c
+tests/minus-zero.h
 tests/nan.h
 tests/signature.h
 tests/macros.h
index 5320d88b356f0001fa22a216bec6b619481dd385..e281d262e673eaa08be5853bbdc1272faab3f6ff 100644 (file)
@@ -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
index 4be9c2b3ad2454dacee10af63ee63ee61289c283..8702bdcbde84d51aa38146265211f22f580def9c 100644 (file)
@@ -1,5 +1,6 @@
 Files:
 tests/test-vasprintf-posix.c
+tests/minus-zero.h
 tests/nan.h
 tests/macros.h
 
index 530e57ca661e48fd913e6ba88bfdf75297cbbb40..687d28d44928039ed045a05f6863c182d11ce3d4 100644 (file)
@@ -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
index 7b5412ff85b4a22447c565cbf36592009851e20f..2f04f875a85ac20f8a475b14ac49adfd23f485c7 100644 (file)
@@ -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 (file)
index 0000000..65bd1b4
--- /dev/null
@@ -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
index ff6db5edc34d45d8309614754317f37bb5c4e57c..86bb49e00df99c6651c880a67b3ca9c5c06070a6 100644 (file)
 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);
index ec3c6b968571b2e42442a7f6fc09a512a92dd8c5..cac45b77f067d52568aa84f5564d643c7a8cdb80 100644 (file)
@@ -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);
index 389f42b1f270ae2c55d10fd579daf98cb762bf66..39261d805715a60e506a5cb023ec6e590f846b4c 100644 (file)
 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);
index 5bbcaac44da97b1175712ca49787685b3b262ab3..84717f8bebd5c49c8025c6973f7dd57acf4f5c2a 100644 (file)
@@ -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);
index d5ab7e502e4a0c6c505cdd3f76f0daad126f3cb6..b0f1a4ebb69048f01bdb5fcd04baec0ef3e49e74 100644 (file)
@@ -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);
index 8d9d41d25244ac27d8d6606050460f2596c85205..831dffec17e50b42dd0d2dea7f0c5062040a3104 100644 (file)
@@ -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);
index d1d05dcea42a6d3a10780175a3fb83184c70a838..104aa6f076ccf8768cee34b7e0201f732457f946 100644 (file)
 #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));
index f9866217bf29fbb9839e1b222d86ecb1ba6ae1c5..3756aaf83a486e53954f185866183a09dc25ba16 100644 (file)
 
 #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));
index d071b2cc04cac284b4d7b095ae7c351ca6574d4a..b40f2e10d6fd4b8c0d920b93df539c0ea5b47637 100644 (file)
 
 #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));
index 1665cf41cf858dbfb80b7d630d9329766aeae8f7..0831ab3de58f8a0766a10cdd8505912e88fea551 100644 (file)
 #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));
index f3b4e6f2676172e8f267b1d5963e51e0cd78978b..b520609d446a3bc44c0440e98fbbf336cab2bbd0 100644 (file)
@@ -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));
index 5e20d1b6fbd3a83e674acae8c0e221c859f3a0fb..86fd1de7ab53f5882ce221ccf1c9484461e5476a 100644 (file)
 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);
index 62c580ea555dad98855ea8219e9722f55dc60c2d..33609bb6bd8606b4e9870c8f26def680939ce6b9 100644 (file)
 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);
index fca60f052bf8163c2b1393945079df04750582b3..f06db8a017777fdac4ab733a762e9a6ad4e90734 100644 (file)
@@ -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);
index 9581190cc67a09a6b55b9fdcd18b8cc568d8cd04..c763157d2c283d05916ef542928003fbf238b076 100644 (file)
 #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));
index b796d5bae56b9d7f475dc3c724c1516633eef796..f55e49e4767fe5772538b762e52e360e06afe9dd 100644 (file)
@@ -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
@@ -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));
index a50e57ca4dbba8bc37e3b2bf3533cb3551bbe967..3abe27e60ef2977af252092f006d7aae1d2390f7 100644 (file)
@@ -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));
index e1d04af3b9f54085afe6b1d9ad6b02e485f4044b..261761006d19120563e35d5bd01b6221b3fa7d1f 100644 (file)
@@ -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);
       }
index 65b027af7741e8aab05a74043cd327a302abdca2..69530b8753a08214a5da9c7eb6232d2105455d1e 100644 (file)
 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);
index 8b125a8b86a9e036f29907f22473621725319f23..b5f48dd6ae5b1cdb74c02a67eb9fe72c9c2c8d44 100644 (file)
 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);
index 4879075556964ef9feff796bd912c5fdb72ef386..ab1f4443f36d652b6318adf9d72b66011a5311ba 100644 (file)
@@ -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);
index 3a9879f77c6a6ec5427f13896066e49e156a1baf..66b4eb4265303dcc72508977a92893366b875f6a 100644 (file)
@@ -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);
index ef19df8d5127d764f47cc70dcb91edea06fa1f6a..cd48493b810454c78709fde41b4cb0a7cf5e2172 100644 (file)
@@ -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);