1 /* 2 Copyright (c) 1991, 1993 3 The Regents of the University of California. All rights reserved. 4 c) UNIX System Laboratories, Inc. 5 All or some portions of this file are derived from material licensed 6 to the University of California by American Telephone and Telegraph 7 Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 the permission of UNIX System Laboratories, Inc. 9 10 Redistribution and use in source and binary forms, with or without 11 modification, are permitted provided that the following conditions 12 are met: 13 1. Redistributions of source code must retain the above copyright 14 notice, this list of conditions and the following disclaimer. 15 2. Redistributions in binary form must reproduce the above copyright 16 notice, this list of conditions and the following disclaimer in the 17 documentation and/or other materials provided with the distribution. 18 3. Neither the name of the University nor the names of its contributors 19 may be used to endorse or promote products derived from this software 20 without specific prior written permission. 21 22 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 SUCH DAMAGE. 33 */ 34 35 #ifndef _MATH_H_ 36 #define _MATH_H_ 37 38 #include <sys/cdefs.h> 39 40 _BEGIN_STD_C 41 42 /* Natural log of 2 */ 43 #define _M_LN2 0.693147180559945309417 44 #define _M_LN2_LD 0.693147180559945309417232121458176568l 45 46 #if __GNUC_PREREQ (3, 3) || defined(__clang__) || defined(__COMPCERT__) 47 /* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */ 48 49 # ifndef HUGE_VAL 50 # define HUGE_VAL (__builtin_huge_val()) 51 # endif 52 53 # ifndef HUGE_VALF 54 # define HUGE_VALF (__builtin_huge_valf()) 55 # endif 56 57 # ifndef HUGE_VALL 58 # define HUGE_VALL (__builtin_huge_vall()) 59 # endif 60 61 # ifndef INFINITY 62 # define INFINITY (__builtin_inff()) 63 # endif 64 65 # ifndef NAN 66 # define NAN (__builtin_nanf("")) 67 # endif 68 69 #else /* !gcc >= 3.3 */ 70 71 /* No builtins. Use fixed defines instead. (All 3 HUGE plus the INFINITY 72 * and NAN macros are required to be constant expressions. Using a variable-- 73 * even a static const--does not meet this requirement, as it cannot be 74 * evaluated at translation time.) 75 * The infinities are done using numbers that are far in excess of 76 * something that would be expected to be encountered in a floating-point 77 * implementation. (A more certain way uses values from float.h, but that is 78 * avoided because system includes are not supposed to include each other.) 79 * This method might produce warnings from some compilers. (It does in 80 * newer GCCs, but not for ones that would hit this #else.) If this happens, 81 * please report details to the Newlib mailing list. */ 82 83 #ifndef HUGE_VAL 84 #define HUGE_VAL (1.0e999999999) 85 #endif 86 87 #ifndef HUGE_VALF 88 #define HUGE_VALF (1.0e999999999F) 89 #endif 90 91 #if !defined(HUGE_VALL) && defined(_HAVE_LONG_DOUBLE) 92 #define HUGE_VALL (1.0e999999999L) 93 #endif 94 95 #if !defined(INFINITY) 96 #define INFINITY (HUGE_VALF) 97 #endif 98 99 #if !defined(NAN) 100 #if defined(__GNUC__) && defined(__cplusplus) 101 /* Exception: older g++ versions warn about the divide by 0 used in the 102 * normal case (even though older gccs do not). This trick suppresses the 103 * warning, but causes errors for plain gcc, so is only used in the one 104 * special case. */ 105 static const union { __ULong __i[1]; float __d; } __Nanf = {0x7FC00000}; 106 #define NAN (__Nanf.__d) 107 #else 108 #define NAN (0.0F/0.0F) 109 #endif 110 #endif 111 112 #endif /* !gcc >= 3.3 */ 113 114 extern double atan (double); 115 extern double cos (double); 116 extern double sin (double); 117 extern double tan (double); 118 extern double tanh (double); 119 extern double frexp (double, int *); 120 extern double modf (double, double *); 121 extern double ceil (double); 122 extern double fabs (double); 123 extern double floor (double); 124 125 extern double acos (double); 126 extern double asin (double); 127 extern double atan2 (double, double); 128 extern double cosh (double); 129 extern double sinh (double); 130 extern double exp (double); 131 extern double ldexp (double, int); 132 extern double log (double); 133 extern double log10 (double); 134 extern double pow (double, double); 135 extern double sqrt (double); 136 extern double fmod (double, double); 137 138 #if __MISC_VISIBLE 139 extern int finite (double); 140 extern int finitef (float); 141 extern int isinff (float); 142 extern int isnanf (float); 143 #if defined(_HAVE_LONG_DOUBLE) 144 extern int finitel (long double); 145 extern int isinfl (long double); 146 extern int isnanl (long double); 147 #endif 148 #if !defined(__cplusplus) || __cplusplus < 201103L 149 extern int isinf (double); 150 #endif 151 #endif /* __MISC_VISIBLE */ 152 #if (__MISC_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 600)) \ 153 && (!defined(__cplusplus) || __cplusplus < 201103L) 154 extern int isnan (double); 155 #endif 156 157 #if __ISO_C_VISIBLE >= 1999 158 /* ISO C99 types and macros. */ 159 160 /* FIXME: FLT_EVAL_METHOD should somehow be gotten from float.h (which is hard, 161 * considering that the standard says the includes it defines should not 162 * include other includes that it defines) and that value used. (This can be 163 * solved, but autoconf has a bug which makes the solution more difficult, so 164 * it has been skipped for now.) */ 165 #if !defined(FLT_EVAL_METHOD) && defined(__FLT_EVAL_METHOD__) 166 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ 167 #define __TMP_FLT_EVAL_METHOD 168 #endif /* FLT_EVAL_METHOD */ 169 #if defined FLT_EVAL_METHOD 170 /* FLT_EVAL_METHOD == 16 has meaning as defined in ISO/IEC TS 18661-3, 171 * which provides non-compliant extensions to C and POSIX (by adding 172 * additional positive values for FLT_EVAL_METHOD). It effectively has 173 * same meaning as the C99 and C11 definitions for value 0, while also 174 * serving as a flag that the _Float16 (float16_t) type exists. 175 * 176 * FLT_EVAL_METHOD could be any number of bits of supported floating point 177 * format (e.g. 32, 64, 128), but currently only AArch64 and few other targets 178 * might define that as 16. */ 179 #if (FLT_EVAL_METHOD == 0) \ 180 || (FLT_EVAL_METHOD == 16) 181 typedef float float_t; 182 typedef double double_t; 183 #elif FLT_EVAL_METHOD == 1 184 typedef double float_t; 185 typedef double double_t; 186 #elif FLT_EVAL_METHOD == 2 187 typedef long double float_t; 188 typedef long double double_t; 189 #else 190 /* Implementation-defined. Assume float_t and double_t have been 191 * defined previously for this configuration (e.g. config.h). */ 192 193 /* If __DOUBLE_TYPE is defined (__FLOAT_TYPE is then supposed to be 194 defined as well) float_t and double_t definition is suggested by 195 an arch specific header. */ 196 #ifdef __DOUBLE_TYPE 197 typedef __DOUBLE_TYPE double_t; 198 typedef __FLOAT_TYPE float_t; 199 #endif 200 /* Assume config.h has provided these types. */ 201 #endif 202 #else 203 /* Assume basic definitions. */ 204 typedef float float_t; 205 typedef double double_t; 206 #endif 207 #if defined(__TMP_FLT_EVAL_METHOD) 208 #undef FLT_EVAL_METHOD 209 #endif 210 211 #define FP_NAN 0 212 #define FP_INFINITE 1 213 #define FP_ZERO 2 214 #define FP_SUBNORMAL 3 215 #define FP_NORMAL 4 216 217 #ifndef FP_ILOGB0 218 # define FP_ILOGB0 (-__INT_MAX__) 219 #endif 220 #ifndef FP_ILOGBNAN 221 # define FP_ILOGBNAN __INT_MAX__ 222 #endif 223 224 #if !defined(FP_FAST_FMA) && (_HAVE_FAST_FMA || defined(__FP_FAST_FMA)) 225 #define FP_FAST_FMA 226 #endif 227 228 #if !defined(FP_FAST_FMAF) && (_HAVE_FAST_FMAF || defined(__FP_FAST_FMAF)) 229 #define FP_FAST_FMAF 230 #endif 231 232 #if !defined(FP_FAST_FMAL) && (_HAVE_FAST_FMAL || defined(__FP_FAST_FMAL)) 233 #define FP_FAST_FMAL 234 #endif 235 236 #ifndef MATH_ERRNO 237 # define MATH_ERRNO 1 238 #endif 239 #ifndef MATH_ERREXCEPT 240 # define MATH_ERREXCEPT 2 241 #endif 242 #ifndef math_errhandling 243 # ifdef _IEEE_LIBM 244 # define _MATH_ERRHANDLING_ERRNO 0 245 # else 246 # define _MATH_ERRHANDLING_ERRNO MATH_ERRNO 247 # endif 248 # ifdef _SUPPORTS_ERREXCEPT 249 # define _MATH_ERRHANDLING_ERREXCEPT MATH_ERREXCEPT 250 # else 251 # define _MATH_ERRHANDLING_ERREXCEPT 0 252 # endif 253 # define math_errhandling (_MATH_ERRHANDLING_ERRNO | _MATH_ERRHANDLING_ERREXCEPT) 254 #endif 255 256 /* 257 * Specifies whether the target uses the snan/nan discriminator 258 * definition from IEEE 754 2008 (top bit of significand is 1 for qNaN 259 * and 0 for sNaN). This is set to zero in machine/math.h for targets 260 * that don't do this (such as MIPS). 261 */ 262 #ifndef _IEEE_754_2008_SNAN 263 # define _IEEE_754_2008_SNAN 1 264 #endif 265 266 extern int __isinff (float); 267 extern int __isinfd (double); 268 extern int __isnanf (float); 269 extern int __isnand (double); 270 extern int __fpclassifyf (float); 271 extern int __fpclassifyd (double); 272 extern int __signbitf (float); 273 extern int __signbitd (double); 274 extern int __finite (double); 275 extern int __finitef (float); 276 #if defined(_HAVE_LONG_DOUBLE) 277 extern int __fpclassifyl (long double); 278 extern int __isinfl (long double); 279 extern int __isnanl (long double); 280 extern int __finitel (long double); 281 extern int __signbitl (long double); 282 #endif 283 284 /* Note: isinf and isnan were once functions in newlib that took double 285 * arguments. C99 specifies that these names are reserved for macros 286 * supporting multiple floating point types. Thus, they are 287 * now defined as macros. Implementations of the old functions 288 * taking double arguments still exist for compatibility purposes 289 * (prototypes for them are earlier in this header). */ 290 291 /* 292 * GCC bug 66462 raises INVALID exception when __builtin_fpclassify is 293 * passed snan, so we cannot use it when building with snan support. 294 * clang doesn't appear to have an option to control snan behavior, and 295 * it's builtin fpclassify also raises INVALID for snan, so always use 296 * our version for that. 297 */ 298 #if __GNUC_PREREQ (4, 4) && !defined(__SUPPORT_SNAN__) && !defined(__clang__) 299 #define fpclassify(__x) (__builtin_fpclassify (FP_NAN, FP_INFINITE, \ 300 FP_NORMAL, FP_SUBNORMAL, \ 301 FP_ZERO, __x)) 302 #define isfinite(__x) (__builtin_isfinite (__x)) 303 #define isinf(__x) (__builtin_isinf_sign (__x)) 304 #define isnan(__x) (__builtin_isnan (__x)) 305 #define isnormal(__x) (__builtin_isnormal (__x)) 306 #define issubnormal(__x) (__builtin_issubnormal (__x)) 307 #define iszero(__x) (__builtin_iszero(__x)) 308 #else 309 #if defined(_HAVE_LONG_DOUBLE) 310 #define fpclassify(__x) \ 311 ((sizeof(__x) == sizeof(float) ? __fpclassifyf(__x) \ 312 : (sizeof(__x) == sizeof(double)) ? __fpclassifyd((double) (__x)) \ 313 : __fpclassifyl((long double) (__x)))) 314 #define isfinite(__x) \ 315 ((sizeof(__x) == sizeof(float)) ? __finitef(__x) \ 316 : (sizeof(__x) == sizeof(double)) ? __finite((double) (__x)) \ 317 : __finitel((long double) (__x))) 318 #else 319 #define fpclassify(__x) \ 320 ((sizeof(__x) == sizeof(float)) ? __fpclassifyf(__x) : \ 321 __fpclassifyd((double) (__x))) 322 #define isfinite(__x) ((sizeof(__x) == sizeof(float)) ? \ 323 __finitef(__x) : __finite((double) __x)) 324 #endif 325 #define isinf(__x) (fpclassify(__x) == FP_INFINITE) 326 #define isnan(__x) (fpclassify(__x) == FP_NAN) 327 #define isnormal(__x) (fpclassify(__x) == FP_NORMAL) 328 #define issubnormal(__x) (fpclassify(__x) == FP_SUBNORMAL) 329 #define iszero(__x) (fpclassify(__x) == FP_ZERO) 330 #endif 331 332 #define isfinitef(x) isfinite((float) (x)) 333 #define isinff(x) isinf((float) (x)) 334 #define isnanf(x) isnan((float) (x)) 335 #define isnormalf(x) isnormal((float) (x)) 336 #define iszerof(x) iszero((float) (x)) 337 338 #ifndef iseqsig 339 int __iseqsigd(double x, double y); 340 int __iseqsigf(float x, float y); 341 342 #ifdef _HAVE_LONG_DOUBLE 343 int __iseqsigl(long double x, long double y); 344 #define iseqsig(__x,__y) \ 345 ((sizeof(__x) == sizeof(float) && sizeof(__y) == sizeof(float)) ? \ 346 __iseqsigf(__x, __y) : \ 347 (sizeof(__x) == sizeof(double) && sizeof(__y) == sizeof(double)) ? \ 348 __iseqsigd(__x, __y) : \ 349 __iseqsigl(__x, __y)) 350 #else 351 #ifdef _DOUBLE_IS_32BITS 352 #define iseqsig(__x, __y) __iseqsigf((float)(__x), (float)(__y)) 353 #else 354 #define iseqsig(__x,__y) \ 355 ((sizeof(__x) == sizeof(float) && sizeof(__y) == sizeof(float)) ? \ 356 __iseqsigf(__x, __y) : __iseqsigd(__x, __y)) 357 #endif 358 #endif 359 #endif 360 361 #ifndef issignaling 362 int __issignalingf(float f); 363 int __issignaling(double d); 364 365 #if defined(_HAVE_LONG_DOUBLE) 366 int __issignalingl(long double d); 367 #define issignaling(__x) \ 368 ((sizeof(__x) == sizeof(float)) ? __issignalingf(__x) : \ 369 (sizeof(__x) == sizeof(double)) ? __issignaling ((double) (__x)) : \ 370 __issignalingl((long double) (__x))) 371 #else 372 #ifdef _DOUBLE_IS_32BITS 373 #define issignaling(__x) __issignalingf((float) (__x)) 374 #else 375 #define issignaling(__x) \ 376 ((sizeof(__x) == sizeof(float)) ? __issignalingf(__x) : \ 377 __issignaling ((double) (__x))) 378 #endif /* _DOUBLE_IS_32BITS */ 379 #endif /* _HAVE_LONG_DOUBLE */ 380 #endif 381 382 #if __GNUC_PREREQ (4, 0) 383 #if defined(_HAVE_LONG_DOUBLE) 384 #define signbit(__x) \ 385 ((sizeof(__x) == sizeof(float)) ? __builtin_signbitf(__x) : \ 386 ((sizeof(__x) == sizeof(double)) ? __builtin_signbit ((double)(__x)) : \ 387 __builtin_signbitl((long double)(__x)))) 388 #else 389 #define signbit(__x) \ 390 ((sizeof(__x) == sizeof(float)) ? __builtin_signbitf(__x) : \ 391 __builtin_signbit ((double) (__x))) 392 #endif 393 #else 394 #if defined(_HAVE_LONG_DOUBLE) 395 #define signbit(__x) \ 396 ((sizeof(__x) == sizeof(float)) ? __signbitf(__x) : \ 397 ((sizeof(__x) == sizeof(double)) ? __signbit ((double)(__x)) : \ 398 __signbitl((long double)(__x)))) 399 #else 400 #define signbit(__x) \ 401 ((sizeof(__x) == sizeof(float)) ? __signbitf(__x) : \ 402 __signbitd((double) (__x))) 403 #endif 404 #endif 405 406 #if __GNUC_PREREQ (2, 97) && !(defined(__riscv) && defined(__clang__)) 407 #define isgreater(__x,__y) (__builtin_isgreater (__x, __y)) 408 #define isgreaterequal(__x,__y) (__builtin_isgreaterequal (__x, __y)) 409 #define isless(__x,__y) (__builtin_isless (__x, __y)) 410 #define islessequal(__x,__y) (__builtin_islessequal (__x, __y)) 411 #define islessgreater(__x,__y) (__builtin_islessgreater (__x, __y)) 412 #define isunordered(__x,__y) (__builtin_isunordered (__x, __y)) 413 #else 414 #define isgreater(x,y) \ 415 (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ 416 !isunordered(__x,__y) && (__x > __y);})) 417 #define isgreaterequal(x,y) \ 418 (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ 419 !isunordered(__x,__y) && (__x >= __y);})) 420 #define isless(x,y) \ 421 (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ 422 !isunordered(__x,__y) && (__x < __y);})) 423 #define islessequal(x,y) \ 424 (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ 425 !isunordered(__x,__y) && (__x <= __y);})) 426 #define islessgreater(x,y) \ 427 (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ 428 !isunordered(__x,__y) && (__x < __y || __x > __y);})) 429 430 #define isunordered(a,b) \ 431 (__extension__ ({__typeof__(a) __a = (a); __typeof__(b) __b = (b); \ 432 fpclassify(__a) == FP_NAN || fpclassify(__b) == FP_NAN;})) 433 #endif 434 435 /* Non ANSI double precision functions. */ 436 437 extern double infinity (void); 438 extern double nan (const char *); 439 extern double copysign (double, double); 440 extern double logb (double); 441 extern int ilogb (double); 442 443 extern double asinh (double); 444 extern double cbrt (double); 445 extern double nextafter (double, double); 446 extern double rint (double); 447 extern double scalbn (double, int); 448 extern double scalb (double, double); 449 extern double getpayload(const double *x); 450 extern double significand (double); 451 452 extern double exp2 (double); 453 extern double scalbln (double, long int); 454 extern double tgamma (double); 455 extern double nearbyint (double); 456 extern long int lrint (double); 457 extern long long int llrint (double); 458 extern double round (double); 459 extern long int lround (double); 460 extern long long int llround (double); 461 extern double trunc (double); 462 extern double remquo (double, double, int *); 463 extern double fdim (double, double); 464 extern double fmax (double, double); 465 extern double fmin (double, double); 466 extern double fma (double, double, double); 467 468 extern double log1p (double); 469 extern double expm1 (double); 470 471 extern double acosh (double); 472 extern double atanh (double); 473 extern double remainder (double, double); 474 extern double gamma (double); 475 extern double lgamma (double); 476 extern double erf (double); 477 extern double erfc (double); 478 extern double log2 (double); 479 #if !defined(__cplusplus) 480 #define log2(x) (log (x) / _M_LN2) 481 #endif 482 483 extern double hypot (double, double); 484 485 /* Single precision versions of ANSI functions. */ 486 487 extern float atanf (float); 488 extern float cosf (float); 489 extern float sinf (float); 490 extern float tanf (float); 491 extern float tanhf (float); 492 extern float frexpf (float, int *); 493 extern float modff (float, float *); 494 extern float ceilf (float); 495 extern float fabsf (float); 496 extern float floorf (float); 497 498 extern float acosf (float); 499 extern float asinf (float); 500 extern float atan2f (float, float); 501 extern float coshf (float); 502 extern float sinhf (float); 503 extern float expf (float); 504 extern float ldexpf (float, int); 505 extern float logf (float); 506 extern float log10f (float); 507 extern float powf (float, float); 508 extern float sqrtf (float); 509 extern float fmodf (float, float); 510 511 /* Other single precision functions. */ 512 513 extern float exp2f (float); 514 extern float scalblnf (float, long int); 515 extern float tgammaf (float); 516 extern float nearbyintf (float); 517 extern long int lrintf (float); 518 extern long long int llrintf (float); 519 extern float roundf (float); 520 extern long int lroundf (float); 521 extern long long int llroundf (float); 522 extern float truncf (float); 523 extern float remquof (float, float, int *); 524 extern float fdimf (float, float); 525 extern float fmaxf (float, float); 526 extern float fminf (float, float); 527 extern float fmaf (float, float, float); 528 529 extern float infinityf (void); 530 extern float nanf (const char *); 531 extern float copysignf (float, float); 532 extern float logbf (float); 533 extern int ilogbf (float); 534 535 extern float asinhf (float); 536 extern float cbrtf (float); 537 extern float nextafterf (float, float); 538 extern float rintf (float); 539 extern float scalbnf (float, int); 540 extern float scalbf (float, float); 541 extern float log1pf (float); 542 extern float expm1f (float); 543 extern float getpayloadf(const float *x); 544 extern float significandf (float); 545 546 extern float acoshf (float); 547 extern float atanhf (float); 548 extern float remainderf (float, float); 549 extern float gammaf (float); 550 extern float lgammaf (float); 551 extern float erff (float); 552 extern float erfcf (float); 553 extern float log2f (float); 554 extern float hypotf (float, float); 555 556 #ifdef _HAVE_LONG_DOUBLE 557 558 /* These functions are always available for long double */ 559 560 extern long double hypotl (long double, long double); 561 extern long double infinityl (void); 562 extern long double sqrtl (long double); 563 extern long double frexpl (long double, int *); 564 extern long double scalbnl (long double, int); 565 extern long double scalblnl (long double, long); 566 extern long double rintl (long double); 567 extern long int lrintl (long double); 568 extern long long int llrintl (long double); 569 extern int ilogbl (long double); 570 extern long double logbl (long double); 571 extern long double ldexpl (long double, int); 572 extern long double nearbyintl (long double); 573 extern long double ceill (long double); 574 extern long double fmaxl (long double, long double); 575 extern long double fminl (long double, long double); 576 extern long double roundl (long double); 577 extern long lroundl (long double); 578 extern long long int llroundl (long double); 579 extern long double truncl (long double); 580 extern long double nanl (const char *); 581 extern long double floorl (long double); 582 extern long double scalbl (long double, long double); 583 extern long double significandl(long double); 584 /* Compiler provides these */ 585 extern long double fabsl (long double); 586 extern long double copysignl (long double, long double); 587 588 #ifdef _HAVE_LONG_DOUBLE_MATH 589 extern long double atanl (long double); 590 extern long double cosl (long double); 591 extern long double sinl (long double); 592 extern long double tanl (long double); 593 extern long double tanhl (long double); 594 extern long double modfl (long double, long double *); 595 extern long double log1pl (long double); 596 extern long double expm1l (long double); 597 extern long double acosl (long double); 598 extern long double asinl (long double); 599 extern long double atan2l (long double, long double); 600 extern long double coshl (long double); 601 extern long double sinhl (long double); 602 extern long double expl (long double); 603 extern long double logl (long double); 604 extern long double log10l (long double); 605 extern long double powl (long double, long double); 606 extern long double fmodl (long double, long double); 607 extern long double asinhl (long double); 608 extern long double cbrtl (long double); 609 extern long double nextafterl (long double, long double); 610 extern float nexttowardf (float, long double); 611 extern double nexttoward (double, long double); 612 extern long double nexttowardl (long double, long double); 613 extern long double log2l (long double); 614 extern long double exp2l (long double); 615 extern long double tgammal (long double); 616 extern long double remquol (long double, long double, int *); 617 extern long double fdiml (long double, long double); 618 extern long double fmal (long double, long double, long double); 619 extern long double acoshl (long double); 620 extern long double atanhl (long double); 621 extern long double remainderl (long double, long double); 622 extern long double lgammal (long double); 623 extern long double gammal (long double); 624 extern long double erfl (long double); 625 extern long double erfcl (long double); 626 extern long double j0l(long double); 627 extern long double y0l(long double); 628 extern long double j1l(long double); 629 extern long double y1l(long double); 630 extern long double jnl(int, long double); 631 extern long double ynl(int, long double); 632 633 extern long double getpayloadl(const long double *x); 634 635 #endif /* _HAVE_LONG_DOUBLE_MATH */ 636 637 #endif /* _HAVE_LONG_DOUBLE */ 638 639 #endif /* __ISO_C_VISIBLE >= 1999 */ 640 641 #if __MISC_VISIBLE 642 extern double drem (double, double); 643 extern float dremf (float, float); 644 #ifdef _HAVE_LONG_DOUBLE_MATH 645 extern long double dreml (long double, long double); 646 extern long double lgammal_r (long double, int *); 647 #endif 648 extern double lgamma_r (double, int *); 649 extern float lgammaf_r (float, int *); 650 #endif 651 652 #if __MISC_VISIBLE || __XSI_VISIBLE 653 extern double y0 (double); 654 extern double y1 (double); 655 extern double yn (int, double); 656 extern double j0 (double); 657 extern double j1 (double); 658 extern double jn (int, double); 659 #endif 660 661 #if __MISC_VISIBLE || __XSI_VISIBLE >= 600 662 extern float y0f (float); 663 extern float y1f (float); 664 extern float ynf (int, float); 665 extern float j0f (float); 666 extern float j1f (float); 667 extern float jnf (int, float); 668 #endif 669 670 /* GNU extensions */ 671 #if __GNU_VISIBLE 672 extern void sincos (double, double *, double *); 673 extern void sincosf (float, float *, float *); 674 #ifdef _HAVE_LONG_DOUBLE_MATH 675 extern void sincosl (long double, long double *, long double *); 676 #endif 677 extern double exp10 (double); 678 extern double pow10 (double); 679 extern float exp10f (float); 680 extern float pow10f (float); 681 #ifdef _HAVE_LONG_DOUBLE_MATH 682 extern long double exp10l (long double); 683 extern long double pow10l (long double); 684 #endif 685 #endif /* __GNU_VISIBLE */ 686 687 #if __MISC_VISIBLE || __XSI_VISIBLE 688 extern int signgam; 689 #endif /* __MISC_VISIBLE || __XSI_VISIBLE */ 690 691 /* Useful constants. */ 692 693 #if __BSD_VISIBLE || __XSI_VISIBLE 694 695 #define MAXFLOAT 3.40282347e+38F 696 697 #define M_E 2.7182818284590452354 698 #define _M_E_L 2.718281828459045235360287471352662498L 699 #define M_LOG2E 1.4426950408889634074 700 #define M_LOG10E 0.43429448190325182765 701 #define M_LN2 _M_LN2 702 #define M_LN10 2.30258509299404568402 703 #define M_PI 3.14159265358979323846 704 #define _M_PI_L 3.141592653589793238462643383279502884L 705 #define M_PI_2 1.57079632679489661923 706 #define _M_PI_2 1.57079632679489661923 707 #define _M_PI_2L 1.570796326794896619231321691639751442L 708 #define M_PI_4 0.78539816339744830962 709 #define _M_PI_4L 0.785398163397448309615660845819875721L 710 #define M_1_PI 0.31830988618379067154 711 #define M_2_PI 0.63661977236758134308 712 #define M_2_SQRTPI 1.12837916709551257390 713 #define M_SQRT2 1.41421356237309504880 714 #define M_SQRT1_2 0.70710678118654752440 715 716 #ifdef __GNU_VISIBLE 717 #define M_PIl _M_PI_L 718 #define M_PI_2l _M_PI_2L 719 #define M_PI_4l _M_PI_4L 720 #define M_El _M_E_L 721 #endif 722 723 #endif 724 725 #if __BSD_VISIBLE 726 727 #define M_TWOPI (M_PI * 2.0) 728 #define M_3PI_4 2.3561944901923448370E0 729 #define M_SQRTPI 1.77245385090551602792981 730 #define M_LN2LO 1.9082149292705877000E-10 731 #define M_LN2HI 6.9314718036912381649E-1 732 #define M_SQRT3 1.73205080756887719000 733 #define M_IVLN10 0.43429448190325182765 /* 1 / log(10) */ 734 #define _M_IVLN10L 0.43429448190325182765112891891660508229439700580366656611445378316586464920887L 735 #define M_LOG2_E _M_LN2 736 #define M_INVLN2 1.4426950408889633870E0 /* 1 / log(2) */ 737 738 #endif /* __BSD_VISIBLE */ 739 740 #include <machine/math.h> 741 742 #ifdef __FAST_MATH__ 743 #include <machine/fastmath.h> 744 #endif 745 746 _END_STD_C 747 748 #endif /* _MATH_H_ */ 749