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