blob: 66bed0defb354cb640ec5950d7bd3cfa00caecd7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
Description: Fix detection of floating point endianness
See https://lists.gnu.org/archive/html/bug-gnulib/2013-12/msg00104.html
Author: Alan Modra <amodra@gmail.com>
Author: Colin Watson <cjwatson@ubuntu.com>
Forwarded: no
Last-Update: 2013-12-18
Index: b/tests/test-isnanl.h
===================================================================
--- a/tests/test-isnanl.h
+++ b/tests/test-isnanl.h
@@ -38,6 +38,12 @@
long double minus_zero = -0.0L;
#endif
+#ifdef __FLOAT_WORD_ORDER__
+# define FLOAT_BIG_ENDIAN (__FLOAT_WORD_ORDER__ != __ORDER_LITTLE_ENDIAN__)
+#else
+# define FLOAT_BIG_ENDIAN (LDBL_EXPBIT0_WORD < NWORDS / 2)
+#endif
+
int
main ()
{
@@ -70,10 +76,10 @@
# 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)]
+ m.word[LDBL_EXPBIT0_WORD + (FLOAT_BIG_ENDIAN ? 1 : - 1)]
^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1);
# endif
- m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)]
+ m.word[LDBL_EXPBIT0_WORD + (FLOAT_BIG_ENDIAN ? 1 : - 1)]
|= (unsigned int) 1 << LDBL_EXPBIT0_BIT;
ASSERT (isnanl (m.value));
}
Index: b/tests/test-signbit.c
===================================================================
--- a/tests/test-signbit.c
+++ b/tests/test-signbit.c
@@ -56,6 +56,12 @@
long double minus_zerol = -0.0L;
#endif
+#ifdef __FLOAT_WORD_ORDER__
+# define FLOAT_BIG_ENDIAN (__FLOAT_WORD_ORDER__ != __ORDER_LITTLE_ENDIAN__)
+#else
+# define FLOAT_BIG_ENDIAN (LDBL_EXPBIT0_WORD < NWORDS / 2)
+#endif
+
static void
test_signbitf ()
{
@@ -176,10 +182,10 @@
# 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)]
+ m.word[LDBL_EXPBIT0_WORD + (FLOAT_BIG_ENDIAN ? 1 : - 1)]
^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1);
# endif
- m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)]
+ m.word[LDBL_EXPBIT0_WORD + (FLOAT_BIG_ENDIAN ? 1 : - 1)]
|= (unsigned int) 1 << LDBL_EXPBIT0_BIT;
(void) signbit (m.value);
#undef NWORDS
|