1 // -*- C++ -*- 2 //===---------------------------- math.h ----------------------------------===// 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef _LIBCPP_MATH_H 11 #define _LIBCPP_MATH_H 12 13 /* 14 math.h synopsis 15 16 Macros: 17 18 HUGE_VAL 19 HUGE_VALF // C99 20 HUGE_VALL // C99 21 INFINITY // C99 22 NAN // C99 23 FP_INFINITE // C99 24 FP_NAN // C99 25 FP_NORMAL // C99 26 FP_SUBNORMAL // C99 27 FP_ZERO // C99 28 FP_FAST_FMA // C99 29 FP_FAST_FMAF // C99 30 FP_FAST_FMAL // C99 31 FP_ILOGB0 // C99 32 FP_ILOGBNAN // C99 33 MATH_ERRNO // C99 34 MATH_ERREXCEPT // C99 35 math_errhandling // C99 36 37 Types: 38 39 float_t // C99 40 double_t // C99 41 42 // C90 43 44 floating_point abs(floating_point x); 45 46 floating_point acos (arithmetic x); 47 float acosf(float x); 48 long double acosl(long double x); 49 50 floating_point asin (arithmetic x); 51 float asinf(float x); 52 long double asinl(long double x); 53 54 floating_point atan (arithmetic x); 55 float atanf(float x); 56 long double atanl(long double x); 57 58 floating_point atan2 (arithmetic y, arithmetic x); 59 float atan2f(float y, float x); 60 long double atan2l(long double y, long double x); 61 62 floating_point ceil (arithmetic x); 63 float ceilf(float x); 64 long double ceill(long double x); 65 66 floating_point cos (arithmetic x); 67 float cosf(float x); 68 long double cosl(long double x); 69 70 floating_point cosh (arithmetic x); 71 float coshf(float x); 72 long double coshl(long double x); 73 74 floating_point exp (arithmetic x); 75 float expf(float x); 76 long double expl(long double x); 77 78 floating_point fabs (arithmetic x); 79 float fabsf(float x); 80 long double fabsl(long double x); 81 82 floating_point floor (arithmetic x); 83 float floorf(float x); 84 long double floorl(long double x); 85 86 floating_point fmod (arithmetic x, arithmetic y); 87 float fmodf(float x, float y); 88 long double fmodl(long double x, long double y); 89 90 floating_point frexp (arithmetic value, int* exp); 91 float frexpf(float value, int* exp); 92 long double frexpl(long double value, int* exp); 93 94 floating_point ldexp (arithmetic value, int exp); 95 float ldexpf(float value, int exp); 96 long double ldexpl(long double value, int exp); 97 98 floating_point log (arithmetic x); 99 float logf(float x); 100 long double logl(long double x); 101 102 floating_point log10 (arithmetic x); 103 float log10f(float x); 104 long double log10l(long double x); 105 106 floating_point modf (floating_point value, floating_point* iptr); 107 float modff(float value, float* iptr); 108 long double modfl(long double value, long double* iptr); 109 110 floating_point pow (arithmetic x, arithmetic y); 111 float powf(float x, float y); 112 long double powl(long double x, long double y); 113 114 floating_point sin (arithmetic x); 115 float sinf(float x); 116 long double sinl(long double x); 117 118 floating_point sinh (arithmetic x); 119 float sinhf(float x); 120 long double sinhl(long double x); 121 122 floating_point sqrt (arithmetic x); 123 float sqrtf(float x); 124 long double sqrtl(long double x); 125 126 floating_point tan (arithmetic x); 127 float tanf(float x); 128 long double tanl(long double x); 129 130 floating_point tanh (arithmetic x); 131 float tanhf(float x); 132 long double tanhl(long double x); 133 134 // C99 135 136 bool signbit(arithmetic x); 137 138 int fpclassify(arithmetic x); 139 140 bool isfinite(arithmetic x); 141 bool isinf(arithmetic x); 142 bool isnan(arithmetic x); 143 bool isnormal(arithmetic x); 144 145 bool isgreater(arithmetic x, arithmetic y); 146 bool isgreaterequal(arithmetic x, arithmetic y); 147 bool isless(arithmetic x, arithmetic y); 148 bool islessequal(arithmetic x, arithmetic y); 149 bool islessgreater(arithmetic x, arithmetic y); 150 bool isunordered(arithmetic x, arithmetic y); 151 152 floating_point acosh (arithmetic x); 153 float acoshf(float x); 154 long double acoshl(long double x); 155 156 floating_point asinh (arithmetic x); 157 float asinhf(float x); 158 long double asinhl(long double x); 159 160 floating_point atanh (arithmetic x); 161 float atanhf(float x); 162 long double atanhl(long double x); 163 164 floating_point cbrt (arithmetic x); 165 float cbrtf(float x); 166 long double cbrtl(long double x); 167 168 floating_point copysign (arithmetic x, arithmetic y); 169 float copysignf(float x, float y); 170 long double copysignl(long double x, long double y); 171 172 floating_point erf (arithmetic x); 173 float erff(float x); 174 long double erfl(long double x); 175 176 floating_point erfc (arithmetic x); 177 float erfcf(float x); 178 long double erfcl(long double x); 179 180 floating_point exp2 (arithmetic x); 181 float exp2f(float x); 182 long double exp2l(long double x); 183 184 floating_point expm1 (arithmetic x); 185 float expm1f(float x); 186 long double expm1l(long double x); 187 188 floating_point fdim (arithmetic x, arithmetic y); 189 float fdimf(float x, float y); 190 long double fdiml(long double x, long double y); 191 192 floating_point fma (arithmetic x, arithmetic y, arithmetic z); 193 float fmaf(float x, float y, float z); 194 long double fmal(long double x, long double y, long double z); 195 196 floating_point fmax (arithmetic x, arithmetic y); 197 float fmaxf(float x, float y); 198 long double fmaxl(long double x, long double y); 199 200 floating_point fmin (arithmetic x, arithmetic y); 201 float fminf(float x, float y); 202 long double fminl(long double x, long double y); 203 204 floating_point hypot (arithmetic x, arithmetic y); 205 float hypotf(float x, float y); 206 long double hypotl(long double x, long double y); 207 208 int ilogb (arithmetic x); 209 int ilogbf(float x); 210 int ilogbl(long double x); 211 212 floating_point lgamma (arithmetic x); 213 float lgammaf(float x); 214 long double lgammal(long double x); 215 216 long long llrint (arithmetic x); 217 long long llrintf(float x); 218 long long llrintl(long double x); 219 220 long long llround (arithmetic x); 221 long long llroundf(float x); 222 long long llroundl(long double x); 223 224 floating_point log1p (arithmetic x); 225 float log1pf(float x); 226 long double log1pl(long double x); 227 228 floating_point log2 (arithmetic x); 229 float log2f(float x); 230 long double log2l(long double x); 231 232 floating_point logb (arithmetic x); 233 float logbf(float x); 234 long double logbl(long double x); 235 236 long lrint (arithmetic x); 237 long lrintf(float x); 238 long lrintl(long double x); 239 240 long lround (arithmetic x); 241 long lroundf(float x); 242 long lroundl(long double x); 243 244 double nan (const char* str); 245 float nanf(const char* str); 246 long double nanl(const char* str); 247 248 floating_point nearbyint (arithmetic x); 249 float nearbyintf(float x); 250 long double nearbyintl(long double x); 251 252 floating_point nextafter (arithmetic x, arithmetic y); 253 float nextafterf(float x, float y); 254 long double nextafterl(long double x, long double y); 255 256 floating_point nexttoward (arithmetic x, long double y); 257 float nexttowardf(float x, long double y); 258 long double nexttowardl(long double x, long double y); 259 260 floating_point remainder (arithmetic x, arithmetic y); 261 float remainderf(float x, float y); 262 long double remainderl(long double x, long double y); 263 264 floating_point remquo (arithmetic x, arithmetic y, int* pquo); 265 float remquof(float x, float y, int* pquo); 266 long double remquol(long double x, long double y, int* pquo); 267 268 floating_point rint (arithmetic x); 269 float rintf(float x); 270 long double rintl(long double x); 271 272 floating_point round (arithmetic x); 273 float roundf(float x); 274 long double roundl(long double x); 275 276 floating_point scalbln (arithmetic x, long ex); 277 float scalblnf(float x, long ex); 278 long double scalblnl(long double x, long ex); 279 280 floating_point scalbn (arithmetic x, int ex); 281 float scalbnf(float x, int ex); 282 long double scalbnl(long double x, int ex); 283 284 floating_point tgamma (arithmetic x); 285 float tgammaf(float x); 286 long double tgammal(long double x); 287 288 floating_point trunc (arithmetic x); 289 float truncf(float x); 290 long double truncl(long double x); 291 292 */ 293 294 #include <__config> 295 296 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 297 #pragma GCC system_header 298 #endif 299 300 #include_next <math.h> 301 302 #ifdef __cplusplus 303 304 // We support including .h headers inside 'extern "C"' contexts, so switch 305 // back to C++ linkage before including these C++ headers. 306 extern "C++" { 307 308 #include <stdlib.h> 309 #include <type_traits> 310 #include <limits> 311 312 // signbit 313 314 #ifdef signbit 315 316 template <class _A1> 317 _LIBCPP_INLINE_VISIBILITY 318 bool 319 __libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT 320 { 321 #if __has_builtin(__builtin_signbit) 322 return __builtin_signbit(__lcpp_x); 323 #else 324 return signbit(__lcpp_x); 325 #endif 326 } 327 328 #undef signbit 329 330 template <class _A1> 331 inline _LIBCPP_INLINE_VISIBILITY 332 typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type 333 signbit(_A1 __lcpp_x) _NOEXCEPT 334 { 335 return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x); 336 } 337 338 template <class _A1> 339 inline _LIBCPP_INLINE_VISIBILITY 340 typename std::enable_if< 341 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type 342 signbit(_A1 __lcpp_x) _NOEXCEPT 343 { return __lcpp_x < 0; } 344 345 template <class _A1> 346 inline _LIBCPP_INLINE_VISIBILITY 347 typename std::enable_if< 348 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type 349 signbit(_A1) _NOEXCEPT 350 { return false; } 351 352 #elif defined(_LIBCPP_MSVCRT) 353 354 template <typename _A1> 355 inline _LIBCPP_INLINE_VISIBILITY 356 typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type 357 signbit(_A1 __lcpp_x) _NOEXCEPT 358 { 359 return ::signbit(static_cast<typename std::__promote<_A1>::type>(__lcpp_x)); 360 } 361 362 template <class _A1> 363 inline _LIBCPP_INLINE_VISIBILITY 364 typename std::enable_if< 365 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type 366 signbit(_A1 __lcpp_x) _NOEXCEPT 367 { return __lcpp_x < 0; } 368 369 template <class _A1> 370 inline _LIBCPP_INLINE_VISIBILITY 371 typename std::enable_if< 372 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type 373 signbit(_A1) _NOEXCEPT 374 { return false; } 375 376 #endif // signbit 377 378 // fpclassify 379 380 #ifdef fpclassify 381 382 template <class _A1> 383 _LIBCPP_INLINE_VISIBILITY 384 int 385 __libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT 386 { 387 #if __has_builtin(__builtin_fpclassify) 388 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, 389 FP_ZERO, __lcpp_x); 390 #else 391 return fpclassify(__lcpp_x); 392 #endif 393 } 394 395 #undef fpclassify 396 397 template <class _A1> 398 inline _LIBCPP_INLINE_VISIBILITY 399 typename std::enable_if<std::is_floating_point<_A1>::value, int>::type 400 fpclassify(_A1 __lcpp_x) _NOEXCEPT 401 { 402 return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x); 403 } 404 405 template <class _A1> 406 inline _LIBCPP_INLINE_VISIBILITY 407 typename std::enable_if<std::is_integral<_A1>::value, int>::type 408 fpclassify(_A1 __lcpp_x) _NOEXCEPT 409 { return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; } 410 411 #elif defined(_LIBCPP_MSVCRT) 412 413 template <typename _A1> 414 inline _LIBCPP_INLINE_VISIBILITY 415 typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type 416 fpclassify(_A1 __lcpp_x) _NOEXCEPT 417 { 418 return ::fpclassify(static_cast<typename std::__promote<_A1>::type>(__lcpp_x)); 419 } 420 421 template <class _A1> 422 inline _LIBCPP_INLINE_VISIBILITY 423 typename std::enable_if<std::is_integral<_A1>::value, int>::type 424 fpclassify(_A1 __lcpp_x) _NOEXCEPT 425 { return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; } 426 427 #endif // fpclassify 428 429 // isfinite 430 431 #ifdef isfinite 432 433 template <class _A1> 434 _LIBCPP_INLINE_VISIBILITY 435 bool 436 __libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT 437 { 438 #if __has_builtin(__builtin_isfinite) 439 return __builtin_isfinite(__lcpp_x); 440 #else 441 return isfinite(__lcpp_x); 442 #endif 443 } 444 445 #undef isfinite 446 447 template <class _A1> 448 inline _LIBCPP_INLINE_VISIBILITY 449 typename std::enable_if< 450 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, 451 bool>::type 452 isfinite(_A1 __lcpp_x) _NOEXCEPT 453 { 454 return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x); 455 } 456 457 template <class _A1> 458 inline _LIBCPP_INLINE_VISIBILITY 459 typename std::enable_if< 460 std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, 461 bool>::type 462 isfinite(_A1) _NOEXCEPT 463 { return true; } 464 465 #endif // isfinite 466 467 // isinf 468 469 #ifdef isinf 470 471 template <class _A1> 472 _LIBCPP_INLINE_VISIBILITY 473 bool 474 __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT 475 { 476 #if __has_builtin(__builtin_isinf) 477 return __builtin_isinf(__lcpp_x); 478 #else 479 return isinf(__lcpp_x); 480 #endif 481 } 482 483 #undef isinf 484 485 template <class _A1> 486 inline _LIBCPP_INLINE_VISIBILITY 487 typename std::enable_if< 488 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, 489 bool>::type 490 isinf(_A1 __lcpp_x) _NOEXCEPT 491 { 492 return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x); 493 } 494 495 template <class _A1> 496 inline _LIBCPP_INLINE_VISIBILITY 497 typename std::enable_if< 498 std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, 499 bool>::type 500 isinf(_A1) _NOEXCEPT 501 { return false; } 502 503 #ifdef _LIBCPP_PREFERRED_OVERLOAD 504 inline _LIBCPP_INLINE_VISIBILITY 505 bool 506 isinf(float __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); } 507 508 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD 509 bool 510 isinf(double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); } 511 512 inline _LIBCPP_INLINE_VISIBILITY 513 bool 514 isinf(long double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); } 515 #endif 516 517 #endif // isinf 518 519 // isnan 520 521 #ifdef isnan 522 523 template <class _A1> 524 _LIBCPP_INLINE_VISIBILITY 525 bool 526 __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT 527 { 528 #if __has_builtin(__builtin_isnan) 529 return __builtin_isnan(__lcpp_x); 530 #else 531 return isnan(__lcpp_x); 532 #endif 533 } 534 535 #undef isnan 536 537 template <class _A1> 538 inline _LIBCPP_INLINE_VISIBILITY 539 typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type 540 isnan(_A1 __lcpp_x) _NOEXCEPT 541 { 542 return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x); 543 } 544 545 template <class _A1> 546 inline _LIBCPP_INLINE_VISIBILITY 547 typename std::enable_if<std::is_integral<_A1>::value, bool>::type 548 isnan(_A1) _NOEXCEPT 549 { return false; } 550 551 #ifdef _LIBCPP_PREFERRED_OVERLOAD 552 inline _LIBCPP_INLINE_VISIBILITY 553 bool 554 isnan(float __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); } 555 556 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD 557 bool 558 isnan(double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); } 559 560 inline _LIBCPP_INLINE_VISIBILITY 561 bool 562 isnan(long double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); } 563 #endif 564 565 #endif // isnan 566 567 // isnormal 568 569 #ifdef isnormal 570 571 template <class _A1> 572 _LIBCPP_INLINE_VISIBILITY 573 bool 574 __libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT 575 { 576 #if __has_builtin(__builtin_isnormal) 577 return __builtin_isnormal(__lcpp_x); 578 #else 579 return isnormal(__lcpp_x); 580 #endif 581 } 582 583 #undef isnormal 584 585 template <class _A1> 586 inline _LIBCPP_INLINE_VISIBILITY 587 typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type 588 isnormal(_A1 __lcpp_x) _NOEXCEPT 589 { 590 return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x); 591 } 592 593 template <class _A1> 594 inline _LIBCPP_INLINE_VISIBILITY 595 typename std::enable_if<std::is_integral<_A1>::value, bool>::type 596 isnormal(_A1 __lcpp_x) _NOEXCEPT 597 { return __lcpp_x != 0; } 598 599 #endif // isnormal 600 601 // isgreater 602 603 #ifdef isgreater 604 605 template <class _A1, class _A2> 606 _LIBCPP_INLINE_VISIBILITY 607 bool 608 __libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 609 { 610 return isgreater(__lcpp_x, __lcpp_y); 611 } 612 613 #undef isgreater 614 615 template <class _A1, class _A2> 616 inline _LIBCPP_INLINE_VISIBILITY 617 typename std::enable_if 618 < 619 std::is_arithmetic<_A1>::value && 620 std::is_arithmetic<_A2>::value, 621 bool 622 >::type 623 isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 624 { 625 typedef typename std::__promote<_A1, _A2>::type type; 626 return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y); 627 } 628 629 #endif // isgreater 630 631 // isgreaterequal 632 633 #ifdef isgreaterequal 634 635 template <class _A1, class _A2> 636 _LIBCPP_INLINE_VISIBILITY 637 bool 638 __libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 639 { 640 return isgreaterequal(__lcpp_x, __lcpp_y); 641 } 642 643 #undef isgreaterequal 644 645 template <class _A1, class _A2> 646 inline _LIBCPP_INLINE_VISIBILITY 647 typename std::enable_if 648 < 649 std::is_arithmetic<_A1>::value && 650 std::is_arithmetic<_A2>::value, 651 bool 652 >::type 653 isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 654 { 655 typedef typename std::__promote<_A1, _A2>::type type; 656 return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y); 657 } 658 659 #endif // isgreaterequal 660 661 // isless 662 663 #ifdef isless 664 665 template <class _A1, class _A2> 666 _LIBCPP_INLINE_VISIBILITY 667 bool 668 __libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 669 { 670 return isless(__lcpp_x, __lcpp_y); 671 } 672 673 #undef isless 674 675 template <class _A1, class _A2> 676 inline _LIBCPP_INLINE_VISIBILITY 677 typename std::enable_if 678 < 679 std::is_arithmetic<_A1>::value && 680 std::is_arithmetic<_A2>::value, 681 bool 682 >::type 683 isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 684 { 685 typedef typename std::__promote<_A1, _A2>::type type; 686 return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y); 687 } 688 689 #endif // isless 690 691 // islessequal 692 693 #ifdef islessequal 694 695 template <class _A1, class _A2> 696 _LIBCPP_INLINE_VISIBILITY 697 bool 698 __libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 699 { 700 return islessequal(__lcpp_x, __lcpp_y); 701 } 702 703 #undef islessequal 704 705 template <class _A1, class _A2> 706 inline _LIBCPP_INLINE_VISIBILITY 707 typename std::enable_if 708 < 709 std::is_arithmetic<_A1>::value && 710 std::is_arithmetic<_A2>::value, 711 bool 712 >::type 713 islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 714 { 715 typedef typename std::__promote<_A1, _A2>::type type; 716 return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y); 717 } 718 719 #endif // islessequal 720 721 // islessgreater 722 723 #ifdef islessgreater 724 725 template <class _A1, class _A2> 726 _LIBCPP_INLINE_VISIBILITY 727 bool 728 __libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 729 { 730 return islessgreater(__lcpp_x, __lcpp_y); 731 } 732 733 #undef islessgreater 734 735 template <class _A1, class _A2> 736 inline _LIBCPP_INLINE_VISIBILITY 737 typename std::enable_if 738 < 739 std::is_arithmetic<_A1>::value && 740 std::is_arithmetic<_A2>::value, 741 bool 742 >::type 743 islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 744 { 745 typedef typename std::__promote<_A1, _A2>::type type; 746 return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y); 747 } 748 749 #endif // islessgreater 750 751 // isunordered 752 753 #ifdef isunordered 754 755 template <class _A1, class _A2> 756 _LIBCPP_INLINE_VISIBILITY 757 bool 758 __libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 759 { 760 return isunordered(__lcpp_x, __lcpp_y); 761 } 762 763 #undef isunordered 764 765 template <class _A1, class _A2> 766 inline _LIBCPP_INLINE_VISIBILITY 767 typename std::enable_if 768 < 769 std::is_arithmetic<_A1>::value && 770 std::is_arithmetic<_A2>::value, 771 bool 772 >::type 773 isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 774 { 775 typedef typename std::__promote<_A1, _A2>::type type; 776 return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y); 777 } 778 779 #endif // isunordered 780 781 // abs 782 // 783 // handled in stdlib.h 784 785 // div 786 // 787 // handled in stdlib.h 788 789 // acos 790 791 #if !(defined(_AIX) || defined(__sun__)) 792 inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return ::acosf(__lcpp_x);} 793 inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);} 794 #endif 795 796 template <class _A1> 797 inline _LIBCPP_INLINE_VISIBILITY 798 typename std::enable_if<std::is_integral<_A1>::value, double>::type 799 acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);} 800 801 // asin 802 803 #if !(defined(_AIX) || defined(__sun__)) 804 inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return ::asinf(__lcpp_x);} 805 inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);} 806 #endif 807 808 template <class _A1> 809 inline _LIBCPP_INLINE_VISIBILITY 810 typename std::enable_if<std::is_integral<_A1>::value, double>::type 811 asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);} 812 813 // atan 814 815 #if !(defined(_AIX) || defined(__sun__)) 816 inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return ::atanf(__lcpp_x);} 817 inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_x);} 818 #endif 819 820 template <class _A1> 821 inline _LIBCPP_INLINE_VISIBILITY 822 typename std::enable_if<std::is_integral<_A1>::value, double>::type 823 atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);} 824 825 // atan2 826 827 #if !(defined(_AIX) || defined(__sun__)) 828 inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);} 829 inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return ::atan2l(__lcpp_y, __lcpp_x);} 830 #endif 831 832 template <class _A1, class _A2> 833 inline _LIBCPP_INLINE_VISIBILITY 834 typename std::_EnableIf 835 < 836 std::is_arithmetic<_A1>::value && 837 std::is_arithmetic<_A2>::value, 838 std::__promote<_A1, _A2> 839 >::type 840 atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT 841 { 842 typedef typename std::__promote<_A1, _A2>::type __result_type; 843 static_assert((!(std::_IsSame<_A1, __result_type>::value && 844 std::_IsSame<_A2, __result_type>::value)), ""); 845 return ::atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x); 846 } 847 848 // ceil 849 850 #if !(defined(_AIX) || defined(__sun__)) 851 inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ::ceilf(__lcpp_x);} 852 inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ::ceill(__lcpp_x);} 853 #endif 854 855 template <class _A1> 856 inline _LIBCPP_INLINE_VISIBILITY 857 typename std::enable_if<std::is_integral<_A1>::value, double>::type 858 ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);} 859 860 // cos 861 862 #if !(defined(_AIX) || defined(__sun__)) 863 inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return ::cosf(__lcpp_x);} 864 inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return ::cosl(__lcpp_x);} 865 #endif 866 867 template <class _A1> 868 inline _LIBCPP_INLINE_VISIBILITY 869 typename std::enable_if<std::is_integral<_A1>::value, double>::type 870 cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);} 871 872 // cosh 873 874 #if !(defined(_AIX) || defined(__sun__)) 875 inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return ::coshf(__lcpp_x);} 876 inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return ::coshl(__lcpp_x);} 877 #endif 878 879 template <class _A1> 880 inline _LIBCPP_INLINE_VISIBILITY 881 typename std::enable_if<std::is_integral<_A1>::value, double>::type 882 cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);} 883 884 // exp 885 886 #if !(defined(_AIX) || defined(__sun__)) 887 inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return ::expf(__lcpp_x);} 888 inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return ::expl(__lcpp_x);} 889 #endif 890 891 template <class _A1> 892 inline _LIBCPP_INLINE_VISIBILITY 893 typename std::enable_if<std::is_integral<_A1>::value, double>::type 894 exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);} 895 896 // fabs 897 898 #if !(defined(_AIX) || defined(__sun__)) 899 inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);} 900 inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);} 901 #endif 902 903 template <class _A1> 904 inline _LIBCPP_INLINE_VISIBILITY 905 typename std::enable_if<std::is_integral<_A1>::value, double>::type 906 fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);} 907 908 // floor 909 910 #if !(defined(_AIX) || defined(__sun__)) 911 inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return ::floorf(__lcpp_x);} 912 inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return ::floorl(__lcpp_x);} 913 #endif 914 915 template <class _A1> 916 inline _LIBCPP_INLINE_VISIBILITY 917 typename std::enable_if<std::is_integral<_A1>::value, double>::type 918 floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);} 919 920 // fmod 921 922 #if !(defined(_AIX) || defined(__sun__)) 923 inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmodf(__lcpp_x, __lcpp_y);} 924 inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmodl(__lcpp_x, __lcpp_y);} 925 #endif 926 927 template <class _A1, class _A2> 928 inline _LIBCPP_INLINE_VISIBILITY 929 typename std::_EnableIf 930 < 931 std::is_arithmetic<_A1>::value && 932 std::is_arithmetic<_A2>::value, 933 std::__promote<_A1, _A2> 934 >::type 935 fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 936 { 937 typedef typename std::__promote<_A1, _A2>::type __result_type; 938 static_assert((!(std::_IsSame<_A1, __result_type>::value && 939 std::_IsSame<_A2, __result_type>::value)), ""); 940 return ::fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y); 941 } 942 943 // frexp 944 945 #if !(defined(_AIX) || defined(__sun__)) 946 inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpf(__lcpp_x, __lcpp_e);} 947 inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpl(__lcpp_x, __lcpp_e);} 948 #endif 949 950 template <class _A1> 951 inline _LIBCPP_INLINE_VISIBILITY 952 typename std::enable_if<std::is_integral<_A1>::value, double>::type 953 frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexp((double)__lcpp_x, __lcpp_e);} 954 955 // ldexp 956 957 #if !(defined(_AIX) || defined(__sun__)) 958 inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpf(__lcpp_x, __lcpp_e);} 959 inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpl(__lcpp_x, __lcpp_e);} 960 #endif 961 962 template <class _A1> 963 inline _LIBCPP_INLINE_VISIBILITY 964 typename std::enable_if<std::is_integral<_A1>::value, double>::type 965 ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexp((double)__lcpp_x, __lcpp_e);} 966 967 // log 968 969 #if !(defined(_AIX) || defined(__sun__)) 970 inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return ::logf(__lcpp_x);} 971 inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return ::logl(__lcpp_x);} 972 #endif 973 974 template <class _A1> 975 inline _LIBCPP_INLINE_VISIBILITY 976 typename std::enable_if<std::is_integral<_A1>::value, double>::type 977 log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);} 978 979 // log10 980 981 #if !(defined(_AIX) || defined(__sun__)) 982 inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return ::log10f(__lcpp_x);} 983 inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return ::log10l(__lcpp_x);} 984 #endif 985 986 template <class _A1> 987 inline _LIBCPP_INLINE_VISIBILITY 988 typename std::enable_if<std::is_integral<_A1>::value, double>::type 989 log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);} 990 991 // modf 992 993 #if !(defined(_AIX) || defined(__sun__)) 994 inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return ::modff(__lcpp_x, __lcpp_y);} 995 inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return ::modfl(__lcpp_x, __lcpp_y);} 996 #endif 997 998 // pow 999 1000 #if !(defined(_AIX) || defined(__sun__)) 1001 inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::powf(__lcpp_x, __lcpp_y);} 1002 inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::powl(__lcpp_x, __lcpp_y);} 1003 #endif 1004 1005 template <class _A1, class _A2> 1006 inline _LIBCPP_INLINE_VISIBILITY 1007 typename std::_EnableIf 1008 < 1009 std::is_arithmetic<_A1>::value && 1010 std::is_arithmetic<_A2>::value, 1011 std::__promote<_A1, _A2> 1012 >::type 1013 pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 1014 { 1015 typedef typename std::__promote<_A1, _A2>::type __result_type; 1016 static_assert((!(std::_IsSame<_A1, __result_type>::value && 1017 std::_IsSame<_A2, __result_type>::value)), ""); 1018 return ::pow((__result_type)__lcpp_x, (__result_type)__lcpp_y); 1019 } 1020 1021 // sin 1022 1023 #if !(defined(_AIX) || defined(__sun__)) 1024 inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return ::sinf(__lcpp_x);} 1025 inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return ::sinl(__lcpp_x);} 1026 #endif 1027 1028 template <class _A1> 1029 inline _LIBCPP_INLINE_VISIBILITY 1030 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1031 sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);} 1032 1033 // sinh 1034 1035 #if !(defined(_AIX) || defined(__sun__)) 1036 inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return ::sinhf(__lcpp_x);} 1037 inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return ::sinhl(__lcpp_x);} 1038 #endif 1039 1040 template <class _A1> 1041 inline _LIBCPP_INLINE_VISIBILITY 1042 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1043 sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);} 1044 1045 // sqrt 1046 1047 #if !(defined(_AIX) || defined(__sun__)) 1048 inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return ::sqrtf(__lcpp_x);} 1049 inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return ::sqrtl(__lcpp_x);} 1050 #endif 1051 1052 template <class _A1> 1053 inline _LIBCPP_INLINE_VISIBILITY 1054 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1055 sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);} 1056 1057 // tan 1058 1059 #if !(defined(_AIX) || defined(__sun__)) 1060 inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return ::tanf(__lcpp_x);} 1061 inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return ::tanl(__lcpp_x);} 1062 #endif 1063 1064 template <class _A1> 1065 inline _LIBCPP_INLINE_VISIBILITY 1066 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1067 tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);} 1068 1069 // tanh 1070 1071 #if !(defined(_AIX) || defined(__sun__)) 1072 inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return ::tanhf(__lcpp_x);} 1073 inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return ::tanhl(__lcpp_x);} 1074 #endif 1075 1076 template <class _A1> 1077 inline _LIBCPP_INLINE_VISIBILITY 1078 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1079 tanh(_A1 __lcpp_x) _NOEXCEPT {return ::tanh((double)__lcpp_x);} 1080 1081 // acosh 1082 1083 inline _LIBCPP_INLINE_VISIBILITY float acosh(float __lcpp_x) _NOEXCEPT {return ::acoshf(__lcpp_x);} 1084 inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return ::acoshl(__lcpp_x);} 1085 1086 template <class _A1> 1087 inline _LIBCPP_INLINE_VISIBILITY 1088 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1089 acosh(_A1 __lcpp_x) _NOEXCEPT {return ::acosh((double)__lcpp_x);} 1090 1091 // asinh 1092 1093 inline _LIBCPP_INLINE_VISIBILITY float asinh(float __lcpp_x) _NOEXCEPT {return ::asinhf(__lcpp_x);} 1094 inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return ::asinhl(__lcpp_x);} 1095 1096 template <class _A1> 1097 inline _LIBCPP_INLINE_VISIBILITY 1098 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1099 asinh(_A1 __lcpp_x) _NOEXCEPT {return ::asinh((double)__lcpp_x);} 1100 1101 // atanh 1102 1103 inline _LIBCPP_INLINE_VISIBILITY float atanh(float __lcpp_x) _NOEXCEPT {return ::atanhf(__lcpp_x);} 1104 inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return ::atanhl(__lcpp_x);} 1105 1106 template <class _A1> 1107 inline _LIBCPP_INLINE_VISIBILITY 1108 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1109 atanh(_A1 __lcpp_x) _NOEXCEPT {return ::atanh((double)__lcpp_x);} 1110 1111 // cbrt 1112 1113 inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __lcpp_x) _NOEXCEPT {return ::cbrtf(__lcpp_x);} 1114 inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return ::cbrtl(__lcpp_x);} 1115 1116 template <class _A1> 1117 inline _LIBCPP_INLINE_VISIBILITY 1118 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1119 cbrt(_A1 __lcpp_x) _NOEXCEPT {return ::cbrt((double)__lcpp_x);} 1120 1121 // copysign 1122 1123 inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x, 1124 float __lcpp_y) _NOEXCEPT { 1125 #if __has_builtin(__builtin_copysignf) 1126 return __builtin_copysignf(__lcpp_x, __lcpp_y); 1127 #else 1128 return ::copysignf(__lcpp_x, __lcpp_y); 1129 #endif 1130 } 1131 inline _LIBCPP_INLINE_VISIBILITY long double 1132 copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT { 1133 #if __has_builtin(__builtin_copysignl) 1134 return __builtin_copysignl(__lcpp_x, __lcpp_y); 1135 #else 1136 return ::copysignl(__lcpp_x, __lcpp_y); 1137 #endif 1138 } 1139 1140 template <class _A1, class _A2> 1141 inline _LIBCPP_INLINE_VISIBILITY 1142 typename std::_EnableIf 1143 < 1144 std::is_arithmetic<_A1>::value && 1145 std::is_arithmetic<_A2>::value, 1146 std::__promote<_A1, _A2> 1147 >::type 1148 copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 1149 { 1150 typedef typename std::__promote<_A1, _A2>::type __result_type; 1151 static_assert((!(std::_IsSame<_A1, __result_type>::value && 1152 std::_IsSame<_A2, __result_type>::value)), ""); 1153 #if __has_builtin(__builtin_copysign) 1154 return __builtin_copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y); 1155 #else 1156 return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y); 1157 #endif 1158 } 1159 1160 // erf 1161 1162 inline _LIBCPP_INLINE_VISIBILITY float erf(float __lcpp_x) _NOEXCEPT {return ::erff(__lcpp_x);} 1163 inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return ::erfl(__lcpp_x);} 1164 1165 template <class _A1> 1166 inline _LIBCPP_INLINE_VISIBILITY 1167 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1168 erf(_A1 __lcpp_x) _NOEXCEPT {return ::erf((double)__lcpp_x);} 1169 1170 // erfc 1171 1172 inline _LIBCPP_INLINE_VISIBILITY float erfc(float __lcpp_x) _NOEXCEPT {return ::erfcf(__lcpp_x);} 1173 inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return ::erfcl(__lcpp_x);} 1174 1175 template <class _A1> 1176 inline _LIBCPP_INLINE_VISIBILITY 1177 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1178 erfc(_A1 __lcpp_x) _NOEXCEPT {return ::erfc((double)__lcpp_x);} 1179 1180 // exp2 1181 1182 inline _LIBCPP_INLINE_VISIBILITY float exp2(float __lcpp_x) _NOEXCEPT {return ::exp2f(__lcpp_x);} 1183 inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return ::exp2l(__lcpp_x);} 1184 1185 template <class _A1> 1186 inline _LIBCPP_INLINE_VISIBILITY 1187 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1188 exp2(_A1 __lcpp_x) _NOEXCEPT {return ::exp2((double)__lcpp_x);} 1189 1190 // expm1 1191 1192 inline _LIBCPP_INLINE_VISIBILITY float expm1(float __lcpp_x) _NOEXCEPT {return ::expm1f(__lcpp_x);} 1193 inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return ::expm1l(__lcpp_x);} 1194 1195 template <class _A1> 1196 inline _LIBCPP_INLINE_VISIBILITY 1197 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1198 expm1(_A1 __lcpp_x) _NOEXCEPT {return ::expm1((double)__lcpp_x);} 1199 1200 // fdim 1201 1202 inline _LIBCPP_INLINE_VISIBILITY float fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fdimf(__lcpp_x, __lcpp_y);} 1203 inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fdiml(__lcpp_x, __lcpp_y);} 1204 1205 template <class _A1, class _A2> 1206 inline _LIBCPP_INLINE_VISIBILITY 1207 typename std::_EnableIf 1208 < 1209 std::is_arithmetic<_A1>::value && 1210 std::is_arithmetic<_A2>::value, 1211 std::__promote<_A1, _A2> 1212 >::type 1213 fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 1214 { 1215 typedef typename std::__promote<_A1, _A2>::type __result_type; 1216 static_assert((!(std::_IsSame<_A1, __result_type>::value && 1217 std::_IsSame<_A2, __result_type>::value)), ""); 1218 return ::fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y); 1219 } 1220 1221 // fma 1222 1223 inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT 1224 { 1225 #if __has_builtin(__builtin_fmaf) 1226 return __builtin_fmaf(__lcpp_x, __lcpp_y, __lcpp_z); 1227 #else 1228 return ::fmaf(__lcpp_x, __lcpp_y, __lcpp_z); 1229 #endif 1230 } 1231 inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT 1232 { 1233 #if __has_builtin(__builtin_fmal) 1234 return __builtin_fmal(__lcpp_x, __lcpp_y, __lcpp_z); 1235 #else 1236 return ::fmal(__lcpp_x, __lcpp_y, __lcpp_z); 1237 #endif 1238 } 1239 1240 template <class _A1, class _A2, class _A3> 1241 inline _LIBCPP_INLINE_VISIBILITY 1242 typename std::_EnableIf 1243 < 1244 std::is_arithmetic<_A1>::value && 1245 std::is_arithmetic<_A2>::value && 1246 std::is_arithmetic<_A3>::value, 1247 std::__promote<_A1, _A2, _A3> 1248 >::type 1249 fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT 1250 { 1251 typedef typename std::__promote<_A1, _A2, _A3>::type __result_type; 1252 static_assert((!(std::_IsSame<_A1, __result_type>::value && 1253 std::_IsSame<_A2, __result_type>::value && 1254 std::_IsSame<_A3, __result_type>::value)), ""); 1255 #if __has_builtin(__builtin_fma) 1256 return __builtin_fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z); 1257 #else 1258 return ::fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z); 1259 #endif 1260 } 1261 1262 // fmax 1263 1264 inline _LIBCPP_INLINE_VISIBILITY float fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmaxf(__lcpp_x, __lcpp_y);} 1265 inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmaxl(__lcpp_x, __lcpp_y);} 1266 1267 template <class _A1, class _A2> 1268 inline _LIBCPP_INLINE_VISIBILITY 1269 typename std::_EnableIf 1270 < 1271 std::is_arithmetic<_A1>::value && 1272 std::is_arithmetic<_A2>::value, 1273 std::__promote<_A1, _A2> 1274 >::type 1275 fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 1276 { 1277 typedef typename std::__promote<_A1, _A2>::type __result_type; 1278 static_assert((!(std::_IsSame<_A1, __result_type>::value && 1279 std::_IsSame<_A2, __result_type>::value)), ""); 1280 return ::fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y); 1281 } 1282 1283 // fmin 1284 1285 inline _LIBCPP_INLINE_VISIBILITY float fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fminf(__lcpp_x, __lcpp_y);} 1286 inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fminl(__lcpp_x, __lcpp_y);} 1287 1288 template <class _A1, class _A2> 1289 inline _LIBCPP_INLINE_VISIBILITY 1290 typename std::_EnableIf 1291 < 1292 std::is_arithmetic<_A1>::value && 1293 std::is_arithmetic<_A2>::value, 1294 std::__promote<_A1, _A2> 1295 >::type 1296 fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 1297 { 1298 typedef typename std::__promote<_A1, _A2>::type __result_type; 1299 static_assert((!(std::_IsSame<_A1, __result_type>::value && 1300 std::_IsSame<_A2, __result_type>::value)), ""); 1301 return ::fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y); 1302 } 1303 1304 // hypot 1305 1306 inline _LIBCPP_INLINE_VISIBILITY float hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::hypotf(__lcpp_x, __lcpp_y);} 1307 inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::hypotl(__lcpp_x, __lcpp_y);} 1308 1309 template <class _A1, class _A2> 1310 inline _LIBCPP_INLINE_VISIBILITY 1311 typename std::_EnableIf 1312 < 1313 std::is_arithmetic<_A1>::value && 1314 std::is_arithmetic<_A2>::value, 1315 std::__promote<_A1, _A2> 1316 >::type 1317 hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 1318 { 1319 typedef typename std::__promote<_A1, _A2>::type __result_type; 1320 static_assert((!(std::_IsSame<_A1, __result_type>::value && 1321 std::_IsSame<_A2, __result_type>::value)), ""); 1322 return ::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y); 1323 } 1324 1325 // ilogb 1326 1327 inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT {return ::ilogbf(__lcpp_x);} 1328 inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ::ilogbl(__lcpp_x);} 1329 1330 template <class _A1> 1331 inline _LIBCPP_INLINE_VISIBILITY 1332 typename std::enable_if<std::is_integral<_A1>::value, int>::type 1333 ilogb(_A1 __lcpp_x) _NOEXCEPT {return ::ilogb((double)__lcpp_x);} 1334 1335 // lgamma 1336 1337 inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __lcpp_x) _NOEXCEPT {return ::lgammaf(__lcpp_x);} 1338 inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return ::lgammal(__lcpp_x);} 1339 1340 template <class _A1> 1341 inline _LIBCPP_INLINE_VISIBILITY 1342 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1343 lgamma(_A1 __lcpp_x) _NOEXCEPT {return ::lgamma((double)__lcpp_x);} 1344 1345 // llrint 1346 1347 inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT 1348 { 1349 #if __has_builtin(__builtin_llrintf) 1350 return __builtin_llrintf(__lcpp_x); 1351 #else 1352 return ::llrintf(__lcpp_x); 1353 #endif 1354 } 1355 inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT 1356 { 1357 #if __has_builtin(__builtin_llrintl) 1358 return __builtin_llrintl(__lcpp_x); 1359 #else 1360 return ::llrintl(__lcpp_x); 1361 #endif 1362 } 1363 1364 template <class _A1> 1365 inline _LIBCPP_INLINE_VISIBILITY 1366 typename std::enable_if<std::is_integral<_A1>::value, long long>::type 1367 llrint(_A1 __lcpp_x) _NOEXCEPT 1368 { 1369 #if __has_builtin(__builtin_llrint) 1370 return __builtin_llrint((double)__lcpp_x); 1371 #else 1372 return ::llrint((double)__lcpp_x); 1373 #endif 1374 } 1375 1376 // llround 1377 1378 inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT 1379 { 1380 #if __has_builtin(__builtin_llroundf) 1381 return __builtin_llroundf(__lcpp_x); 1382 #else 1383 return ::llroundf(__lcpp_x); 1384 #endif 1385 } 1386 inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT 1387 { 1388 #if __has_builtin(__builtin_llroundl) 1389 return __builtin_llroundl(__lcpp_x); 1390 #else 1391 return ::llroundl(__lcpp_x); 1392 #endif 1393 } 1394 1395 template <class _A1> 1396 inline _LIBCPP_INLINE_VISIBILITY 1397 typename std::enable_if<std::is_integral<_A1>::value, long long>::type 1398 llround(_A1 __lcpp_x) _NOEXCEPT 1399 { 1400 #if __has_builtin(__builtin_llround) 1401 return __builtin_llround((double)__lcpp_x); 1402 #else 1403 return ::llround((double)__lcpp_x); 1404 #endif 1405 } 1406 1407 // log1p 1408 1409 inline _LIBCPP_INLINE_VISIBILITY float log1p(float __lcpp_x) _NOEXCEPT {return ::log1pf(__lcpp_x);} 1410 inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return ::log1pl(__lcpp_x);} 1411 1412 template <class _A1> 1413 inline _LIBCPP_INLINE_VISIBILITY 1414 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1415 log1p(_A1 __lcpp_x) _NOEXCEPT {return ::log1p((double)__lcpp_x);} 1416 1417 // log2 1418 1419 inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return ::log2f(__lcpp_x);} 1420 inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return ::log2l(__lcpp_x);} 1421 1422 template <class _A1> 1423 inline _LIBCPP_INLINE_VISIBILITY 1424 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1425 log2(_A1 __lcpp_x) _NOEXCEPT {return ::log2((double)__lcpp_x);} 1426 1427 // logb 1428 1429 inline _LIBCPP_INLINE_VISIBILITY float logb(float __lcpp_x) _NOEXCEPT {return ::logbf(__lcpp_x);} 1430 inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return ::logbl(__lcpp_x);} 1431 1432 template <class _A1> 1433 inline _LIBCPP_INLINE_VISIBILITY 1434 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1435 logb(_A1 __lcpp_x) _NOEXCEPT {return ::logb((double)__lcpp_x);} 1436 1437 // lrint 1438 1439 inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT 1440 { 1441 #if __has_builtin(__builtin_lrintf) 1442 return __builtin_lrintf(__lcpp_x); 1443 #else 1444 return ::lrintf(__lcpp_x); 1445 #endif 1446 } 1447 inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT 1448 { 1449 #if __has_builtin(__builtin_lrintl) 1450 return __builtin_lrintl(__lcpp_x); 1451 #else 1452 return ::lrintl(__lcpp_x); 1453 #endif 1454 } 1455 1456 template <class _A1> 1457 inline _LIBCPP_INLINE_VISIBILITY 1458 typename std::enable_if<std::is_integral<_A1>::value, long>::type 1459 lrint(_A1 __lcpp_x) _NOEXCEPT 1460 { 1461 #if __has_builtin(__builtin_lrint) 1462 return __builtin_lrint((double)__lcpp_x); 1463 #else 1464 return ::lrint((double)__lcpp_x); 1465 #endif 1466 } 1467 1468 // lround 1469 1470 inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT 1471 { 1472 #if __has_builtin(__builtin_lroundf) 1473 return __builtin_lroundf(__lcpp_x); 1474 #else 1475 return ::lroundf(__lcpp_x); 1476 #endif 1477 } 1478 inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT 1479 { 1480 #if __has_builtin(__builtin_lroundl) 1481 return __builtin_lroundl(__lcpp_x); 1482 #else 1483 return ::lroundl(__lcpp_x); 1484 #endif 1485 } 1486 1487 template <class _A1> 1488 inline _LIBCPP_INLINE_VISIBILITY 1489 typename std::enable_if<std::is_integral<_A1>::value, long>::type 1490 lround(_A1 __lcpp_x) _NOEXCEPT 1491 { 1492 #if __has_builtin(__builtin_lround) 1493 return __builtin_lround((double)__lcpp_x); 1494 #else 1495 return ::lround((double)__lcpp_x); 1496 #endif 1497 } 1498 1499 // nan 1500 1501 // nearbyint 1502 1503 inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __lcpp_x) _NOEXCEPT {return ::nearbyintf(__lcpp_x);} 1504 inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return ::nearbyintl(__lcpp_x);} 1505 1506 template <class _A1> 1507 inline _LIBCPP_INLINE_VISIBILITY 1508 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1509 nearbyint(_A1 __lcpp_x) _NOEXCEPT {return ::nearbyint((double)__lcpp_x);} 1510 1511 // nextafter 1512 1513 inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::nextafterf(__lcpp_x, __lcpp_y);} 1514 inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nextafterl(__lcpp_x, __lcpp_y);} 1515 1516 template <class _A1, class _A2> 1517 inline _LIBCPP_INLINE_VISIBILITY 1518 typename std::_EnableIf 1519 < 1520 std::is_arithmetic<_A1>::value && 1521 std::is_arithmetic<_A2>::value, 1522 std::__promote<_A1, _A2> 1523 >::type 1524 nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 1525 { 1526 typedef typename std::__promote<_A1, _A2>::type __result_type; 1527 static_assert((!(std::_IsSame<_A1, __result_type>::value && 1528 std::_IsSame<_A2, __result_type>::value)), ""); 1529 return ::nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y); 1530 } 1531 1532 // nexttoward 1533 1534 inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardf(__lcpp_x, __lcpp_y);} 1535 inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardl(__lcpp_x, __lcpp_y);} 1536 1537 template <class _A1> 1538 inline _LIBCPP_INLINE_VISIBILITY 1539 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1540 nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttoward((double)__lcpp_x, __lcpp_y);} 1541 1542 // remainder 1543 1544 inline _LIBCPP_INLINE_VISIBILITY float remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::remainderf(__lcpp_x, __lcpp_y);} 1545 inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::remainderl(__lcpp_x, __lcpp_y);} 1546 1547 template <class _A1, class _A2> 1548 inline _LIBCPP_INLINE_VISIBILITY 1549 typename std::_EnableIf 1550 < 1551 std::is_arithmetic<_A1>::value && 1552 std::is_arithmetic<_A2>::value, 1553 std::__promote<_A1, _A2> 1554 >::type 1555 remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT 1556 { 1557 typedef typename std::__promote<_A1, _A2>::type __result_type; 1558 static_assert((!(std::_IsSame<_A1, __result_type>::value && 1559 std::_IsSame<_A2, __result_type>::value)), ""); 1560 return ::remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y); 1561 } 1562 1563 // remquo 1564 1565 inline _LIBCPP_INLINE_VISIBILITY float remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT {return ::remquof(__lcpp_x, __lcpp_y, __lcpp_z);} 1566 inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long double __lcpp_y, int* __lcpp_z) _NOEXCEPT {return ::remquol(__lcpp_x, __lcpp_y, __lcpp_z);} 1567 1568 template <class _A1, class _A2> 1569 inline _LIBCPP_INLINE_VISIBILITY 1570 typename std::_EnableIf 1571 < 1572 std::is_arithmetic<_A1>::value && 1573 std::is_arithmetic<_A2>::value, 1574 std::__promote<_A1, _A2> 1575 >::type 1576 remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT 1577 { 1578 typedef typename std::__promote<_A1, _A2>::type __result_type; 1579 static_assert((!(std::_IsSame<_A1, __result_type>::value && 1580 std::_IsSame<_A2, __result_type>::value)), ""); 1581 return ::remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z); 1582 } 1583 1584 // rint 1585 1586 inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT 1587 { 1588 #if __has_builtin(__builtin_rintf) 1589 return __builtin_rintf(__lcpp_x); 1590 #else 1591 return ::rintf(__lcpp_x); 1592 #endif 1593 } 1594 inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT 1595 { 1596 #if __has_builtin(__builtin_rintl) 1597 return __builtin_rintl(__lcpp_x); 1598 #else 1599 return ::rintl(__lcpp_x); 1600 #endif 1601 } 1602 1603 template <class _A1> 1604 inline _LIBCPP_INLINE_VISIBILITY 1605 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1606 rint(_A1 __lcpp_x) _NOEXCEPT 1607 { 1608 #if __has_builtin(__builtin_rint) 1609 return __builtin_rint((double)__lcpp_x); 1610 #else 1611 return ::rint((double)__lcpp_x); 1612 #endif 1613 } 1614 1615 // round 1616 1617 inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT 1618 { 1619 #if __has_builtin(__builtin_round) 1620 return __builtin_round(__lcpp_x); 1621 #else 1622 return ::round(__lcpp_x); 1623 #endif 1624 } 1625 inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT 1626 { 1627 #if __has_builtin(__builtin_roundl) 1628 return __builtin_roundl(__lcpp_x); 1629 #else 1630 return ::roundl(__lcpp_x); 1631 #endif 1632 } 1633 1634 template <class _A1> 1635 inline _LIBCPP_INLINE_VISIBILITY 1636 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1637 round(_A1 __lcpp_x) _NOEXCEPT 1638 { 1639 #if __has_builtin(__builtin_round) 1640 return __builtin_round((double)__lcpp_x); 1641 #else 1642 return ::round((double)__lcpp_x); 1643 #endif 1644 } 1645 1646 // scalbln 1647 1648 inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnf(__lcpp_x, __lcpp_y);} 1649 inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnl(__lcpp_x, __lcpp_y);} 1650 1651 template <class _A1> 1652 inline _LIBCPP_INLINE_VISIBILITY 1653 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1654 scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalbln((double)__lcpp_x, __lcpp_y);} 1655 1656 // scalbn 1657 1658 inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnf(__lcpp_x, __lcpp_y);} 1659 inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnl(__lcpp_x, __lcpp_y);} 1660 1661 template <class _A1> 1662 inline _LIBCPP_INLINE_VISIBILITY 1663 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1664 scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbn((double)__lcpp_x, __lcpp_y);} 1665 1666 // tgamma 1667 1668 inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __lcpp_x) _NOEXCEPT {return ::tgammaf(__lcpp_x);} 1669 inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return ::tgammal(__lcpp_x);} 1670 1671 template <class _A1> 1672 inline _LIBCPP_INLINE_VISIBILITY 1673 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1674 tgamma(_A1 __lcpp_x) _NOEXCEPT {return ::tgamma((double)__lcpp_x);} 1675 1676 // trunc 1677 1678 inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT 1679 { 1680 #if __has_builtin(__builtin_trunc) 1681 return __builtin_trunc(__lcpp_x); 1682 #else 1683 return ::trunc(__lcpp_x); 1684 #endif 1685 } 1686 inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT 1687 { 1688 #if __has_builtin(__builtin_truncl) 1689 return __builtin_truncl(__lcpp_x); 1690 #else 1691 return ::truncl(__lcpp_x); 1692 #endif 1693 } 1694 1695 template <class _A1> 1696 inline _LIBCPP_INLINE_VISIBILITY 1697 typename std::enable_if<std::is_integral<_A1>::value, double>::type 1698 trunc(_A1 __lcpp_x) _NOEXCEPT 1699 { 1700 #if __has_builtin(__builtin_trunc) 1701 return __builtin_trunc((double)__lcpp_x); 1702 #else 1703 return ::trunc((double)__lcpp_x); 1704 #endif 1705 } 1706 1707 } // extern "C++" 1708 1709 #endif // __cplusplus 1710 1711 #else // _LIBCPP_MATH_H 1712 1713 // This include lives outside the header guard in order to support an MSVC 1714 // extension which allows users to do: 1715 // 1716 // #define _USE_MATH_DEFINES 1717 // #include <math.h> 1718 // 1719 // and receive the definitions of mathematical constants, even if <math.h> 1720 // has previously been included. 1721 #if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES) 1722 #include_next <math.h> 1723 #endif 1724 1725 #endif // _LIBCPP_MATH_H 1726