]>
Commit | Line | Data |
---|---|---|
2636ffe6 | 1 | /* `NAN' constant for IEEE 754 machines. MIPS version. |
568035b7 | 2 | Copyright (C) 1992-2013 Free Software Foundation, Inc. |
5a484dae AJ |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
2636ffe6 | 16 | License along with the GNU C Library; if not, see |
ab84e3ff | 17 | <http://www.gnu.org/licenses/>. */ |
5a484dae AJ |
18 | |
19 | #ifndef _MATH_H | |
20 | # error "Never use <bits/nan.h> directly; include <math.h> instead." | |
21 | #endif | |
22 | ||
23 | ||
2636ffe6 | 24 | /* IEEE Not A Number. */ |
67e971f1 TS |
25 | /* Note that MIPS has the qNaN and sNaN patterns reversed compared to most |
26 | other architectures. IEEE 754-1985 left the definition of this open to | |
2636ffe6 | 27 | implementations, and for MIPS the top bit of the mantissa must be SET to |
67e971f1 | 28 | indicate a sNaN. */ |
5a484dae | 29 | |
154a5429 RH |
30 | #if __GNUC_PREREQ(3,3) |
31 | ||
2636ffe6 | 32 | # define NAN (__builtin_nanf ("")) |
154a5429 RH |
33 | |
34 | #elif defined __GNUC__ | |
5a484dae AJ |
35 | |
36 | # define NAN \ | |
2636ffe6 TS |
37 | (__extension__ \ |
38 | ((union { unsigned __l __attribute__ ((__mode__ (__SI__))); float __d; }) \ | |
5a484dae AJ |
39 | { __l: 0x7fbfffffUL }).__d) |
40 | ||
41 | #else | |
42 | ||
43 | # include <endian.h> | |
44 | ||
45 | # if __BYTE_ORDER == __BIG_ENDIAN | |
67e971f1 | 46 | # define __qnan_bytes { 0x7f, 0xbf, 0xff, 0xff } |
5a484dae AJ |
47 | # endif |
48 | # if __BYTE_ORDER == __LITTLE_ENDIAN | |
67e971f1 | 49 | # define __qnan_bytes { 0xff, 0xff, 0xbf, 0x7f } |
5a484dae AJ |
50 | # endif |
51 | ||
67e971f1 TS |
52 | static union { unsigned char __c[4]; float __d; } __qnan_union |
53 | __attribute__ ((__unused__)) = { __qnan_bytes }; | |
54 | # define NAN (__qnan_union.__d) | |
5a484dae AJ |
55 | |
56 | #endif /* GCC. */ |