xref: /freebsd/contrib/llvm-project/clang/lib/Headers/float.h (revision e32fecd0c2c3ee37c47ee100f169e7eb0282a873)
1 /*===---- float.h - Characteristics of floating point types ----------------===
2  *
3  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4  * See https://llvm.org/LICENSE.txt for license information.
5  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6  *
7  *===-----------------------------------------------------------------------===
8  */
9 
10 #ifndef __CLANG_FLOAT_H
11 #define __CLANG_FLOAT_H
12 
13 /* If we're on MinGW, fall back to the system's float.h, which might have
14  * additional definitions provided for Windows.
15  * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx
16  *
17  * Also fall back on Darwin and AIX to allow additional definitions and
18  * implementation-defined values.
19  */
20 #if (defined(__APPLE__) || defined(__MINGW32__) || defined(_MSC_VER) ||        \
21      defined(_AIX)) &&                                                         \
22     __STDC_HOSTED__ && __has_include_next(<float.h>)
23 
24 /* Prior to Apple's 10.7 SDK, float.h SDK header used to apply an extra level
25  * of #include_next<float.h> to keep Metrowerks compilers happy. Avoid this
26  * extra indirection.
27  */
28 #ifdef __APPLE__
29 #define _FLOAT_H_
30 #endif
31 
32 #  include_next <float.h>
33 
34 /* Undefine anything that we'll be redefining below. */
35 #  undef FLT_EVAL_METHOD
36 #  undef FLT_ROUNDS
37 #  undef FLT_RADIX
38 #  undef FLT_MANT_DIG
39 #  undef DBL_MANT_DIG
40 #  undef LDBL_MANT_DIG
41 #  if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) ||              \
42       __cplusplus >= 201103L ||                                                \
43       (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
44 #    undef DECIMAL_DIG
45 #  endif
46 #  undef FLT_DIG
47 #  undef DBL_DIG
48 #  undef LDBL_DIG
49 #  undef FLT_MIN_EXP
50 #  undef DBL_MIN_EXP
51 #  undef LDBL_MIN_EXP
52 #  undef FLT_MIN_10_EXP
53 #  undef DBL_MIN_10_EXP
54 #  undef LDBL_MIN_10_EXP
55 #  undef FLT_MAX_EXP
56 #  undef DBL_MAX_EXP
57 #  undef LDBL_MAX_EXP
58 #  undef FLT_MAX_10_EXP
59 #  undef DBL_MAX_10_EXP
60 #  undef LDBL_MAX_10_EXP
61 #  undef FLT_MAX
62 #  undef DBL_MAX
63 #  undef LDBL_MAX
64 #  undef FLT_EPSILON
65 #  undef DBL_EPSILON
66 #  undef LDBL_EPSILON
67 #  undef FLT_MIN
68 #  undef DBL_MIN
69 #  undef LDBL_MIN
70 #  if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) ||              \
71       __cplusplus >= 201703L ||                                                \
72       (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
73 #    undef FLT_TRUE_MIN
74 #    undef DBL_TRUE_MIN
75 #    undef LDBL_TRUE_MIN
76 #    undef FLT_DECIMAL_DIG
77 #    undef DBL_DECIMAL_DIG
78 #    undef LDBL_DECIMAL_DIG
79 #    undef FLT_HAS_SUBNORM
80 #    undef DBL_HAS_SUBNORM
81 #    undef LDBL_HAS_SUBNORM
82 #  endif
83 #endif
84 
85 /* Characteristics of floating point types, C99 5.2.4.2.2 */
86 
87 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
88 #define FLT_ROUNDS (__builtin_flt_rounds())
89 #define FLT_RADIX __FLT_RADIX__
90 
91 #define FLT_MANT_DIG __FLT_MANT_DIG__
92 #define DBL_MANT_DIG __DBL_MANT_DIG__
93 #define LDBL_MANT_DIG __LDBL_MANT_DIG__
94 
95 #if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) ||                \
96     __cplusplus >= 201103L ||                                                  \
97     (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
98 #  define DECIMAL_DIG __DECIMAL_DIG__
99 #endif
100 
101 #define FLT_DIG __FLT_DIG__
102 #define DBL_DIG __DBL_DIG__
103 #define LDBL_DIG __LDBL_DIG__
104 
105 #define FLT_MIN_EXP __FLT_MIN_EXP__
106 #define DBL_MIN_EXP __DBL_MIN_EXP__
107 #define LDBL_MIN_EXP __LDBL_MIN_EXP__
108 
109 #define FLT_MIN_10_EXP __FLT_MIN_10_EXP__
110 #define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
111 #define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
112 
113 #define FLT_MAX_EXP __FLT_MAX_EXP__
114 #define DBL_MAX_EXP __DBL_MAX_EXP__
115 #define LDBL_MAX_EXP __LDBL_MAX_EXP__
116 
117 #define FLT_MAX_10_EXP __FLT_MAX_10_EXP__
118 #define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
119 #define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
120 
121 #define FLT_MAX __FLT_MAX__
122 #define DBL_MAX __DBL_MAX__
123 #define LDBL_MAX __LDBL_MAX__
124 
125 #define FLT_EPSILON __FLT_EPSILON__
126 #define DBL_EPSILON __DBL_EPSILON__
127 #define LDBL_EPSILON __LDBL_EPSILON__
128 
129 #define FLT_MIN __FLT_MIN__
130 #define DBL_MIN __DBL_MIN__
131 #define LDBL_MIN __LDBL_MIN__
132 
133 #if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) ||                \
134     __cplusplus >= 201703L ||                                                  \
135     (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
136 #  define FLT_TRUE_MIN __FLT_DENORM_MIN__
137 #  define DBL_TRUE_MIN __DBL_DENORM_MIN__
138 #  define LDBL_TRUE_MIN __LDBL_DENORM_MIN__
139 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
140 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
141 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
142 #  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
143 #  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
144 #  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
145 #endif
146 
147 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
148 #  define FLT16_MANT_DIG    __FLT16_MANT_DIG__
149 #  define FLT16_DECIMAL_DIG __FLT16_DECIMAL_DIG__
150 #  define FLT16_DIG         __FLT16_DIG__
151 #  define FLT16_MIN_EXP     __FLT16_MIN_EXP__
152 #  define FLT16_MIN_10_EXP  __FLT16_MIN_10_EXP__
153 #  define FLT16_MAX_EXP     __FLT16_MAX_EXP__
154 #  define FLT16_MAX_10_EXP  __FLT16_MAX_10_EXP__
155 #  define FLT16_MAX         __FLT16_MAX__
156 #  define FLT16_EPSILON     __FLT16_EPSILON__
157 #  define FLT16_MIN         __FLT16_MIN__
158 #  define FLT16_TRUE_MIN    __FLT16_TRUE_MIN__
159 #endif /* __STDC_WANT_IEC_60559_TYPES_EXT__ */
160 
161 #endif /* __CLANG_FLOAT_H */
162