Fix ChangeLog typo
[glibc.git] / bits / floatn-common.h
blob1b3ab51aaf9cb6c7d7bc46fda4067a5868c7bbef
1 /* Macros to control TS 18661-3 glibc features where the same
2 definitions are appropriate for all platforms.
3 Copyright (C) 2017 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef _BITS_FLOATN_COMMON_H
21 #define _BITS_FLOATN_COMMON_H
23 #include <features.h>
25 /* This header should be included at the bottom of each bits/floatn.h.
26 It defines the following macros for each _FloatN and _FloatNx type,
27 where the same definitions, or definitions based only on the macros
28 in bits/floatn.h, are appropriate for all glibc configurations. */
30 /* Defined to 1 if the current compiler invocation provides a
31 floating-point type with the right format for this type, and this
32 glibc includes corresponding *fN or *fNx interfaces for it. */
33 #define __HAVE_FLOAT16 0
34 #define __HAVE_FLOAT32 0
35 #define __HAVE_FLOAT64 0
36 #define __HAVE_FLOAT32X 0
37 #define __HAVE_FLOAT64X 0
38 #define __HAVE_FLOAT128X 0
40 /* Defined to 1 if the corresponding __HAVE_<type> macro is 1 and the
41 type is the first with its format in the sequence of (the default
42 choices for) float, double, long double, _Float16, _Float32,
43 _Float64, _Float128, _Float32x, _Float64x, _Float128x for this
44 glibc; that is, if functions present once per floating-point format
45 rather than once per type are present for this type.
47 All configurations supported by glibc have _Float32 the same format
48 as float, _Float64 and _Float32x the same format as double, the
49 _Float64x the same format as either long double or _Float128. No
50 configurations support _Float128x or, as of GCC 7, have compiler
51 support for a type meeting the requirements for _Float128x. */
52 #define __HAVE_DISTINCT_FLOAT16 __HAVE_FLOAT16
53 #define __HAVE_DISTINCT_FLOAT32 0
54 #define __HAVE_DISTINCT_FLOAT64 0
55 #define __HAVE_DISTINCT_FLOAT32X 0
56 #define __HAVE_DISTINCT_FLOAT64X 0
57 #define __HAVE_DISTINCT_FLOAT128X __HAVE_FLOAT128X
59 /* Defined to 1 if __HAVE_FLOAT64X is 1 and _Float64x has the format
60 of long double. Otherwise, if __HAVE_FLOAT64X is 1, _Float64x has
61 the format of _Float128, which must be different from that of long
62 double. */
63 #define __HAVE_FLOAT64X_LONG_DOUBLE 0
65 /* Defined to 1 if any _FloatN or _FloatNx types that are not
66 ABI-distinct are however distinct types at the C language level (so
67 for the purposes of __builtin_types_compatible_p and _Generic). */
68 #if __GNUC_PREREQ (7, 0) && !defined __cplusplus
69 # define __HAVE_FLOATN_NOT_TYPEDEF 1
70 #else
71 # define __HAVE_FLOATN_NOT_TYPEDEF 0
72 #endif
74 /* Defined to concatenate the literal suffix to be used with _FloatN
75 or _FloatNx types, if __HAVE_<type> is 1. The corresponding
76 literal suffixes exist since GCC 7, for C only. */
77 #if __HAVE_FLOAT16
78 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
79 /* No corresponding suffix available for this type. */
80 # define __f16(x) ((_Float16) x##f)
81 # else
82 # define __f16(x) x##f16
83 # endif
84 #endif
86 #if __HAVE_FLOAT32
87 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
88 # define __f32(x) x##f
89 # else
90 # define __f32(x) x##f32
91 # endif
92 #endif
94 #if __HAVE_FLOAT64
95 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
96 # define __f64(x) x
97 # else
98 # define __f64(x) x##f64
99 # endif
100 #endif
102 #if __HAVE_FLOAT32X
103 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
104 # define __f32x(x) x
105 # else
106 # define __f32x(x) x##f32x
107 # endif
108 #endif
110 #if __HAVE_FLOAT64X
111 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
112 # if __HAVE_FLOAT64X_LONG_DOUBLE
113 # define __f64x(x) x##l
114 # else
115 # define __f64x(x) __f128 (x)
116 # endif
117 # else
118 # define __f64x(x) x##f64x
119 # endif
120 #endif
122 #if __HAVE_FLOAT128X
123 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
124 # error "_Float128X supported but no constant suffix"
125 # else
126 # define __f128x(x) x##f128x
127 # endif
128 #endif
130 /* Defined to a complex type if __HAVE_<type> is 1. */
131 #if __HAVE_FLOAT16
132 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
133 typedef _Complex float __cfloat16 __attribute__ ((__mode__ (__HC__)));
134 # define __CFLOAT16 __cfloat16
135 # else
136 # define __CFLOAT16 _Complex _Float16
137 # endif
138 #endif
140 #if __HAVE_FLOAT32
141 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
142 # define __CFLOAT32 _Complex float
143 # else
144 # define __CFLOAT32 _Complex _Float32
145 # endif
146 #endif
148 #if __HAVE_FLOAT64
149 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
150 # define __CFLOAT64 _Complex double
151 # else
152 # define __CFLOAT64 _Complex _Float64
153 # endif
154 #endif
156 #if __HAVE_FLOAT32X
157 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
158 # define __CFLOAT32X _Complex double
159 # else
160 # define __CFLOAT32X _Complex _Float32x
161 # endif
162 #endif
164 #if __HAVE_FLOAT64X
165 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
166 # if __HAVE_FLOAT64X_LONG_DOUBLE
167 # define __CFLOAT64X _Complex long double
168 # else
169 # define __CFLOAT64X __CFLOAT128
170 # endif
171 # else
172 # define __CFLOAT64X _Complex _Float64x
173 # endif
174 #endif
176 #if __HAVE_FLOAT128X
177 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
178 # error "_Float128X supported but no complex type"
179 # else
180 # define __CFLOAT128X _Complex _Float128x
181 # endif
182 #endif
184 /* The remaining of this file provides support for older compilers. */
185 #if __HAVE_FLOAT16
187 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
188 typedef float _Float16 __attribute__ ((__mode__ (__HF__)));
189 # endif
191 # if !__GNUC_PREREQ (7, 0)
192 # define __builtin_huge_valf16() ((_Float16) __builtin_huge_val ())
193 # define __builtin_inff16() ((_Float16) __builtin_inf ())
194 # define __builtin_nanf16(x) ((_Float16) __builtin_nan (x))
195 # define __builtin_nansf16(x) ((_Float16) __builtin_nans (x))
196 # endif
198 #endif
200 #if __HAVE_FLOAT32
202 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
203 typedef float _Float32;
204 # endif
206 # if !__GNUC_PREREQ (7, 0)
207 # define __builtin_huge_valf32() (__builtin_huge_valf ())
208 # define __builtin_inff32() (__builtin_inff ())
209 # define __builtin_nanf32(x) (__builtin_nanf (x))
210 # define __builtin_nansf32(x) (__builtin_nansf (x))
211 # endif
213 #endif
215 #if __HAVE_FLOAT64
217 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
218 typedef double _Float64;
219 # endif
221 # if !__GNUC_PREREQ (7, 0)
222 # define __builtin_huge_valf64() (__builtin_huge_val ())
223 # define __builtin_inff64() (__builtin_inf ())
224 # define __builtin_nanf64(x) (__builtin_nan (x))
225 # define __builtin_nansf64(x) (__builtin_nans (x))
226 # endif
228 #endif
230 #if __HAVE_FLOAT32X
232 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
233 typedef double _Float32x;
234 # endif
236 # if !__GNUC_PREREQ (7, 0)
237 # define __builtin_huge_valf32x() (__builtin_huge_val ())
238 # define __builtin_inff32x() (__builtin_inf ())
239 # define __builtin_nanf32x(x) (__builtin_nan (x))
240 # define __builtin_nansf32x(x) (__builtin_nans (x))
241 # endif
243 #endif
245 #if __HAVE_FLOAT64X
247 # if __HAVE_FLOAT64X_LONG_DOUBLE
249 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
250 typedef long double _Float64x;
251 # endif
253 # if !__GNUC_PREREQ (7, 0)
254 # define __builtin_huge_valf64x() (__builtin_huge_vall ())
255 # define __builtin_inff64x() (__builtin_infl ())
256 # define __builtin_nanf64x(x) (__builtin_nanl (x))
257 # define __builtin_nansf64x(x) (__builtin_nansl (x))
258 # endif
260 # else
262 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
263 typedef _Float128 _Float64x;
264 # endif
266 # if !__GNUC_PREREQ (7, 0)
267 # define __builtin_huge_valf64x() (__builtin_huge_valf128 ())
268 # define __builtin_inff64x() (__builtin_inff128 ())
269 # define __builtin_nanf64x(x) (__builtin_nanf128 (x))
270 # define __builtin_nansf64x(x) (__builtin_nansf128 (x))
271 # endif
273 # endif
275 #endif
277 #if __HAVE_FLOAT128X
279 # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
280 # error "_Float128x supported but no type"
281 # endif
283 # if !__GNUC_PREREQ (7, 0)
284 # define __builtin_huge_valf128x() ((_Float128x) __builtin_huge_val ())
285 # define __builtin_inff128x() ((_Float128x) __builtin_inf ())
286 # define __builtin_nanf128x(x) ((_Float128x) __builtin_nan (x))
287 # define __builtin_nansf128x(x) ((_Float128x) __builtin_nans (x))
288 # endif
290 #endif
292 #endif /* _BITS_FLOATN_COMMON_H */