1 diff --git a/fdlibm.h b/fdlibm.h
6 * from: @(#)fdlibm.h 5.1 93/09/24
13 -#include <sys/cdefs.h>
14 -#include <sys/_types.h>
15 -#include <machine/_limits.h>
20 -extern const union __infinity_un {
21 - unsigned char __uc[8];
25 -extern const union __nan_un {
26 - unsigned char __uc[sizeof(float)];
30 -#if __GNUC_PREREQ__(3, 3)
31 -#define __MATH_BUILTIN_CONSTANTS
34 -#if __GNUC_PREREQ__(3, 0)
35 -#define __MATH_BUILTIN_RELOPS
38 -#ifdef __MATH_BUILTIN_CONSTANTS
39 -#define HUGE_VAL __builtin_huge_val()
41 -#define HUGE_VAL (__infinity.__ud)
44 -#if __ISO_C_VISIBLE >= 1999
45 -#define FP_ILOGB0 (-__INT_MAX)
46 -#define FP_ILOGBNAN __INT_MAX
48 -#ifdef __MATH_BUILTIN_CONSTANTS
49 -#define HUGE_VALF __builtin_huge_valf()
50 -#define HUGE_VALL __builtin_huge_vall()
51 -#define INFINITY __builtin_inff()
52 -#define NAN __builtin_nanf("")
54 -#define HUGE_VALF (float)HUGE_VAL
55 -#define HUGE_VALL (long double)HUGE_VAL
56 -#define INFINITY HUGE_VALF
57 -#define NAN (__nan.__uf)
58 -#endif /* __MATH_BUILTIN_CONSTANTS */
61 -#define MATH_ERREXCEPT 2
62 -#define math_errhandling MATH_ERREXCEPT
64 -#define FP_FAST_FMAF 1
66 -/* Symbolic constants to classify floating point numbers. */
67 -#define FP_INFINITE 0x01
69 -#define FP_NORMAL 0x04
70 -#define FP_SUBNORMAL 0x08
73 -#if __STDC_VERSION__ >= 201112L || __has_extension(c_generic_selections)
74 -#define __fp_type_select(x, f, d, ld) __extension__ _Generic((x), \
78 -#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
79 -#define __fp_type_select(x, f, d, ld) __builtin_choose_expr( \
80 - __builtin_types_compatible_p(__typeof(x), long double), ld(x), \
81 - __builtin_choose_expr( \
82 - __builtin_types_compatible_p(__typeof(x), double), d(x), \
83 - __builtin_choose_expr( \
84 - __builtin_types_compatible_p(__typeof(x), float), f(x), (void)0)))
86 -#define __fp_type_select(x, f, d, ld) \
87 - ((sizeof(x) == sizeof(float)) ? f(x) \
88 - : (sizeof(x) == sizeof(double)) ? d(x) \
92 -#define fpclassify(x) \
93 - __fp_type_select(x, __fpclassifyf, __fpclassifyd, __fpclassifyl)
94 -#define isfinite(x) __fp_type_select(x, __isfinitef, __isfinite, __isfinitel)
95 -#define isinf(x) __fp_type_select(x, __isinff, __isinf, __isinfl)
97 - __fp_type_select(x, __inline_isnanf, __inline_isnan, __inline_isnanl)
98 -#define isnormal(x) __fp_type_select(x, __isnormalf, __isnormal, __isnormall)
100 -#ifdef __MATH_BUILTIN_RELOPS
101 -#define isgreater(x, y) __builtin_isgreater((x), (y))
102 -#define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y))
103 -#define isless(x, y) __builtin_isless((x), (y))
104 -#define islessequal(x, y) __builtin_islessequal((x), (y))
105 -#define islessgreater(x, y) __builtin_islessgreater((x), (y))
106 -#define isunordered(x, y) __builtin_isunordered((x), (y))
108 -#define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y))
109 -#define isgreaterequal(x, y) (!isunordered((x), (y)) && (x) >= (y))
110 -#define isless(x, y) (!isunordered((x), (y)) && (x) < (y))
111 -#define islessequal(x, y) (!isunordered((x), (y)) && (x) <= (y))
112 -#define islessgreater(x, y) (!isunordered((x), (y)) && \
113 - ((x) > (y) || (y) > (x)))
114 -#define isunordered(x, y) (isnan(x) || isnan(y))
115 -#endif /* __MATH_BUILTIN_RELOPS */
117 -#define signbit(x) __fp_type_select(x, __signbitf, __signbit, __signbitl)
119 -typedef __double_t double_t;
120 -typedef __float_t float_t;
121 -#endif /* __ISO_C_VISIBLE >= 1999 */
126 -#if __BSD_VISIBLE || __XSI_VISIBLE
127 -#define M_E 2.7182818284590452354 /* e */
128 -#define M_LOG2E 1.4426950408889634074 /* log 2e */
129 -#define M_LOG10E 0.43429448190325182765 /* log 10e */
130 -#define M_LN2 0.69314718055994530942 /* log e2 */
131 -#define M_LN10 2.30258509299404568402 /* log e10 */
132 -#define M_PI 3.14159265358979323846 /* pi */
133 #define M_PI_2 1.57079632679489661923 /* pi/2 */
134 -#define M_PI_4 0.78539816339744830962 /* pi/4 */
135 -#define M_1_PI 0.31830988618379067154 /* 1/pi */
136 -#define M_2_PI 0.63661977236758134308 /* 2/pi */
137 -#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
138 -#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
139 -#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
141 -#define MAXFLOAT ((float)3.40282346638528860e+38)
143 -#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
147 -/* Old value from 4.4BSD-Lite math.h; this is probably better. */
148 -#define HUGE HUGE_VAL
150 -#define HUGE MAXFLOAT
152 -#endif /* __BSD_VISIBLE */
155 - * Most of these functions depend on the rounding mode and have the side
156 - * effect of raising floating-point exceptions, so they are not declared
157 - * as __pure2. In C99, FENV_ACCESS affects the purity of these functions.
163 -int __fpclassifyd(double) __pure2;
164 -int __fpclassifyf(float) __pure2;
165 -int __fpclassifyl(long double) __pure2;
166 -int __isfinitef(float) __pure2;
167 -int __isfinite(double) __pure2;
168 -int __isfinitel(long double) __pure2;
169 -int __isinff(float) __pure2;
170 -int __isinf(double) __pure2;
171 -int __isinfl(long double) __pure2;
172 -int __isnormalf(float) __pure2;
173 -int __isnormal(double) __pure2;
174 -int __isnormall(long double) __pure2;
175 -int __signbit(double) __pure2;
176 -int __signbitf(float) __pure2;
177 -int __signbitl(long double) __pure2;
180 -__inline_isnan(__const double __x)
183 - return (__x != __x);
187 -__inline_isnanf(__const float __x)
190 - return (__x != __x);
194 -__inline_isnanl(__const long double __x)
197 - return (__x != __x);
201 - * Define the following aliases, for compatibility with glibc and CUDA.
203 -#define __isnan __inline_isnan
204 -#define __isnanf __inline_isnanf
207 - * Version 2 of the Single UNIX Specification (UNIX98) defined isnan() and
208 - * isinf() as functions taking double. C99, and the subsequent POSIX revisions
209 - * (SUSv3, POSIX.1-2001, define it as a macro that accepts any real floating
210 - * point type. If we are targeting SUSv2 and C99 or C11 (or C++11) then we
211 - * expose the newer definition, assuming that the language spec takes
212 - * precedence over the operating system interface spec.
214 -#if __XSI_VISIBLE > 0 && __XSI_VISIBLE < 600 && __ISO_C_VISIBLE < 1999
224 double atan2(double, double);
234 -double frexp(double, int *); /* fundamentally !__pure2 */
235 -double ldexp(double, int);
237 double log10(double);
238 -double modf(double, double *); /* fundamentally !__pure2 */
240 double pow(double, double);
241 -double sqrt(double);
244 -double fabs(double) __pure2;
245 +double fabs(double);
246 double floor(double);
247 -double fmod(double, double);
250 - * These functions are not in C90.
252 -#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE
253 double acosh(double);
254 double asinh(double);
255 double atanh(double);
258 -double erfc(double);
260 double expm1(double);
261 -double fma(double, double, double);
262 double hypot(double, double);
263 -int ilogb(double) __pure2;
264 -double lgamma(double);
265 -long long llrint(double);
266 -long long llround(double);
267 double log1p(double);
269 -double logb(double);
271 -long lround(double);
272 -double nan(const char *) __pure2;
273 -double nextafter(double, double);
274 -double remainder(double, double);
275 -double remquo(double, double, int *);
277 -#endif /* __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE */
279 -#if __BSD_VISIBLE || __XSI_VISIBLE
282 -double jn(int, double);
285 -double yn(int, double);
287 -#if __XSI_VISIBLE <= 500 || __BSD_VISIBLE
288 -double gamma(double);
291 -#if __XSI_VISIBLE <= 600 || __BSD_VISIBLE
292 -double scalb(double, double);
294 -#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
296 -#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999
297 -double copysign(double, double) __pure2;
298 -double fdim(double, double);
299 -double fmax(double, double) __pure2;
300 -double fmin(double, double) __pure2;
301 +double copysign(double, double);
302 double nearbyint(double);
303 -double round(double);
304 -double scalbln(double, long);
305 double scalbn(double, int);
306 -double tgamma(double);
307 double trunc(double);
311 - * BSD math library entry points
314 -double drem(double, double);
315 -int finite(double) __pure2;
316 -int isnanf(float) __pure2;
319 - * Reentrant version of gamma & lgamma; passes signgam back by reference
320 - * as the second argument; user must allocate space for signgam.
322 -double gamma_r(double, int *);
323 -double lgamma_r(double, int *);
328 -double significand(double);
329 -#endif /* __BSD_VISIBLE */
331 -/* float versions of ANSI/POSIX functions */
332 -#if __ISO_C_VISIBLE >= 1999
336 -float atan2f(float, float);
347 -float expm1f(float);
348 -float frexpf(float, int *); /* fundamentally !__pure2 */
349 -int ilogbf(float) __pure2;
350 -float ldexpf(float, int);
352 -float log1pf(float);
355 -float modff(float, float *); /* fundamentally !__pure2 */
357 float powf(float, float);
361 -float fabsf(float) __pure2;
364 -float fmodf(float, float);
365 -float roundf(float);
369 float hypotf(float, float);
370 -float lgammaf(float);
371 -float tgammaf(float);
373 -float acoshf(float);
374 -float asinhf(float);
375 -float atanhf(float);
378 -float copysignf(float, float) __pure2;
379 -long long llrintf(float);
380 -long long llroundf(float);
382 -long lroundf(float);
383 -float nanf(const char *) __pure2;
384 float nearbyintf(float);
385 -float nextafterf(float, float);
386 -float remainderf(float, float);
387 -float remquof(float, float, int *);
389 -float scalblnf(float, long);
390 float scalbnf(float, int);
393 -float fdimf(float, float);
394 -float fmaf(float, float, float);
395 -float fmaxf(float, float) __pure2;
396 -float fminf(float, float) __pure2;
400 - * float versions of BSD math library entry points
403 -float dremf(float, float);
404 -int finitef(float) __pure2;
405 -float gammaf(float);
408 -float jnf(int, float);
409 -float scalbf(float, float);
412 -float ynf(int, float);
415 - * Float versions of reentrant version of gamma & lgamma; passes
416 - * signgam back by reference as the second argument; user must
417 - * allocate space for signgam.
419 -float gammaf_r(float, int *);
420 -float lgammaf_r(float, int *);
423 - * float version of IEEE Test Vector
425 -float significandf(float);
426 -#endif /* __BSD_VISIBLE */
429 - * long double versions of ISO/POSIX math functions
431 -#if __ISO_C_VISIBLE >= 1999
432 -long double acoshl(long double);
433 -long double acosl(long double);
434 -long double asinhl(long double);
435 -long double asinl(long double);
436 -long double atan2l(long double, long double);
437 -long double atanhl(long double);
438 -long double atanl(long double);
439 -long double cbrtl(long double);
440 -long double ceill(long double);
441 -long double copysignl(long double, long double) __pure2;
442 -long double coshl(long double);
443 -long double cosl(long double);
444 -long double erfcl(long double);
445 -long double erfl(long double);
446 -long double exp2l(long double);
447 -long double expl(long double);
448 -long double expm1l(long double);
449 -long double fabsl(long double) __pure2;
450 -long double fdiml(long double, long double);
451 -long double floorl(long double);
452 -long double fmal(long double, long double, long double);
453 -long double fmaxl(long double, long double) __pure2;
454 -long double fminl(long double, long double) __pure2;
455 -long double fmodl(long double, long double);
456 -long double frexpl(long double, int *); /* fundamentally !__pure2 */
457 -long double hypotl(long double, long double);
458 -int ilogbl(long double) __pure2;
459 -long double ldexpl(long double, int);
460 -long double lgammal(long double);
461 -long long llrintl(long double);
462 -long long llroundl(long double);
463 -long double log10l(long double);
464 -long double log1pl(long double);
465 -long double log2l(long double);
466 -long double logbl(long double);
467 -long double logl(long double);
468 -long lrintl(long double);
469 -long lroundl(long double);
470 -long double modfl(long double, long double *); /* fundamentally !__pure2 */
471 -long double nanl(const char *) __pure2;
472 -long double nearbyintl(long double);
473 -long double nextafterl(long double, long double);
474 -double nexttoward(double, long double);
475 -float nexttowardf(float, long double);
476 -long double nexttowardl(long double, long double);
477 -long double powl(long double, long double);
478 -long double remainderl(long double, long double);
479 -long double remquol(long double, long double, int *);
480 -long double rintl(long double);
481 -long double roundl(long double);
482 -long double scalblnl(long double, long);
483 -long double scalbnl(long double, int);
484 -long double sinhl(long double);
485 -long double sinl(long double);
486 -long double sqrtl(long double);
487 -long double tanhl(long double);
488 -long double tanl(long double);
489 -long double tgammal(long double);
490 -long double truncl(long double);
491 -#endif /* __ISO_C_VISIBLE >= 1999 */
494 -long double lgammal_r(long double, int *);
495 -void sincos(double, double *, double *);
496 -void sincosf(float, float *, float *);
497 -void sincosl(long double, long double *, long double *);
498 -double cospi(double);
499 -float cospif(float);
500 -long double cospil(long double);
501 -double sinpi(double);
502 -float sinpif(float);
503 -long double sinpil(long double);
504 -double tanpi(double);
505 -float tanpif(float);
506 -long double tanpil(long double);
511 #endif /* !_MATH_H_ */