xref: /utopia/UTPA2-700.0.x/projects/tools/lint/mips-linux-gnu_include/bits/nan.h (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1*53ee8cc1Swenshuai.xi /* `NAN' constant for IEEE 754 machines.
2*53ee8cc1Swenshuai.xi    Copyright (C) 1992, 1996, 1997, 1999, 2002, 2004
3*53ee8cc1Swenshuai.xi    Free Software Foundation, Inc.
4*53ee8cc1Swenshuai.xi    This file is part of the GNU C Library.
5*53ee8cc1Swenshuai.xi 
6*53ee8cc1Swenshuai.xi    The GNU C Library is free software; you can redistribute it and/or
7*53ee8cc1Swenshuai.xi    modify it under the terms of the GNU Lesser General Public
8*53ee8cc1Swenshuai.xi    License as published by the Free Software Foundation; either
9*53ee8cc1Swenshuai.xi    version 2.1 of the License, or (at your option) any later version.
10*53ee8cc1Swenshuai.xi 
11*53ee8cc1Swenshuai.xi    The GNU C Library is distributed in the hope that it will be useful,
12*53ee8cc1Swenshuai.xi    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*53ee8cc1Swenshuai.xi    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14*53ee8cc1Swenshuai.xi    Lesser General Public License for more details.
15*53ee8cc1Swenshuai.xi 
16*53ee8cc1Swenshuai.xi    You should have received a copy of the GNU Lesser General Public
17*53ee8cc1Swenshuai.xi    License along with the GNU C Library; if not, write to the Free
18*53ee8cc1Swenshuai.xi    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19*53ee8cc1Swenshuai.xi    02111-1307 USA.  */
20*53ee8cc1Swenshuai.xi 
21*53ee8cc1Swenshuai.xi #ifndef _MATH_H
22*53ee8cc1Swenshuai.xi # error "Never use <bits/nan.h> directly; include <math.h> instead."
23*53ee8cc1Swenshuai.xi #endif
24*53ee8cc1Swenshuai.xi 
25*53ee8cc1Swenshuai.xi 
26*53ee8cc1Swenshuai.xi /* IEEE Not A Number (QNaN). Note that MIPS has the QNaN and SNaN patterns
27*53ee8cc1Swenshuai.xi    reversed compared to most other architectures. The IEEE spec left
28*53ee8cc1Swenshuai.xi    the definition of this open to implementations, and for MIPS the top
29*53ee8cc1Swenshuai.xi    bit of the mantissa must be SET to indicate a SNaN.  */
30*53ee8cc1Swenshuai.xi 
31*53ee8cc1Swenshuai.xi #if __GNUC_PREREQ(3,3)
32*53ee8cc1Swenshuai.xi 
33*53ee8cc1Swenshuai.xi # define NAN	(__builtin_nanf(""))
34*53ee8cc1Swenshuai.xi 
35*53ee8cc1Swenshuai.xi #elif defined __GNUC__
36*53ee8cc1Swenshuai.xi 
37*53ee8cc1Swenshuai.xi # define NAN \
38*53ee8cc1Swenshuai.xi   (__extension__                                                            \
39*53ee8cc1Swenshuai.xi    ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; })  \
40*53ee8cc1Swenshuai.xi     { __l: 0x7fbfffffUL }).__d)
41*53ee8cc1Swenshuai.xi 
42*53ee8cc1Swenshuai.xi #else
43*53ee8cc1Swenshuai.xi 
44*53ee8cc1Swenshuai.xi # include <endian.h>
45*53ee8cc1Swenshuai.xi 
46*53ee8cc1Swenshuai.xi # if __BYTE_ORDER == __BIG_ENDIAN
47*53ee8cc1Swenshuai.xi #  define __nan_bytes		{ 0x7f, 0xbf, 0xff, 0xff }
48*53ee8cc1Swenshuai.xi # endif
49*53ee8cc1Swenshuai.xi # if __BYTE_ORDER == __LITTLE_ENDIAN
50*53ee8cc1Swenshuai.xi #  define __nan_bytes		{ 0xff, 0xff, 0xbf, 0x7f }
51*53ee8cc1Swenshuai.xi # endif
52*53ee8cc1Swenshuai.xi 
53*53ee8cc1Swenshuai.xi static union { unsigned char __c[4]; float __d; } __nan_union = { __nan_bytes };
54*53ee8cc1Swenshuai.xi # define NAN	(__nan_union.__d)
55*53ee8cc1Swenshuai.xi 
56*53ee8cc1Swenshuai.xi #endif	/* GCC.  */
57