summaryrefslogtreecommitdiff
path: root/tests/test-isnanl.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-isnanl.h')
-rw-r--r--tests/test-isnanl.h57
1 files changed, 34 insertions, 23 deletions
diff --git a/tests/test-isnanl.h b/tests/test-isnanl.h
index 2e65afae..1665cf41 100644
--- a/tests/test-isnanl.h
+++ b/tests/test-isnanl.h
@@ -1,5 +1,5 @@
/* Test of isnanl() substitute.
- Copyright (C) 2007-2015 Free Software Foundation, Inc.
+ Copyright (C) 2007-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
@@ -19,11 +19,25 @@
#include <float.h>
#include <limits.h>
-#include "minus-zero.h"
-#include "infinity.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 ()
{
@@ -40,10 +54,10 @@ main ()
ASSERT (!isnanl (-2.718e30L));
ASSERT (!isnanl (-2.718e-30L));
ASSERT (!isnanl (0.0L));
- ASSERT (!isnanl (minus_zerol));
+ ASSERT (!isnanl (minus_zero));
/* Infinite values. */
- ASSERT (!isnanl (Infinityl ()));
- ASSERT (!isnanl (- Infinityl ()));
+ ASSERT (!isnanl (1.0L / 0.0L));
+ ASSERT (!isnanl (-1.0L / 0.0L));
/* Quiet NaN. */
ASSERT (isnanl (NaNl ()));
@@ -51,15 +65,6 @@ main ()
/* A bit pattern that is different from a Quiet NaN. With a bit of luck,
it's a Signalling NaN. */
{
-#if defined __powerpc__ && LDBL_MANT_DIG == 106
- /* This is PowerPC "double double", a pair of two doubles. Inf and Nan are
- represented as the corresponding 64-bit IEEE values in the first double;
- the second is ignored. Manipulate only the first double. */
- #undef NWORDS
- #define NWORDS \
- ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
-#endif
-
memory_long_double m;
m.value = NaNl ();
# if LDBL_EXPBIT0_BIT > 0
@@ -74,13 +79,13 @@ main ()
}
#endif
-#if ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
+#if ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_))
/* Representation of an 80-bit 'long double' as an initializer for a sequence
of 'unsigned int' words. */
# ifdef WORDS_BIGENDIAN
# define LDBL80_WORDS(exponent,manthi,mantlo) \
{ ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \
- ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16), \
+ ((unsigned int) (manthi) << 16) | (unsigned int) (mantlo) >> 16), \
(unsigned int) (mantlo) << 16 \
}
# else
@@ -98,31 +103,37 @@ main ()
{ LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) };
ASSERT (isnanl (x.value));
}
- /* isnanl should return something for noncanonical values. */
+ /* The isnanl function should recognize Pseudo-NaNs, Pseudo-Infinities,
+ Pseudo-Zeroes, Unnormalized Numbers, and Pseudo-Denormals, as defined in
+ Intel IA-64 Architecture Software Developer's Manual, Volume 1:
+ Application Architecture.
+ Table 5-2 "Floating-Point Register Encodings"
+ Figure 5-6 "Memory to Floating-Point Register Data Translation"
+ */
{ /* Pseudo-NaN. */
static memory_long_double x =
{ LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) };
- ASSERT (isnanl (x.value) || !isnanl (x.value));
+ ASSERT (isnanl (x.value));
}
{ /* Pseudo-Infinity. */
static memory_long_double x =
{ LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) };
- ASSERT (isnanl (x.value) || !isnanl (x.value));
+ ASSERT (isnanl (x.value));
}
{ /* Pseudo-Zero. */
static memory_long_double x =
{ LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) };
- ASSERT (isnanl (x.value) || !isnanl (x.value));
+ ASSERT (isnanl (x.value));
}
{ /* Unnormalized number. */
static memory_long_double x =
{ LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) };
- ASSERT (isnanl (x.value) || !isnanl (x.value));
+ ASSERT (isnanl (x.value));
}
{ /* Pseudo-Denormal. */
static memory_long_double x =
{ LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) };
- ASSERT (isnanl (x.value) || !isnanl (x.value));
+ ASSERT (isnanl (x.value));
}
#endif