1 | /* Declarations for math functions. |
2 | Copyright (C) 1991-2018 Free Software Foundation, Inc. |
3 | This file is part of the GNU C Library. |
4 | |
5 | The GNU C Library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2.1 of the License, or (at your option) any later version. |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Lesser General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ |
18 | |
19 | /* |
20 | * ISO C99 Standard: 7.12 Mathematics <math.h> |
21 | */ |
22 | |
23 | #ifndef _MATH_H |
24 | #define _MATH_H 1 |
25 | |
26 | #define |
27 | #include <bits/libc-header-start.h> |
28 | |
29 | #if defined log && defined __GNUC__ |
30 | # warning A macro called log was already defined when <math.h> was included. |
31 | # warning This will cause compilation problems. |
32 | #endif |
33 | |
34 | __BEGIN_DECLS |
35 | |
36 | /* Get definitions of __intmax_t and __uintmax_t. */ |
37 | #include <bits/types.h> |
38 | |
39 | /* Get machine-dependent vector math functions declarations. */ |
40 | #include <bits/math-vector.h> |
41 | |
42 | /* Gather machine dependent type support. */ |
43 | #include <bits/floatn.h> |
44 | |
45 | /* Value returned on overflow. With IEEE 754 floating point, this is |
46 | +Infinity, otherwise the largest representable positive value. */ |
47 | #if __GNUC_PREREQ (3, 3) |
48 | # define HUGE_VAL (__builtin_huge_val ()) |
49 | #else |
50 | /* This may provoke compiler warnings, and may not be rounded to |
51 | +Infinity in all IEEE 754 rounding modes, but is the best that can |
52 | be done in ISO C while remaining a constant expression. 10,000 is |
53 | greater than the maximum (decimal) exponent for all supported |
54 | floating-point formats and widths. */ |
55 | # define HUGE_VAL 1e10000 |
56 | #endif |
57 | #ifdef __USE_ISOC99 |
58 | # if __GNUC_PREREQ (3, 3) |
59 | # define HUGE_VALF (__builtin_huge_valf ()) |
60 | # define HUGE_VALL (__builtin_huge_vall ()) |
61 | # else |
62 | # define HUGE_VALF 1e10000f |
63 | # define HUGE_VALL 1e10000L |
64 | # endif |
65 | #endif |
66 | #if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT) |
67 | # define HUGE_VAL_F16 (__builtin_huge_valf16 ()) |
68 | #endif |
69 | #if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT) |
70 | # define HUGE_VAL_F32 (__builtin_huge_valf32 ()) |
71 | #endif |
72 | #if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT) |
73 | # define HUGE_VAL_F64 (__builtin_huge_valf64 ()) |
74 | #endif |
75 | #if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) |
76 | # define HUGE_VAL_F128 (__builtin_huge_valf128 ()) |
77 | #endif |
78 | #if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT) |
79 | # define HUGE_VAL_F32X (__builtin_huge_valf32x ()) |
80 | #endif |
81 | #if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT) |
82 | # define HUGE_VAL_F64X (__builtin_huge_valf64x ()) |
83 | #endif |
84 | #if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT) |
85 | # define HUGE_VAL_F128X (__builtin_huge_valf128x ()) |
86 | #endif |
87 | |
88 | #ifdef __USE_ISOC99 |
89 | /* IEEE positive infinity. */ |
90 | # if __GNUC_PREREQ (3, 3) |
91 | # define INFINITY (__builtin_inff ()) |
92 | # else |
93 | # define INFINITY HUGE_VALF |
94 | # endif |
95 | |
96 | /* IEEE Not A Number. */ |
97 | # if __GNUC_PREREQ (3, 3) |
98 | # define NAN (__builtin_nanf ("")) |
99 | # else |
100 | /* This will raise an "invalid" exception outside static initializers, |
101 | but is the best that can be done in ISO C while remaining a |
102 | constant expression. */ |
103 | # define NAN (0.0f / 0.0f) |
104 | # endif |
105 | #endif /* __USE_ISOC99 */ |
106 | |
107 | #if __GLIBC_USE (IEC_60559_BFP_EXT) |
108 | /* Signaling NaN macros, if supported. */ |
109 | # if __GNUC_PREREQ (3, 3) |
110 | # define SNANF (__builtin_nansf ("")) |
111 | # define SNAN (__builtin_nans ("")) |
112 | # define SNANL (__builtin_nansl ("")) |
113 | # endif |
114 | #endif |
115 | #if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT) |
116 | # define SNANF16 (__builtin_nansf16 ("")) |
117 | #endif |
118 | #if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT) |
119 | # define SNANF32 (__builtin_nansf32 ("")) |
120 | #endif |
121 | #if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT) |
122 | # define SNANF64 (__builtin_nansf64 ("")) |
123 | #endif |
124 | #if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) |
125 | # define SNANF128 (__builtin_nansf128 ("")) |
126 | #endif |
127 | #if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT) |
128 | # define SNANF32X (__builtin_nansf32x ("")) |
129 | #endif |
130 | #if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT) |
131 | # define SNANF64X (__builtin_nansf64x ("")) |
132 | #endif |
133 | #if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT) |
134 | # define SNANF128X (__builtin_nansf128x ("")) |
135 | #endif |
136 | |
137 | /* Get __GLIBC_FLT_EVAL_METHOD. */ |
138 | #include <bits/flt-eval-method.h> |
139 | |
140 | #ifdef __USE_ISOC99 |
141 | /* Define the following typedefs. |
142 | |
143 | float_t floating-point type at least as wide as `float' used |
144 | to evaluate `float' expressions |
145 | double_t floating-point type at least as wide as `double' used |
146 | to evaluate `double' expressions |
147 | */ |
148 | # if __GLIBC_FLT_EVAL_METHOD == 0 || __GLIBC_FLT_EVAL_METHOD == 16 |
149 | typedef float float_t; |
150 | typedef double double_t; |
151 | # elif __GLIBC_FLT_EVAL_METHOD == 1 |
152 | typedef double float_t; |
153 | typedef double double_t; |
154 | # elif __GLIBC_FLT_EVAL_METHOD == 2 |
155 | typedef long double float_t; |
156 | typedef long double double_t; |
157 | # elif __GLIBC_FLT_EVAL_METHOD == 32 |
158 | typedef _Float32 float_t; |
159 | typedef double double_t; |
160 | # elif __GLIBC_FLT_EVAL_METHOD == 33 |
161 | typedef _Float32x float_t; |
162 | typedef _Float32x double_t; |
163 | # elif __GLIBC_FLT_EVAL_METHOD == 64 |
164 | typedef _Float64 float_t; |
165 | typedef _Float64 double_t; |
166 | # elif __GLIBC_FLT_EVAL_METHOD == 65 |
167 | typedef _Float64x float_t; |
168 | typedef _Float64x double_t; |
169 | # elif __GLIBC_FLT_EVAL_METHOD == 128 |
170 | typedef _Float128 float_t; |
171 | typedef _Float128 double_t; |
172 | # elif __GLIBC_FLT_EVAL_METHOD == 129 |
173 | typedef _Float128x float_t; |
174 | typedef _Float128x double_t; |
175 | # else |
176 | # error "Unknown __GLIBC_FLT_EVAL_METHOD" |
177 | # endif |
178 | #endif |
179 | |
180 | /* Define macros for the return values of ilogb and llogb, based on |
181 | __FP_LOGB0_IS_MIN and __FP_LOGBNAN_IS_MIN. |
182 | |
183 | FP_ILOGB0 Expands to a value returned by `ilogb (0.0)'. |
184 | FP_ILOGBNAN Expands to a value returned by `ilogb (NAN)'. |
185 | FP_LLOGB0 Expands to a value returned by `llogb (0.0)'. |
186 | FP_LLOGBNAN Expands to a value returned by `llogb (NAN)'. |
187 | |
188 | */ |
189 | |
190 | #include <bits/fp-logb.h> |
191 | #ifdef __USE_ISOC99 |
192 | # if __FP_LOGB0_IS_MIN |
193 | # define FP_ILOGB0 (-2147483647 - 1) |
194 | # else |
195 | # define FP_ILOGB0 (-2147483647) |
196 | # endif |
197 | # if __FP_LOGBNAN_IS_MIN |
198 | # define FP_ILOGBNAN (-2147483647 - 1) |
199 | # else |
200 | # define FP_ILOGBNAN 2147483647 |
201 | # endif |
202 | #endif |
203 | #if __GLIBC_USE (IEC_60559_BFP_EXT) |
204 | # if __WORDSIZE == 32 |
205 | # define __FP_LONG_MAX 0x7fffffffL |
206 | # else |
207 | # define __FP_LONG_MAX 0x7fffffffffffffffL |
208 | # endif |
209 | # if __FP_LOGB0_IS_MIN |
210 | # define FP_LLOGB0 (-__FP_LONG_MAX - 1) |
211 | # else |
212 | # define FP_LLOGB0 (-__FP_LONG_MAX) |
213 | # endif |
214 | # if __FP_LOGBNAN_IS_MIN |
215 | # define FP_LLOGBNAN (-__FP_LONG_MAX - 1) |
216 | # else |
217 | # define FP_LLOGBNAN __FP_LONG_MAX |
218 | # endif |
219 | #endif |
220 | |
221 | /* Get the architecture specific values describing the floating-point |
222 | evaluation. The following symbols will get defined: |
223 | |
224 | FP_FAST_FMA |
225 | FP_FAST_FMAF |
226 | FP_FAST_FMAL |
227 | If defined it indicates that the `fma' function |
228 | generally executes about as fast as a multiply and an add. |
229 | This macro is defined only iff the `fma' function is |
230 | implemented directly with a hardware multiply-add instructions. |
231 | */ |
232 | |
233 | #include <bits/fp-fast.h> |
234 | |
235 | #if __GLIBC_USE (IEC_60559_BFP_EXT) |
236 | /* Rounding direction macros for fromfp functions. */ |
237 | enum |
238 | { |
239 | FP_INT_UPWARD = |
240 | # define FP_INT_UPWARD 0 |
241 | FP_INT_UPWARD, |
242 | FP_INT_DOWNWARD = |
243 | # define FP_INT_DOWNWARD 1 |
244 | FP_INT_DOWNWARD, |
245 | FP_INT_TOWARDZERO = |
246 | # define FP_INT_TOWARDZERO 2 |
247 | FP_INT_TOWARDZERO, |
248 | FP_INT_TONEARESTFROMZERO = |
249 | # define FP_INT_TONEARESTFROMZERO 3 |
250 | FP_INT_TONEARESTFROMZERO, |
251 | FP_INT_TONEAREST = |
252 | # define FP_INT_TONEAREST 4 |
253 | FP_INT_TONEAREST, |
254 | }; |
255 | #endif |
256 | |
257 | /* The file <bits/mathcalls.h> contains the prototypes for all the |
258 | actual math functions. These macros are used for those prototypes, |
259 | so we can easily declare each function as both `name' and `__name', |
260 | and can declare the float versions `namef' and `__namef'. */ |
261 | |
262 | #define __SIMD_DECL(function) __CONCAT (__DECL_SIMD_, function) |
263 | |
264 | #define __MATHCALL_VEC(function, suffix, args) \ |
265 | __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \ |
266 | __MATHCALL (function, suffix, args) |
267 | |
268 | #define __MATHDECL_VEC(type, function,suffix, args) \ |
269 | __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \ |
270 | __MATHDECL(type, function,suffix, args) |
271 | |
272 | #define __MATHCALL(function,suffix, args) \ |
273 | __MATHDECL (_Mdouble_,function,suffix, args) |
274 | #define __MATHDECL(type, function,suffix, args) \ |
275 | __MATHDECL_1(type, function,suffix, args); \ |
276 | __MATHDECL_1(type, __CONCAT(__,function),suffix, args) |
277 | #define __MATHCALLX(function,suffix, args, attrib) \ |
278 | __MATHDECLX (_Mdouble_,function,suffix, args, attrib) |
279 | #define __MATHDECLX(type, function,suffix, args, attrib) \ |
280 | __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \ |
281 | __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib) |
282 | #define __MATHDECL_1(type, function,suffix, args) \ |
283 | extern type __MATH_PRECNAME(function,suffix) args __THROW |
284 | |
285 | #define _Mdouble_ double |
286 | #define __MATH_PRECNAME(name,r) __CONCAT(name,r) |
287 | #define __MATH_DECLARING_DOUBLE 1 |
288 | #define __MATH_DECLARING_FLOATN 0 |
289 | #include <bits/mathcalls-helper-functions.h> |
290 | #include <bits/mathcalls.h> |
291 | #undef _Mdouble_ |
292 | #undef __MATH_PRECNAME |
293 | #undef __MATH_DECLARING_DOUBLE |
294 | #undef __MATH_DECLARING_FLOATN |
295 | |
296 | #ifdef __USE_ISOC99 |
297 | |
298 | |
299 | /* Include the file of declarations again, this time using `float' |
300 | instead of `double' and appending f to each function name. */ |
301 | |
302 | # define _Mdouble_ float |
303 | # define __MATH_PRECNAME(name,r) name##f##r |
304 | # define __MATH_DECLARING_DOUBLE 0 |
305 | # define __MATH_DECLARING_FLOATN 0 |
306 | # include <bits/mathcalls-helper-functions.h> |
307 | # include <bits/mathcalls.h> |
308 | # undef _Mdouble_ |
309 | # undef __MATH_PRECNAME |
310 | # undef __MATH_DECLARING_DOUBLE |
311 | # undef __MATH_DECLARING_FLOATN |
312 | |
313 | # if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \ |
314 | || defined __LDBL_COMPAT \ |
315 | || defined _LIBC_TEST |
316 | # ifdef __LDBL_COMPAT |
317 | |
318 | # ifdef __USE_ISOC99 |
319 | extern float __nldbl_nexttowardf (float __x, long double __y) |
320 | __THROW __attribute__ ((__const__)); |
321 | # ifdef __REDIRECT_NTH |
322 | extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y), |
323 | __nldbl_nexttowardf) |
324 | __attribute__ ((__const__)); |
325 | extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y), |
326 | nextafter) __attribute__ ((__const__)); |
327 | extern long double __REDIRECT_NTH (nexttowardl, |
328 | (long double __x, long double __y), |
329 | nextafter) __attribute__ ((__const__)); |
330 | # endif |
331 | # endif |
332 | |
333 | # undef __MATHDECL_1 |
334 | # define __MATHDECL_2(type, function,suffix, args, alias) \ |
335 | extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix), \ |
336 | args, alias) |
337 | # define __MATHDECL_1(type, function,suffix, args) \ |
338 | __MATHDECL_2(type, function,suffix, args, __CONCAT(function,suffix)) |
339 | # endif |
340 | |
341 | /* Include the file of declarations again, this time using `long double' |
342 | instead of `double' and appending l to each function name. */ |
343 | |
344 | # define _Mdouble_ long double |
345 | # define __MATH_PRECNAME(name,r) name##l##r |
346 | # define __MATH_DECLARING_DOUBLE 0 |
347 | # define __MATH_DECLARING_FLOATN 0 |
348 | # define __MATH_DECLARE_LDOUBLE 1 |
349 | # include <bits/mathcalls-helper-functions.h> |
350 | # include <bits/mathcalls.h> |
351 | # undef _Mdouble_ |
352 | # undef __MATH_PRECNAME |
353 | # undef __MATH_DECLARING_DOUBLE |
354 | # undef __MATH_DECLARING_FLOATN |
355 | |
356 | # endif /* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */ |
357 | |
358 | #endif /* Use ISO C99. */ |
359 | |
360 | /* Include the file of declarations for _FloatN and _FloatNx |
361 | types. */ |
362 | |
363 | #if __HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC) |
364 | # define _Mdouble_ _Float16 |
365 | # define __MATH_PRECNAME(name,r) name##f16##r |
366 | # define __MATH_DECLARING_DOUBLE 0 |
367 | # define __MATH_DECLARING_FLOATN 1 |
368 | # if __HAVE_DISTINCT_FLOAT16 |
369 | # include <bits/mathcalls-helper-functions.h> |
370 | # endif |
371 | # if __GLIBC_USE (IEC_60559_TYPES_EXT) |
372 | # include <bits/mathcalls.h> |
373 | # endif |
374 | # undef _Mdouble_ |
375 | # undef __MATH_PRECNAME |
376 | # undef __MATH_DECLARING_DOUBLE |
377 | # undef __MATH_DECLARING_FLOATN |
378 | #endif /* __HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !_LIBC). */ |
379 | |
380 | #if __HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC) |
381 | # define _Mdouble_ _Float32 |
382 | # define __MATH_PRECNAME(name,r) name##f32##r |
383 | # define __MATH_DECLARING_DOUBLE 0 |
384 | # define __MATH_DECLARING_FLOATN 1 |
385 | # if __HAVE_DISTINCT_FLOAT32 |
386 | # include <bits/mathcalls-helper-functions.h> |
387 | # endif |
388 | # if __GLIBC_USE (IEC_60559_TYPES_EXT) |
389 | # include <bits/mathcalls.h> |
390 | # endif |
391 | # undef _Mdouble_ |
392 | # undef __MATH_PRECNAME |
393 | # undef __MATH_DECLARING_DOUBLE |
394 | # undef __MATH_DECLARING_FLOATN |
395 | #endif /* __HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !_LIBC). */ |
396 | |
397 | #if __HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC) |
398 | # define _Mdouble_ _Float64 |
399 | # define __MATH_PRECNAME(name,r) name##f64##r |
400 | # define __MATH_DECLARING_DOUBLE 0 |
401 | # define __MATH_DECLARING_FLOATN 1 |
402 | # if __HAVE_DISTINCT_FLOAT64 |
403 | # include <bits/mathcalls-helper-functions.h> |
404 | # endif |
405 | # if __GLIBC_USE (IEC_60559_TYPES_EXT) |
406 | # include <bits/mathcalls.h> |
407 | # endif |
408 | # undef _Mdouble_ |
409 | # undef __MATH_PRECNAME |
410 | # undef __MATH_DECLARING_DOUBLE |
411 | # undef __MATH_DECLARING_FLOATN |
412 | #endif /* __HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !_LIBC). */ |
413 | |
414 | #if __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC) |
415 | # define _Mdouble_ _Float128 |
416 | # define __MATH_PRECNAME(name,r) name##f128##r |
417 | # define __MATH_DECLARING_DOUBLE 0 |
418 | # define __MATH_DECLARING_FLOATN 1 |
419 | # if __HAVE_DISTINCT_FLOAT128 |
420 | # include <bits/mathcalls-helper-functions.h> |
421 | # endif |
422 | # if __GLIBC_USE (IEC_60559_TYPES_EXT) |
423 | # include <bits/mathcalls.h> |
424 | # endif |
425 | # undef _Mdouble_ |
426 | # undef __MATH_PRECNAME |
427 | # undef __MATH_DECLARING_DOUBLE |
428 | # undef __MATH_DECLARING_FLOATN |
429 | #endif /* __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !_LIBC). */ |
430 | |
431 | #if __HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC) |
432 | # define _Mdouble_ _Float32x |
433 | # define __MATH_PRECNAME(name,r) name##f32x##r |
434 | # define __MATH_DECLARING_DOUBLE 0 |
435 | # define __MATH_DECLARING_FLOATN 1 |
436 | # if __HAVE_DISTINCT_FLOAT32X |
437 | # include <bits/mathcalls-helper-functions.h> |
438 | # endif |
439 | # if __GLIBC_USE (IEC_60559_TYPES_EXT) |
440 | # include <bits/mathcalls.h> |
441 | # endif |
442 | # undef _Mdouble_ |
443 | # undef __MATH_PRECNAME |
444 | # undef __MATH_DECLARING_DOUBLE |
445 | # undef __MATH_DECLARING_FLOATN |
446 | #endif /* __HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !_LIBC). */ |
447 | |
448 | #if __HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC) |
449 | # define _Mdouble_ _Float64x |
450 | # define __MATH_PRECNAME(name,r) name##f64x##r |
451 | # define __MATH_DECLARING_DOUBLE 0 |
452 | # define __MATH_DECLARING_FLOATN 1 |
453 | # if __HAVE_DISTINCT_FLOAT64X |
454 | # include <bits/mathcalls-helper-functions.h> |
455 | # endif |
456 | # if __GLIBC_USE (IEC_60559_TYPES_EXT) |
457 | # include <bits/mathcalls.h> |
458 | # endif |
459 | # undef _Mdouble_ |
460 | # undef __MATH_PRECNAME |
461 | # undef __MATH_DECLARING_DOUBLE |
462 | # undef __MATH_DECLARING_FLOATN |
463 | #endif /* __HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !_LIBC). */ |
464 | |
465 | #if __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC) |
466 | # define _Mdouble_ _Float128x |
467 | # define __MATH_PRECNAME(name,r) name##f128x##r |
468 | # define __MATH_DECLARING_DOUBLE 0 |
469 | # define __MATH_DECLARING_FLOATN 1 |
470 | # if __HAVE_DISTINCT_FLOAT128X |
471 | # include <bits/mathcalls-helper-functions.h> |
472 | # endif |
473 | # if __GLIBC_USE (IEC_60559_TYPES_EXT) |
474 | # include <bits/mathcalls.h> |
475 | # endif |
476 | # undef _Mdouble_ |
477 | # undef __MATH_PRECNAME |
478 | # undef __MATH_DECLARING_DOUBLE |
479 | # undef __MATH_DECLARING_FLOATN |
480 | #endif /* __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !_LIBC). */ |
481 | |
482 | #undef __MATHDECL_1 |
483 | #undef __MATHDECL |
484 | #undef __MATHCALL |
485 | |
486 | /* Declare functions returning a narrower type. */ |
487 | #define __MATHCALL_NARROW_ARGS_1 (_Marg_ __x) |
488 | #define __MATHCALL_NARROW_ARGS_2 (_Marg_ __x, _Marg_ __y) |
489 | #define __MATHCALL_NARROW_ARGS_3 (_Marg_ __x, _Marg_ __y, _Marg_ __z) |
490 | #define __MATHCALL_NARROW_NORMAL(func, nargs) \ |
491 | extern _Mret_ func __MATHCALL_NARROW_ARGS_ ## nargs __THROW |
492 | #define __MATHCALL_NARROW_REDIR(func, redir, nargs) \ |
493 | extern _Mret_ __REDIRECT_NTH (func, __MATHCALL_NARROW_ARGS_ ## nargs, \ |
494 | redir) |
495 | #define __MATHCALL_NARROW(func, redir, nargs) \ |
496 | __MATHCALL_NARROW_NORMAL (func, nargs) |
497 | |
498 | #if __GLIBC_USE (IEC_60559_BFP_EXT) |
499 | |
500 | # define _Mret_ float |
501 | # define _Marg_ double |
502 | # define __MATHCALL_NAME(name) f ## name |
503 | # include <bits/mathcalls-narrow.h> |
504 | # undef _Mret_ |
505 | # undef _Marg_ |
506 | # undef __MATHCALL_NAME |
507 | |
508 | # define _Mret_ float |
509 | # define _Marg_ long double |
510 | # define __MATHCALL_NAME(name) f ## name ## l |
511 | # ifdef __LDBL_COMPAT |
512 | # define __MATHCALL_REDIR_NAME(name) f ## name |
513 | # undef __MATHCALL_NARROW |
514 | # define __MATHCALL_NARROW(func, redir, nargs) \ |
515 | __MATHCALL_NARROW_REDIR (func, redir, nargs) |
516 | # endif |
517 | # include <bits/mathcalls-narrow.h> |
518 | # undef _Mret_ |
519 | # undef _Marg_ |
520 | # undef __MATHCALL_NAME |
521 | # ifdef __LDBL_COMPAT |
522 | # undef __MATHCALL_REDIR_NAME |
523 | # undef __MATHCALL_NARROW |
524 | # define __MATHCALL_NARROW(func, redir, nargs) \ |
525 | __MATHCALL_NARROW_NORMAL (func, nargs) |
526 | # endif |
527 | |
528 | # define _Mret_ double |
529 | # define _Marg_ long double |
530 | # define __MATHCALL_NAME(name) d ## name ## l |
531 | # ifdef __LDBL_COMPAT |
532 | # define __MATHCALL_REDIR_NAME(name) __nldbl_d ## name ## l |
533 | # undef __MATHCALL_NARROW |
534 | # define __MATHCALL_NARROW(func, redir, nargs) \ |
535 | __MATHCALL_NARROW_REDIR (func, redir, nargs) |
536 | # endif |
537 | # include <bits/mathcalls-narrow.h> |
538 | # undef _Mret_ |
539 | # undef _Marg_ |
540 | # undef __MATHCALL_NAME |
541 | # ifdef __LDBL_COMPAT |
542 | # undef __MATHCALL_REDIR_NAME |
543 | # undef __MATHCALL_NARROW |
544 | # define __MATHCALL_NARROW(func, redir, nargs) \ |
545 | __MATHCALL_NARROW_NORMAL (func, nargs) |
546 | # endif |
547 | |
548 | #endif |
549 | |
550 | #if __GLIBC_USE (IEC_60559_TYPES_EXT) |
551 | |
552 | # if __HAVE_FLOAT16 && __HAVE_FLOAT32 |
553 | # define _Mret_ _Float16 |
554 | # define _Marg_ _Float32 |
555 | # define __MATHCALL_NAME(name) f16 ## name ## f32 |
556 | # include <bits/mathcalls-narrow.h> |
557 | # undef _Mret_ |
558 | # undef _Marg_ |
559 | # undef __MATHCALL_NAME |
560 | # endif |
561 | |
562 | # if __HAVE_FLOAT16 && __HAVE_FLOAT32X |
563 | # define _Mret_ _Float16 |
564 | # define _Marg_ _Float32x |
565 | # define __MATHCALL_NAME(name) f16 ## name ## f32x |
566 | # include <bits/mathcalls-narrow.h> |
567 | # undef _Mret_ |
568 | # undef _Marg_ |
569 | # undef __MATHCALL_NAME |
570 | # endif |
571 | |
572 | # if __HAVE_FLOAT16 && __HAVE_FLOAT64 |
573 | # define _Mret_ _Float16 |
574 | # define _Marg_ _Float64 |
575 | # define __MATHCALL_NAME(name) f16 ## name ## f64 |
576 | # include <bits/mathcalls-narrow.h> |
577 | # undef _Mret_ |
578 | # undef _Marg_ |
579 | # undef __MATHCALL_NAME |
580 | # endif |
581 | |
582 | # if __HAVE_FLOAT16 && __HAVE_FLOAT64X |
583 | # define _Mret_ _Float16 |
584 | # define _Marg_ _Float64x |
585 | # define __MATHCALL_NAME(name) f16 ## name ## f64x |
586 | # include <bits/mathcalls-narrow.h> |
587 | # undef _Mret_ |
588 | # undef _Marg_ |
589 | # undef __MATHCALL_NAME |
590 | # endif |
591 | |
592 | # if __HAVE_FLOAT16 && __HAVE_FLOAT128 |
593 | # define _Mret_ _Float16 |
594 | # define _Marg_ _Float128 |
595 | # define __MATHCALL_NAME(name) f16 ## name ## f128 |
596 | # include <bits/mathcalls-narrow.h> |
597 | # undef _Mret_ |
598 | # undef _Marg_ |
599 | # undef __MATHCALL_NAME |
600 | # endif |
601 | |
602 | # if __HAVE_FLOAT16 && __HAVE_FLOAT128X |
603 | # define _Mret_ _Float16 |
604 | # define _Marg_ _Float128x |
605 | # define __MATHCALL_NAME(name) f16 ## name ## f128x |
606 | # include <bits/mathcalls-narrow.h> |
607 | # undef _Mret_ |
608 | # undef _Marg_ |
609 | # undef __MATHCALL_NAME |
610 | # endif |
611 | |
612 | # if __HAVE_FLOAT32 && __HAVE_FLOAT32X |
613 | # define _Mret_ _Float32 |
614 | # define _Marg_ _Float32x |
615 | # define __MATHCALL_NAME(name) f32 ## name ## f32x |
616 | # include <bits/mathcalls-narrow.h> |
617 | # undef _Mret_ |
618 | # undef _Marg_ |
619 | # undef __MATHCALL_NAME |
620 | # endif |
621 | |
622 | # if __HAVE_FLOAT32 && __HAVE_FLOAT64 |
623 | # define _Mret_ _Float32 |
624 | # define _Marg_ _Float64 |
625 | # define __MATHCALL_NAME(name) f32 ## name ## f64 |
626 | # include <bits/mathcalls-narrow.h> |
627 | # undef _Mret_ |
628 | # undef _Marg_ |
629 | # undef __MATHCALL_NAME |
630 | # endif |
631 | |
632 | # if __HAVE_FLOAT32 && __HAVE_FLOAT64X |
633 | # define _Mret_ _Float32 |
634 | # define _Marg_ _Float64x |
635 | # define __MATHCALL_NAME(name) f32 ## name ## f64x |
636 | # include <bits/mathcalls-narrow.h> |
637 | # undef _Mret_ |
638 | # undef _Marg_ |
639 | # undef __MATHCALL_NAME |
640 | # endif |
641 | |
642 | # if __HAVE_FLOAT32 && __HAVE_FLOAT128 |
643 | # define _Mret_ _Float32 |
644 | # define _Marg_ _Float128 |
645 | # define __MATHCALL_NAME(name) f32 ## name ## f128 |
646 | # include <bits/mathcalls-narrow.h> |
647 | # undef _Mret_ |
648 | # undef _Marg_ |
649 | # undef __MATHCALL_NAME |
650 | # endif |
651 | |
652 | # if __HAVE_FLOAT32 && __HAVE_FLOAT128X |
653 | # define _Mret_ _Float32 |
654 | # define _Marg_ _Float128x |
655 | # define __MATHCALL_NAME(name) f32 ## name ## f128x |
656 | # include <bits/mathcalls-narrow.h> |
657 | # undef _Mret_ |
658 | # undef _Marg_ |
659 | # undef __MATHCALL_NAME |
660 | # endif |
661 | |
662 | # if __HAVE_FLOAT32X && __HAVE_FLOAT64 |
663 | # define _Mret_ _Float32x |
664 | # define _Marg_ _Float64 |
665 | # define __MATHCALL_NAME(name) f32x ## name ## f64 |
666 | # include <bits/mathcalls-narrow.h> |
667 | # undef _Mret_ |
668 | # undef _Marg_ |
669 | # undef __MATHCALL_NAME |
670 | # endif |
671 | |
672 | # if __HAVE_FLOAT32X && __HAVE_FLOAT64X |
673 | # define _Mret_ _Float32x |
674 | # define _Marg_ _Float64x |
675 | # define __MATHCALL_NAME(name) f32x ## name ## f64x |
676 | # include <bits/mathcalls-narrow.h> |
677 | # undef _Mret_ |
678 | # undef _Marg_ |
679 | # undef __MATHCALL_NAME |
680 | # endif |
681 | |
682 | # if __HAVE_FLOAT32X && __HAVE_FLOAT128 |
683 | # define _Mret_ _Float32x |
684 | # define _Marg_ _Float128 |
685 | # define __MATHCALL_NAME(name) f32x ## name ## f128 |
686 | # include <bits/mathcalls-narrow.h> |
687 | # undef _Mret_ |
688 | # undef _Marg_ |
689 | # undef __MATHCALL_NAME |
690 | # endif |
691 | |
692 | # if __HAVE_FLOAT32X && __HAVE_FLOAT128X |
693 | # define _Mret_ _Float32x |
694 | # define _Marg_ _Float128x |
695 | # define __MATHCALL_NAME(name) f32x ## name ## f128x |
696 | # include <bits/mathcalls-narrow.h> |
697 | # undef _Mret_ |
698 | # undef _Marg_ |
699 | # undef __MATHCALL_NAME |
700 | # endif |
701 | |
702 | # if __HAVE_FLOAT64 && __HAVE_FLOAT64X |
703 | # define _Mret_ _Float64 |
704 | # define _Marg_ _Float64x |
705 | # define __MATHCALL_NAME(name) f64 ## name ## f64x |
706 | # include <bits/mathcalls-narrow.h> |
707 | # undef _Mret_ |
708 | # undef _Marg_ |
709 | # undef __MATHCALL_NAME |
710 | # endif |
711 | |
712 | # if __HAVE_FLOAT64 && __HAVE_FLOAT128 |
713 | # define _Mret_ _Float64 |
714 | # define _Marg_ _Float128 |
715 | # define __MATHCALL_NAME(name) f64 ## name ## f128 |
716 | # include <bits/mathcalls-narrow.h> |
717 | # undef _Mret_ |
718 | # undef _Marg_ |
719 | # undef __MATHCALL_NAME |
720 | # endif |
721 | |
722 | # if __HAVE_FLOAT64 && __HAVE_FLOAT128X |
723 | # define _Mret_ _Float64 |
724 | # define _Marg_ _Float128x |
725 | # define __MATHCALL_NAME(name) f64 ## name ## f128x |
726 | # include <bits/mathcalls-narrow.h> |
727 | # undef _Mret_ |
728 | # undef _Marg_ |
729 | # undef __MATHCALL_NAME |
730 | # endif |
731 | |
732 | # if __HAVE_FLOAT64X && __HAVE_FLOAT128 |
733 | # define _Mret_ _Float64x |
734 | # define _Marg_ _Float128 |
735 | # define __MATHCALL_NAME(name) f64x ## name ## f128 |
736 | # include <bits/mathcalls-narrow.h> |
737 | # undef _Mret_ |
738 | # undef _Marg_ |
739 | # undef __MATHCALL_NAME |
740 | # endif |
741 | |
742 | # if __HAVE_FLOAT64X && __HAVE_FLOAT128X |
743 | # define _Mret_ _Float64x |
744 | # define _Marg_ _Float128x |
745 | # define __MATHCALL_NAME(name) f64x ## name ## f128x |
746 | # include <bits/mathcalls-narrow.h> |
747 | # undef _Mret_ |
748 | # undef _Marg_ |
749 | # undef __MATHCALL_NAME |
750 | # endif |
751 | |
752 | # if __HAVE_FLOAT128 && __HAVE_FLOAT128X |
753 | # define _Mret_ _Float128 |
754 | # define _Marg_ _Float128x |
755 | # define __MATHCALL_NAME(name) f128 ## name ## f128x |
756 | # include <bits/mathcalls-narrow.h> |
757 | # undef _Mret_ |
758 | # undef _Marg_ |
759 | # undef __MATHCALL_NAME |
760 | # endif |
761 | |
762 | #endif |
763 | |
764 | #undef __MATHCALL_NARROW_ARGS_1 |
765 | #undef __MATHCALL_NARROW_ARGS_2 |
766 | #undef __MATHCALL_NARROW_ARGS_3 |
767 | #undef __MATHCALL_NARROW_NORMAL |
768 | #undef __MATHCALL_NARROW_REDIR |
769 | #undef __MATHCALL_NARROW |
770 | |
771 | #if defined __USE_MISC || defined __USE_XOPEN |
772 | /* This variable is used by `gamma' and `lgamma'. */ |
773 | extern int signgam; |
774 | #endif |
775 | |
776 | #if (__HAVE_DISTINCT_FLOAT16 \ |
777 | || __HAVE_DISTINCT_FLOAT32 \ |
778 | || __HAVE_DISTINCT_FLOAT64 \ |
779 | || __HAVE_DISTINCT_FLOAT32X \ |
780 | || __HAVE_DISTINCT_FLOAT64X \ |
781 | || __HAVE_DISTINCT_FLOAT128X) |
782 | # error "Unsupported _FloatN or _FloatNx types for <math.h>." |
783 | #endif |
784 | |
785 | /* Depending on the type of TG_ARG, call an appropriately suffixed |
786 | version of FUNC with arguments (including parentheses) ARGS. |
787 | Suffixed functions may not exist for long double if it has the same |
788 | format as double, or for other types with the same format as float, |
789 | double or long double. The behavior is undefined if the argument |
790 | does not have a real floating type. The definition may use a |
791 | conditional expression, so all suffixed versions of FUNC must |
792 | return the same type (FUNC may include a cast if necessary rather |
793 | than being a single identifier). */ |
794 | #ifdef __NO_LONG_DOUBLE_MATH |
795 | # if __HAVE_DISTINCT_FLOAT128 |
796 | # error "Distinct _Float128 without distinct long double not supported." |
797 | # endif |
798 | # define __MATH_TG(TG_ARG, FUNC, ARGS) \ |
799 | (sizeof (TG_ARG) == sizeof (float) ? FUNC ## f ARGS : FUNC ARGS) |
800 | #elif __HAVE_DISTINCT_FLOAT128 |
801 | # if __HAVE_GENERIC_SELECTION |
802 | # if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT32 |
803 | # define __MATH_TG_F32(FUNC, ARGS) _Float32: FUNC ## f ARGS, |
804 | # else |
805 | # define __MATH_TG_F32(FUNC, ARGS) |
806 | # endif |
807 | # if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT64X |
808 | # if __HAVE_FLOAT64X_LONG_DOUBLE |
809 | # define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## l ARGS, |
810 | # else |
811 | # define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## f128 ARGS, |
812 | # endif |
813 | # else |
814 | # define __MATH_TG_F64X(FUNC, ARGS) |
815 | # endif |
816 | # define __MATH_TG(TG_ARG, FUNC, ARGS) \ |
817 | _Generic ((TG_ARG), \ |
818 | float: FUNC ## f ARGS, \ |
819 | __MATH_TG_F32 (FUNC, ARGS) \ |
820 | default: FUNC ARGS, \ |
821 | long double: FUNC ## l ARGS, \ |
822 | __MATH_TG_F64X (FUNC, ARGS) \ |
823 | _Float128: FUNC ## f128 ARGS) |
824 | # else |
825 | # if __HAVE_FLOATN_NOT_TYPEDEF |
826 | # error "Non-typedef _FloatN but no _Generic." |
827 | # endif |
828 | # define __MATH_TG(TG_ARG, FUNC, ARGS) \ |
829 | __builtin_choose_expr \ |
830 | (__builtin_types_compatible_p (__typeof (TG_ARG), float), \ |
831 | FUNC ## f ARGS, \ |
832 | __builtin_choose_expr \ |
833 | (__builtin_types_compatible_p (__typeof (TG_ARG), double), \ |
834 | FUNC ARGS, \ |
835 | __builtin_choose_expr \ |
836 | (__builtin_types_compatible_p (__typeof (TG_ARG), long double), \ |
837 | FUNC ## l ARGS, \ |
838 | FUNC ## f128 ARGS))) |
839 | # endif |
840 | #else |
841 | # define __MATH_TG(TG_ARG, FUNC, ARGS) \ |
842 | (sizeof (TG_ARG) == sizeof (float) \ |
843 | ? FUNC ## f ARGS \ |
844 | : sizeof (TG_ARG) == sizeof (double) \ |
845 | ? FUNC ARGS \ |
846 | : FUNC ## l ARGS) |
847 | #endif |
848 | |
849 | /* ISO C99 defines some generic macros which work on any data type. */ |
850 | #ifdef __USE_ISOC99 |
851 | |
852 | /* All floating-point numbers can be put in one of these categories. */ |
853 | enum |
854 | { |
855 | FP_NAN = |
856 | # define FP_NAN 0 |
857 | FP_NAN, |
858 | FP_INFINITE = |
859 | # define FP_INFINITE 1 |
860 | FP_INFINITE, |
861 | FP_ZERO = |
862 | # define FP_ZERO 2 |
863 | FP_ZERO, |
864 | FP_SUBNORMAL = |
865 | # define FP_SUBNORMAL 3 |
866 | FP_SUBNORMAL, |
867 | FP_NORMAL = |
868 | # define FP_NORMAL 4 |
869 | FP_NORMAL |
870 | }; |
871 | |
872 | /* GCC bug 66462 means we cannot use the math builtins with -fsignaling-nan, |
873 | so disable builtins if this is enabled. When fixed in a newer GCC, |
874 | the __SUPPORT_SNAN__ check may be skipped for those versions. */ |
875 | |
876 | /* Return number of classification appropriate for X. */ |
877 | # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ \ |
878 | && (!defined __OPTIMIZE_SIZE__ || defined __cplusplus) |
879 | /* The check for __cplusplus allows the use of the builtin, even |
880 | when optimization for size is on. This is provided for |
881 | libstdc++, only to let its configure test work when it is built |
882 | with -Os. No further use of this definition of fpclassify is |
883 | expected in C++ mode, since libstdc++ provides its own version |
884 | of fpclassify in cmath (which undefines fpclassify). */ |
885 | # define fpclassify(x) __builtin_fpclassify (FP_NAN, FP_INFINITE, \ |
886 | FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x) |
887 | # else |
888 | # define fpclassify(x) __MATH_TG ((x), __fpclassify, (x)) |
889 | # endif |
890 | |
891 | /* Return nonzero value if sign of X is negative. */ |
892 | # if __GNUC_PREREQ (6,0) |
893 | # define signbit(x) __builtin_signbit (x) |
894 | # elif defined __cplusplus |
895 | /* In C++ mode, __MATH_TG cannot be used, because it relies on |
896 | __builtin_types_compatible_p, which is a C-only builtin. |
897 | The check for __cplusplus allows the use of the builtin instead of |
898 | __MATH_TG. This is provided for libstdc++, only to let its configure |
899 | test work. No further use of this definition of signbit is expected |
900 | in C++ mode, since libstdc++ provides its own version of signbit |
901 | in cmath (which undefines signbit). */ |
902 | # define signbit(x) __builtin_signbitl (x) |
903 | # elif __GNUC_PREREQ (4,0) |
904 | # define signbit(x) __MATH_TG ((x), __builtin_signbit, (x)) |
905 | # else |
906 | # define signbit(x) __MATH_TG ((x), __signbit, (x)) |
907 | # endif |
908 | |
909 | /* Return nonzero value if X is not +-Inf or NaN. */ |
910 | # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ |
911 | # define isfinite(x) __builtin_isfinite (x) |
912 | # else |
913 | # define isfinite(x) __MATH_TG ((x), __finite, (x)) |
914 | # endif |
915 | |
916 | /* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN. */ |
917 | # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ |
918 | # define isnormal(x) __builtin_isnormal (x) |
919 | # else |
920 | # define isnormal(x) (fpclassify (x) == FP_NORMAL) |
921 | # endif |
922 | |
923 | /* Return nonzero value if X is a NaN. We could use `fpclassify' but |
924 | we already have this functions `__isnan' and it is faster. */ |
925 | # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ |
926 | # define isnan(x) __builtin_isnan (x) |
927 | # else |
928 | # define isnan(x) __MATH_TG ((x), __isnan, (x)) |
929 | # endif |
930 | |
931 | /* Return nonzero value if X is positive or negative infinity. */ |
932 | # if __HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7,0) \ |
933 | && !defined __SUPPORT_SNAN__ && !defined __cplusplus |
934 | /* Since __builtin_isinf_sign is broken for float128 before GCC 7.0, |
935 | use the helper function, __isinff128, with older compilers. This is |
936 | only provided for C mode, because in C++ mode, GCC has no support |
937 | for __builtin_types_compatible_p (and when in C++ mode, this macro is |
938 | not used anyway, because libstdc++ headers undefine it). */ |
939 | # define isinf(x) \ |
940 | (__builtin_types_compatible_p (__typeof (x), _Float128) \ |
941 | ? __isinff128 (x) : __builtin_isinf_sign (x)) |
942 | # elif __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ |
943 | # define isinf(x) __builtin_isinf_sign (x) |
944 | # else |
945 | # define isinf(x) __MATH_TG ((x), __isinf, (x)) |
946 | # endif |
947 | |
948 | /* Bitmasks for the math_errhandling macro. */ |
949 | # define MATH_ERRNO 1 /* errno set by math functions. */ |
950 | # define MATH_ERREXCEPT 2 /* Exceptions raised by math functions. */ |
951 | |
952 | /* By default all math functions support both errno and exception handling |
953 | (except for soft floating point implementations which may only support |
954 | errno handling). If errno handling is disabled, exceptions are still |
955 | supported by GLIBC. Set math_errhandling to 0 with -ffast-math (this is |
956 | nonconforming but it is more useful than leaving it undefined). */ |
957 | # ifdef __FAST_MATH__ |
958 | # define math_errhandling 0 |
959 | # elif defined __NO_MATH_ERRNO__ |
960 | # define math_errhandling (MATH_ERREXCEPT) |
961 | # else |
962 | # define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT) |
963 | # endif |
964 | |
965 | #endif /* Use ISO C99. */ |
966 | |
967 | #if __GLIBC_USE (IEC_60559_BFP_EXT) |
968 | # include <bits/iscanonical.h> |
969 | |
970 | /* Return nonzero value if X is a signaling NaN. */ |
971 | # ifndef __cplusplus |
972 | # define issignaling(x) __MATH_TG ((x), __issignaling, (x)) |
973 | # else |
974 | /* In C++ mode, __MATH_TG cannot be used, because it relies on |
975 | __builtin_types_compatible_p, which is a C-only builtin. On the |
976 | other hand, overloading provides the means to distinguish between |
977 | the floating-point types. The overloading resolution will match |
978 | the correct parameter (regardless of type qualifiers (i.e.: const |
979 | and volatile)). */ |
980 | extern "C++" { |
981 | inline int issignaling (float __val) { return __issignalingf (__val); } |
982 | inline int issignaling (double __val) { return __issignaling (__val); } |
983 | inline int |
984 | issignaling (long double __val) |
985 | { |
986 | # ifdef __NO_LONG_DOUBLE_MATH |
987 | return __issignaling (__val); |
988 | # else |
989 | return __issignalingl (__val); |
990 | # endif |
991 | } |
992 | # if __HAVE_FLOAT128_UNLIKE_LDBL |
993 | /* When using an IEEE 128-bit long double, _Float128 is defined as long double |
994 | in C++. */ |
995 | inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); } |
996 | # endif |
997 | } /* extern C++ */ |
998 | # endif |
999 | |
1000 | /* Return nonzero value if X is subnormal. */ |
1001 | # define issubnormal(x) (fpclassify (x) == FP_SUBNORMAL) |
1002 | |
1003 | /* Return nonzero value if X is zero. */ |
1004 | # ifndef __cplusplus |
1005 | # ifdef __SUPPORT_SNAN__ |
1006 | # define iszero(x) (fpclassify (x) == FP_ZERO) |
1007 | # else |
1008 | # define iszero(x) (((__typeof (x)) (x)) == 0) |
1009 | # endif |
1010 | # else /* __cplusplus */ |
1011 | extern "C++" { |
1012 | # ifdef __SUPPORT_SNAN__ |
1013 | inline int |
1014 | iszero (float __val) |
1015 | { |
1016 | return __fpclassifyf (__val) == FP_ZERO; |
1017 | } |
1018 | inline int |
1019 | iszero (double __val) |
1020 | { |
1021 | return __fpclassify (__val) == FP_ZERO; |
1022 | } |
1023 | inline int |
1024 | iszero (long double __val) |
1025 | { |
1026 | # ifdef __NO_LONG_DOUBLE_MATH |
1027 | return __fpclassify (__val) == FP_ZERO; |
1028 | # else |
1029 | return __fpclassifyl (__val) == FP_ZERO; |
1030 | # endif |
1031 | } |
1032 | # if __HAVE_FLOAT128_UNLIKE_LDBL |
1033 | /* When using an IEEE 128-bit long double, _Float128 is defined as long double |
1034 | in C++. */ |
1035 | inline int |
1036 | iszero (_Float128 __val) |
1037 | { |
1038 | return __fpclassifyf128 (__val) == FP_ZERO; |
1039 | } |
1040 | # endif |
1041 | # else |
1042 | template <class __T> inline bool |
1043 | iszero (__T __val) |
1044 | { |
1045 | return __val == 0; |
1046 | } |
1047 | # endif |
1048 | } /* extern C++ */ |
1049 | # endif /* __cplusplus */ |
1050 | #endif /* Use IEC_60559_BFP_EXT. */ |
1051 | |
1052 | #ifdef __USE_XOPEN |
1053 | /* X/Open wants another strange constant. */ |
1054 | # define MAXFLOAT 3.40282347e+38F |
1055 | #endif |
1056 | |
1057 | |
1058 | /* Some useful constants. */ |
1059 | #if defined __USE_MISC || defined __USE_XOPEN |
1060 | # define M_E 2.7182818284590452354 /* e */ |
1061 | # define M_LOG2E 1.4426950408889634074 /* log_2 e */ |
1062 | # define M_LOG10E 0.43429448190325182765 /* log_10 e */ |
1063 | # define M_LN2 0.69314718055994530942 /* log_e 2 */ |
1064 | # define M_LN10 2.30258509299404568402 /* log_e 10 */ |
1065 | # define M_PI 3.14159265358979323846 /* pi */ |
1066 | # define M_PI_2 1.57079632679489661923 /* pi/2 */ |
1067 | # define M_PI_4 0.78539816339744830962 /* pi/4 */ |
1068 | # define M_1_PI 0.31830988618379067154 /* 1/pi */ |
1069 | # define M_2_PI 0.63661977236758134308 /* 2/pi */ |
1070 | # define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ |
1071 | # define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ |
1072 | # define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ |
1073 | #endif |
1074 | |
1075 | /* The above constants are not adequate for computation using `long double's. |
1076 | Therefore we provide as an extension constants with similar names as a |
1077 | GNU extension. Provide enough digits for the 128-bit IEEE quad. */ |
1078 | #ifdef __USE_GNU |
1079 | # define M_El 2.718281828459045235360287471352662498L /* e */ |
1080 | # define M_LOG2El 1.442695040888963407359924681001892137L /* log_2 e */ |
1081 | # define M_LOG10El 0.434294481903251827651128918916605082L /* log_10 e */ |
1082 | # define M_LN2l 0.693147180559945309417232121458176568L /* log_e 2 */ |
1083 | # define M_LN10l 2.302585092994045684017991454684364208L /* log_e 10 */ |
1084 | # define M_PIl 3.141592653589793238462643383279502884L /* pi */ |
1085 | # define M_PI_2l 1.570796326794896619231321691639751442L /* pi/2 */ |
1086 | # define M_PI_4l 0.785398163397448309615660845819875721L /* pi/4 */ |
1087 | # define M_1_PIl 0.318309886183790671537767526745028724L /* 1/pi */ |
1088 | # define M_2_PIl 0.636619772367581343075535053490057448L /* 2/pi */ |
1089 | # define M_2_SQRTPIl 1.128379167095512573896158903121545172L /* 2/sqrt(pi) */ |
1090 | # define M_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */ |
1091 | # define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */ |
1092 | #endif |
1093 | |
1094 | #if __HAVE_FLOAT16 && defined __USE_GNU |
1095 | # define M_Ef16 __f16 (2.718281828459045235360287471352662498) /* e */ |
1096 | # define M_LOG2Ef16 __f16 (1.442695040888963407359924681001892137) /* log_2 e */ |
1097 | # define M_LOG10Ef16 __f16 (0.434294481903251827651128918916605082) /* log_10 e */ |
1098 | # define M_LN2f16 __f16 (0.693147180559945309417232121458176568) /* log_e 2 */ |
1099 | # define M_LN10f16 __f16 (2.302585092994045684017991454684364208) /* log_e 10 */ |
1100 | # define M_PIf16 __f16 (3.141592653589793238462643383279502884) /* pi */ |
1101 | # define M_PI_2f16 __f16 (1.570796326794896619231321691639751442) /* pi/2 */ |
1102 | # define M_PI_4f16 __f16 (0.785398163397448309615660845819875721) /* pi/4 */ |
1103 | # define M_1_PIf16 __f16 (0.318309886183790671537767526745028724) /* 1/pi */ |
1104 | # define M_2_PIf16 __f16 (0.636619772367581343075535053490057448) /* 2/pi */ |
1105 | # define M_2_SQRTPIf16 __f16 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ |
1106 | # define M_SQRT2f16 __f16 (1.414213562373095048801688724209698079) /* sqrt(2) */ |
1107 | # define M_SQRT1_2f16 __f16 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ |
1108 | #endif |
1109 | |
1110 | #if __HAVE_FLOAT32 && defined __USE_GNU |
1111 | # define M_Ef32 __f32 (2.718281828459045235360287471352662498) /* e */ |
1112 | # define M_LOG2Ef32 __f32 (1.442695040888963407359924681001892137) /* log_2 e */ |
1113 | # define M_LOG10Ef32 __f32 (0.434294481903251827651128918916605082) /* log_10 e */ |
1114 | # define M_LN2f32 __f32 (0.693147180559945309417232121458176568) /* log_e 2 */ |
1115 | # define M_LN10f32 __f32 (2.302585092994045684017991454684364208) /* log_e 10 */ |
1116 | # define M_PIf32 __f32 (3.141592653589793238462643383279502884) /* pi */ |
1117 | # define M_PI_2f32 __f32 (1.570796326794896619231321691639751442) /* pi/2 */ |
1118 | # define M_PI_4f32 __f32 (0.785398163397448309615660845819875721) /* pi/4 */ |
1119 | # define M_1_PIf32 __f32 (0.318309886183790671537767526745028724) /* 1/pi */ |
1120 | # define M_2_PIf32 __f32 (0.636619772367581343075535053490057448) /* 2/pi */ |
1121 | # define M_2_SQRTPIf32 __f32 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ |
1122 | # define M_SQRT2f32 __f32 (1.414213562373095048801688724209698079) /* sqrt(2) */ |
1123 | # define M_SQRT1_2f32 __f32 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ |
1124 | #endif |
1125 | |
1126 | #if __HAVE_FLOAT64 && defined __USE_GNU |
1127 | # define M_Ef64 __f64 (2.718281828459045235360287471352662498) /* e */ |
1128 | # define M_LOG2Ef64 __f64 (1.442695040888963407359924681001892137) /* log_2 e */ |
1129 | # define M_LOG10Ef64 __f64 (0.434294481903251827651128918916605082) /* log_10 e */ |
1130 | # define M_LN2f64 __f64 (0.693147180559945309417232121458176568) /* log_e 2 */ |
1131 | # define M_LN10f64 __f64 (2.302585092994045684017991454684364208) /* log_e 10 */ |
1132 | # define M_PIf64 __f64 (3.141592653589793238462643383279502884) /* pi */ |
1133 | # define M_PI_2f64 __f64 (1.570796326794896619231321691639751442) /* pi/2 */ |
1134 | # define M_PI_4f64 __f64 (0.785398163397448309615660845819875721) /* pi/4 */ |
1135 | # define M_1_PIf64 __f64 (0.318309886183790671537767526745028724) /* 1/pi */ |
1136 | # define M_2_PIf64 __f64 (0.636619772367581343075535053490057448) /* 2/pi */ |
1137 | # define M_2_SQRTPIf64 __f64 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ |
1138 | # define M_SQRT2f64 __f64 (1.414213562373095048801688724209698079) /* sqrt(2) */ |
1139 | # define M_SQRT1_2f64 __f64 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ |
1140 | #endif |
1141 | |
1142 | #if __HAVE_FLOAT128 && defined __USE_GNU |
1143 | # define M_Ef128 __f128 (2.718281828459045235360287471352662498) /* e */ |
1144 | # define M_LOG2Ef128 __f128 (1.442695040888963407359924681001892137) /* log_2 e */ |
1145 | # define M_LOG10Ef128 __f128 (0.434294481903251827651128918916605082) /* log_10 e */ |
1146 | # define M_LN2f128 __f128 (0.693147180559945309417232121458176568) /* log_e 2 */ |
1147 | # define M_LN10f128 __f128 (2.302585092994045684017991454684364208) /* log_e 10 */ |
1148 | # define M_PIf128 __f128 (3.141592653589793238462643383279502884) /* pi */ |
1149 | # define M_PI_2f128 __f128 (1.570796326794896619231321691639751442) /* pi/2 */ |
1150 | # define M_PI_4f128 __f128 (0.785398163397448309615660845819875721) /* pi/4 */ |
1151 | # define M_1_PIf128 __f128 (0.318309886183790671537767526745028724) /* 1/pi */ |
1152 | # define M_2_PIf128 __f128 (0.636619772367581343075535053490057448) /* 2/pi */ |
1153 | # define M_2_SQRTPIf128 __f128 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ |
1154 | # define M_SQRT2f128 __f128 (1.414213562373095048801688724209698079) /* sqrt(2) */ |
1155 | # define M_SQRT1_2f128 __f128 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ |
1156 | #endif |
1157 | |
1158 | #if __HAVE_FLOAT32X && defined __USE_GNU |
1159 | # define M_Ef32x __f32x (2.718281828459045235360287471352662498) /* e */ |
1160 | # define M_LOG2Ef32x __f32x (1.442695040888963407359924681001892137) /* log_2 e */ |
1161 | # define M_LOG10Ef32x __f32x (0.434294481903251827651128918916605082) /* log_10 e */ |
1162 | # define M_LN2f32x __f32x (0.693147180559945309417232121458176568) /* log_e 2 */ |
1163 | # define M_LN10f32x __f32x (2.302585092994045684017991454684364208) /* log_e 10 */ |
1164 | # define M_PIf32x __f32x (3.141592653589793238462643383279502884) /* pi */ |
1165 | # define M_PI_2f32x __f32x (1.570796326794896619231321691639751442) /* pi/2 */ |
1166 | # define M_PI_4f32x __f32x (0.785398163397448309615660845819875721) /* pi/4 */ |
1167 | # define M_1_PIf32x __f32x (0.318309886183790671537767526745028724) /* 1/pi */ |
1168 | # define M_2_PIf32x __f32x (0.636619772367581343075535053490057448) /* 2/pi */ |
1169 | # define M_2_SQRTPIf32x __f32x (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ |
1170 | # define M_SQRT2f32x __f32x (1.414213562373095048801688724209698079) /* sqrt(2) */ |
1171 | # define M_SQRT1_2f32x __f32x (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ |
1172 | #endif |
1173 | |
1174 | #if __HAVE_FLOAT64X && defined __USE_GNU |
1175 | # define M_Ef64x __f64x (2.718281828459045235360287471352662498) /* e */ |
1176 | # define M_LOG2Ef64x __f64x (1.442695040888963407359924681001892137) /* log_2 e */ |
1177 | # define M_LOG10Ef64x __f64x (0.434294481903251827651128918916605082) /* log_10 e */ |
1178 | # define M_LN2f64x __f64x (0.693147180559945309417232121458176568) /* log_e 2 */ |
1179 | # define M_LN10f64x __f64x (2.302585092994045684017991454684364208) /* log_e 10 */ |
1180 | # define M_PIf64x __f64x (3.141592653589793238462643383279502884) /* pi */ |
1181 | # define M_PI_2f64x __f64x (1.570796326794896619231321691639751442) /* pi/2 */ |
1182 | # define M_PI_4f64x __f64x (0.785398163397448309615660845819875721) /* pi/4 */ |
1183 | # define M_1_PIf64x __f64x (0.318309886183790671537767526745028724) /* 1/pi */ |
1184 | # define M_2_PIf64x __f64x (0.636619772367581343075535053490057448) /* 2/pi */ |
1185 | # define M_2_SQRTPIf64x __f64x (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ |
1186 | # define M_SQRT2f64x __f64x (1.414213562373095048801688724209698079) /* sqrt(2) */ |
1187 | # define M_SQRT1_2f64x __f64x (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ |
1188 | #endif |
1189 | |
1190 | #if __HAVE_FLOAT128X && defined __USE_GNU |
1191 | # error "M_* values needed for _Float128x" |
1192 | #endif |
1193 | |
1194 | /* When compiling in strict ISO C compatible mode we must not use the |
1195 | inline functions since they, among other things, do not set the |
1196 | `errno' variable correctly. */ |
1197 | #if defined __STRICT_ANSI__ && !defined __NO_MATH_INLINES |
1198 | # define __NO_MATH_INLINES 1 |
1199 | #endif |
1200 | |
1201 | #ifdef __USE_ISOC99 |
1202 | # if __GNUC_PREREQ (3, 1) |
1203 | /* ISO C99 defines some macros to compare number while taking care for |
1204 | unordered numbers. Many FPUs provide special instructions to support |
1205 | these operations. Generic support in GCC for these as builtins went |
1206 | in 2.97, but not all cpus added their patterns until 3.1. Therefore |
1207 | we enable the builtins from 3.1 onwards and use a generic implementation |
1208 | othwerwise. */ |
1209 | # define isgreater(x, y) __builtin_isgreater(x, y) |
1210 | # define isgreaterequal(x, y) __builtin_isgreaterequal(x, y) |
1211 | # define isless(x, y) __builtin_isless(x, y) |
1212 | # define islessequal(x, y) __builtin_islessequal(x, y) |
1213 | # define islessgreater(x, y) __builtin_islessgreater(x, y) |
1214 | # define isunordered(x, y) __builtin_isunordered(x, y) |
1215 | # else |
1216 | # define isgreater(x, y) \ |
1217 | (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \ |
1218 | !isunordered (__x, __y) && __x > __y; })) |
1219 | # define isgreaterequal(x, y) \ |
1220 | (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \ |
1221 | !isunordered (__x, __y) && __x >= __y; })) |
1222 | # define isless(x, y) \ |
1223 | (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \ |
1224 | !isunordered (__x, __y) && __x < __y; })) |
1225 | # define islessequal(x, y) \ |
1226 | (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \ |
1227 | !isunordered (__x, __y) && __x <= __y; })) |
1228 | # define islessgreater(x, y) \ |
1229 | (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \ |
1230 | !isunordered (__x, __y) && __x != __y; })) |
1231 | /* isunordered must always check both operands first for signaling NaNs. */ |
1232 | # define isunordered(x, y) \ |
1233 | (__extension__ ({ __typeof__ (x) __u = (x); __typeof__ (y) __v = (y); \ |
1234 | __u != __v && (__u != __u || __v != __v); })) |
1235 | # endif |
1236 | #endif |
1237 | |
1238 | /* Get machine-dependent inline versions (if there are any). */ |
1239 | #ifdef __USE_EXTERN_INLINES |
1240 | # include <bits/mathinline.h> |
1241 | #endif |
1242 | |
1243 | /* Define special entry points to use when the compiler got told to |
1244 | only expect finite results. */ |
1245 | #if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0 |
1246 | |
1247 | /* Include bits/math-finite.h for double. */ |
1248 | # define _Mdouble_ double |
1249 | # define __MATH_DECLARING_DOUBLE 1 |
1250 | # define __MATH_DECLARING_FLOATN 0 |
1251 | # define __REDIRFROM_X(function, reentrant) \ |
1252 | function ## reentrant |
1253 | # define __REDIRTO_X(function, reentrant) \ |
1254 | __ ## function ## reentrant ## _finite |
1255 | # include <bits/math-finite.h> |
1256 | # undef _Mdouble_ |
1257 | # undef __MATH_DECLARING_DOUBLE |
1258 | # undef __MATH_DECLARING_FLOATN |
1259 | # undef __REDIRFROM_X |
1260 | # undef __REDIRTO_X |
1261 | |
1262 | /* When __USE_ISOC99 is defined, include math-finite for float and |
1263 | long double, as well. */ |
1264 | # ifdef __USE_ISOC99 |
1265 | |
1266 | /* Include bits/math-finite.h for float. */ |
1267 | # define _Mdouble_ float |
1268 | # define __MATH_DECLARING_DOUBLE 0 |
1269 | # define __MATH_DECLARING_FLOATN 0 |
1270 | # define __REDIRFROM_X(function, reentrant) \ |
1271 | function ## f ## reentrant |
1272 | # define __REDIRTO_X(function, reentrant) \ |
1273 | __ ## function ## f ## reentrant ## _finite |
1274 | # include <bits/math-finite.h> |
1275 | # undef _Mdouble_ |
1276 | # undef __MATH_DECLARING_DOUBLE |
1277 | # undef __MATH_DECLARING_FLOATN |
1278 | # undef __REDIRFROM_X |
1279 | # undef __REDIRTO_X |
1280 | |
1281 | /* Include bits/math-finite.h for long double. */ |
1282 | # ifdef __MATH_DECLARE_LDOUBLE |
1283 | # define _Mdouble_ long double |
1284 | # define __MATH_DECLARING_DOUBLE 0 |
1285 | # define __MATH_DECLARING_FLOATN 0 |
1286 | # define __REDIRFROM_X(function, reentrant) \ |
1287 | function ## l ## reentrant |
1288 | # ifdef __NO_LONG_DOUBLE_MATH |
1289 | # define __REDIRTO_X(function, reentrant) \ |
1290 | __ ## function ## reentrant ## _finite |
1291 | # else |
1292 | # define __REDIRTO_X(function, reentrant) \ |
1293 | __ ## function ## l ## reentrant ## _finite |
1294 | # endif |
1295 | # include <bits/math-finite.h> |
1296 | # undef _Mdouble_ |
1297 | # undef __MATH_DECLARING_DOUBLE |
1298 | # undef __MATH_DECLARING_FLOATN |
1299 | # undef __REDIRFROM_X |
1300 | # undef __REDIRTO_X |
1301 | # endif |
1302 | |
1303 | # endif /* __USE_ISOC99. */ |
1304 | |
1305 | /* Include bits/math-finite.h for _FloatN and _FloatNx. */ |
1306 | |
1307 | # if (__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC)) \ |
1308 | && __GLIBC_USE (IEC_60559_TYPES_EXT) |
1309 | # define _Mdouble_ _Float16 |
1310 | # define __MATH_DECLARING_DOUBLE 0 |
1311 | # define __MATH_DECLARING_FLOATN 1 |
1312 | # define __REDIRFROM_X(function, reentrant) \ |
1313 | function ## f16 ## reentrant |
1314 | # if __HAVE_DISTINCT_FLOAT16 |
1315 | # define __REDIRTO_X(function, reentrant) \ |
1316 | __ ## function ## f16 ## reentrant ## _finite |
1317 | # else |
1318 | # error "non-disinct _Float16" |
1319 | # endif |
1320 | # include <bits/math-finite.h> |
1321 | # undef _Mdouble_ |
1322 | # undef __MATH_DECLARING_DOUBLE |
1323 | # undef __MATH_DECLARING_FLOATN |
1324 | # undef __REDIRFROM_X |
1325 | # undef __REDIRTO_X |
1326 | # endif |
1327 | |
1328 | # if (__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC)) \ |
1329 | && __GLIBC_USE (IEC_60559_TYPES_EXT) |
1330 | # define _Mdouble_ _Float32 |
1331 | # define __MATH_DECLARING_DOUBLE 0 |
1332 | # define __MATH_DECLARING_FLOATN 1 |
1333 | # define __REDIRFROM_X(function, reentrant) \ |
1334 | function ## f32 ## reentrant |
1335 | # if __HAVE_DISTINCT_FLOAT32 |
1336 | # define __REDIRTO_X(function, reentrant) \ |
1337 | __ ## function ## f32 ## reentrant ## _finite |
1338 | # else |
1339 | # define __REDIRTO_X(function, reentrant) \ |
1340 | __ ## function ## f ## reentrant ## _finite |
1341 | # endif |
1342 | # include <bits/math-finite.h> |
1343 | # undef _Mdouble_ |
1344 | # undef __MATH_DECLARING_DOUBLE |
1345 | # undef __MATH_DECLARING_FLOATN |
1346 | # undef __REDIRFROM_X |
1347 | # undef __REDIRTO_X |
1348 | # endif |
1349 | |
1350 | # if (__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC)) \ |
1351 | && __GLIBC_USE (IEC_60559_TYPES_EXT) |
1352 | # define _Mdouble_ _Float64 |
1353 | # define __MATH_DECLARING_DOUBLE 0 |
1354 | # define __MATH_DECLARING_FLOATN 1 |
1355 | # define __REDIRFROM_X(function, reentrant) \ |
1356 | function ## f64 ## reentrant |
1357 | # if __HAVE_DISTINCT_FLOAT64 |
1358 | # define __REDIRTO_X(function, reentrant) \ |
1359 | __ ## function ## f64 ## reentrant ## _finite |
1360 | # else |
1361 | # define __REDIRTO_X(function, reentrant) \ |
1362 | __ ## function ## reentrant ## _finite |
1363 | # endif |
1364 | # include <bits/math-finite.h> |
1365 | # undef _Mdouble_ |
1366 | # undef __MATH_DECLARING_DOUBLE |
1367 | # undef __MATH_DECLARING_FLOATN |
1368 | # undef __REDIRFROM_X |
1369 | # undef __REDIRTO_X |
1370 | # endif |
1371 | |
1372 | # if (__HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC)) \ |
1373 | && __GLIBC_USE (IEC_60559_TYPES_EXT) |
1374 | # define _Mdouble_ _Float128 |
1375 | # define __MATH_DECLARING_DOUBLE 0 |
1376 | # define __MATH_DECLARING_FLOATN 1 |
1377 | # define __REDIRFROM_X(function, reentrant) \ |
1378 | function ## f128 ## reentrant |
1379 | # if __HAVE_DISTINCT_FLOAT128 |
1380 | # define __REDIRTO_X(function, reentrant) \ |
1381 | __ ## function ## f128 ## reentrant ## _finite |
1382 | # else |
1383 | # define __REDIRTO_X(function, reentrant) \ |
1384 | __ ## function ## l ## reentrant ## _finite |
1385 | # endif |
1386 | # include <bits/math-finite.h> |
1387 | # undef _Mdouble_ |
1388 | # undef __MATH_DECLARING_DOUBLE |
1389 | # undef __MATH_DECLARING_FLOATN |
1390 | # undef __REDIRFROM_X |
1391 | # undef __REDIRTO_X |
1392 | # endif |
1393 | |
1394 | # if (__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC)) \ |
1395 | && __GLIBC_USE (IEC_60559_TYPES_EXT) |
1396 | # define _Mdouble_ _Float32x |
1397 | # define __MATH_DECLARING_DOUBLE 0 |
1398 | # define __MATH_DECLARING_FLOATN 1 |
1399 | # define __REDIRFROM_X(function, reentrant) \ |
1400 | function ## f32x ## reentrant |
1401 | # if __HAVE_DISTINCT_FLOAT32X |
1402 | # define __REDIRTO_X(function, reentrant) \ |
1403 | __ ## function ## f32x ## reentrant ## _finite |
1404 | # else |
1405 | # define __REDIRTO_X(function, reentrant) \ |
1406 | __ ## function ## reentrant ## _finite |
1407 | # endif |
1408 | # include <bits/math-finite.h> |
1409 | # undef _Mdouble_ |
1410 | # undef __MATH_DECLARING_DOUBLE |
1411 | # undef __MATH_DECLARING_FLOATN |
1412 | # undef __REDIRFROM_X |
1413 | # undef __REDIRTO_X |
1414 | # endif |
1415 | |
1416 | # if (__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC)) \ |
1417 | && __GLIBC_USE (IEC_60559_TYPES_EXT) |
1418 | # define _Mdouble_ _Float64x |
1419 | # define __MATH_DECLARING_DOUBLE 0 |
1420 | # define __MATH_DECLARING_FLOATN 1 |
1421 | # define __REDIRFROM_X(function, reentrant) \ |
1422 | function ## f64x ## reentrant |
1423 | # if __HAVE_DISTINCT_FLOAT64X |
1424 | # define __REDIRTO_X(function, reentrant) \ |
1425 | __ ## function ## f64x ## reentrant ## _finite |
1426 | # elif __HAVE_FLOAT64X_LONG_DOUBLE |
1427 | # define __REDIRTO_X(function, reentrant) \ |
1428 | __ ## function ## l ## reentrant ## _finite |
1429 | # else |
1430 | # define __REDIRTO_X(function, reentrant) \ |
1431 | __ ## function ## f128 ## reentrant ## _finite |
1432 | # endif |
1433 | # include <bits/math-finite.h> |
1434 | # undef _Mdouble_ |
1435 | # undef __MATH_DECLARING_DOUBLE |
1436 | # undef __MATH_DECLARING_FLOATN |
1437 | # undef __REDIRFROM_X |
1438 | # undef __REDIRTO_X |
1439 | # endif |
1440 | |
1441 | # if (__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)) \ |
1442 | && __GLIBC_USE (IEC_60559_TYPES_EXT) |
1443 | # define _Mdouble_ _Float128x |
1444 | # define __MATH_DECLARING_DOUBLE 0 |
1445 | # define __MATH_DECLARING_FLOATN 1 |
1446 | # define __REDIRFROM_X(function, reentrant) \ |
1447 | function ## f128x ## reentrant |
1448 | # if __HAVE_DISTINCT_FLOAT128X |
1449 | # define __REDIRTO_X(function, reentrant) \ |
1450 | __ ## function ## f128x ## reentrant ## _finite |
1451 | # else |
1452 | # error "non-disinct _Float128x" |
1453 | # endif |
1454 | # include <bits/math-finite.h> |
1455 | # undef _Mdouble_ |
1456 | # undef __MATH_DECLARING_DOUBLE |
1457 | # undef __MATH_DECLARING_FLOATN |
1458 | # undef __REDIRFROM_X |
1459 | # undef __REDIRTO_X |
1460 | # endif |
1461 | |
1462 | #endif /* __FINITE_MATH_ONLY__ > 0. */ |
1463 | |
1464 | #if __GLIBC_USE (IEC_60559_BFP_EXT) |
1465 | /* An expression whose type has the widest of the evaluation formats |
1466 | of X and Y (which are of floating-point types). */ |
1467 | # if __FLT_EVAL_METHOD__ == 2 || __FLT_EVAL_METHOD__ > 64 |
1468 | # define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0L) |
1469 | # elif __FLT_EVAL_METHOD__ == 1 || __FLT_EVAL_METHOD__ > 32 |
1470 | # define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0) |
1471 | # elif __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 32 |
1472 | # define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0f) |
1473 | # else |
1474 | # define __MATH_EVAL_FMT2(x, y) ((x) + (y)) |
1475 | # endif |
1476 | |
1477 | /* Return X == Y but raising "invalid" and setting errno if X or Y is |
1478 | a NaN. */ |
1479 | # if !defined __cplusplus || (__cplusplus < 201103L && !defined __GNUC__) |
1480 | # define iseqsig(x, y) \ |
1481 | __MATH_TG (__MATH_EVAL_FMT2 (x, y), __iseqsig, ((x), (y))) |
1482 | # else |
1483 | /* In C++ mode, __MATH_TG cannot be used, because it relies on |
1484 | __builtin_types_compatible_p, which is a C-only builtin. Moreover, |
1485 | the comparison macros from ISO C take two floating-point arguments, |
1486 | which need not have the same type. Choosing what underlying function |
1487 | to call requires evaluating the formats of the arguments, then |
1488 | selecting which is wider. The macro __MATH_EVAL_FMT2 provides this |
1489 | information, however, only the type of the macro expansion is |
1490 | relevant (actually evaluating the expression would be incorrect). |
1491 | Thus, the type is used as a template parameter for __iseqsig_type, |
1492 | which calls the appropriate underlying function. */ |
1493 | extern "C++" { |
1494 | template<typename> struct __iseqsig_type; |
1495 | |
1496 | template<> struct __iseqsig_type<float> |
1497 | { |
1498 | static int __call (float __x, float __y) throw () |
1499 | { |
1500 | return __iseqsigf (__x, __y); |
1501 | } |
1502 | }; |
1503 | |
1504 | template<> struct __iseqsig_type<double> |
1505 | { |
1506 | static int __call (double __x, double __y) throw () |
1507 | { |
1508 | return __iseqsig (__x, __y); |
1509 | } |
1510 | }; |
1511 | |
1512 | template<> struct __iseqsig_type<long double> |
1513 | { |
1514 | static int __call (long double __x, long double __y) throw () |
1515 | { |
1516 | # ifndef __NO_LONG_DOUBLE_MATH |
1517 | return __iseqsigl (__x, __y); |
1518 | # else |
1519 | return __iseqsig (__x, __y); |
1520 | # endif |
1521 | } |
1522 | }; |
1523 | |
1524 | # if __HAVE_FLOAT128_UNLIKE_LDBL |
1525 | /* When using an IEEE 128-bit long double, _Float128 is defined as long double |
1526 | in C++. */ |
1527 | template<> struct __iseqsig_type<_Float128> |
1528 | { |
1529 | static int __call (_Float128 __x, _Float128 __y) throw () |
1530 | { |
1531 | return __iseqsigf128 (__x, __y); |
1532 | } |
1533 | }; |
1534 | # endif |
1535 | |
1536 | template<typename _T1, typename _T2> |
1537 | inline int |
1538 | iseqsig (_T1 __x, _T2 __y) throw () |
1539 | { |
1540 | # if __cplusplus >= 201103L |
1541 | typedef decltype (__MATH_EVAL_FMT2 (__x, __y)) _T3; |
1542 | # else |
1543 | typedef __typeof (__MATH_EVAL_FMT2 (__x, __y)) _T3; |
1544 | # endif |
1545 | return __iseqsig_type<_T3>::__call (__x, __y); |
1546 | } |
1547 | |
1548 | } /* extern "C++" */ |
1549 | # endif /* __cplusplus */ |
1550 | |
1551 | #endif |
1552 | |
1553 | __END_DECLS |
1554 | |
1555 | |
1556 | #endif /* math.h */ |
1557 | |