[__USE_BSD] (sig_t): New typedef.
[glibc.git] / sysdeps / ieee754 / huge_val.h
blob183f213b831e9c6730f9720a0cca004aa2f95e95
1 /* `HUGE_VAL' constant for IEEE 754 machines (where it is infinity).
2 Used by <stdlib.h> and <math.h> functions for overflow.
4 Copyright (C) 1992, 1995 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public
18 License along with the GNU C Library; see the file COPYING.LIB. If
19 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
20 Cambridge, MA 02139, USA. */
22 #ifndef _HUGE_VAL_H
23 #define _HUGE_VAL_H 1
25 #include <features.h>
26 #include <sys/cdefs.h>
27 #include <endian.h>
29 /* IEEE positive infinity (-HUGE_VAL is negative infinity). */
31 #if __BYTE_ORDER == __BIG_ENDIAN
32 #define __HUGE_VAL_bytes { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }
33 #endif
34 #if __BYTE_ORDER == __LITTLE_ENDIAN
35 #define __HUGE_VAL_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }
36 #endif
38 #define __huge_val_t union { unsigned char __c[8]; double __d; }
39 #ifdef __GNUC__
40 #define HUGE_VAL (__extension__ \
41 ((__huge_val_t) { __c: __HUGE_VAL_bytes }).__d)
42 #else /* Not GCC. */
43 static __huge_val_t __huge_val = { __HUGE_VAL_bytes };
44 #define HUGE_VAL (__huge_val.__d)
45 #endif /* GCC. */
48 /* GNU extensions: (float) HUGE_VALf and (long double) HUGE_VALl. */
50 #ifdef __USE_GNU
52 #if __BYTE_ORDER == __BIG_ENDIAN
53 #define __HUGE_VALf_bytes { 0x7f, 0x80, 0, 0 }
54 #endif
55 #if __BYTE_ORDER == __LITTLE_ENDIAN
56 #define __HUGE_VALf_bytes { 0, 0, 0x80, 0x7f }
57 #endif
59 #define __huge_valf_t union { unsigned char __c[4]; float __f; }
60 #ifdef __GNUC__
61 #define HUGE_VALf (__extension__ \
62 ((__huge_valf_t) { __c: __HUGE_VALf_bytes }).__f)
63 #else /* Not GCC. */
64 static __huge_valf_t __huge_valf = { __HUGE_VALf_bytes };
65 #define HUGE_VALf (__huge_valf.__f)
66 #endif /* GCC. */
68 #if __BYTE_ORDER == __BIG_ENDIAN
69 #define __HUGE_VALl_bytes { 0x7f, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
70 #endif
71 #if __BYTE_ORDER == __LITTLE_ENDIAN
72 #define __HUGE_VALl_bytes { 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0x7f, 0, 0 }
73 #endif
75 #define __huge_vall_t union { unsigned char __c[12]; long double __ld; }
76 #ifdef __GNUC__
77 #define HUGE_VALl (__extension__ \
78 ((__huge_vall_t) { __c: __HUGE_VALl_bytes }).__ld)
79 #else /* Not GCC. */
80 static __huge_vall_t __huge_vall = { __HUGE_VALl_bytes };
81 #define HUGE_VALl (__huge_vall.__ld)
82 #endif /* GCC. */
84 #endif /* __USE_GNU. */
87 #endif /* huge_val.h */