diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2024-03-03 19:11:32 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2024-03-03 19:11:32 +0100 |
commit | 00893e79fc62966067af1a106567db96bd170338 (patch) | |
tree | 52b35cd0b42ca28e62a2ffbecade2e13dd8332cf /tests/test-isnanl.h | |
parent | 26112352a774737e1ce5580c93654a26c1e82b39 (diff) |
New upstream version 1.2upstream/1.2
Diffstat (limited to 'tests/test-isnanl.h')
-rw-r--r-- | tests/test-isnanl.h | 52 |
1 files changed, 13 insertions, 39 deletions
diff --git a/tests/test-isnanl.h b/tests/test-isnanl.h index 37f986ed..ff42ee54 100644 --- a/tests/test-isnanl.h +++ b/tests/test-isnanl.h @@ -1,5 +1,5 @@ /* Test of isnanl() substitute. - Copyright (C) 2007-2022 Free Software Foundation, Inc. + Copyright (C) 2007-2024 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 @@ -22,16 +22,12 @@ #include "minus-zero.h" #include "infinity.h" #include "nan.h" +#include "snan.h" #include "macros.h" int main () { - #define NWORDS \ - ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) - typedef union { unsigned int word[NWORDS]; long double value; } - memory_long_double; - /* Finite values. */ ASSERT (!isnanl (3.141L)); ASSERT (!isnanl (3.141e30L)); @@ -46,32 +42,9 @@ main () ASSERT (!isnanl (- Infinityl ())); /* Quiet NaN. */ ASSERT (isnanl (NaNl ())); - -#if defined LDBL_EXPBIT0_WORD && defined LDBL_EXPBIT0_BIT - /* 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 - m.word[LDBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (LDBL_EXPBIT0_BIT - 1); -# else - m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] - ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); -# endif - m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] - |= (unsigned int) 1 << LDBL_EXPBIT0_BIT; - ASSERT (isnanl (m.value)); - } +#if HAVE_SNANL + /* Signalling NaN. */ + ASSERT (isnanl (SNaNl ())); #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 @@ -89,41 +62,42 @@ main () # endif { /* Quiet NaN. */ static memory_long_double x = - { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; + { .word = LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; ASSERT (isnanl (x.value)); } { /* Signalling NaN. */ static memory_long_double x = - { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; + { .word = LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; ASSERT (isnanl (x.value)); } /* isnanl should return something for noncanonical values. */ { /* Pseudo-NaN. */ static memory_long_double x = - { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; + { .word = LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; ASSERT (isnanl (x.value) || !isnanl (x.value)); } { /* Pseudo-Infinity. */ static memory_long_double x = - { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; + { .word = LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; ASSERT (isnanl (x.value) || !isnanl (x.value)); } { /* Pseudo-Zero. */ static memory_long_double x = - { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; + { .word = LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; ASSERT (isnanl (x.value) || !isnanl (x.value)); } { /* Unnormalized number. */ static memory_long_double x = - { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; + { .word = LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; ASSERT (isnanl (x.value) || !isnanl (x.value)); } { /* Pseudo-Denormal. */ static memory_long_double x = - { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; + { .word = LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; ASSERT (isnanl (x.value) || !isnanl (x.value)); } + #undef NWORDS #endif return 0; |