146035553Spatrick // -*- C++ -*-
2*dc37c87aSrobert //===----------------------------------------------------------------------===//
346035553Spatrick //
446035553Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
546035553Spatrick // See https://llvm.org/LICENSE.txt for license information.
646035553Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
746035553Spatrick //
846035553Spatrick //===----------------------------------------------------------------------===//
946035553Spatrick
1046035553Spatrick #ifndef _LIBCPP_MATH_H
1146035553Spatrick #define _LIBCPP_MATH_H
1246035553Spatrick
1346035553Spatrick /*
1446035553Spatrick math.h synopsis
1546035553Spatrick
1646035553Spatrick Macros:
1746035553Spatrick
1846035553Spatrick HUGE_VAL
1946035553Spatrick HUGE_VALF // C99
2046035553Spatrick HUGE_VALL // C99
2146035553Spatrick INFINITY // C99
2246035553Spatrick NAN // C99
2346035553Spatrick FP_INFINITE // C99
2446035553Spatrick FP_NAN // C99
2546035553Spatrick FP_NORMAL // C99
2646035553Spatrick FP_SUBNORMAL // C99
2746035553Spatrick FP_ZERO // C99
2846035553Spatrick FP_FAST_FMA // C99
2946035553Spatrick FP_FAST_FMAF // C99
3046035553Spatrick FP_FAST_FMAL // C99
3146035553Spatrick FP_ILOGB0 // C99
3246035553Spatrick FP_ILOGBNAN // C99
3346035553Spatrick MATH_ERRNO // C99
3446035553Spatrick MATH_ERREXCEPT // C99
3546035553Spatrick math_errhandling // C99
3646035553Spatrick
3746035553Spatrick Types:
3846035553Spatrick
3946035553Spatrick float_t // C99
4046035553Spatrick double_t // C99
4146035553Spatrick
4246035553Spatrick // C90
4346035553Spatrick
4446035553Spatrick floating_point abs(floating_point x);
4546035553Spatrick
4646035553Spatrick floating_point acos (arithmetic x);
4746035553Spatrick float acosf(float x);
4846035553Spatrick long double acosl(long double x);
4946035553Spatrick
5046035553Spatrick floating_point asin (arithmetic x);
5146035553Spatrick float asinf(float x);
5246035553Spatrick long double asinl(long double x);
5346035553Spatrick
5446035553Spatrick floating_point atan (arithmetic x);
5546035553Spatrick float atanf(float x);
5646035553Spatrick long double atanl(long double x);
5746035553Spatrick
5846035553Spatrick floating_point atan2 (arithmetic y, arithmetic x);
5946035553Spatrick float atan2f(float y, float x);
6046035553Spatrick long double atan2l(long double y, long double x);
6146035553Spatrick
6246035553Spatrick floating_point ceil (arithmetic x);
6346035553Spatrick float ceilf(float x);
6446035553Spatrick long double ceill(long double x);
6546035553Spatrick
6646035553Spatrick floating_point cos (arithmetic x);
6746035553Spatrick float cosf(float x);
6846035553Spatrick long double cosl(long double x);
6946035553Spatrick
7046035553Spatrick floating_point cosh (arithmetic x);
7146035553Spatrick float coshf(float x);
7246035553Spatrick long double coshl(long double x);
7346035553Spatrick
7446035553Spatrick floating_point exp (arithmetic x);
7546035553Spatrick float expf(float x);
7646035553Spatrick long double expl(long double x);
7746035553Spatrick
7846035553Spatrick floating_point fabs (arithmetic x);
7946035553Spatrick float fabsf(float x);
8046035553Spatrick long double fabsl(long double x);
8146035553Spatrick
8246035553Spatrick floating_point floor (arithmetic x);
8346035553Spatrick float floorf(float x);
8446035553Spatrick long double floorl(long double x);
8546035553Spatrick
8646035553Spatrick floating_point fmod (arithmetic x, arithmetic y);
8746035553Spatrick float fmodf(float x, float y);
8846035553Spatrick long double fmodl(long double x, long double y);
8946035553Spatrick
9046035553Spatrick floating_point frexp (arithmetic value, int* exp);
9146035553Spatrick float frexpf(float value, int* exp);
9246035553Spatrick long double frexpl(long double value, int* exp);
9346035553Spatrick
9446035553Spatrick floating_point ldexp (arithmetic value, int exp);
9546035553Spatrick float ldexpf(float value, int exp);
9646035553Spatrick long double ldexpl(long double value, int exp);
9746035553Spatrick
9846035553Spatrick floating_point log (arithmetic x);
9946035553Spatrick float logf(float x);
10046035553Spatrick long double logl(long double x);
10146035553Spatrick
10246035553Spatrick floating_point log10 (arithmetic x);
10346035553Spatrick float log10f(float x);
10446035553Spatrick long double log10l(long double x);
10546035553Spatrick
10646035553Spatrick floating_point modf (floating_point value, floating_point* iptr);
10746035553Spatrick float modff(float value, float* iptr);
10846035553Spatrick long double modfl(long double value, long double* iptr);
10946035553Spatrick
11046035553Spatrick floating_point pow (arithmetic x, arithmetic y);
11146035553Spatrick float powf(float x, float y);
11246035553Spatrick long double powl(long double x, long double y);
11346035553Spatrick
11446035553Spatrick floating_point sin (arithmetic x);
11546035553Spatrick float sinf(float x);
11646035553Spatrick long double sinl(long double x);
11746035553Spatrick
11846035553Spatrick floating_point sinh (arithmetic x);
11946035553Spatrick float sinhf(float x);
12046035553Spatrick long double sinhl(long double x);
12146035553Spatrick
12246035553Spatrick floating_point sqrt (arithmetic x);
12346035553Spatrick float sqrtf(float x);
12446035553Spatrick long double sqrtl(long double x);
12546035553Spatrick
12646035553Spatrick floating_point tan (arithmetic x);
12746035553Spatrick float tanf(float x);
12846035553Spatrick long double tanl(long double x);
12946035553Spatrick
13046035553Spatrick floating_point tanh (arithmetic x);
13146035553Spatrick float tanhf(float x);
13246035553Spatrick long double tanhl(long double x);
13346035553Spatrick
13446035553Spatrick // C99
13546035553Spatrick
13646035553Spatrick bool signbit(arithmetic x);
13746035553Spatrick
13846035553Spatrick int fpclassify(arithmetic x);
13946035553Spatrick
14046035553Spatrick bool isfinite(arithmetic x);
14146035553Spatrick bool isinf(arithmetic x);
14246035553Spatrick bool isnan(arithmetic x);
14346035553Spatrick bool isnormal(arithmetic x);
14446035553Spatrick
14546035553Spatrick bool isgreater(arithmetic x, arithmetic y);
14646035553Spatrick bool isgreaterequal(arithmetic x, arithmetic y);
14746035553Spatrick bool isless(arithmetic x, arithmetic y);
14846035553Spatrick bool islessequal(arithmetic x, arithmetic y);
14946035553Spatrick bool islessgreater(arithmetic x, arithmetic y);
15046035553Spatrick bool isunordered(arithmetic x, arithmetic y);
15146035553Spatrick
15246035553Spatrick floating_point acosh (arithmetic x);
15346035553Spatrick float acoshf(float x);
15446035553Spatrick long double acoshl(long double x);
15546035553Spatrick
15646035553Spatrick floating_point asinh (arithmetic x);
15746035553Spatrick float asinhf(float x);
15846035553Spatrick long double asinhl(long double x);
15946035553Spatrick
16046035553Spatrick floating_point atanh (arithmetic x);
16146035553Spatrick float atanhf(float x);
16246035553Spatrick long double atanhl(long double x);
16346035553Spatrick
16446035553Spatrick floating_point cbrt (arithmetic x);
16546035553Spatrick float cbrtf(float x);
16646035553Spatrick long double cbrtl(long double x);
16746035553Spatrick
16846035553Spatrick floating_point copysign (arithmetic x, arithmetic y);
16946035553Spatrick float copysignf(float x, float y);
17046035553Spatrick long double copysignl(long double x, long double y);
17146035553Spatrick
17246035553Spatrick floating_point erf (arithmetic x);
17346035553Spatrick float erff(float x);
17446035553Spatrick long double erfl(long double x);
17546035553Spatrick
17646035553Spatrick floating_point erfc (arithmetic x);
17746035553Spatrick float erfcf(float x);
17846035553Spatrick long double erfcl(long double x);
17946035553Spatrick
18046035553Spatrick floating_point exp2 (arithmetic x);
18146035553Spatrick float exp2f(float x);
18246035553Spatrick long double exp2l(long double x);
18346035553Spatrick
18446035553Spatrick floating_point expm1 (arithmetic x);
18546035553Spatrick float expm1f(float x);
18646035553Spatrick long double expm1l(long double x);
18746035553Spatrick
18846035553Spatrick floating_point fdim (arithmetic x, arithmetic y);
18946035553Spatrick float fdimf(float x, float y);
19046035553Spatrick long double fdiml(long double x, long double y);
19146035553Spatrick
19246035553Spatrick floating_point fma (arithmetic x, arithmetic y, arithmetic z);
19346035553Spatrick float fmaf(float x, float y, float z);
19446035553Spatrick long double fmal(long double x, long double y, long double z);
19546035553Spatrick
19646035553Spatrick floating_point fmax (arithmetic x, arithmetic y);
19746035553Spatrick float fmaxf(float x, float y);
19846035553Spatrick long double fmaxl(long double x, long double y);
19946035553Spatrick
20046035553Spatrick floating_point fmin (arithmetic x, arithmetic y);
20146035553Spatrick float fminf(float x, float y);
20246035553Spatrick long double fminl(long double x, long double y);
20346035553Spatrick
20446035553Spatrick floating_point hypot (arithmetic x, arithmetic y);
20546035553Spatrick float hypotf(float x, float y);
20646035553Spatrick long double hypotl(long double x, long double y);
20746035553Spatrick
20846035553Spatrick int ilogb (arithmetic x);
20946035553Spatrick int ilogbf(float x);
21046035553Spatrick int ilogbl(long double x);
21146035553Spatrick
21246035553Spatrick floating_point lgamma (arithmetic x);
21346035553Spatrick float lgammaf(float x);
21446035553Spatrick long double lgammal(long double x);
21546035553Spatrick
21646035553Spatrick long long llrint (arithmetic x);
21746035553Spatrick long long llrintf(float x);
21846035553Spatrick long long llrintl(long double x);
21946035553Spatrick
22046035553Spatrick long long llround (arithmetic x);
22146035553Spatrick long long llroundf(float x);
22246035553Spatrick long long llroundl(long double x);
22346035553Spatrick
22446035553Spatrick floating_point log1p (arithmetic x);
22546035553Spatrick float log1pf(float x);
22646035553Spatrick long double log1pl(long double x);
22746035553Spatrick
22846035553Spatrick floating_point log2 (arithmetic x);
22946035553Spatrick float log2f(float x);
23046035553Spatrick long double log2l(long double x);
23146035553Spatrick
23246035553Spatrick floating_point logb (arithmetic x);
23346035553Spatrick float logbf(float x);
23446035553Spatrick long double logbl(long double x);
23546035553Spatrick
23646035553Spatrick long lrint (arithmetic x);
23746035553Spatrick long lrintf(float x);
23846035553Spatrick long lrintl(long double x);
23946035553Spatrick
24046035553Spatrick long lround (arithmetic x);
24146035553Spatrick long lroundf(float x);
24246035553Spatrick long lroundl(long double x);
24346035553Spatrick
24446035553Spatrick double nan (const char* str);
24546035553Spatrick float nanf(const char* str);
24646035553Spatrick long double nanl(const char* str);
24746035553Spatrick
24846035553Spatrick floating_point nearbyint (arithmetic x);
24946035553Spatrick float nearbyintf(float x);
25046035553Spatrick long double nearbyintl(long double x);
25146035553Spatrick
25246035553Spatrick floating_point nextafter (arithmetic x, arithmetic y);
25346035553Spatrick float nextafterf(float x, float y);
25446035553Spatrick long double nextafterl(long double x, long double y);
25546035553Spatrick
25646035553Spatrick floating_point nexttoward (arithmetic x, long double y);
25746035553Spatrick float nexttowardf(float x, long double y);
25846035553Spatrick long double nexttowardl(long double x, long double y);
25946035553Spatrick
26046035553Spatrick floating_point remainder (arithmetic x, arithmetic y);
26146035553Spatrick float remainderf(float x, float y);
26246035553Spatrick long double remainderl(long double x, long double y);
26346035553Spatrick
26446035553Spatrick floating_point remquo (arithmetic x, arithmetic y, int* pquo);
26546035553Spatrick float remquof(float x, float y, int* pquo);
26646035553Spatrick long double remquol(long double x, long double y, int* pquo);
26746035553Spatrick
26846035553Spatrick floating_point rint (arithmetic x);
26946035553Spatrick float rintf(float x);
27046035553Spatrick long double rintl(long double x);
27146035553Spatrick
27246035553Spatrick floating_point round (arithmetic x);
27346035553Spatrick float roundf(float x);
27446035553Spatrick long double roundl(long double x);
27546035553Spatrick
27646035553Spatrick floating_point scalbln (arithmetic x, long ex);
27746035553Spatrick float scalblnf(float x, long ex);
27846035553Spatrick long double scalblnl(long double x, long ex);
27946035553Spatrick
28046035553Spatrick floating_point scalbn (arithmetic x, int ex);
28146035553Spatrick float scalbnf(float x, int ex);
28246035553Spatrick long double scalbnl(long double x, int ex);
28346035553Spatrick
28446035553Spatrick floating_point tgamma (arithmetic x);
28546035553Spatrick float tgammaf(float x);
28646035553Spatrick long double tgammal(long double x);
28746035553Spatrick
28846035553Spatrick floating_point trunc (arithmetic x);
28946035553Spatrick float truncf(float x);
29046035553Spatrick long double truncl(long double x);
29146035553Spatrick
29246035553Spatrick */
29346035553Spatrick
29446035553Spatrick #include <__config>
29546035553Spatrick
29646035553Spatrick #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29746035553Spatrick # pragma GCC system_header
29846035553Spatrick #endif
29946035553Spatrick
300*dc37c87aSrobert # if __has_include_next(<math.h>)
30146035553Spatrick # include_next <math.h>
302*dc37c87aSrobert # endif
30346035553Spatrick
30446035553Spatrick #ifdef __cplusplus
30546035553Spatrick
30646035553Spatrick // We support including .h headers inside 'extern "C"' contexts, so switch
30746035553Spatrick // back to C++ linkage before including these C++ headers.
30846035553Spatrick extern "C++" {
30946035553Spatrick
310*dc37c87aSrobert #include <__type_traits/enable_if.h>
311*dc37c87aSrobert #include <__type_traits/is_floating_point.h>
312*dc37c87aSrobert #include <__type_traits/is_integral.h>
313*dc37c87aSrobert #include <__type_traits/is_same.h>
314*dc37c87aSrobert #include <__type_traits/promote.h>
31546035553Spatrick #include <limits>
316*dc37c87aSrobert #include <stdlib.h>
317*dc37c87aSrobert
318*dc37c87aSrobert
319*dc37c87aSrobert # ifdef fpclassify
320*dc37c87aSrobert # undef fpclassify
321*dc37c87aSrobert # endif
322*dc37c87aSrobert
323*dc37c87aSrobert # ifdef signbit
324*dc37c87aSrobert # undef signbit
325*dc37c87aSrobert # endif
326*dc37c87aSrobert
327*dc37c87aSrobert # ifdef isfinite
328*dc37c87aSrobert # undef isfinite
329*dc37c87aSrobert # endif
330*dc37c87aSrobert
331*dc37c87aSrobert # ifdef isinf
332*dc37c87aSrobert # undef isinf
333*dc37c87aSrobert # endif
334*dc37c87aSrobert
335*dc37c87aSrobert # ifdef isnan
336*dc37c87aSrobert # undef isnan
337*dc37c87aSrobert # endif
338*dc37c87aSrobert
339*dc37c87aSrobert # ifdef isnormal
340*dc37c87aSrobert # undef isnormal
341*dc37c87aSrobert # endif
342*dc37c87aSrobert
343*dc37c87aSrobert # ifdef isgreater
344*dc37c87aSrobert # undef isgreater
345*dc37c87aSrobert # endif
346*dc37c87aSrobert
347*dc37c87aSrobert # ifdef isgreaterequal
348*dc37c87aSrobert # undef isgreaterequal
349*dc37c87aSrobert # endif
350*dc37c87aSrobert
351*dc37c87aSrobert # ifdef isless
352*dc37c87aSrobert # undef isless
353*dc37c87aSrobert # endif
354*dc37c87aSrobert
355*dc37c87aSrobert # ifdef islessequal
356*dc37c87aSrobert # undef islessequal
357*dc37c87aSrobert # endif
358*dc37c87aSrobert
359*dc37c87aSrobert # ifdef islessgreater
360*dc37c87aSrobert # undef islessgreater
361*dc37c87aSrobert # endif
362*dc37c87aSrobert
363*dc37c87aSrobert # ifdef isunordered
364*dc37c87aSrobert # undef isunordered
365*dc37c87aSrobert # endif
36646035553Spatrick
36746035553Spatrick // signbit
36846035553Spatrick
369*dc37c87aSrobert template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
signbit(_A1 __x)370*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
371*dc37c87aSrobert return __builtin_signbit(__x);
37246035553Spatrick }
37346035553Spatrick
374*dc37c87aSrobert template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && std::is_signed<_A1>::value, int> = 0>
signbit(_A1 __x)375*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
376*dc37c87aSrobert return __x < 0;
37746035553Spatrick }
37846035553Spatrick
379*dc37c87aSrobert template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && !std::is_signed<_A1>::value, int> = 0>
signbit(_A1)380*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT {
381*dc37c87aSrobert return false;
38246035553Spatrick }
38346035553Spatrick
38446035553Spatrick // fpclassify
38546035553Spatrick
386*dc37c87aSrobert template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
fpclassify(_A1 __x)387*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
388*dc37c87aSrobert return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
38946035553Spatrick }
39046035553Spatrick
391*dc37c87aSrobert template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
fpclassify(_A1 __x)392*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
393*dc37c87aSrobert return __x == 0 ? FP_ZERO : FP_NORMAL;
39446035553Spatrick }
39546035553Spatrick
396*dc37c87aSrobert // The MSVC runtime already provides these functions as templates
397*dc37c87aSrobert #ifndef _LIBCPP_MSVCRT
39846035553Spatrick
39946035553Spatrick // isfinite
40046035553Spatrick
401*dc37c87aSrobert template <class _A1,
402*dc37c87aSrobert std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
isfinite(_A1 __x)403*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT {
404*dc37c87aSrobert return __builtin_isfinite((typename std::__promote<_A1>::type)__x);
40546035553Spatrick }
40646035553Spatrick
407*dc37c87aSrobert template <class _A1,
408*dc37c87aSrobert std::__enable_if_t<std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, int> = 0>
isfinite(_A1)409*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT {
410*dc37c87aSrobert return true;
41146035553Spatrick }
41246035553Spatrick
41346035553Spatrick // isinf
41446035553Spatrick
415*dc37c87aSrobert template <class _A1,
416*dc37c87aSrobert std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
isinf(_A1 __x)417*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT {
418*dc37c87aSrobert return __builtin_isinf((typename std::__promote<_A1>::type)__x);
41946035553Spatrick }
42046035553Spatrick
42146035553Spatrick template <class _A1>
422*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
423*dc37c87aSrobert typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type
isinf(_A1)424*dc37c87aSrobert isinf(_A1) _NOEXCEPT {
425*dc37c87aSrobert return false;
426*dc37c87aSrobert }
42746035553Spatrick
42846035553Spatrick # ifdef _LIBCPP_PREFERRED_OVERLOAD
isinf(float __x)429*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT {
430*dc37c87aSrobert return __builtin_isinf(__x);
431*dc37c87aSrobert }
43246035553Spatrick
isinf(double __x)433*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT {
434*dc37c87aSrobert return __builtin_isinf(__x);
435*dc37c87aSrobert }
43646035553Spatrick
isinf(long double __x)437*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT {
438*dc37c87aSrobert return __builtin_isinf(__x);
439*dc37c87aSrobert }
44046035553Spatrick # endif
44146035553Spatrick
44246035553Spatrick // isnan
44346035553Spatrick
444*dc37c87aSrobert template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
isnan(_A1 __x)445*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT {
446*dc37c87aSrobert return __builtin_isnan(__x);
44746035553Spatrick }
44846035553Spatrick
449*dc37c87aSrobert template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
isnan(_A1)450*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT {
451*dc37c87aSrobert return false;
45246035553Spatrick }
45346035553Spatrick
45446035553Spatrick # ifdef _LIBCPP_PREFERRED_OVERLOAD
isnan(float __x)455*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT {
456*dc37c87aSrobert return __builtin_isnan(__x);
457*dc37c87aSrobert }
45846035553Spatrick
isnan(double __x)459*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT {
460*dc37c87aSrobert return __builtin_isnan(__x);
461*dc37c87aSrobert }
46246035553Spatrick
isnan(long double __x)463*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT {
464*dc37c87aSrobert return __builtin_isnan(__x);
465*dc37c87aSrobert }
46646035553Spatrick # endif
46746035553Spatrick
46846035553Spatrick // isnormal
46946035553Spatrick
470*dc37c87aSrobert template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
isnormal(_A1 __x)471*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
472*dc37c87aSrobert return __builtin_isnormal(__x);
47346035553Spatrick }
47446035553Spatrick
475*dc37c87aSrobert template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
isnormal(_A1 __x)476*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
477*dc37c87aSrobert return __x != 0;
47846035553Spatrick }
47946035553Spatrick
48046035553Spatrick // isgreater
48146035553Spatrick
482*dc37c87aSrobert template <class _A1,
483*dc37c87aSrobert class _A2,
484*dc37c87aSrobert std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
isgreater(_A1 __x,_A2 __y)485*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT {
48646035553Spatrick typedef typename std::__promote<_A1, _A2>::type type;
487*dc37c87aSrobert return __builtin_isgreater((type)__x, (type)__y);
48846035553Spatrick }
48946035553Spatrick
49046035553Spatrick // isgreaterequal
49146035553Spatrick
492*dc37c87aSrobert template <class _A1,
493*dc37c87aSrobert class _A2,
494*dc37c87aSrobert std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
isgreaterequal(_A1 __x,_A2 __y)495*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {
49646035553Spatrick typedef typename std::__promote<_A1, _A2>::type type;
497*dc37c87aSrobert return __builtin_isgreaterequal((type)__x, (type)__y);
49846035553Spatrick }
49946035553Spatrick
50046035553Spatrick // isless
50146035553Spatrick
502*dc37c87aSrobert template <class _A1,
503*dc37c87aSrobert class _A2,
504*dc37c87aSrobert std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
isless(_A1 __x,_A2 __y)505*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT {
50646035553Spatrick typedef typename std::__promote<_A1, _A2>::type type;
507*dc37c87aSrobert return __builtin_isless((type)__x, (type)__y);
50846035553Spatrick }
50946035553Spatrick
51046035553Spatrick // islessequal
51146035553Spatrick
512*dc37c87aSrobert template <class _A1,
513*dc37c87aSrobert class _A2,
514*dc37c87aSrobert std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
islessequal(_A1 __x,_A2 __y)515*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT {
51646035553Spatrick typedef typename std::__promote<_A1, _A2>::type type;
517*dc37c87aSrobert return __builtin_islessequal((type)__x, (type)__y);
51846035553Spatrick }
51946035553Spatrick
52046035553Spatrick // islessgreater
52146035553Spatrick
522*dc37c87aSrobert template <class _A1,
523*dc37c87aSrobert class _A2,
524*dc37c87aSrobert std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
islessgreater(_A1 __x,_A2 __y)525*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {
52646035553Spatrick typedef typename std::__promote<_A1, _A2>::type type;
527*dc37c87aSrobert return __builtin_islessgreater((type)__x, (type)__y);
52846035553Spatrick }
52946035553Spatrick
53046035553Spatrick // isunordered
53146035553Spatrick
532*dc37c87aSrobert template <class _A1,
533*dc37c87aSrobert class _A2,
534*dc37c87aSrobert std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
isunordered(_A1 __x,_A2 __y)535*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT {
53646035553Spatrick typedef typename std::__promote<_A1, _A2>::type type;
537*dc37c87aSrobert return __builtin_isunordered((type)__x, (type)__y);
53846035553Spatrick }
53946035553Spatrick
540*dc37c87aSrobert #endif // _LIBCPP_MSVCRT
54146035553Spatrick
54246035553Spatrick // abs
543862558c2Skettenis //
544862558c2Skettenis // handled in stdlib.h
54546035553Spatrick
54646035553Spatrick // div
547862558c2Skettenis //
548862558c2Skettenis // handled in stdlib.h
54946035553Spatrick
550*dc37c87aSrobert // We have to provide double overloads for <math.h> to work on platforms that don't provide the full set of math
551*dc37c87aSrobert // functions. To make the overload set work with multiple functions that take the same arguments, we make our overloads
552*dc37c87aSrobert // templates. Functions are preferred over function templates during overload resolution, which means that our overload
553*dc37c87aSrobert // will only be selected when the C library doesn't provide one.
554*dc37c87aSrobert
55546035553Spatrick // acos
55646035553Spatrick
557*dc37c87aSrobert # if !defined(__sun__)
acos(float __x)558*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return __builtin_acosf(__x);}
559*dc37c87aSrobert
560*dc37c87aSrobert template <class = int>
acos(double __x)561*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double acos(double __x) _NOEXCEPT {
562*dc37c87aSrobert return __builtin_acos(__x);
563*dc37c87aSrobert }
564*dc37c87aSrobert
acos(long double __x)565*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT {return __builtin_acosl(__x);}
56646035553Spatrick # endif
56746035553Spatrick
56846035553Spatrick template <class _A1>
569*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
57046035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
acos(_A1 __x)571*dc37c87aSrobert acos(_A1 __x) _NOEXCEPT {return __builtin_acos((double)__x);}
57246035553Spatrick
57346035553Spatrick // asin
57446035553Spatrick
575*dc37c87aSrobert # if !defined(__sun__)
asin(float __x)576*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return __builtin_asinf(__x);}
577*dc37c87aSrobert
578*dc37c87aSrobert template <class = int>
asin(double __x)579*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double asin(double __x) _NOEXCEPT {
580*dc37c87aSrobert return __builtin_asin(__x);
581*dc37c87aSrobert }
582*dc37c87aSrobert
asin(long double __x)583*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT {return __builtin_asinl(__x);}
58446035553Spatrick # endif
58546035553Spatrick
58646035553Spatrick template <class _A1>
587*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
58846035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
asin(_A1 __x)589*dc37c87aSrobert asin(_A1 __x) _NOEXCEPT {return __builtin_asin((double)__x);}
59046035553Spatrick
59146035553Spatrick // atan
59246035553Spatrick
593*dc37c87aSrobert # if !defined(__sun__)
atan(float __x)594*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return __builtin_atanf(__x);}
595*dc37c87aSrobert
596*dc37c87aSrobert template <class = int>
atan(double __x)597*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double atan(double __x) _NOEXCEPT {
598*dc37c87aSrobert return __builtin_atan(__x);
599*dc37c87aSrobert }
600*dc37c87aSrobert
atan(long double __x)601*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT {return __builtin_atanl(__x);}
60246035553Spatrick # endif
60346035553Spatrick
60446035553Spatrick template <class _A1>
605*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
60646035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
atan(_A1 __x)607*dc37c87aSrobert atan(_A1 __x) _NOEXCEPT {return __builtin_atan((double)__x);}
60846035553Spatrick
60946035553Spatrick // atan2
61046035553Spatrick
611*dc37c87aSrobert # if !defined(__sun__)
atan2(float __y,float __x)612*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return __builtin_atan2f(__y, __x);}
613*dc37c87aSrobert
614*dc37c87aSrobert template <class = int>
atan2(double __x,double __y)615*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double atan2(double __x, double __y) _NOEXCEPT {
616*dc37c87aSrobert return __builtin_atan2(__x, __y);
617*dc37c87aSrobert }
618*dc37c87aSrobert
atan2(long double __y,long double __x)619*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) _NOEXCEPT {return __builtin_atan2l(__y, __x);}
62046035553Spatrick # endif
62146035553Spatrick
62246035553Spatrick template <class _A1, class _A2>
623*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
624*dc37c87aSrobert typename std::__enable_if_t
62546035553Spatrick <
62646035553Spatrick std::is_arithmetic<_A1>::value &&
62746035553Spatrick std::is_arithmetic<_A2>::value,
62846035553Spatrick std::__promote<_A1, _A2>
62946035553Spatrick >::type
atan2(_A1 __y,_A2 __x)630*dc37c87aSrobert atan2(_A1 __y, _A2 __x) _NOEXCEPT
63146035553Spatrick {
63246035553Spatrick typedef typename std::__promote<_A1, _A2>::type __result_type;
63346035553Spatrick static_assert((!(std::_IsSame<_A1, __result_type>::value &&
63446035553Spatrick std::_IsSame<_A2, __result_type>::value)), "");
635*dc37c87aSrobert return ::atan2((__result_type)__y, (__result_type)__x);
63646035553Spatrick }
63746035553Spatrick
63846035553Spatrick // ceil
63946035553Spatrick
640*dc37c87aSrobert # if !defined(__sun__)
ceil(float __x)641*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return __builtin_ceilf(__x);}
642*dc37c87aSrobert
643*dc37c87aSrobert template <class = int>
ceil(double __x)644*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT {
645*dc37c87aSrobert return __builtin_ceil(__x);
646*dc37c87aSrobert }
647*dc37c87aSrobert
ceil(long double __x)648*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return __builtin_ceill(__x);}
64946035553Spatrick # endif
65046035553Spatrick
65146035553Spatrick template <class _A1>
652*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
65346035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
ceil(_A1 __x)654*dc37c87aSrobert ceil(_A1 __x) _NOEXCEPT {return __builtin_ceil((double)__x);}
65546035553Spatrick
65646035553Spatrick // cos
65746035553Spatrick
658*dc37c87aSrobert # if !defined(__sun__)
cos(float __x)659*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return __builtin_cosf(__x);}
660*dc37c87aSrobert
661*dc37c87aSrobert template <class = int>
cos(double __x)662*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double cos(double __x) _NOEXCEPT {
663*dc37c87aSrobert return __builtin_cos(__x);
664*dc37c87aSrobert }
665*dc37c87aSrobert
cos(long double __x)666*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT {return __builtin_cosl(__x);}
66746035553Spatrick # endif
66846035553Spatrick
66946035553Spatrick template <class _A1>
670*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
67146035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
cos(_A1 __x)672*dc37c87aSrobert cos(_A1 __x) _NOEXCEPT {return __builtin_cos((double)__x);}
67346035553Spatrick
67446035553Spatrick // cosh
67546035553Spatrick
676*dc37c87aSrobert # if !defined(__sun__)
cosh(float __x)677*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return __builtin_coshf(__x);}
678*dc37c87aSrobert
679*dc37c87aSrobert template <class = int>
cosh(double __x)680*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double cosh(double __x) _NOEXCEPT {
681*dc37c87aSrobert return __builtin_cosh(__x);
682*dc37c87aSrobert }
683*dc37c87aSrobert
cosh(long double __x)684*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT {return __builtin_coshl(__x);}
68546035553Spatrick # endif
68646035553Spatrick
68746035553Spatrick template <class _A1>
688*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
68946035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
cosh(_A1 __x)690*dc37c87aSrobert cosh(_A1 __x) _NOEXCEPT {return __builtin_cosh((double)__x);}
69146035553Spatrick
69246035553Spatrick // exp
69346035553Spatrick
694*dc37c87aSrobert # if !defined(__sun__)
exp(float __x)695*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return __builtin_expf(__x);}
696*dc37c87aSrobert
697*dc37c87aSrobert template <class = int>
exp(double __x)698*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double exp(double __x) _NOEXCEPT {
699*dc37c87aSrobert return __builtin_exp(__x);
700*dc37c87aSrobert }
701*dc37c87aSrobert
exp(long double __x)702*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT {return __builtin_expl(__x);}
70346035553Spatrick # endif
70446035553Spatrick
70546035553Spatrick template <class _A1>
706*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
70746035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
exp(_A1 __x)708*dc37c87aSrobert exp(_A1 __x) _NOEXCEPT {return __builtin_exp((double)__x);}
70946035553Spatrick
71046035553Spatrick // fabs
71146035553Spatrick
712*dc37c87aSrobert # if !defined(__sun__)
fabs(float __x)713*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return __builtin_fabsf(__x);}
714*dc37c87aSrobert
715*dc37c87aSrobert template <class = int>
fabs(double __x)716*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT {
717*dc37c87aSrobert return __builtin_fabs(__x);
718*dc37c87aSrobert }
719*dc37c87aSrobert
fabs(long double __x)720*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return __builtin_fabsl(__x);}
72146035553Spatrick # endif
72246035553Spatrick
72346035553Spatrick template <class _A1>
724*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
72546035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
fabs(_A1 __x)726*dc37c87aSrobert fabs(_A1 __x) _NOEXCEPT {return __builtin_fabs((double)__x);}
72746035553Spatrick
72846035553Spatrick // floor
72946035553Spatrick
730*dc37c87aSrobert # if !defined(__sun__)
floor(float __x)731*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return __builtin_floorf(__x);}
732*dc37c87aSrobert
733*dc37c87aSrobert template <class = int>
floor(double __x)734*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT {
735*dc37c87aSrobert return __builtin_floor(__x);
736*dc37c87aSrobert }
737*dc37c87aSrobert
floor(long double __x)738*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return __builtin_floorl(__x);}
73946035553Spatrick # endif
74046035553Spatrick
74146035553Spatrick template <class _A1>
742*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
74346035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
floor(_A1 __x)744*dc37c87aSrobert floor(_A1 __x) _NOEXCEPT {return __builtin_floor((double)__x);}
74546035553Spatrick
74646035553Spatrick // fmod
74746035553Spatrick
748*dc37c87aSrobert # if !defined(__sun__)
fmod(float __x,float __y)749*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return __builtin_fmodf(__x, __y);}
750*dc37c87aSrobert
751*dc37c87aSrobert template <class = int>
fmod(double __x,double __y)752*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double fmod(double __x, double __y) _NOEXCEPT {
753*dc37c87aSrobert return __builtin_fmod(__x, __y);
754*dc37c87aSrobert }
755*dc37c87aSrobert
fmod(long double __x,long double __y)756*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) _NOEXCEPT {return __builtin_fmodl(__x, __y);}
75746035553Spatrick # endif
75846035553Spatrick
75946035553Spatrick template <class _A1, class _A2>
760*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
761*dc37c87aSrobert typename std::__enable_if_t
76246035553Spatrick <
76346035553Spatrick std::is_arithmetic<_A1>::value &&
76446035553Spatrick std::is_arithmetic<_A2>::value,
76546035553Spatrick std::__promote<_A1, _A2>
76646035553Spatrick >::type
fmod(_A1 __x,_A2 __y)767*dc37c87aSrobert fmod(_A1 __x, _A2 __y) _NOEXCEPT
76846035553Spatrick {
76946035553Spatrick typedef typename std::__promote<_A1, _A2>::type __result_type;
77046035553Spatrick static_assert((!(std::_IsSame<_A1, __result_type>::value &&
77146035553Spatrick std::_IsSame<_A2, __result_type>::value)), "");
772*dc37c87aSrobert return ::fmod((__result_type)__x, (__result_type)__y);
77346035553Spatrick }
77446035553Spatrick
77546035553Spatrick // frexp
77646035553Spatrick
777*dc37c87aSrobert # if !defined(__sun__)
frexp(float __x,int * __e)778*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return __builtin_frexpf(__x, __e);}
779*dc37c87aSrobert
780*dc37c87aSrobert template <class = int>
frexp(double __x,int * __e)781*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double frexp(double __x, int* __e) _NOEXCEPT {
782*dc37c87aSrobert return __builtin_frexp(__x, __e);
783*dc37c87aSrobert }
784*dc37c87aSrobert
frexp(long double __x,int * __e)785*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {return __builtin_frexpl(__x, __e);}
78646035553Spatrick # endif
78746035553Spatrick
78846035553Spatrick template <class _A1>
789*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
79046035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
frexp(_A1 __x,int * __e)791*dc37c87aSrobert frexp(_A1 __x, int* __e) _NOEXCEPT {return __builtin_frexp((double)__x, __e);}
79246035553Spatrick
79346035553Spatrick // ldexp
79446035553Spatrick
795*dc37c87aSrobert # if !defined(__sun__)
ldexp(float __x,int __e)796*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return __builtin_ldexpf(__x, __e);}
797*dc37c87aSrobert
798*dc37c87aSrobert template <class = int>
ldexp(double __x,int __e)799*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double ldexp(double __x, int __e) _NOEXCEPT {
800*dc37c87aSrobert return __builtin_ldexp(__x, __e);
801*dc37c87aSrobert }
802*dc37c87aSrobert
ldexp(long double __x,int __e)803*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {return __builtin_ldexpl(__x, __e);}
80446035553Spatrick # endif
80546035553Spatrick
80646035553Spatrick template <class _A1>
807*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
80846035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
ldexp(_A1 __x,int __e)809*dc37c87aSrobert ldexp(_A1 __x, int __e) _NOEXCEPT {return __builtin_ldexp((double)__x, __e);}
81046035553Spatrick
81146035553Spatrick // log
81246035553Spatrick
813*dc37c87aSrobert # if !defined(__sun__)
log(float __x)814*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return __builtin_logf(__x);}
815*dc37c87aSrobert
816*dc37c87aSrobert template <class = int>
log(double __x)817*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double log(double __x) _NOEXCEPT {
818*dc37c87aSrobert return __builtin_log(__x);
819*dc37c87aSrobert }
820*dc37c87aSrobert
log(long double __x)821*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT {return __builtin_logl(__x);}
82246035553Spatrick # endif
82346035553Spatrick
82446035553Spatrick template <class _A1>
825*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
82646035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
log(_A1 __x)827*dc37c87aSrobert log(_A1 __x) _NOEXCEPT {return __builtin_log((double)__x);}
82846035553Spatrick
82946035553Spatrick // log10
83046035553Spatrick
831*dc37c87aSrobert # if !defined(__sun__)
log10(float __x)832*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return __builtin_log10f(__x);}
833*dc37c87aSrobert
834*dc37c87aSrobert
835*dc37c87aSrobert template <class = int>
log10(double __x)836*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double log10(double __x) _NOEXCEPT {
837*dc37c87aSrobert return __builtin_log10(__x);
838*dc37c87aSrobert }
839*dc37c87aSrobert
log10(long double __x)840*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT {return __builtin_log10l(__x);}
84146035553Spatrick # endif
84246035553Spatrick
84346035553Spatrick template <class _A1>
844*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
84546035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
log10(_A1 __x)846*dc37c87aSrobert log10(_A1 __x) _NOEXCEPT {return __builtin_log10((double)__x);}
84746035553Spatrick
84846035553Spatrick // modf
84946035553Spatrick
850*dc37c87aSrobert # if !defined(__sun__)
modf(float __x,float * __y)851*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return __builtin_modff(__x, __y);}
852*dc37c87aSrobert
853*dc37c87aSrobert template <class = int>
modf(double __x,double * __y)854*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double modf(double __x, double* __y) _NOEXCEPT {
855*dc37c87aSrobert return __builtin_modf(__x, __y);
856*dc37c87aSrobert }
857*dc37c87aSrobert
modf(long double __x,long double * __y)858*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double modf(long double __x, long double* __y) _NOEXCEPT {return __builtin_modfl(__x, __y);}
85946035553Spatrick # endif
86046035553Spatrick
86146035553Spatrick // pow
86246035553Spatrick
863*dc37c87aSrobert # if !defined(__sun__)
pow(float __x,float __y)864*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return __builtin_powf(__x, __y);}
865*dc37c87aSrobert
866*dc37c87aSrobert template <class = int>
pow(double __x,double __y)867*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double pow(double __x, double __y) _NOEXCEPT {
868*dc37c87aSrobert return __builtin_pow(__x, __y);
869*dc37c87aSrobert }
870*dc37c87aSrobert
pow(long double __x,long double __y)871*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _NOEXCEPT {return __builtin_powl(__x, __y);}
87246035553Spatrick # endif
87346035553Spatrick
87446035553Spatrick template <class _A1, class _A2>
875*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
876*dc37c87aSrobert typename std::__enable_if_t
87746035553Spatrick <
87846035553Spatrick std::is_arithmetic<_A1>::value &&
87946035553Spatrick std::is_arithmetic<_A2>::value,
88046035553Spatrick std::__promote<_A1, _A2>
88146035553Spatrick >::type
pow(_A1 __x,_A2 __y)882*dc37c87aSrobert pow(_A1 __x, _A2 __y) _NOEXCEPT
88346035553Spatrick {
88446035553Spatrick typedef typename std::__promote<_A1, _A2>::type __result_type;
88546035553Spatrick static_assert((!(std::_IsSame<_A1, __result_type>::value &&
88646035553Spatrick std::_IsSame<_A2, __result_type>::value)), "");
887*dc37c87aSrobert return ::pow((__result_type)__x, (__result_type)__y);
88846035553Spatrick }
88946035553Spatrick
89046035553Spatrick // sin
89146035553Spatrick
892*dc37c87aSrobert # if !defined(__sun__)
sin(float __x)893*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return __builtin_sinf(__x);}
894*dc37c87aSrobert
895*dc37c87aSrobert template <class = int>
sin(double __x)896*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double sin(double __x) _NOEXCEPT {
897*dc37c87aSrobert return __builtin_sin(__x);
898*dc37c87aSrobert }
899*dc37c87aSrobert
sin(long double __x)900*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT {return __builtin_sinl(__x);}
90146035553Spatrick #endif
90246035553Spatrick
90346035553Spatrick template <class _A1>
904*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
90546035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
sin(_A1 __x)906*dc37c87aSrobert sin(_A1 __x) _NOEXCEPT {return __builtin_sin((double)__x);}
90746035553Spatrick
90846035553Spatrick // sinh
90946035553Spatrick
910*dc37c87aSrobert # if !defined(__sun__)
sinh(float __x)911*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return __builtin_sinhf(__x);}
912*dc37c87aSrobert
913*dc37c87aSrobert template <class = int>
sinh(double __x)914*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double sinh(double __x) _NOEXCEPT {
915*dc37c87aSrobert return __builtin_sinh(__x);
916*dc37c87aSrobert }
917*dc37c87aSrobert
sinh(long double __x)918*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT {return __builtin_sinhl(__x);}
91946035553Spatrick # endif
92046035553Spatrick
92146035553Spatrick template <class _A1>
922*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
92346035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
sinh(_A1 __x)924*dc37c87aSrobert sinh(_A1 __x) _NOEXCEPT {return __builtin_sinh((double)__x);}
92546035553Spatrick
92646035553Spatrick // sqrt
92746035553Spatrick
928*dc37c87aSrobert # if !defined(__sun__)
sqrt(float __x)929*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return __builtin_sqrtf(__x);}
930*dc37c87aSrobert
931*dc37c87aSrobert template <class = int>
sqrt(double __x)932*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double sqrt(double __x) _NOEXCEPT {
933*dc37c87aSrobert return __builtin_sqrt(__x);
934*dc37c87aSrobert }
935*dc37c87aSrobert
sqrt(long double __x)936*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT {return __builtin_sqrtl(__x);}
93746035553Spatrick # endif
93846035553Spatrick
93946035553Spatrick template <class _A1>
940*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
94146035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
sqrt(_A1 __x)942*dc37c87aSrobert sqrt(_A1 __x) _NOEXCEPT {return __builtin_sqrt((double)__x);}
94346035553Spatrick
94446035553Spatrick // tan
94546035553Spatrick
946*dc37c87aSrobert # if !defined(__sun__)
tan(float __x)947*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return __builtin_tanf(__x);}
948*dc37c87aSrobert
949*dc37c87aSrobert template <class = int>
tan(double __x)950*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double tan(double __x) _NOEXCEPT {
951*dc37c87aSrobert return __builtin_tan(__x);
952*dc37c87aSrobert }
953*dc37c87aSrobert
tan(long double __x)954*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT {return __builtin_tanl(__x);}
95546035553Spatrick # endif
95646035553Spatrick
95746035553Spatrick template <class _A1>
958*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
95946035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
tan(_A1 __x)960*dc37c87aSrobert tan(_A1 __x) _NOEXCEPT {return __builtin_tan((double)__x);}
96146035553Spatrick
96246035553Spatrick // tanh
96346035553Spatrick
964*dc37c87aSrobert # if !defined(__sun__)
tanh(float __x)965*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return __builtin_tanhf(__x);}
966*dc37c87aSrobert
967*dc37c87aSrobert template <class = int>
tanh(double __x)968*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double tanh(double __x) _NOEXCEPT {
969*dc37c87aSrobert return __builtin_tanh(__x);
970*dc37c87aSrobert }
971*dc37c87aSrobert
tanh(long double __x)972*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT {return __builtin_tanhl(__x);}
97346035553Spatrick # endif
97446035553Spatrick
97546035553Spatrick template <class _A1>
976*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
97746035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
tanh(_A1 __x)978*dc37c87aSrobert tanh(_A1 __x) _NOEXCEPT {return __builtin_tanh((double)__x);}
97946035553Spatrick
98046035553Spatrick // acosh
98146035553Spatrick
acosh(float __x)982*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return __builtin_acoshf(__x);}
983*dc37c87aSrobert
984*dc37c87aSrobert template <class = int>
acosh(double __x)985*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double acosh(double __x) _NOEXCEPT {
986*dc37c87aSrobert return __builtin_acosh(__x);
987*dc37c87aSrobert }
988*dc37c87aSrobert
acosh(long double __x)989*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT {return __builtin_acoshl(__x);}
99046035553Spatrick
99146035553Spatrick template <class _A1>
992*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
99346035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
acosh(_A1 __x)994*dc37c87aSrobert acosh(_A1 __x) _NOEXCEPT {return __builtin_acosh((double)__x);}
99546035553Spatrick
99646035553Spatrick // asinh
99746035553Spatrick
asinh(float __x)998*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return __builtin_asinhf(__x);}
999*dc37c87aSrobert
1000*dc37c87aSrobert template <class = int>
asinh(double __x)1001*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double asinh(double __x) _NOEXCEPT {
1002*dc37c87aSrobert return __builtin_asinh(__x);
1003*dc37c87aSrobert }
1004*dc37c87aSrobert
asinh(long double __x)1005*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT {return __builtin_asinhl(__x);}
100646035553Spatrick
100746035553Spatrick template <class _A1>
1008*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
100946035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
asinh(_A1 __x)1010*dc37c87aSrobert asinh(_A1 __x) _NOEXCEPT {return __builtin_asinh((double)__x);}
101146035553Spatrick
101246035553Spatrick // atanh
101346035553Spatrick
atanh(float __x)1014*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return __builtin_atanhf(__x);}
1015*dc37c87aSrobert
1016*dc37c87aSrobert template <class = int>
atanh(double __x)1017*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double atanh(double __x) _NOEXCEPT {
1018*dc37c87aSrobert return __builtin_atanh(__x);
1019*dc37c87aSrobert }
1020*dc37c87aSrobert
atanh(long double __x)1021*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT {return __builtin_atanhl(__x);}
102246035553Spatrick
102346035553Spatrick template <class _A1>
1024*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
102546035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
atanh(_A1 __x)1026*dc37c87aSrobert atanh(_A1 __x) _NOEXCEPT {return __builtin_atanh((double)__x);}
102746035553Spatrick
102846035553Spatrick // cbrt
102946035553Spatrick
cbrt(float __x)1030*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return __builtin_cbrtf(__x);}
1031*dc37c87aSrobert
1032*dc37c87aSrobert template <class = int>
cbrt(double __x)1033*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT {
1034*dc37c87aSrobert return __builtin_cbrt(__x);
1035*dc37c87aSrobert }
1036*dc37c87aSrobert
cbrt(long double __x)1037*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {return __builtin_cbrtl(__x);}
103846035553Spatrick
103946035553Spatrick template <class _A1>
1040*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
104146035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
cbrt(_A1 __x)1042*dc37c87aSrobert cbrt(_A1 __x) _NOEXCEPT {return __builtin_cbrt((double)__x);}
104346035553Spatrick
104446035553Spatrick // copysign
104546035553Spatrick
copysign(float __x,float __y)1046*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT {
1047*dc37c87aSrobert return ::__builtin_copysignf(__x, __y);
104846035553Spatrick }
1049a0747c9fSpatrick
copysign(long double __x,long double __y)1050*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT {
1051*dc37c87aSrobert return ::__builtin_copysignl(__x, __y);
1052a0747c9fSpatrick }
1053a0747c9fSpatrick
1054a0747c9fSpatrick template <class _A1, class _A2>
1055*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
1056*dc37c87aSrobert typename std::__enable_if_t
1057a0747c9fSpatrick <
1058a0747c9fSpatrick std::is_arithmetic<_A1>::value &&
1059a0747c9fSpatrick std::is_arithmetic<_A2>::value,
1060a0747c9fSpatrick std::__promote<_A1, _A2>
1061a0747c9fSpatrick >::type
copysign(_A1 __x,_A2 __y)1062*dc37c87aSrobert copysign(_A1 __x, _A2 __y) _NOEXCEPT {
1063*dc37c87aSrobert return ::__builtin_copysign(__x, __y);
106446035553Spatrick }
106546035553Spatrick
106646035553Spatrick // erf
106746035553Spatrick
erf(float __x)1068*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return __builtin_erff(__x);}
1069*dc37c87aSrobert
1070*dc37c87aSrobert template <class = int>
erf(double __x)1071*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double erf(double __x) _NOEXCEPT {
1072*dc37c87aSrobert return __builtin_erf(__x);
1073*dc37c87aSrobert }
1074*dc37c87aSrobert
erf(long double __x)1075*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT {return __builtin_erfl(__x);}
107646035553Spatrick
107746035553Spatrick template <class _A1>
1078*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
107946035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
erf(_A1 __x)1080*dc37c87aSrobert erf(_A1 __x) _NOEXCEPT {return __builtin_erf((double)__x);}
108146035553Spatrick
108246035553Spatrick // erfc
108346035553Spatrick
erfc(float __x)1084*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return __builtin_erfcf(__x);}
1085*dc37c87aSrobert
1086*dc37c87aSrobert template <class = int>
erfc(double __x)1087*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double erfc(double __x) _NOEXCEPT {
1088*dc37c87aSrobert return __builtin_erfc(__x);
1089*dc37c87aSrobert }
1090*dc37c87aSrobert
erfc(long double __x)1091*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT {return __builtin_erfcl(__x);}
109246035553Spatrick
109346035553Spatrick template <class _A1>
1094*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
109546035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
erfc(_A1 __x)1096*dc37c87aSrobert erfc(_A1 __x) _NOEXCEPT {return __builtin_erfc((double)__x);}
109746035553Spatrick
109846035553Spatrick // exp2
109946035553Spatrick
exp2(float __x)1100*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return __builtin_exp2f(__x);}
1101*dc37c87aSrobert
1102*dc37c87aSrobert template <class = int>
exp2(double __x)1103*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double exp2(double __x) _NOEXCEPT {
1104*dc37c87aSrobert return __builtin_exp2(__x);
1105*dc37c87aSrobert }
1106*dc37c87aSrobert
exp2(long double __x)1107*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT {return __builtin_exp2l(__x);}
110846035553Spatrick
110946035553Spatrick template <class _A1>
1110*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
111146035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
exp2(_A1 __x)1112*dc37c87aSrobert exp2(_A1 __x) _NOEXCEPT {return __builtin_exp2((double)__x);}
111346035553Spatrick
111446035553Spatrick // expm1
111546035553Spatrick
expm1(float __x)1116*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return __builtin_expm1f(__x);}
1117*dc37c87aSrobert
1118*dc37c87aSrobert template <class = int>
expm1(double __x)1119*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double expm1(double __x) _NOEXCEPT {
1120*dc37c87aSrobert return __builtin_expm1(__x);
1121*dc37c87aSrobert }
1122*dc37c87aSrobert
expm1(long double __x)1123*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT {return __builtin_expm1l(__x);}
112446035553Spatrick
112546035553Spatrick template <class _A1>
1126*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
112746035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
expm1(_A1 __x)1128*dc37c87aSrobert expm1(_A1 __x) _NOEXCEPT {return __builtin_expm1((double)__x);}
112946035553Spatrick
113046035553Spatrick // fdim
113146035553Spatrick
fdim(float __x,float __y)1132*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return __builtin_fdimf(__x, __y);}
1133*dc37c87aSrobert
1134*dc37c87aSrobert template <class = int>
fdim(double __x,double __y)1135*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double fdim(double __x, double __y) _NOEXCEPT {
1136*dc37c87aSrobert return __builtin_fdim(__x, __y);
1137*dc37c87aSrobert }
1138*dc37c87aSrobert
fdim(long double __x,long double __y)1139*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) _NOEXCEPT {return __builtin_fdiml(__x, __y);}
114046035553Spatrick
114146035553Spatrick template <class _A1, class _A2>
1142*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
1143*dc37c87aSrobert typename std::__enable_if_t
114446035553Spatrick <
114546035553Spatrick std::is_arithmetic<_A1>::value &&
114646035553Spatrick std::is_arithmetic<_A2>::value,
114746035553Spatrick std::__promote<_A1, _A2>
114846035553Spatrick >::type
fdim(_A1 __x,_A2 __y)1149*dc37c87aSrobert fdim(_A1 __x, _A2 __y) _NOEXCEPT
115046035553Spatrick {
115146035553Spatrick typedef typename std::__promote<_A1, _A2>::type __result_type;
115246035553Spatrick static_assert((!(std::_IsSame<_A1, __result_type>::value &&
115346035553Spatrick std::_IsSame<_A2, __result_type>::value)), "");
1154*dc37c87aSrobert return ::fdim((__result_type)__x, (__result_type)__y);
115546035553Spatrick }
115646035553Spatrick
115746035553Spatrick // fma
115846035553Spatrick
fma(float __x,float __y,float __z)1159*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT
1160a0747c9fSpatrick {
1161*dc37c87aSrobert return __builtin_fmaf(__x, __y, __z);
1162a0747c9fSpatrick }
1163*dc37c87aSrobert
1164*dc37c87aSrobert
1165*dc37c87aSrobert template <class = int>
fma(double __x,double __y,double __z)1166*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double fma(double __x, double __y, double __z) _NOEXCEPT {
1167*dc37c87aSrobert return __builtin_fma(__x, __y, __z);
1168*dc37c87aSrobert }
1169*dc37c87aSrobert
fma(long double __x,long double __y,long double __z)1170*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT
1171a0747c9fSpatrick {
1172*dc37c87aSrobert return __builtin_fmal(__x, __y, __z);
1173a0747c9fSpatrick }
117446035553Spatrick
117546035553Spatrick template <class _A1, class _A2, class _A3>
1176*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
1177*dc37c87aSrobert typename std::__enable_if_t
117846035553Spatrick <
117946035553Spatrick std::is_arithmetic<_A1>::value &&
118046035553Spatrick std::is_arithmetic<_A2>::value &&
118146035553Spatrick std::is_arithmetic<_A3>::value,
118246035553Spatrick std::__promote<_A1, _A2, _A3>
118346035553Spatrick >::type
fma(_A1 __x,_A2 __y,_A3 __z)1184*dc37c87aSrobert fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT
118546035553Spatrick {
118646035553Spatrick typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
118746035553Spatrick static_assert((!(std::_IsSame<_A1, __result_type>::value &&
118846035553Spatrick std::_IsSame<_A2, __result_type>::value &&
118946035553Spatrick std::_IsSame<_A3, __result_type>::value)), "");
1190*dc37c87aSrobert return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
119146035553Spatrick }
119246035553Spatrick
119346035553Spatrick // fmax
119446035553Spatrick
fmax(float __x,float __y)1195*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return __builtin_fmaxf(__x, __y);}
1196*dc37c87aSrobert
1197*dc37c87aSrobert template <class = int>
fmax(double __x,double __y)1198*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT {
1199*dc37c87aSrobert return __builtin_fmax(__x, __y);
1200*dc37c87aSrobert }
1201*dc37c87aSrobert
fmax(long double __x,long double __y)1202*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT {return __builtin_fmaxl(__x, __y);}
120346035553Spatrick
120446035553Spatrick template <class _A1, class _A2>
1205*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
1206*dc37c87aSrobert typename std::__enable_if_t
120746035553Spatrick <
120846035553Spatrick std::is_arithmetic<_A1>::value &&
120946035553Spatrick std::is_arithmetic<_A2>::value,
121046035553Spatrick std::__promote<_A1, _A2>
121146035553Spatrick >::type
fmax(_A1 __x,_A2 __y)1212*dc37c87aSrobert fmax(_A1 __x, _A2 __y) _NOEXCEPT
121346035553Spatrick {
121446035553Spatrick typedef typename std::__promote<_A1, _A2>::type __result_type;
121546035553Spatrick static_assert((!(std::_IsSame<_A1, __result_type>::value &&
121646035553Spatrick std::_IsSame<_A2, __result_type>::value)), "");
1217*dc37c87aSrobert return ::fmax((__result_type)__x, (__result_type)__y);
121846035553Spatrick }
121946035553Spatrick
122046035553Spatrick // fmin
122146035553Spatrick
fmin(float __x,float __y)1222*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return __builtin_fminf(__x, __y);}
1223*dc37c87aSrobert
1224*dc37c87aSrobert template <class = int>
fmin(double __x,double __y)1225*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT {
1226*dc37c87aSrobert return __builtin_fmin(__x, __y);
1227*dc37c87aSrobert }
1228*dc37c87aSrobert
fmin(long double __x,long double __y)1229*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT {return __builtin_fminl(__x, __y);}
123046035553Spatrick
123146035553Spatrick template <class _A1, class _A2>
1232*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
1233*dc37c87aSrobert typename std::__enable_if_t
123446035553Spatrick <
123546035553Spatrick std::is_arithmetic<_A1>::value &&
123646035553Spatrick std::is_arithmetic<_A2>::value,
123746035553Spatrick std::__promote<_A1, _A2>
123846035553Spatrick >::type
fmin(_A1 __x,_A2 __y)1239*dc37c87aSrobert fmin(_A1 __x, _A2 __y) _NOEXCEPT
124046035553Spatrick {
124146035553Spatrick typedef typename std::__promote<_A1, _A2>::type __result_type;
124246035553Spatrick static_assert((!(std::_IsSame<_A1, __result_type>::value &&
124346035553Spatrick std::_IsSame<_A2, __result_type>::value)), "");
1244*dc37c87aSrobert return ::fmin((__result_type)__x, (__result_type)__y);
124546035553Spatrick }
124646035553Spatrick
124746035553Spatrick // hypot
124846035553Spatrick
hypot(float __x,float __y)1249*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return __builtin_hypotf(__x, __y);}
1250*dc37c87aSrobert
1251*dc37c87aSrobert template <class = int>
hypot(double __x,double __y)1252*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y) _NOEXCEPT {
1253*dc37c87aSrobert return __builtin_hypot(__x, __y);
1254*dc37c87aSrobert }
1255*dc37c87aSrobert
hypot(long double __x,long double __y)1256*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) _NOEXCEPT {return __builtin_hypotl(__x, __y);}
125746035553Spatrick
125846035553Spatrick template <class _A1, class _A2>
1259*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
1260*dc37c87aSrobert typename std::__enable_if_t
126146035553Spatrick <
126246035553Spatrick std::is_arithmetic<_A1>::value &&
126346035553Spatrick std::is_arithmetic<_A2>::value,
126446035553Spatrick std::__promote<_A1, _A2>
126546035553Spatrick >::type
hypot(_A1 __x,_A2 __y)1266*dc37c87aSrobert hypot(_A1 __x, _A2 __y) _NOEXCEPT
126746035553Spatrick {
126846035553Spatrick typedef typename std::__promote<_A1, _A2>::type __result_type;
126946035553Spatrick static_assert((!(std::_IsSame<_A1, __result_type>::value &&
127046035553Spatrick std::_IsSame<_A2, __result_type>::value)), "");
1271*dc37c87aSrobert return ::hypot((__result_type)__x, (__result_type)__y);
127246035553Spatrick }
127346035553Spatrick
127446035553Spatrick // ilogb
127546035553Spatrick
ilogb(float __x)1276*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return __builtin_ilogbf(__x);}
1277*dc37c87aSrobert
1278*dc37c87aSrobert template <class = int>
ilogb(double __x)1279*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double ilogb(double __x) _NOEXCEPT {
1280*dc37c87aSrobert return __builtin_ilogb(__x);
1281*dc37c87aSrobert }
1282*dc37c87aSrobert
ilogb(long double __x)1283*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI int ilogb(long double __x) _NOEXCEPT {return __builtin_ilogbl(__x);}
128446035553Spatrick
128546035553Spatrick template <class _A1>
1286*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
128746035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, int>::type
ilogb(_A1 __x)1288*dc37c87aSrobert ilogb(_A1 __x) _NOEXCEPT {return __builtin_ilogb((double)__x);}
128946035553Spatrick
129046035553Spatrick // lgamma
129146035553Spatrick
lgamma(float __x)1292*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return __builtin_lgammaf(__x);}
1293*dc37c87aSrobert
1294*dc37c87aSrobert template <class = int>
lgamma(double __x)1295*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double lgamma(double __x) _NOEXCEPT {
1296*dc37c87aSrobert return __builtin_lgamma(__x);
1297*dc37c87aSrobert }
1298*dc37c87aSrobert
lgamma(long double __x)1299*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT {return __builtin_lgammal(__x);}
130046035553Spatrick
130146035553Spatrick template <class _A1>
1302*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
130346035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
lgamma(_A1 __x)1304*dc37c87aSrobert lgamma(_A1 __x) _NOEXCEPT {return __builtin_lgamma((double)__x);}
130546035553Spatrick
130646035553Spatrick // llrint
130746035553Spatrick
llrint(float __x)1308*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT
1309a0747c9fSpatrick {
1310*dc37c87aSrobert return __builtin_llrintf(__x);
1311a0747c9fSpatrick }
1312*dc37c87aSrobert
1313*dc37c87aSrobert template <class = int>
llrint(double __x)1314*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI long long llrint(double __x) _NOEXCEPT {
1315*dc37c87aSrobert return __builtin_llrint(__x);
1316*dc37c87aSrobert }
1317*dc37c87aSrobert
llrint(long double __x)1318*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT
1319a0747c9fSpatrick {
1320*dc37c87aSrobert return __builtin_llrintl(__x);
1321a0747c9fSpatrick }
132246035553Spatrick
132346035553Spatrick template <class _A1>
1324*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
132546035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, long long>::type
llrint(_A1 __x)1326*dc37c87aSrobert llrint(_A1 __x) _NOEXCEPT
1327a0747c9fSpatrick {
1328*dc37c87aSrobert return __builtin_llrint((double)__x);
1329a0747c9fSpatrick }
133046035553Spatrick
133146035553Spatrick // llround
133246035553Spatrick
llround(float __x)1333*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT
1334a0747c9fSpatrick {
1335*dc37c87aSrobert return __builtin_llroundf(__x);
1336a0747c9fSpatrick }
1337*dc37c87aSrobert
1338*dc37c87aSrobert template <class = int>
llround(double __x)1339*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI long long llround(double __x) _NOEXCEPT {
1340*dc37c87aSrobert return __builtin_llround(__x);
1341*dc37c87aSrobert }
1342*dc37c87aSrobert
llround(long double __x)1343*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT
1344a0747c9fSpatrick {
1345*dc37c87aSrobert return __builtin_llroundl(__x);
1346a0747c9fSpatrick }
134746035553Spatrick
134846035553Spatrick template <class _A1>
1349*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
135046035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, long long>::type
llround(_A1 __x)1351*dc37c87aSrobert llround(_A1 __x) _NOEXCEPT
1352a0747c9fSpatrick {
1353*dc37c87aSrobert return __builtin_llround((double)__x);
1354a0747c9fSpatrick }
135546035553Spatrick
135646035553Spatrick // log1p
135746035553Spatrick
log1p(float __x)1358*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return __builtin_log1pf(__x);}
1359*dc37c87aSrobert
1360*dc37c87aSrobert template <class = int>
log1p(double __x)1361*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double log1p(double __x) _NOEXCEPT {
1362*dc37c87aSrobert return __builtin_log1p(__x);
1363*dc37c87aSrobert }
1364*dc37c87aSrobert
log1p(long double __x)1365*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double log1p(long double __x) _NOEXCEPT {return __builtin_log1pl(__x);}
136646035553Spatrick
136746035553Spatrick template <class _A1>
1368*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
136946035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
log1p(_A1 __x)1370*dc37c87aSrobert log1p(_A1 __x) _NOEXCEPT {return __builtin_log1p((double)__x);}
137146035553Spatrick
137246035553Spatrick // log2
137346035553Spatrick
log2(float __x)1374*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return __builtin_log2f(__x);}
1375*dc37c87aSrobert
1376*dc37c87aSrobert template <class = int>
log2(double __x)1377*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double log2(double __x) _NOEXCEPT {
1378*dc37c87aSrobert return __builtin_log2(__x);
1379*dc37c87aSrobert }
1380*dc37c87aSrobert
log2(long double __x)1381*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double log2(long double __x) _NOEXCEPT {return __builtin_log2l(__x);}
138246035553Spatrick
138346035553Spatrick template <class _A1>
1384*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
138546035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
log2(_A1 __x)1386*dc37c87aSrobert log2(_A1 __x) _NOEXCEPT {return __builtin_log2((double)__x);}
138746035553Spatrick
138846035553Spatrick // logb
138946035553Spatrick
logb(float __x)1390*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return __builtin_logbf(__x);}
1391*dc37c87aSrobert
1392*dc37c87aSrobert template <class = int>
logb(double __x)1393*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double logb(double __x) _NOEXCEPT {
1394*dc37c87aSrobert return __builtin_logb(__x);
1395*dc37c87aSrobert }
1396*dc37c87aSrobert
logb(long double __x)1397*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double logb(long double __x) _NOEXCEPT {return __builtin_logbl(__x);}
139846035553Spatrick
139946035553Spatrick template <class _A1>
1400*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
140146035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
logb(_A1 __x)1402*dc37c87aSrobert logb(_A1 __x) _NOEXCEPT {return __builtin_logb((double)__x);}
140346035553Spatrick
140446035553Spatrick // lrint
140546035553Spatrick
lrint(float __x)1406*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT
1407a0747c9fSpatrick {
1408*dc37c87aSrobert return __builtin_lrintf(__x);
1409a0747c9fSpatrick }
1410*dc37c87aSrobert
1411*dc37c87aSrobert template <class = int>
lrint(double __x)1412*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI long lrint(double __x) _NOEXCEPT {
1413*dc37c87aSrobert return __builtin_lrint(__x);
1414*dc37c87aSrobert }
1415*dc37c87aSrobert
lrint(long double __x)1416*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT
1417a0747c9fSpatrick {
1418*dc37c87aSrobert return __builtin_lrintl(__x);
1419a0747c9fSpatrick }
142046035553Spatrick
142146035553Spatrick template <class _A1>
1422*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
142346035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, long>::type
lrint(_A1 __x)1424*dc37c87aSrobert lrint(_A1 __x) _NOEXCEPT
1425a0747c9fSpatrick {
1426*dc37c87aSrobert return __builtin_lrint((double)__x);
1427a0747c9fSpatrick }
142846035553Spatrick
142946035553Spatrick // lround
143046035553Spatrick
lround(float __x)1431*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT
1432a0747c9fSpatrick {
1433*dc37c87aSrobert return __builtin_lroundf(__x);
1434a0747c9fSpatrick }
1435*dc37c87aSrobert
1436*dc37c87aSrobert template <class = int>
lround(double __x)1437*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI long lround(double __x) _NOEXCEPT {
1438*dc37c87aSrobert return __builtin_lround(__x);
1439*dc37c87aSrobert }
1440*dc37c87aSrobert
lround(long double __x)1441*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _NOEXCEPT
1442a0747c9fSpatrick {
1443*dc37c87aSrobert return __builtin_lroundl(__x);
1444a0747c9fSpatrick }
144546035553Spatrick
144646035553Spatrick template <class _A1>
1447*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
144846035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, long>::type
lround(_A1 __x)1449*dc37c87aSrobert lround(_A1 __x) _NOEXCEPT
1450a0747c9fSpatrick {
1451*dc37c87aSrobert return __builtin_lround((double)__x);
1452a0747c9fSpatrick }
145346035553Spatrick
145446035553Spatrick // nan
145546035553Spatrick
145646035553Spatrick // nearbyint
145746035553Spatrick
nearbyint(float __x)1458*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return __builtin_nearbyintf(__x);}
1459*dc37c87aSrobert
1460*dc37c87aSrobert template <class = int>
nearbyint(double __x)1461*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT {
1462*dc37c87aSrobert return __builtin_nearbyint(__x);
1463*dc37c87aSrobert }
1464*dc37c87aSrobert
nearbyint(long double __x)1465*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {return __builtin_nearbyintl(__x);}
146646035553Spatrick
146746035553Spatrick template <class _A1>
1468*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
146946035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
nearbyint(_A1 __x)1470*dc37c87aSrobert nearbyint(_A1 __x) _NOEXCEPT {return __builtin_nearbyint((double)__x);}
147146035553Spatrick
147246035553Spatrick // nextafter
147346035553Spatrick
nextafter(float __x,float __y)1474*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return __builtin_nextafterf(__x, __y);}
1475*dc37c87aSrobert
1476*dc37c87aSrobert template <class = int>
nextafter(double __x,double __y)1477*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double nextafter(double __x, double __y) _NOEXCEPT {
1478*dc37c87aSrobert return __builtin_nextafter(__x, __y);
1479*dc37c87aSrobert }
1480*dc37c87aSrobert
nextafter(long double __x,long double __y)1481*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double __y) _NOEXCEPT {return __builtin_nextafterl(__x, __y);}
148246035553Spatrick
148346035553Spatrick template <class _A1, class _A2>
1484*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
1485*dc37c87aSrobert typename std::__enable_if_t
148646035553Spatrick <
148746035553Spatrick std::is_arithmetic<_A1>::value &&
148846035553Spatrick std::is_arithmetic<_A2>::value,
148946035553Spatrick std::__promote<_A1, _A2>
149046035553Spatrick >::type
nextafter(_A1 __x,_A2 __y)1491*dc37c87aSrobert nextafter(_A1 __x, _A2 __y) _NOEXCEPT
149246035553Spatrick {
149346035553Spatrick typedef typename std::__promote<_A1, _A2>::type __result_type;
149446035553Spatrick static_assert((!(std::_IsSame<_A1, __result_type>::value &&
149546035553Spatrick std::_IsSame<_A2, __result_type>::value)), "");
1496*dc37c87aSrobert return ::nextafter((__result_type)__x, (__result_type)__y);
149746035553Spatrick }
149846035553Spatrick
149946035553Spatrick // nexttoward
150046035553Spatrick
nexttoward(float __x,long double __y)1501*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return __builtin_nexttowardf(__x, __y);}
1502*dc37c87aSrobert
1503*dc37c87aSrobert template <class = int>
nexttoward(double __x,long double __y)1504*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double nexttoward(double __x, long double __y) _NOEXCEPT {
1505*dc37c87aSrobert return __builtin_nexttoward(__x, __y);
1506*dc37c87aSrobert }
1507*dc37c87aSrobert
nexttoward(long double __x,long double __y)1508*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double nexttoward(long double __x, long double __y) _NOEXCEPT {return __builtin_nexttowardl(__x, __y);}
150946035553Spatrick
151046035553Spatrick template <class _A1>
1511*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
151246035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
nexttoward(_A1 __x,long double __y)1513*dc37c87aSrobert nexttoward(_A1 __x, long double __y) _NOEXCEPT {return __builtin_nexttoward((double)__x, __y);}
151446035553Spatrick
151546035553Spatrick // remainder
151646035553Spatrick
remainder(float __x,float __y)1517*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return __builtin_remainderf(__x, __y);}
1518*dc37c87aSrobert
1519*dc37c87aSrobert template <class = int>
remainder(double __x,double __y)1520*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double remainder(double __x, double __y) _NOEXCEPT {
1521*dc37c87aSrobert return __builtin_remainder(__x, __y);
1522*dc37c87aSrobert }
1523*dc37c87aSrobert
remainder(long double __x,long double __y)1524*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double __y) _NOEXCEPT {return __builtin_remainderl(__x, __y);}
152546035553Spatrick
152646035553Spatrick template <class _A1, class _A2>
1527*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
1528*dc37c87aSrobert typename std::__enable_if_t
152946035553Spatrick <
153046035553Spatrick std::is_arithmetic<_A1>::value &&
153146035553Spatrick std::is_arithmetic<_A2>::value,
153246035553Spatrick std::__promote<_A1, _A2>
153346035553Spatrick >::type
remainder(_A1 __x,_A2 __y)1534*dc37c87aSrobert remainder(_A1 __x, _A2 __y) _NOEXCEPT
153546035553Spatrick {
153646035553Spatrick typedef typename std::__promote<_A1, _A2>::type __result_type;
153746035553Spatrick static_assert((!(std::_IsSame<_A1, __result_type>::value &&
153846035553Spatrick std::_IsSame<_A2, __result_type>::value)), "");
1539*dc37c87aSrobert return ::remainder((__result_type)__x, (__result_type)__y);
154046035553Spatrick }
154146035553Spatrick
154246035553Spatrick // remquo
154346035553Spatrick
remquo(float __x,float __y,int * __z)1544*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return __builtin_remquof(__x, __y, __z);}
1545*dc37c87aSrobert
1546*dc37c87aSrobert template <class = int>
remquo(double __x,double __y,int * __z)1547*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double remquo(double __x, double __y, int* __z) _NOEXCEPT {
1548*dc37c87aSrobert return __builtin_remquo(__x, __y, __z);
1549*dc37c87aSrobert }
1550*dc37c87aSrobert
remquo(long double __x,long double __y,int * __z)1551*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y, int* __z) _NOEXCEPT {return __builtin_remquol(__x, __y, __z);}
155246035553Spatrick
155346035553Spatrick template <class _A1, class _A2>
1554*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
1555*dc37c87aSrobert typename std::__enable_if_t
155646035553Spatrick <
155746035553Spatrick std::is_arithmetic<_A1>::value &&
155846035553Spatrick std::is_arithmetic<_A2>::value,
155946035553Spatrick std::__promote<_A1, _A2>
156046035553Spatrick >::type
remquo(_A1 __x,_A2 __y,int * __z)1561*dc37c87aSrobert remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT
156246035553Spatrick {
156346035553Spatrick typedef typename std::__promote<_A1, _A2>::type __result_type;
156446035553Spatrick static_assert((!(std::_IsSame<_A1, __result_type>::value &&
156546035553Spatrick std::_IsSame<_A2, __result_type>::value)), "");
1566*dc37c87aSrobert return ::remquo((__result_type)__x, (__result_type)__y, __z);
156746035553Spatrick }
156846035553Spatrick
156946035553Spatrick // rint
157046035553Spatrick
rint(float __x)1571*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT
1572a0747c9fSpatrick {
1573*dc37c87aSrobert return __builtin_rintf(__x);
1574a0747c9fSpatrick }
1575*dc37c87aSrobert
1576*dc37c87aSrobert template <class = int>
rint(double __x)1577*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT {
1578*dc37c87aSrobert return __builtin_rint(__x);
1579*dc37c87aSrobert }
1580*dc37c87aSrobert
rint(long double __x)1581*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT
1582a0747c9fSpatrick {
1583*dc37c87aSrobert return __builtin_rintl(__x);
1584a0747c9fSpatrick }
158546035553Spatrick
158646035553Spatrick template <class _A1>
1587*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
158846035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
rint(_A1 __x)1589*dc37c87aSrobert rint(_A1 __x) _NOEXCEPT
1590a0747c9fSpatrick {
1591*dc37c87aSrobert return __builtin_rint((double)__x);
1592a0747c9fSpatrick }
159346035553Spatrick
159446035553Spatrick // round
159546035553Spatrick
round(float __x)1596*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT
1597a0747c9fSpatrick {
1598*dc37c87aSrobert return __builtin_round(__x);
1599a0747c9fSpatrick }
1600*dc37c87aSrobert
1601*dc37c87aSrobert template <class = int>
round(double __x)1602*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT {
1603*dc37c87aSrobert return __builtin_round(__x);
1604*dc37c87aSrobert }
1605*dc37c87aSrobert
round(long double __x)1606*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT
1607a0747c9fSpatrick {
1608*dc37c87aSrobert return __builtin_roundl(__x);
1609a0747c9fSpatrick }
161046035553Spatrick
161146035553Spatrick template <class _A1>
1612*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
161346035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
round(_A1 __x)1614*dc37c87aSrobert round(_A1 __x) _NOEXCEPT
1615a0747c9fSpatrick {
1616*dc37c87aSrobert return __builtin_round((double)__x);
1617a0747c9fSpatrick }
161846035553Spatrick
161946035553Spatrick // scalbln
162046035553Spatrick
scalbln(float __x,long __y)1621*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return __builtin_scalblnf(__x, __y);}
1622*dc37c87aSrobert
1623*dc37c87aSrobert template <class = int>
scalbln(double __x,long __y)1624*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double scalbln(double __x, long __y) _NOEXCEPT {
1625*dc37c87aSrobert return __builtin_scalbln(__x, __y);
1626*dc37c87aSrobert }
1627*dc37c87aSrobert
scalbln(long double __x,long __y)1628*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT {return __builtin_scalblnl(__x, __y);}
162946035553Spatrick
163046035553Spatrick template <class _A1>
1631*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
163246035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
scalbln(_A1 __x,long __y)1633*dc37c87aSrobert scalbln(_A1 __x, long __y) _NOEXCEPT {return __builtin_scalbln((double)__x, __y);}
163446035553Spatrick
163546035553Spatrick // scalbn
163646035553Spatrick
scalbn(float __x,int __y)1637*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return __builtin_scalbnf(__x, __y);}
1638*dc37c87aSrobert
1639*dc37c87aSrobert template <class = int>
scalbn(double __x,int __y)1640*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double scalbn(double __x, int __y) _NOEXCEPT {
1641*dc37c87aSrobert return __builtin_scalbn(__x, __y);
1642*dc37c87aSrobert }
1643*dc37c87aSrobert
scalbn(long double __x,int __y)1644*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT {return __builtin_scalbnl(__x, __y);}
164546035553Spatrick
164646035553Spatrick template <class _A1>
1647*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
164846035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
scalbn(_A1 __x,int __y)1649*dc37c87aSrobert scalbn(_A1 __x, int __y) _NOEXCEPT {return __builtin_scalbn((double)__x, __y);}
165046035553Spatrick
165146035553Spatrick // tgamma
165246035553Spatrick
tgamma(float __x)1653*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return __builtin_tgammaf(__x);}
1654*dc37c87aSrobert
1655*dc37c87aSrobert template <class = int>
tgamma(double __x)1656*dc37c87aSrobert _LIBCPP_HIDE_FROM_ABI double tgamma(double __x) _NOEXCEPT {
1657*dc37c87aSrobert return __builtin_tgamma(__x);
1658*dc37c87aSrobert }
1659*dc37c87aSrobert
tgamma(long double __x)1660*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT {return __builtin_tgammal(__x);}
166146035553Spatrick
166246035553Spatrick template <class _A1>
1663*dc37c87aSrobert inline _LIBCPP_HIDE_FROM_ABI
166446035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
tgamma(_A1 __x)1665*dc37c87aSrobert tgamma(_A1 __x) _NOEXCEPT {return __builtin_tgamma((double)__x);}
166646035553Spatrick
166746035553Spatrick // trunc
166846035553Spatrick
trunc(float __x)1669*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT
1670a0747c9fSpatrick {
1671*dc37c87aSrobert return __builtin_trunc(__x);
1672a0747c9fSpatrick }
1673*dc37c87aSrobert
1674*dc37c87aSrobert template <class = int>
trunc(double __x)1675*dc37c87aSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT {
1676*dc37c87aSrobert return __builtin_trunc(__x);
1677*dc37c87aSrobert }
1678*dc37c87aSrobert
trunc(long double __x)1679*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT
1680a0747c9fSpatrick {
1681*dc37c87aSrobert return __builtin_truncl(__x);
1682a0747c9fSpatrick }
168346035553Spatrick
168446035553Spatrick template <class _A1>
1685*dc37c87aSrobert _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
168646035553Spatrick typename std::enable_if<std::is_integral<_A1>::value, double>::type
trunc(_A1 __x)1687*dc37c87aSrobert trunc(_A1 __x) _NOEXCEPT
1688a0747c9fSpatrick {
1689*dc37c87aSrobert return __builtin_trunc((double)__x);
1690a0747c9fSpatrick }
169146035553Spatrick
169246035553Spatrick } // extern "C++"
169346035553Spatrick
169446035553Spatrick #endif // __cplusplus
169546035553Spatrick
169646035553Spatrick #else // _LIBCPP_MATH_H
169746035553Spatrick
169846035553Spatrick // This include lives outside the header guard in order to support an MSVC
169946035553Spatrick // extension which allows users to do:
170046035553Spatrick //
170146035553Spatrick // #define _USE_MATH_DEFINES
170246035553Spatrick // #include <math.h>
170346035553Spatrick //
170446035553Spatrick // and receive the definitions of mathematical constants, even if <math.h>
170546035553Spatrick // has previously been included.
170646035553Spatrick #if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
170746035553Spatrick #include_next <math.h>
170846035553Spatrick #endif
170946035553Spatrick
171046035553Spatrick #endif // _LIBCPP_MATH_H
1711