xref: /utopia/UTPA2-700.0.x/projects/tools/lint/mips-linux-gnu_include/bits/huge_val.h (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1*53ee8cc1Swenshuai.xi /* `HUGE_VAL' constant for IEEE 754 machines (where it is infinity).
2*53ee8cc1Swenshuai.xi    Used by <stdlib.h> and <math.h> functions for overflow.
3*53ee8cc1Swenshuai.xi    Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000, 2004
4*53ee8cc1Swenshuai.xi    Free Software Foundation, Inc.
5*53ee8cc1Swenshuai.xi    This file is part of the GNU C Library.
6*53ee8cc1Swenshuai.xi 
7*53ee8cc1Swenshuai.xi    The GNU C Library is free software; you can redistribute it and/or
8*53ee8cc1Swenshuai.xi    modify it under the terms of the GNU Lesser General Public
9*53ee8cc1Swenshuai.xi    License as published by the Free Software Foundation; either
10*53ee8cc1Swenshuai.xi    version 2.1 of the License, or (at your option) any later version.
11*53ee8cc1Swenshuai.xi 
12*53ee8cc1Swenshuai.xi    The GNU C Library is distributed in the hope that it will be useful,
13*53ee8cc1Swenshuai.xi    but WITHOUT ANY WARRANTY; without even the implied warranty of
14*53ee8cc1Swenshuai.xi    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15*53ee8cc1Swenshuai.xi    Lesser General Public License for more details.
16*53ee8cc1Swenshuai.xi 
17*53ee8cc1Swenshuai.xi    You should have received a copy of the GNU Lesser General Public
18*53ee8cc1Swenshuai.xi    License along with the GNU C Library; if not, write to the Free
19*53ee8cc1Swenshuai.xi    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20*53ee8cc1Swenshuai.xi    02111-1307 USA.  */
21*53ee8cc1Swenshuai.xi 
22*53ee8cc1Swenshuai.xi #ifndef _MATH_H
23*53ee8cc1Swenshuai.xi # error "Never use <bits/huge_val.h> directly; include <math.h> instead."
24*53ee8cc1Swenshuai.xi #endif
25*53ee8cc1Swenshuai.xi 
26*53ee8cc1Swenshuai.xi /* IEEE positive infinity (-HUGE_VAL is negative infinity).  */
27*53ee8cc1Swenshuai.xi 
28*53ee8cc1Swenshuai.xi #if __GNUC_PREREQ(3,3)
29*53ee8cc1Swenshuai.xi # define HUGE_VAL	(__builtin_huge_val())
30*53ee8cc1Swenshuai.xi #elif __GNUC_PREREQ(2,96)
31*53ee8cc1Swenshuai.xi # define HUGE_VAL	(__extension__ 0x1.0p2047)
32*53ee8cc1Swenshuai.xi #elif defined __GNUC__
33*53ee8cc1Swenshuai.xi 
34*53ee8cc1Swenshuai.xi # define HUGE_VAL \
35*53ee8cc1Swenshuai.xi   (__extension__							      \
36*53ee8cc1Swenshuai.xi    ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; })   \
37*53ee8cc1Swenshuai.xi     { __l: 0x7ff0000000000000ULL }).__d)
38*53ee8cc1Swenshuai.xi 
39*53ee8cc1Swenshuai.xi #else /* not GCC */
40*53ee8cc1Swenshuai.xi 
41*53ee8cc1Swenshuai.xi # include <endian.h>
42*53ee8cc1Swenshuai.xi 
43*53ee8cc1Swenshuai.xi typedef union { unsigned char __c[8]; double __d; } __huge_val_t;
44*53ee8cc1Swenshuai.xi 
45*53ee8cc1Swenshuai.xi # if __BYTE_ORDER == __BIG_ENDIAN
46*53ee8cc1Swenshuai.xi #  define __HUGE_VAL_bytes	{ 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }
47*53ee8cc1Swenshuai.xi # endif
48*53ee8cc1Swenshuai.xi # if __BYTE_ORDER == __LITTLE_ENDIAN
49*53ee8cc1Swenshuai.xi #  define __HUGE_VAL_bytes	{ 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }
50*53ee8cc1Swenshuai.xi # endif
51*53ee8cc1Swenshuai.xi 
52*53ee8cc1Swenshuai.xi static __huge_val_t __huge_val = { __HUGE_VAL_bytes };
53*53ee8cc1Swenshuai.xi # define HUGE_VAL	(__huge_val.__d)
54*53ee8cc1Swenshuai.xi 
55*53ee8cc1Swenshuai.xi #endif	/* GCC.  */
56