Use macros NaNf, NaNd, NaNl instead of NAN.
authorBruno Haible <bruno@clisp.org>
Wed, 2 Apr 2008 01:06:02 +0000 (03:06 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 2 Apr 2008 01:06:02 +0000 (03:06 +0200)
36 files changed:
ChangeLog
lib/isnan.c
modules/ceilf-tests
modules/floorf-tests
modules/frexp-tests
modules/isnand-nolibm
modules/isnand-nolibm-tests
modules/isnanf-nolibm
modules/isnanf-nolibm-tests
modules/isnanl
modules/isnanl-nolibm
modules/round-tests
modules/roundf-tests
modules/snprintf-posix-tests
modules/sprintf-posix-tests
modules/trunc-tests
modules/truncf-tests
modules/vasnprintf-posix-tests
modules/vasprintf-posix-tests
modules/vsnprintf-posix-tests
modules/vsprintf-posix-tests
tests/nan.h [new file with mode: 0644]
tests/test-ceilf1.c
tests/test-floorf1.c
tests/test-frexp.c
tests/test-isnand.c
tests/test-isnanf.c
tests/test-math.c
tests/test-round1.c
tests/test-roundf1.c
tests/test-snprintf-posix.h
tests/test-sprintf-posix.h
tests/test-trunc1.c
tests/test-truncf1.c
tests/test-vasnprintf-posix.c
tests/test-vasprintf-posix.c

index ba14306..9a2c288 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,74 @@
+2008-04-01  Bruno Haible  <bruno@clisp.org>
+
+       * tests/test-vasnprintf-posix.c: Include nan.h instead of <math.h>.
+       (test_function): Use NaNd, NaNl instead of NAN or 0.0L/0.0L.
+       * modules/vasnprintf-posix-tests (Files): Add tests/nan.h.
+       (Depends-on): Remove math.
+
+       * tests/test-vasprintf-posix.c: Include nan.h instead of <math.h>.
+       (test_function): Use NaNd, NaNl instead of NAN or 0.0L/0.0L.
+       * modules/vasprintf-posix-tests (Files): Add tests/nan.h.
+       (Depends-on): Remove math.
+
+       * tests/test-snprintf-posix.h: Include nan.h instead of <math.h>.
+       (test_function): Use NaNd, NaNl instead of NAN or 0.0L/0.0L.
+       * modules/snprintf-posix-tests (Files): Add tests/nan.h.
+       (Depends-on): Remove math.
+       * modules/vsnprintf-posix-tests (Files): Add tests/nan.h.
+       (Depends-on): Remove math.
+
+       * tests/test-sprintf-posix.h: Include nan.h instead of <math.h>.
+       (test_function): Use NaNd, NaNl instead of NAN or 0.0L/0.0L.
+       * modules/sprintf-posix-tests (Files): Add tests/nan.h.
+       (Depends-on): Remove math.
+       * modules/vsprintf-posix-tests (Files): Add tests/nan.h.
+       (Depends-on): Remove math.
+
+       * tests/test-round1.c: Include nan.h.
+       (main): Use NaNd instead of NAN.
+       * modules/round-tests (Files): Add tests/nan.h.
+
+       * tests/test-trunc1.c: Include nan.h.
+       (main): Use NaNd instead of NAN.
+       * modules/trunc-tests (Files): Add tests/nan.h.
+
+       * tests/test-roundf1.c: Include nan.h.
+       (main): Use NaNf instead of NAN.
+       * modules/roundf-tests (Files): Add tests/nan.h.
+
+       * tests/test-truncf1.c: Include nan.h.
+       (main): Use NaNf instead of NAN.
+       * modules/truncf-tests (Files): Add tests/nan.h.
+
+       * tests/test-ceilf1.c: Include nan.h.
+       (main): Use NaNf instead of NAN.
+       * modules/ceilf-tests (Files): Add tests/nan.h.
+
+       * tests/test-floorf1.c: Include nan.h.
+       (main): Use NaNf instead of NAN.
+       * modules/floorf-tests (Files): Add tests/nan.h.
+
+       * tests/test-isnanf.c: Include nan.h instead of <math.h>.
+       (main): Use NaNf instead of NAN.
+       * modules/isnanf-nolibm-tests (Files): Add tests/nan.h.
+
+       * tests/test-isnand.c: Include nan.h instead of <math.h>.
+       (main): Use NaNd instead of NAN.
+       * modules/isnand-nolibm-tests (Files): Add tests/nan.h.
+
+       * tests/test-frexp.c: Include nan.h.
+       (main): Use NaNd instead of NAN.
+       * modules/frexp-tests (Files): Add tests/nan.h.
+
+       * lib/isnan.c: Don't include <math.h>.
+       (FUNC): Don't use NAN macro.
+       * modules/isnand-nolibm (Depends-on): Remove math.
+       * modules/isnanf-nolibm (Depends-on): Remove math.
+       * modules/isnanl (Depends-on): Remove math.
+       * modules/isnanl-nolibm (Depends-on): Remove math.
+
+       * tests/nan.h: New file.
+
 2008-04-01  Eric Blake  <ebb9@byu.net>
 
        Fix typos.
index 81f394d..a5ca38d 100644 (file)
@@ -19,7 +19,6 @@
 #include <config.h>
 
 #include <float.h>
-#include <math.h>
 #include <string.h>
 
 #include "float+.h"
@@ -112,10 +111,11 @@ FUNC (DOUBLE x)
      also fails when constant-folding 0.0 / 0.0 even when constant-folding is
      not required.  The SGI MIPSpro C compiler complains about "floating-point
      operation result is out of range".  */
+  static DOUBLE zero = L_(0.0);
   memory_double nan;
   DOUBLE plus_inf = L_(1.0) / L_(0.0);
   DOUBLE minus_inf = -L_(1.0) / L_(0.0);
-  nan.value = NAN;
+  nan.value = zero / zero;
 #  else
   static memory_double nan = { L_(0.0) / L_(0.0) };
   static DOUBLE plus_inf = L_(1.0) / L_(0.0);
index 33d5be9..8653c47 100644 (file)
@@ -1,6 +1,7 @@
 Files:
 tests/test-ceilf1.c
 tests/test-ceilf2.c
+tests/nan.h
 
 Depends-on:
 float
index 5390f4b..e3f2b03 100644 (file)
@@ -1,6 +1,7 @@
 Files:
 tests/test-floorf1.c
 tests/test-floorf2.c
+tests/nan.h
 
 Depends-on:
 float
index 6982cf9..eee00fd 100644 (file)
@@ -1,5 +1,6 @@
 Files:
 tests/test-frexp.c
+tests/nan.h
 
 Depends-on:
 isnand-nolibm
index cab173d..6bb8c7d 100644 (file)
@@ -10,7 +10,6 @@ m4/isnand.m4
 
 Depends-on:
 fpieee
-math
 
 configure.ac:
 gl_FUNC_ISNAND_NO_LIBM
index cfe52b8..7fd37ba 100644 (file)
@@ -1,5 +1,6 @@
 Files:
 tests/test-isnand.c
+tests/nan.h
 
 Depends-on:
 
index 1489e30..3f90629 100644 (file)
@@ -10,7 +10,6 @@ m4/isnanf.m4
 
 Depends-on:
 fpieee
-math
 
 configure.ac:
 gl_FUNC_ISNANF_NO_LIBM
index fa8b9c0..8225ff4 100644 (file)
@@ -1,5 +1,6 @@
 Files:
 tests/test-isnanf.c
+tests/nan.h
 
 Depends-on:
 
index 6ba1ee4..026981f 100644 (file)
@@ -11,7 +11,6 @@ m4/isnanl.m4
 Depends-on:
 float
 fpieee
-math
 
 configure.ac:
 gl_FUNC_ISNANL
index 783dc77..9250fef 100644 (file)
@@ -11,7 +11,6 @@ m4/isnanl.m4
 Depends-on:
 float
 fpieee
-math
 
 configure.ac:
 gl_FUNC_ISNANL_NO_LIBM
index a4d2a15..909910c 100644 (file)
@@ -1,6 +1,7 @@
 Files:
 tests/test-round1.c
 tests/test-round2.c
+tests/nan.h
 
 Depends-on:
 isnand-nolibm
index 6aa6372..c1ae0de 100644 (file)
@@ -2,6 +2,7 @@ Files:
 tests/test-roundf1.c
 tests/test-round2.c
 tests/test-roundf2.c
+tests/nan.h
 
 Depends-on:
 ceilf
index 3826051..5af4266 100644 (file)
@@ -2,9 +2,9 @@ Files:
 tests/test-snprintf-posix.c
 tests/test-snprintf-posix.h
 tests/test-snprintf.c
+tests/nan.h
 
 Depends-on:
-math
 stdint
 
 configure.ac:
index 5df186a..cf67204 100644 (file)
@@ -1,9 +1,9 @@
 Files:
 tests/test-sprintf-posix.c
 tests/test-sprintf-posix.h
+tests/nan.h
 
 Depends-on:
-math
 stdint
 
 configure.ac:
index 621e76d..f986e3c 100644 (file)
@@ -1,6 +1,7 @@
 Files:
 tests/test-trunc1.c
 tests/test-trunc2.c
+tests/nan.h
 
 Depends-on:
 float
index 3584de2..0f56e7f 100644 (file)
@@ -1,6 +1,7 @@
 Files:
 tests/test-truncf1.c
 tests/test-truncf2.c
+tests/nan.h
 
 Depends-on:
 float
index d8a39d4..f46fffa 100644 (file)
@@ -2,10 +2,10 @@ Files:
 tests/test-vasnprintf-posix.c
 tests/test-vasnprintf-posix2.sh
 tests/test-vasnprintf-posix2.c
+tests/nan.h
 m4/locale-fr.m4
 
 Depends-on:
-math
 stdint
 
 configure.ac:
index 391c6a1..221ccd1 100644 (file)
@@ -1,8 +1,8 @@
 Files:
 tests/test-vasprintf-posix.c
+tests/nan.h
 
 Depends-on:
-math
 stdint
 
 configure.ac:
index 1604b1e..3b45e44 100644 (file)
@@ -2,9 +2,9 @@ Files:
 tests/test-vsnprintf-posix.c
 tests/test-snprintf-posix.h
 tests/test-vsnprintf.c
+tests/nan.h
 
 Depends-on:
-math
 stdint
 
 configure.ac:
index 7c42039..e48d5ae 100644 (file)
@@ -1,9 +1,9 @@
 Files:
 tests/test-vsprintf-posix.c
 tests/test-sprintf-posix.h
+tests/nan.h
 
 Depends-on:
-math
 stdint
 
 configure.ac:
diff --git a/tests/nan.h b/tests/nan.h
new file mode 100644 (file)
index 0000000..3bdf643
--- /dev/null
@@ -0,0 +1,50 @@
+/* Macros for not-a-number.
+   Copyright (C) 2007-2008 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/>.  */
+
+
+/* NaNf () returns a 'float' not-a-number.  */
+
+/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0.  */
+#ifdef __DECC
+static float
+NaNf ()
+{
+  static float zero = 0.0f;
+  return zero / zero;
+}
+#else
+# define NaNf() (0.0f / 0.0f)
+#endif
+
+
+/* NaNd () returns a 'double' not-a-number.  */
+
+/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0.  */
+#ifdef __DECC
+static double
+NaNd ()
+{
+  static double zero = 0.0;
+  return zero / zero;
+}
+#else
+# define NaNd() (0.0 / 0.0)
+#endif
+
+
+/* NaNl () returns a 'long double' not-a-number.  */
+
+#define NaNl() (0.0L / 0.0L)
index b323227..e2a04a0 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of rounding towards positive infinity.
-   Copyright (C) 20072008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2008 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
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 
 #include "isnanf.h"
+#include "nan.h"
 
 #define ASSERT(expr) \
   do                                                                        \
@@ -67,7 +68,7 @@ main ()
   ASSERT (ceilf (1.0f / 0.0f) == 1.0f / 0.0f);
   ASSERT (ceilf (-1.0f / 0.0f) == -1.0f / 0.0f);
   /* NaNs.  */
-  ASSERT (isnanf (ceilf (NAN)));
+  ASSERT (isnanf (ceilf (NaNf ())));
 
   return 0;
 }
index a45bcfc..2a9d103 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of rounding towards negative infinity.
-   Copyright (C) 20072008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2008 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
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 
 #include "isnanf.h"
+#include "nan.h"
 
 #define ASSERT(expr) \
   do                                                                        \
@@ -67,7 +68,7 @@ main ()
   ASSERT (floorf (1.0f / 0.0f) == 1.0f / 0.0f);
   ASSERT (floorf (-1.0f / 0.0f) == -1.0f / 0.0f);
   /* NaNs.  */
-  ASSERT (isnanf (floorf (NAN)));
+  ASSERT (isnanf (floorf (NaNf ())));
 
   return 0;
 }
index cb80f56..9e92667 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 
 #include "isnand.h"
+#include "nan.h"
 
 #define ASSERT(expr) \
   do                                                                        \
@@ -61,7 +62,7 @@ main ()
   { /* NaN.  */
     int exp = -9999;
     double mantissa;
-    x = NAN;
+    x = NaNd ();
     mantissa = frexp (x, &exp);
     ASSERT (isnand (mantissa));
   }
index 1dc9238..ff73101 100644 (file)
 #include "isnand.h"
 
 #include <limits.h>
-#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "nan.h"
+
 #define ASSERT(expr) \
   do                                                                        \
     {                                                                       \
@@ -52,7 +53,7 @@ main ()
   ASSERT (!isnand (1.0 / 0.0));
   ASSERT (!isnand (-1.0 / 0.0));
   /* Quiet NaN.  */
-  ASSERT (isnand (NAN));
+  ASSERT (isnand (NaNd ()));
 #if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT
   /* Signalling NaN.  */
   {
@@ -60,7 +61,7 @@ main ()
       ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
     typedef union { double value; unsigned int word[NWORDS]; } memory_double;
     memory_double m;
-    m.value = NAN;
+    m.value = NaNd ();
 # if DBL_EXPBIT0_BIT > 0
     m.word[DBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (DBL_EXPBIT0_BIT - 1);
 # else
index 6c084ac..c70b619 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of isnanf() substitute.
-   Copyright (C) 20072008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2008 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
 #include "isnanf.h"
 
 #include <limits.h>
-#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "nan.h"
+
 #define ASSERT(expr) \
   do                                                                        \
     {                                                                       \
@@ -52,7 +53,7 @@ main ()
   ASSERT (!isnanf (1.0f / 0.0f));
   ASSERT (!isnanf (-1.0f / 0.0f));
   /* Quiet NaN.  */
-  ASSERT (isnanf (NAN));
+  ASSERT (isnanf (NaNf ()));
 #if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT
   /* Signalling NaN.  */
   {
@@ -60,7 +61,7 @@ main ()
       ((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
     typedef union { float value; unsigned int word[NWORDS]; } memory_float;
     memory_float m;
-    m.value = NAN;
+    m.value = NaNf ();
 # if FLT_EXPBIT0_BIT > 0
     m.word[FLT_EXPBIT0_WORD] ^= (unsigned int) 1 << (FLT_EXPBIT0_BIT - 1);
 # else
index 5c00581..56cf058 100644 (file)
 choke me
 #endif
 
+#if 0
+/* Check that NAN expands into a constant expression.  */
+static float n = NAN;
+#endif
+
 int
 main ()
 {
index 704e1da..2710f91 100644 (file)
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 
 #include "isnand.h"
+#include "nan.h"
 
 #define ASSERT(expr) \
   do                                                                        \
@@ -74,7 +75,7 @@ main ()
   ASSERT (round (1.0 / 0.0) == 1.0 / 0.0);
   ASSERT (round (-1.0 / 0.0) == -1.0 / 0.0);
   /* NaNs.  */
-  ASSERT (isnand (round (NAN)));
+  ASSERT (isnand (round (NaNd ())));
 
   return 0;
 }
index aeee3b1..8131cb2 100644 (file)
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 
 #include "isnanf.h"
+#include "nan.h"
 
 #define ASSERT(expr) \
   do                                                                        \
@@ -74,7 +75,7 @@ main ()
   ASSERT (roundf (1.0 / 0.0f) == 1.0 / 0.0f);
   ASSERT (roundf (-1.0 / 0.0f) == -1.0 / 0.0f);
   /* NaNs.  */
-  ASSERT (isnanf (roundf (NAN)));
+  ASSERT (isnanf (roundf (NaNf ())));
 
   return 0;
 }
index 4d69267..570f8b7 100644 (file)
@@ -16,7 +16,7 @@
 
 /* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
 
-#include <math.h>
+#include "nan.h"
 
 /* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0.  */
 static int
@@ -197,7 +197,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* NaN.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%a %d", NAN, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%a %d", NaNd (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -394,7 +394,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%050a %d", NAN, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%050a %d", NaNd (), 33, 44, 55);
     /* "0000000nan 33" is not a valid result; see
        <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
     ASSERT (strlen (result) == 50 + 3
@@ -461,7 +461,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* NaN.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%La %d", 0.0L / 0.0L, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%La %d", NaNl (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -746,7 +746,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%050La %d", 0.0L / 0.0L, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%050La %d", NaNl (), 33, 44, 55);
     /* "0000000nan 33" is not a valid result; see
        <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
     ASSERT (strlen (result) == 50 + 3
@@ -908,7 +908,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* NaN.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%f %d", NAN, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%f %d", NaNd (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -989,7 +989,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%050f %d", NAN, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%050f %d", NaNd (), 33, 44, 55);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1153,10 +1153,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   }
 
   { /* NaN.  */
-    static long double zero = 0.0L;
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%Lf %d", zero / zero, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%Lf %d", NaNl (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1322,10 +1321,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   }
 
   { /* FLAG_ZERO with NaN.  */
-    static long double zero = 0.0L;
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%050Lf %d", zero / zero, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%050Lf %d", NaNl (), 33, 44, 55);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1404,7 +1402,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* NaN.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%F %d", NAN, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%F %d", NaNd (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 1)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1496,10 +1494,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   }
 
   { /* NaN.  */
-    static long double zero = 0.0L;
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%LF %d", zero / zero, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%LF %d", NaNl (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 1)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1698,7 +1695,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* NaN.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%e %d", NAN, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%e %d", NaNd (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1789,7 +1786,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%050e %d", NAN, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%050e %d", NaNd (), 33, 44, 55);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1954,10 +1951,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   }
 
   { /* NaN.  */
-    static long double zero = 0.0L;
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%Le %d", zero / zero, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%Le %d", NaNl (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -2125,10 +2121,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   }
 
   { /* FLAG_ZERO with NaN.  */
-    static long double zero = 0.0L;
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%050Le %d", zero / zero, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%050Le %d", NaNl (), 33, 44, 55);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -2306,7 +2301,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* NaN.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%g %d", NAN, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%g %d", NaNd (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -2390,7 +2385,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%050g %d", NAN, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%050g %d", NaNd (), 33, 44, 55);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -2555,10 +2550,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   }
 
   { /* NaN.  */
-    static long double zero = 0.0L;
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%Lg %d", zero / zero, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%Lg %d", NaNl (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -2726,10 +2720,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   }
 
   { /* FLAG_ZERO with NaN.  */
-    static long double zero = 0.0L;
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%050Lg %d", zero / zero, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%050Lg %d", NaNl (), 33, 44, 55);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
index ac2afcf..afe7ea2 100644 (file)
@@ -16,7 +16,7 @@
 
 /* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
 
-#include <math.h>
+#include "nan.h"
 
 /* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0.  */
 static int
@@ -183,7 +183,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* NaN.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%a %d", NAN, 33, 44, 55);
+      my_sprintf (result, "%a %d", NaNd (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -380,7 +380,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%050a %d", NAN, 33, 44, 55);
+      my_sprintf (result, "%050a %d", NaNd (), 33, 44, 55);
     /* "0000000nan 33" is not a valid result; see
        <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
     ASSERT (strlen (result) == 50 + 3
@@ -447,7 +447,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* NaN.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%La %d", 0.0L / 0.0L, 33, 44, 55);
+      my_sprintf (result, "%La %d", NaNl (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -732,7 +732,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%050La %d", 0.0L / 0.0L, 33, 44, 55);
+      my_sprintf (result, "%050La %d", NaNl (), 33, 44, 55);
     /* "0000000nan 33" is not a valid result; see
        <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
     ASSERT (strlen (result) == 50 + 3
@@ -894,7 +894,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* NaN.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%f %d", NAN, 33, 44, 55);
+      my_sprintf (result, "%f %d", NaNd (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -969,7 +969,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%050f %d", NAN, 33, 44, 55);
+      my_sprintf (result, "%050f %d", NaNd (), 33, 44, 55);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1133,10 +1133,9 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   }
 
   { /* NaN.  */
-    static long double zero = 0.0L;
     char result[1000];
     int retval =
-      my_sprintf (result, "%Lf %d", zero / zero, 33, 44, 55);
+      my_sprintf (result, "%Lf %d", NaNl (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1296,10 +1295,9 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   }
 
   { /* FLAG_ZERO with NaN.  */
-    static long double zero = 0.0L;
     char result[1000];
     int retval =
-      my_sprintf (result, "%050Lf %d", zero / zero, 33, 44, 55);
+      my_sprintf (result, "%050Lf %d", NaNl (), 33, 44, 55);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1378,7 +1376,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* NaN.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%F %d", NAN, 33, 44, 55);
+      my_sprintf (result, "%F %d", NaNd (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 1)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1470,10 +1468,9 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   }
 
   { /* NaN.  */
-    static long double zero = 0.0L;
     char result[1000];
     int retval =
-      my_sprintf (result, "%LF %d", zero / zero, 33, 44, 55);
+      my_sprintf (result, "%LF %d", NaNl (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 1)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1672,7 +1669,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* NaN.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%e %d", NAN, 33, 44, 55);
+      my_sprintf (result, "%e %d", NaNd (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1763,7 +1760,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%050e %d", NAN, 33, 44, 55);
+      my_sprintf (result, "%050e %d", NaNd (), 33, 44, 55);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1928,10 +1925,9 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   }
 
   { /* NaN.  */
-    static long double zero = 0.0L;
     char result[1000];
     int retval =
-      my_sprintf (result, "%Le %d", zero / zero, 33, 44, 55);
+      my_sprintf (result, "%Le %d", NaNl (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -2099,10 +2095,9 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   }
 
   { /* FLAG_ZERO with NaN.  */
-    static long double zero = 0.0L;
     char result[1000];
     int retval =
-      my_sprintf (result, "%050Le %d", zero / zero, 33, 44, 55);
+      my_sprintf (result, "%050Le %d", NaNl (), 33, 44, 55);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -2280,7 +2275,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* NaN.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%g %d", NAN, 33, 44, 55);
+      my_sprintf (result, "%g %d", NaNd (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -2364,7 +2359,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%050g %d", NAN, 33, 44, 55);
+      my_sprintf (result, "%050g %d", NaNd (), 33, 44, 55);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -2529,10 +2524,9 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   }
 
   { /* NaN.  */
-    static long double zero = 0.0L;
     char result[1000];
     int retval =
-      my_sprintf (result, "%Lg %d", zero / zero, 33, 44, 55);
+      my_sprintf (result, "%Lg %d", NaNl (), 33, 44, 55);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -2700,10 +2694,9 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   }
 
   { /* FLAG_ZERO with NaN.  */
-    static long double zero = 0.0L;
     char result[1000];
     int retval =
-      my_sprintf (result, "%050Lg %d", zero / zero, 33, 44, 55);
+      my_sprintf (result, "%050Lg %d", NaNl (), 33, 44, 55);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
            && strcmp (result + strlen (result) - 3, " 33") == 0);
index 6b28363..7f1bd10 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 
 #include "isnand.h"
+#include "nan.h"
 
 #define ASSERT(expr) \
   do                                                                        \
@@ -66,7 +67,7 @@ main ()
   ASSERT (trunc (1.0 / 0.0) == 1.0 / 0.0);
   ASSERT (trunc (-1.0 / 0.0) == -1.0 / 0.0);
   /* NaNs.  */
-  ASSERT (isnand (trunc (NAN)));
+  ASSERT (isnand (trunc (NaNd ())));
 
   return 0;
 }
index 9d36576..4827389 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of rounding towards zero.
-   Copyright (C) 20072008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2008 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
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 
 #include "isnanf.h"
+#include "nan.h"
 
 #define ASSERT(expr) \
   do                                                                        \
@@ -66,7 +67,7 @@ main ()
   ASSERT (truncf (1.0f / 0.0f) == 1.0f / 0.0f);
   ASSERT (truncf (-1.0f / 0.0f) == -1.0f / 0.0f);
   /* NaNs.  */
-  ASSERT (isnanf (truncf (NAN)));
+  ASSERT (isnanf (truncf (NaNf ())));
 
   return 0;
 }
index c29546a..4605cd1 100644 (file)
@@ -21,7 +21,6 @@
 #include "vasnprintf.h"
 
 #include <float.h>
-#include <math.h>
 #include <stdarg.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -29,6 +28,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "nan.h"
+
 #define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
 #define ASSERT(expr) \
   do                                                                        \
@@ -246,7 +247,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* NaN.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%a %d", NAN, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%a %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
@@ -479,7 +480,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%050a %d", NAN, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%050a %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     /* "0000000nan 33" is not a valid result; see
        <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
@@ -560,7 +561,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* NaN.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%La %d", 0.0L / 0.0L, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%La %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
@@ -895,7 +896,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%050La %d", 0.0L / 0.0L, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%050La %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     /* "0000000nan 33" is not a valid result; see
        <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
@@ -1075,7 +1076,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* NaN.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%f %d", NAN, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%f %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
@@ -1168,7 +1169,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%050f %d", NAN, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%050f %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
@@ -1352,10 +1353,9 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   }
 
   { /* NaN.  */
-    static long double zero = 0.0L;
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%Lf %d", zero / zero, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%Lf %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
@@ -1547,10 +1547,9 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   }
 
   { /* FLAG_ZERO with NaN.  */
-    static long double zero = 0.0L;
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%050Lf %d", zero / zero, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%050Lf %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
@@ -1647,7 +1646,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* NaN.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%F %d", NAN, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%F %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 1)
@@ -1761,10 +1760,9 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   }
 
   { /* NaN.  */
-    static long double zero = 0.0L;
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%LF %d", zero / zero, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%LF %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 1)
@@ -1986,7 +1984,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* NaN.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%e %d", NAN, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%e %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
@@ -2097,7 +2095,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%050e %d", NAN, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%050e %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
@@ -2282,10 +2280,9 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   }
 
   { /* NaN.  */
-    static long double zero = 0.0L;
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%Le %d", zero / zero, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%Le %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
@@ -2487,10 +2484,9 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   }
 
   { /* FLAG_ZERO with NaN.  */
-    static long double zero = 0.0L;
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%050Le %d", zero / zero, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%050Le %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
@@ -2688,7 +2684,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* NaN.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%g %d", NAN, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%g %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
@@ -2792,7 +2788,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%050g %d", NAN, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%050g %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
@@ -2977,10 +2973,9 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   }
 
   { /* NaN.  */
-    static long double zero = 0.0L;
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%Lg %d", zero / zero, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%Lg %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
@@ -3182,10 +3177,9 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   }
 
   { /* FLAG_ZERO with NaN.  */
-    static long double zero = 0.0L;
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%050Lg %d", zero / zero, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%050Lg %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
index 806ce74..2270d6a 100644 (file)
@@ -21,7 +21,6 @@
 #include <stdio.h>
 
 #include <float.h>
-#include <math.h>
 #include <stdarg.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -29,6 +28,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "nan.h"
+
 #define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
 #define ASSERT(expr) \
   do                                                                        \
@@ -227,7 +228,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* NaN.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%a %d", NAN, 33, 44, 55);
+      my_asprintf (&result, "%a %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
@@ -460,7 +461,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%050a %d", NAN, 33, 44, 55);
+      my_asprintf (&result, "%050a %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     /* "0000000nan 33" is not a valid result; see
        <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
@@ -541,7 +542,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* NaN.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%La %d", 0.0L / 0.0L, 33, 44, 55);
+      my_asprintf (&result, "%La %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
@@ -876,7 +877,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%050La %d", 0.0L / 0.0L, 33, 44, 55);
+      my_asprintf (&result, "%050La %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     /* "0000000nan 33" is not a valid result; see
        <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
@@ -1056,7 +1057,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* NaN.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%f %d", NAN, 33, 44, 55);
+      my_asprintf (&result, "%f %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
@@ -1149,7 +1150,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%050f %d", NAN, 33, 44, 55);
+      my_asprintf (&result, "%050f %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
@@ -1333,10 +1334,9 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   }
 
   { /* NaN.  */
-    static long double zero = 0.0L;
     char *result;
     int retval =
-      my_asprintf (&result, "%Lf %d", zero / zero, 33, 44, 55);
+      my_asprintf (&result, "%Lf %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
@@ -1528,10 +1528,9 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   }
 
   { /* FLAG_ZERO with NaN.  */
-    static long double zero = 0.0L;
     char *result;
     int retval =
-      my_asprintf (&result, "%050Lf %d", zero / zero, 33, 44, 55);
+      my_asprintf (&result, "%050Lf %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
@@ -1628,7 +1627,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* NaN.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%F %d", NAN, 33, 44, 55);
+      my_asprintf (&result, "%F %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 1)
@@ -1742,10 +1741,9 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   }
 
   { /* NaN.  */
-    static long double zero = 0.0L;
     char *result;
     int retval =
-      my_asprintf (&result, "%LF %d", zero / zero, 33, 44, 55);
+      my_asprintf (&result, "%LF %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 1)
@@ -1967,7 +1965,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* NaN.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%e %d", NAN, 33, 44, 55);
+      my_asprintf (&result, "%e %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
@@ -2078,7 +2076,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%050e %d", NAN, 33, 44, 55);
+      my_asprintf (&result, "%050e %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
@@ -2263,10 +2261,9 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   }
 
   { /* NaN.  */
-    static long double zero = 0.0L;
     char *result;
     int retval =
-      my_asprintf (&result, "%Le %d", zero / zero, 33, 44, 55);
+      my_asprintf (&result, "%Le %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
@@ -2468,10 +2465,9 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   }
 
   { /* FLAG_ZERO with NaN.  */
-    static long double zero = 0.0L;
     char *result;
     int retval =
-      my_asprintf (&result, "%050Le %d", zero / zero, 33, 44, 55);
+      my_asprintf (&result, "%050Le %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
@@ -2669,7 +2665,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* NaN.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%g %d", NAN, 33, 44, 55);
+      my_asprintf (&result, "%g %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
@@ -2773,7 +2769,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%050g %d", NAN, 33, 44, 55);
+      my_asprintf (&result, "%050g %d", NaNd (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
@@ -2958,10 +2954,9 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   }
 
   { /* NaN.  */
-    static long double zero = 0.0L;
     char *result;
     int retval =
-      my_asprintf (&result, "%Lg %d", zero / zero, 33, 44, 55);
+      my_asprintf (&result, "%Lg %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) >= 3 + 3
            && strisnan (result, 0, strlen (result) - 3, 0)
@@ -3163,10 +3158,9 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   }
 
   { /* FLAG_ZERO with NaN.  */
-    static long double zero = 0.0L;
     char *result;
     int retval =
-      my_asprintf (&result, "%050Lg %d", zero / zero, 33, 44, 55);
+      my_asprintf (&result, "%050Lg %d", NaNl (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strlen (result) == 50 + 3
            && strisnan (result, strspn (result, " "), strlen (result) - 3, 0)