Add sysdeps/ieee754/soft-fp.
[glibc.git] / math / math.h
blobf6d1feed78f6ad9acc90877b21c3d52fc7ebd554
1 /* Declarations for math functions.
2 Copyright (C) 1991-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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/>. */
20 * ISO C99 Standard: 7.12 Mathematics <math.h>
23 #ifndef _MATH_H
24 #define _MATH_H 1
26 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
27 #include <bits/libc-header-start.h>
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
34 __BEGIN_DECLS
36 /* Get definitions of __intmax_t and __uintmax_t. */
37 #include <bits/types.h>
39 /* Get machine-dependent vector math functions declarations. */
40 #include <bits/math-vector.h>
42 /* Gather machine dependent type support. */
43 #include <bits/floatn.h>
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
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
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 */
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
137 /* Get __GLIBC_FLT_EVAL_METHOD. */
138 #include <bits/flt-eval-method.h>
140 #ifdef __USE_ISOC99
141 /* Define the following typedefs.
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
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
180 /* Define macros for the return values of ilogb and llogb, based on
181 __FP_LOGB0_IS_MIN and __FP_LOGBNAN_IS_MIN.
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)'.
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
221 /* Get the architecture specific values describing the floating-point
222 evaluation. The following symbols will get defined:
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.
233 #include <bits/fp-fast.h>
235 #if __GLIBC_USE (IEC_60559_BFP_EXT)
236 /* Rounding direction macros for fromfp functions. */
237 enum
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,
255 #endif
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'. */
262 #define __SIMD_DECL(function) __CONCAT (__DECL_SIMD_, function)
264 #define __MATHCALL_VEC(function, suffix, args) \
265 __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \
266 __MATHCALL (function, suffix, args)
268 #define __MATHDECL_VEC(type, function,suffix, args) \
269 __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \
270 __MATHDECL(type, function,suffix, args)
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
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
296 #ifdef __USE_ISOC99
299 /* Include the file of declarations again, this time using `float'
300 instead of `double' and appending f to each function name. */
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
313 # if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \
314 || defined __LDBL_COMPAT \
315 || defined _LIBC_TEST
316 # ifdef __LDBL_COMPAT
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
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
341 /* Include the file of declarations again, this time using `long double'
342 instead of `double' and appending l to each function name. */
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
356 # endif /* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */
358 #endif /* Use ISO C99. */
360 /* Include the file of declarations for _FloatN and _FloatNx
361 types. */
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). */
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). */
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). */
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). */
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). */
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). */
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). */
482 #undef __MATHDECL_1
483 #undef __MATHDECL
484 #undef __MATHCALL
487 #if defined __USE_MISC || defined __USE_XOPEN
488 /* This variable is used by `gamma' and `lgamma'. */
489 extern int signgam;
490 #endif
492 #if (__HAVE_DISTINCT_FLOAT16 \
493 || __HAVE_DISTINCT_FLOAT32 \
494 || __HAVE_DISTINCT_FLOAT64 \
495 || __HAVE_DISTINCT_FLOAT32X \
496 || __HAVE_DISTINCT_FLOAT64X \
497 || __HAVE_DISTINCT_FLOAT128X)
498 # error "Unsupported _FloatN or _FloatNx types for <math.h>."
499 #endif
501 /* Depending on the type of TG_ARG, call an appropriately suffixed
502 version of FUNC with arguments (including parentheses) ARGS.
503 Suffixed functions may not exist for long double if it has the same
504 format as double, or for other types with the same format as float,
505 double or long double. The behavior is undefined if the argument
506 does not have a real floating type. The definition may use a
507 conditional expression, so all suffixed versions of FUNC must
508 return the same type (FUNC may include a cast if necessary rather
509 than being a single identifier). */
510 #ifdef __NO_LONG_DOUBLE_MATH
511 # if __HAVE_DISTINCT_FLOAT128
512 # error "Distinct _Float128 without distinct long double not supported."
513 # endif
514 # define __MATH_TG(TG_ARG, FUNC, ARGS) \
515 (sizeof (TG_ARG) == sizeof (float) ? FUNC ## f ARGS : FUNC ARGS)
516 #elif __HAVE_DISTINCT_FLOAT128
517 # if __HAVE_GENERIC_SELECTION
518 # if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT32
519 # define __MATH_TG_F32(FUNC, ARGS) _Float32: FUNC ## f ARGS,
520 # else
521 # define __MATH_TG_F32(FUNC, ARGS)
522 # endif
523 # if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT64X
524 # if __HAVE_FLOAT64X_LONG_DOUBLE
525 # define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## l ARGS,
526 # else
527 # define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## f128 ARGS,
528 # endif
529 # else
530 # define __MATH_TG_F64X(FUNC, ARGS)
531 # endif
532 # define __MATH_TG(TG_ARG, FUNC, ARGS) \
533 _Generic ((TG_ARG), \
534 float: FUNC ## f ARGS, \
535 __MATH_TG_F32 (FUNC, ARGS) \
536 default: FUNC ARGS, \
537 long double: FUNC ## l ARGS, \
538 __MATH_TG_F64X (FUNC, ARGS) \
539 _Float128: FUNC ## f128 ARGS)
540 # else
541 # if __HAVE_FLOATN_NOT_TYPEDEF
542 # error "Non-typedef _FloatN but no _Generic."
543 # endif
544 # define __MATH_TG(TG_ARG, FUNC, ARGS) \
545 __builtin_choose_expr \
546 (__builtin_types_compatible_p (__typeof (TG_ARG), float), \
547 FUNC ## f ARGS, \
548 __builtin_choose_expr \
549 (__builtin_types_compatible_p (__typeof (TG_ARG), double), \
550 FUNC ARGS, \
551 __builtin_choose_expr \
552 (__builtin_types_compatible_p (__typeof (TG_ARG), long double), \
553 FUNC ## l ARGS, \
554 FUNC ## f128 ARGS)))
555 # endif
556 #else
557 # define __MATH_TG(TG_ARG, FUNC, ARGS) \
558 (sizeof (TG_ARG) == sizeof (float) \
559 ? FUNC ## f ARGS \
560 : sizeof (TG_ARG) == sizeof (double) \
561 ? FUNC ARGS \
562 : FUNC ## l ARGS)
563 #endif
565 /* ISO C99 defines some generic macros which work on any data type. */
566 #ifdef __USE_ISOC99
568 /* All floating-point numbers can be put in one of these categories. */
569 enum
571 FP_NAN =
572 # define FP_NAN 0
573 FP_NAN,
574 FP_INFINITE =
575 # define FP_INFINITE 1
576 FP_INFINITE,
577 FP_ZERO =
578 # define FP_ZERO 2
579 FP_ZERO,
580 FP_SUBNORMAL =
581 # define FP_SUBNORMAL 3
582 FP_SUBNORMAL,
583 FP_NORMAL =
584 # define FP_NORMAL 4
585 FP_NORMAL
588 /* GCC bug 66462 means we cannot use the math builtins with -fsignaling-nan,
589 so disable builtins if this is enabled. When fixed in a newer GCC,
590 the __SUPPORT_SNAN__ check may be skipped for those versions. */
592 /* Return number of classification appropriate for X. */
593 # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ \
594 && (!defined __OPTIMIZE_SIZE__ || defined __cplusplus)
595 /* The check for __cplusplus allows the use of the builtin, even
596 when optimization for size is on. This is provided for
597 libstdc++, only to let its configure test work when it is built
598 with -Os. No further use of this definition of fpclassify is
599 expected in C++ mode, since libstdc++ provides its own version
600 of fpclassify in cmath (which undefines fpclassify). */
601 # define fpclassify(x) __builtin_fpclassify (FP_NAN, FP_INFINITE, \
602 FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
603 # else
604 # define fpclassify(x) __MATH_TG ((x), __fpclassify, (x))
605 # endif
607 /* Return nonzero value if sign of X is negative. */
608 # if __GNUC_PREREQ (6,0)
609 # define signbit(x) __builtin_signbit (x)
610 # elif defined __cplusplus
611 /* In C++ mode, __MATH_TG cannot be used, because it relies on
612 __builtin_types_compatible_p, which is a C-only builtin.
613 The check for __cplusplus allows the use of the builtin instead of
614 __MATH_TG. This is provided for libstdc++, only to let its configure
615 test work. No further use of this definition of signbit is expected
616 in C++ mode, since libstdc++ provides its own version of signbit
617 in cmath (which undefines signbit). */
618 # define signbit(x) __builtin_signbitl (x)
619 # elif __GNUC_PREREQ (4,0)
620 # define signbit(x) __MATH_TG ((x), __builtin_signbit, (x))
621 # else
622 # define signbit(x) __MATH_TG ((x), __signbit, (x))
623 # endif
625 /* Return nonzero value if X is not +-Inf or NaN. */
626 # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
627 # define isfinite(x) __builtin_isfinite (x)
628 # else
629 # define isfinite(x) __MATH_TG ((x), __finite, (x))
630 # endif
632 /* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN. */
633 # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
634 # define isnormal(x) __builtin_isnormal (x)
635 # else
636 # define isnormal(x) (fpclassify (x) == FP_NORMAL)
637 # endif
639 /* Return nonzero value if X is a NaN. We could use `fpclassify' but
640 we already have this functions `__isnan' and it is faster. */
641 # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
642 # define isnan(x) __builtin_isnan (x)
643 # else
644 # define isnan(x) __MATH_TG ((x), __isnan, (x))
645 # endif
647 /* Return nonzero value if X is positive or negative infinity. */
648 # if __HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7,0) \
649 && !defined __SUPPORT_SNAN__ && !defined __cplusplus
650 /* Since __builtin_isinf_sign is broken for float128 before GCC 7.0,
651 use the helper function, __isinff128, with older compilers. This is
652 only provided for C mode, because in C++ mode, GCC has no support
653 for __builtin_types_compatible_p (and when in C++ mode, this macro is
654 not used anyway, because libstdc++ headers undefine it). */
655 # define isinf(x) \
656 (__builtin_types_compatible_p (__typeof (x), _Float128) \
657 ? __isinff128 (x) : __builtin_isinf_sign (x))
658 # elif __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
659 # define isinf(x) __builtin_isinf_sign (x)
660 # else
661 # define isinf(x) __MATH_TG ((x), __isinf, (x))
662 # endif
664 /* Bitmasks for the math_errhandling macro. */
665 # define MATH_ERRNO 1 /* errno set by math functions. */
666 # define MATH_ERREXCEPT 2 /* Exceptions raised by math functions. */
668 /* By default all functions support both errno and exception handling.
669 In gcc's fast math mode and if inline functions are defined this
670 might not be true. */
671 # ifndef __FAST_MATH__
672 # define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT)
673 # endif
675 #endif /* Use ISO C99. */
677 #if __GLIBC_USE (IEC_60559_BFP_EXT)
678 # include <bits/iscanonical.h>
680 /* Return nonzero value if X is a signaling NaN. */
681 # ifndef __cplusplus
682 # define issignaling(x) __MATH_TG ((x), __issignaling, (x))
683 # else
684 /* In C++ mode, __MATH_TG cannot be used, because it relies on
685 __builtin_types_compatible_p, which is a C-only builtin. On the
686 other hand, overloading provides the means to distinguish between
687 the floating-point types. The overloading resolution will match
688 the correct parameter (regardless of type qualifiers (i.e.: const
689 and volatile)). */
690 extern "C++" {
691 inline int issignaling (float __val) { return __issignalingf (__val); }
692 inline int issignaling (double __val) { return __issignaling (__val); }
693 inline int
694 issignaling (long double __val)
696 # ifdef __NO_LONG_DOUBLE_MATH
697 return __issignaling (__val);
698 # else
699 return __issignalingl (__val);
700 # endif
702 # if __HAVE_DISTINCT_FLOAT128
703 inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); }
704 # endif
705 } /* extern C++ */
706 # endif
708 /* Return nonzero value if X is subnormal. */
709 # define issubnormal(x) (fpclassify (x) == FP_SUBNORMAL)
711 /* Return nonzero value if X is zero. */
712 # ifndef __cplusplus
713 # ifdef __SUPPORT_SNAN__
714 # define iszero(x) (fpclassify (x) == FP_ZERO)
715 # else
716 # define iszero(x) (((__typeof (x)) (x)) == 0)
717 # endif
718 # else /* __cplusplus */
719 extern "C++" {
720 # ifdef __SUPPORT_SNAN__
721 inline int
722 iszero (float __val)
724 return __fpclassifyf (__val) == FP_ZERO;
726 inline int
727 iszero (double __val)
729 return __fpclassify (__val) == FP_ZERO;
731 inline int
732 iszero (long double __val)
734 # ifdef __NO_LONG_DOUBLE_MATH
735 return __fpclassify (__val) == FP_ZERO;
736 # else
737 return __fpclassifyl (__val) == FP_ZERO;
738 # endif
740 # if __HAVE_DISTINCT_FLOAT128
741 inline int
742 iszero (_Float128 __val)
744 return __fpclassifyf128 (__val) == FP_ZERO;
746 # endif
747 # else
748 template <class __T> inline bool
749 iszero (__T __val)
751 return __val == 0;
753 # endif
754 } /* extern C++ */
755 # endif /* __cplusplus */
756 #endif /* Use IEC_60559_BFP_EXT. */
758 #ifdef __USE_XOPEN
759 /* X/Open wants another strange constant. */
760 # define MAXFLOAT 3.40282347e+38F
761 #endif
764 /* Some useful constants. */
765 #if defined __USE_MISC || defined __USE_XOPEN
766 # define M_E 2.7182818284590452354 /* e */
767 # define M_LOG2E 1.4426950408889634074 /* log_2 e */
768 # define M_LOG10E 0.43429448190325182765 /* log_10 e */
769 # define M_LN2 0.69314718055994530942 /* log_e 2 */
770 # define M_LN10 2.30258509299404568402 /* log_e 10 */
771 # define M_PI 3.14159265358979323846 /* pi */
772 # define M_PI_2 1.57079632679489661923 /* pi/2 */
773 # define M_PI_4 0.78539816339744830962 /* pi/4 */
774 # define M_1_PI 0.31830988618379067154 /* 1/pi */
775 # define M_2_PI 0.63661977236758134308 /* 2/pi */
776 # define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
777 # define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
778 # define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
779 #endif
781 /* The above constants are not adequate for computation using `long double's.
782 Therefore we provide as an extension constants with similar names as a
783 GNU extension. Provide enough digits for the 128-bit IEEE quad. */
784 #ifdef __USE_GNU
785 # define M_El 2.718281828459045235360287471352662498L /* e */
786 # define M_LOG2El 1.442695040888963407359924681001892137L /* log_2 e */
787 # define M_LOG10El 0.434294481903251827651128918916605082L /* log_10 e */
788 # define M_LN2l 0.693147180559945309417232121458176568L /* log_e 2 */
789 # define M_LN10l 2.302585092994045684017991454684364208L /* log_e 10 */
790 # define M_PIl 3.141592653589793238462643383279502884L /* pi */
791 # define M_PI_2l 1.570796326794896619231321691639751442L /* pi/2 */
792 # define M_PI_4l 0.785398163397448309615660845819875721L /* pi/4 */
793 # define M_1_PIl 0.318309886183790671537767526745028724L /* 1/pi */
794 # define M_2_PIl 0.636619772367581343075535053490057448L /* 2/pi */
795 # define M_2_SQRTPIl 1.128379167095512573896158903121545172L /* 2/sqrt(pi) */
796 # define M_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */
797 # define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */
798 #endif
800 #if __HAVE_FLOAT16 && defined __USE_GNU
801 # define M_Ef16 __f16 (2.718281828459045235360287471352662498) /* e */
802 # define M_LOG2Ef16 __f16 (1.442695040888963407359924681001892137) /* log_2 e */
803 # define M_LOG10Ef16 __f16 (0.434294481903251827651128918916605082) /* log_10 e */
804 # define M_LN2f16 __f16 (0.693147180559945309417232121458176568) /* log_e 2 */
805 # define M_LN10f16 __f16 (2.302585092994045684017991454684364208) /* log_e 10 */
806 # define M_PIf16 __f16 (3.141592653589793238462643383279502884) /* pi */
807 # define M_PI_2f16 __f16 (1.570796326794896619231321691639751442) /* pi/2 */
808 # define M_PI_4f16 __f16 (0.785398163397448309615660845819875721) /* pi/4 */
809 # define M_1_PIf16 __f16 (0.318309886183790671537767526745028724) /* 1/pi */
810 # define M_2_PIf16 __f16 (0.636619772367581343075535053490057448) /* 2/pi */
811 # define M_2_SQRTPIf16 __f16 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
812 # define M_SQRT2f16 __f16 (1.414213562373095048801688724209698079) /* sqrt(2) */
813 # define M_SQRT1_2f16 __f16 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
814 #endif
816 #if __HAVE_FLOAT32 && defined __USE_GNU
817 # define M_Ef32 __f32 (2.718281828459045235360287471352662498) /* e */
818 # define M_LOG2Ef32 __f32 (1.442695040888963407359924681001892137) /* log_2 e */
819 # define M_LOG10Ef32 __f32 (0.434294481903251827651128918916605082) /* log_10 e */
820 # define M_LN2f32 __f32 (0.693147180559945309417232121458176568) /* log_e 2 */
821 # define M_LN10f32 __f32 (2.302585092994045684017991454684364208) /* log_e 10 */
822 # define M_PIf32 __f32 (3.141592653589793238462643383279502884) /* pi */
823 # define M_PI_2f32 __f32 (1.570796326794896619231321691639751442) /* pi/2 */
824 # define M_PI_4f32 __f32 (0.785398163397448309615660845819875721) /* pi/4 */
825 # define M_1_PIf32 __f32 (0.318309886183790671537767526745028724) /* 1/pi */
826 # define M_2_PIf32 __f32 (0.636619772367581343075535053490057448) /* 2/pi */
827 # define M_2_SQRTPIf32 __f32 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
828 # define M_SQRT2f32 __f32 (1.414213562373095048801688724209698079) /* sqrt(2) */
829 # define M_SQRT1_2f32 __f32 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
830 #endif
832 #if __HAVE_FLOAT64 && defined __USE_GNU
833 # define M_Ef64 __f64 (2.718281828459045235360287471352662498) /* e */
834 # define M_LOG2Ef64 __f64 (1.442695040888963407359924681001892137) /* log_2 e */
835 # define M_LOG10Ef64 __f64 (0.434294481903251827651128918916605082) /* log_10 e */
836 # define M_LN2f64 __f64 (0.693147180559945309417232121458176568) /* log_e 2 */
837 # define M_LN10f64 __f64 (2.302585092994045684017991454684364208) /* log_e 10 */
838 # define M_PIf64 __f64 (3.141592653589793238462643383279502884) /* pi */
839 # define M_PI_2f64 __f64 (1.570796326794896619231321691639751442) /* pi/2 */
840 # define M_PI_4f64 __f64 (0.785398163397448309615660845819875721) /* pi/4 */
841 # define M_1_PIf64 __f64 (0.318309886183790671537767526745028724) /* 1/pi */
842 # define M_2_PIf64 __f64 (0.636619772367581343075535053490057448) /* 2/pi */
843 # define M_2_SQRTPIf64 __f64 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
844 # define M_SQRT2f64 __f64 (1.414213562373095048801688724209698079) /* sqrt(2) */
845 # define M_SQRT1_2f64 __f64 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
846 #endif
848 #if __HAVE_FLOAT128 && defined __USE_GNU
849 # define M_Ef128 __f128 (2.718281828459045235360287471352662498) /* e */
850 # define M_LOG2Ef128 __f128 (1.442695040888963407359924681001892137) /* log_2 e */
851 # define M_LOG10Ef128 __f128 (0.434294481903251827651128918916605082) /* log_10 e */
852 # define M_LN2f128 __f128 (0.693147180559945309417232121458176568) /* log_e 2 */
853 # define M_LN10f128 __f128 (2.302585092994045684017991454684364208) /* log_e 10 */
854 # define M_PIf128 __f128 (3.141592653589793238462643383279502884) /* pi */
855 # define M_PI_2f128 __f128 (1.570796326794896619231321691639751442) /* pi/2 */
856 # define M_PI_4f128 __f128 (0.785398163397448309615660845819875721) /* pi/4 */
857 # define M_1_PIf128 __f128 (0.318309886183790671537767526745028724) /* 1/pi */
858 # define M_2_PIf128 __f128 (0.636619772367581343075535053490057448) /* 2/pi */
859 # define M_2_SQRTPIf128 __f128 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
860 # define M_SQRT2f128 __f128 (1.414213562373095048801688724209698079) /* sqrt(2) */
861 # define M_SQRT1_2f128 __f128 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
862 #endif
864 #if __HAVE_FLOAT32X && defined __USE_GNU
865 # define M_Ef32x __f32x (2.718281828459045235360287471352662498) /* e */
866 # define M_LOG2Ef32x __f32x (1.442695040888963407359924681001892137) /* log_2 e */
867 # define M_LOG10Ef32x __f32x (0.434294481903251827651128918916605082) /* log_10 e */
868 # define M_LN2f32x __f32x (0.693147180559945309417232121458176568) /* log_e 2 */
869 # define M_LN10f32x __f32x (2.302585092994045684017991454684364208) /* log_e 10 */
870 # define M_PIf32x __f32x (3.141592653589793238462643383279502884) /* pi */
871 # define M_PI_2f32x __f32x (1.570796326794896619231321691639751442) /* pi/2 */
872 # define M_PI_4f32x __f32x (0.785398163397448309615660845819875721) /* pi/4 */
873 # define M_1_PIf32x __f32x (0.318309886183790671537767526745028724) /* 1/pi */
874 # define M_2_PIf32x __f32x (0.636619772367581343075535053490057448) /* 2/pi */
875 # define M_2_SQRTPIf32x __f32x (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
876 # define M_SQRT2f32x __f32x (1.414213562373095048801688724209698079) /* sqrt(2) */
877 # define M_SQRT1_2f32x __f32x (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
878 #endif
880 #if __HAVE_FLOAT64X && defined __USE_GNU
881 # define M_Ef64x __f64x (2.718281828459045235360287471352662498) /* e */
882 # define M_LOG2Ef64x __f64x (1.442695040888963407359924681001892137) /* log_2 e */
883 # define M_LOG10Ef64x __f64x (0.434294481903251827651128918916605082) /* log_10 e */
884 # define M_LN2f64x __f64x (0.693147180559945309417232121458176568) /* log_e 2 */
885 # define M_LN10f64x __f64x (2.302585092994045684017991454684364208) /* log_e 10 */
886 # define M_PIf64x __f64x (3.141592653589793238462643383279502884) /* pi */
887 # define M_PI_2f64x __f64x (1.570796326794896619231321691639751442) /* pi/2 */
888 # define M_PI_4f64x __f64x (0.785398163397448309615660845819875721) /* pi/4 */
889 # define M_1_PIf64x __f64x (0.318309886183790671537767526745028724) /* 1/pi */
890 # define M_2_PIf64x __f64x (0.636619772367581343075535053490057448) /* 2/pi */
891 # define M_2_SQRTPIf64x __f64x (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
892 # define M_SQRT2f64x __f64x (1.414213562373095048801688724209698079) /* sqrt(2) */
893 # define M_SQRT1_2f64x __f64x (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
894 #endif
896 #if __HAVE_FLOAT128X && defined __USE_GNU
897 # error "M_* values needed for _Float128x"
898 #endif
900 /* When compiling in strict ISO C compatible mode we must not use the
901 inline functions since they, among other things, do not set the
902 `errno' variable correctly. */
903 #if defined __STRICT_ANSI__ && !defined __NO_MATH_INLINES
904 # define __NO_MATH_INLINES 1
905 #endif
907 #ifdef __USE_ISOC99
908 # if __GNUC_PREREQ (3, 1)
909 /* ISO C99 defines some macros to compare number while taking care for
910 unordered numbers. Many FPUs provide special instructions to support
911 these operations. Generic support in GCC for these as builtins went
912 in 2.97, but not all cpus added their patterns until 3.1. Therefore
913 we enable the builtins from 3.1 onwards and use a generic implementation
914 othwerwise. */
915 # define isgreater(x, y) __builtin_isgreater(x, y)
916 # define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
917 # define isless(x, y) __builtin_isless(x, y)
918 # define islessequal(x, y) __builtin_islessequal(x, y)
919 # define islessgreater(x, y) __builtin_islessgreater(x, y)
920 # define isunordered(x, y) __builtin_isunordered(x, y)
921 # else
922 # define isgreater(x, y) \
923 (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
924 !isunordered (__x, __y) && __x > __y; }))
925 # define isgreaterequal(x, y) \
926 (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
927 !isunordered (__x, __y) && __x >= __y; }))
928 # define isless(x, y) \
929 (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
930 !isunordered (__x, __y) && __x < __y; }))
931 # define islessequal(x, y) \
932 (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
933 !isunordered (__x, __y) && __x <= __y; }))
934 # define islessgreater(x, y) \
935 (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
936 !isunordered (__x, __y) && __x != __y; }))
937 /* isunordered must always check both operands first for signaling NaNs. */
938 # define isunordered(x, y) \
939 (__extension__ ({ __typeof__ (x) __u = (x); __typeof__ (y) __v = (y); \
940 __u != __v && (__u != __u || __v != __v); }))
941 # endif
942 #endif
944 /* Get machine-dependent inline versions (if there are any). */
945 #ifdef __USE_EXTERN_INLINES
946 # include <bits/mathinline.h>
947 #endif
949 /* Define special entry points to use when the compiler got told to
950 only expect finite results. */
951 #if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
953 /* Include bits/math-finite.h for double. */
954 # define _Mdouble_ double
955 # define __MATH_DECLARING_DOUBLE 1
956 # define __MATH_DECLARING_FLOATN 0
957 # define __REDIRFROM_X(function, reentrant) \
958 function ## reentrant
959 # define __REDIRTO_X(function, reentrant) \
960 __ ## function ## reentrant ## _finite
961 # include <bits/math-finite.h>
962 # undef _Mdouble_
963 # undef __MATH_DECLARING_DOUBLE
964 # undef __MATH_DECLARING_FLOATN
965 # undef __REDIRFROM_X
966 # undef __REDIRTO_X
968 /* When __USE_ISOC99 is defined, include math-finite for float and
969 long double, as well. */
970 # ifdef __USE_ISOC99
972 /* Include bits/math-finite.h for float. */
973 # define _Mdouble_ float
974 # define __MATH_DECLARING_DOUBLE 0
975 # define __MATH_DECLARING_FLOATN 0
976 # define __REDIRFROM_X(function, reentrant) \
977 function ## f ## reentrant
978 # define __REDIRTO_X(function, reentrant) \
979 __ ## function ## f ## reentrant ## _finite
980 # include <bits/math-finite.h>
981 # undef _Mdouble_
982 # undef __MATH_DECLARING_DOUBLE
983 # undef __MATH_DECLARING_FLOATN
984 # undef __REDIRFROM_X
985 # undef __REDIRTO_X
987 /* Include bits/math-finite.h for long double. */
988 # ifdef __MATH_DECLARE_LDOUBLE
989 # define _Mdouble_ long double
990 # define __MATH_DECLARING_DOUBLE 0
991 # define __MATH_DECLARING_FLOATN 0
992 # define __REDIRFROM_X(function, reentrant) \
993 function ## l ## reentrant
994 # ifdef __NO_LONG_DOUBLE_MATH
995 # define __REDIRTO_X(function, reentrant) \
996 __ ## function ## reentrant ## _finite
997 # else
998 # define __REDIRTO_X(function, reentrant) \
999 __ ## function ## l ## reentrant ## _finite
1000 # endif
1001 # include <bits/math-finite.h>
1002 # undef _Mdouble_
1003 # undef __MATH_DECLARING_DOUBLE
1004 # undef __MATH_DECLARING_FLOATN
1005 # undef __REDIRFROM_X
1006 # undef __REDIRTO_X
1007 # endif
1009 # endif /* __USE_ISOC99. */
1011 /* Include bits/math-finite.h for _FloatN and _FloatNx. */
1013 # if (__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC)) \
1014 && __GLIBC_USE (IEC_60559_TYPES_EXT)
1015 # define _Mdouble_ _Float16
1016 # define __MATH_DECLARING_DOUBLE 0
1017 # define __MATH_DECLARING_FLOATN 1
1018 # define __REDIRFROM_X(function, reentrant) \
1019 function ## f16 ## reentrant
1020 # if __HAVE_DISTINCT_FLOAT16
1021 # define __REDIRTO_X(function, reentrant) \
1022 __ ## function ## f16 ## reentrant ## _finite
1023 # else
1024 # error "non-disinct _Float16"
1025 # endif
1026 # include <bits/math-finite.h>
1027 # undef _Mdouble_
1028 # undef __MATH_DECLARING_DOUBLE
1029 # undef __MATH_DECLARING_FLOATN
1030 # undef __REDIRFROM_X
1031 # undef __REDIRTO_X
1032 # endif
1034 # if (__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC)) \
1035 && __GLIBC_USE (IEC_60559_TYPES_EXT)
1036 # define _Mdouble_ _Float32
1037 # define __MATH_DECLARING_DOUBLE 0
1038 # define __MATH_DECLARING_FLOATN 1
1039 # define __REDIRFROM_X(function, reentrant) \
1040 function ## f32 ## reentrant
1041 # if __HAVE_DISTINCT_FLOAT32
1042 # define __REDIRTO_X(function, reentrant) \
1043 __ ## function ## f32 ## reentrant ## _finite
1044 # else
1045 # define __REDIRTO_X(function, reentrant) \
1046 __ ## function ## f ## reentrant ## _finite
1047 # endif
1048 # include <bits/math-finite.h>
1049 # undef _Mdouble_
1050 # undef __MATH_DECLARING_DOUBLE
1051 # undef __MATH_DECLARING_FLOATN
1052 # undef __REDIRFROM_X
1053 # undef __REDIRTO_X
1054 # endif
1056 # if (__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC)) \
1057 && __GLIBC_USE (IEC_60559_TYPES_EXT)
1058 # define _Mdouble_ _Float64
1059 # define __MATH_DECLARING_DOUBLE 0
1060 # define __MATH_DECLARING_FLOATN 1
1061 # define __REDIRFROM_X(function, reentrant) \
1062 function ## f64 ## reentrant
1063 # if __HAVE_DISTINCT_FLOAT64
1064 # define __REDIRTO_X(function, reentrant) \
1065 __ ## function ## f64 ## reentrant ## _finite
1066 # else
1067 # define __REDIRTO_X(function, reentrant) \
1068 __ ## function ## reentrant ## _finite
1069 # endif
1070 # include <bits/math-finite.h>
1071 # undef _Mdouble_
1072 # undef __MATH_DECLARING_DOUBLE
1073 # undef __MATH_DECLARING_FLOATN
1074 # undef __REDIRFROM_X
1075 # undef __REDIRTO_X
1076 # endif
1078 # if (__HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC)) \
1079 && __GLIBC_USE (IEC_60559_TYPES_EXT)
1080 # define _Mdouble_ _Float128
1081 # define __MATH_DECLARING_DOUBLE 0
1082 # define __MATH_DECLARING_FLOATN 1
1083 # define __REDIRFROM_X(function, reentrant) \
1084 function ## f128 ## reentrant
1085 # if __HAVE_DISTINCT_FLOAT128
1086 # define __REDIRTO_X(function, reentrant) \
1087 __ ## function ## f128 ## reentrant ## _finite
1088 # else
1089 # define __REDIRTO_X(function, reentrant) \
1090 __ ## function ## l ## reentrant ## _finite
1091 # endif
1092 # include <bits/math-finite.h>
1093 # undef _Mdouble_
1094 # undef __MATH_DECLARING_DOUBLE
1095 # undef __MATH_DECLARING_FLOATN
1096 # undef __REDIRFROM_X
1097 # undef __REDIRTO_X
1098 # endif
1100 # if (__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC)) \
1101 && __GLIBC_USE (IEC_60559_TYPES_EXT)
1102 # define _Mdouble_ _Float32x
1103 # define __MATH_DECLARING_DOUBLE 0
1104 # define __MATH_DECLARING_FLOATN 1
1105 # define __REDIRFROM_X(function, reentrant) \
1106 function ## f32x ## reentrant
1107 # if __HAVE_DISTINCT_FLOAT32X
1108 # define __REDIRTO_X(function, reentrant) \
1109 __ ## function ## f32x ## reentrant ## _finite
1110 # else
1111 # define __REDIRTO_X(function, reentrant) \
1112 __ ## function ## reentrant ## _finite
1113 # endif
1114 # include <bits/math-finite.h>
1115 # undef _Mdouble_
1116 # undef __MATH_DECLARING_DOUBLE
1117 # undef __MATH_DECLARING_FLOATN
1118 # undef __REDIRFROM_X
1119 # undef __REDIRTO_X
1120 # endif
1122 # if (__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC)) \
1123 && __GLIBC_USE (IEC_60559_TYPES_EXT)
1124 # define _Mdouble_ _Float64x
1125 # define __MATH_DECLARING_DOUBLE 0
1126 # define __MATH_DECLARING_FLOATN 1
1127 # define __REDIRFROM_X(function, reentrant) \
1128 function ## f64x ## reentrant
1129 # if __HAVE_DISTINCT_FLOAT64X
1130 # define __REDIRTO_X(function, reentrant) \
1131 __ ## function ## f64x ## reentrant ## _finite
1132 # elif __HAVE_FLOAT64X_LONG_DOUBLE
1133 # define __REDIRTO_X(function, reentrant) \
1134 __ ## function ## l ## reentrant ## _finite
1135 # else
1136 # define __REDIRTO_X(function, reentrant) \
1137 __ ## function ## f128 ## reentrant ## _finite
1138 # endif
1139 # include <bits/math-finite.h>
1140 # undef _Mdouble_
1141 # undef __MATH_DECLARING_DOUBLE
1142 # undef __MATH_DECLARING_FLOATN
1143 # undef __REDIRFROM_X
1144 # undef __REDIRTO_X
1145 # endif
1147 # if (__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)) \
1148 && __GLIBC_USE (IEC_60559_TYPES_EXT)
1149 # define _Mdouble_ _Float128x
1150 # define __MATH_DECLARING_DOUBLE 0
1151 # define __MATH_DECLARING_FLOATN 1
1152 # define __REDIRFROM_X(function, reentrant) \
1153 function ## f128x ## reentrant
1154 # if __HAVE_DISTINCT_FLOAT128X
1155 # define __REDIRTO_X(function, reentrant) \
1156 __ ## function ## f128x ## reentrant ## _finite
1157 # else
1158 # error "non-disinct _Float128x"
1159 # endif
1160 # include <bits/math-finite.h>
1161 # undef _Mdouble_
1162 # undef __MATH_DECLARING_DOUBLE
1163 # undef __MATH_DECLARING_FLOATN
1164 # undef __REDIRFROM_X
1165 # undef __REDIRTO_X
1166 # endif
1168 #endif /* __FINITE_MATH_ONLY__ > 0. */
1170 #if __GLIBC_USE (IEC_60559_BFP_EXT)
1171 /* An expression whose type has the widest of the evaluation formats
1172 of X and Y (which are of floating-point types). */
1173 # if __FLT_EVAL_METHOD__ == 2 || __FLT_EVAL_METHOD__ > 64
1174 # define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0L)
1175 # elif __FLT_EVAL_METHOD__ == 1 || __FLT_EVAL_METHOD__ > 32
1176 # define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0)
1177 # elif __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 32
1178 # define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0f)
1179 # else
1180 # define __MATH_EVAL_FMT2(x, y) ((x) + (y))
1181 # endif
1183 /* Return X == Y but raising "invalid" and setting errno if X or Y is
1184 a NaN. */
1185 # define iseqsig(x, y) \
1186 __MATH_TG (__MATH_EVAL_FMT2 (x, y), __iseqsig, ((x), (y)))
1187 #endif
1189 __END_DECLS
1192 #endif /* math.h */