Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
Louis Dionne | 9bd9388 | 2021-11-17 16:25:01 -0500 | [diff] [blame] | 2 | //===----------------------------------------------------------------------===// |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 3 | // |
Chandler Carruth | d201210 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 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 |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 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> |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 295 | |
| 296 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Arthur O'Dwyer | 6eeaa00 | 2022-02-01 20:16:40 -0500 | [diff] [blame] | 297 | # pragma GCC system_header |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 298 | #endif |
| 299 | |
Louis Dionne | be1aa9e | 2022-11-15 17:08:01 -0500 | [diff] [blame] | 300 | # if __has_include_next(<math.h>) |
| 301 | # include_next <math.h> |
| 302 | # endif |
Mikhail Maltsev | 34b4f97 | 2018-02-22 09:34:08 +0000 | [diff] [blame] | 303 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 304 | #ifdef __cplusplus |
| 305 | |
| 306 | // We support including .h headers inside 'extern "C"' contexts, so switch |
| 307 | // back to C++ linkage before including these C++ headers. |
| 308 | extern "C++" { |
| 309 | |
Nikolas Klauser | ca7ac53 | 2022-12-21 00:07:17 +0100 | [diff] [blame] | 310 | #include <__type_traits/enable_if.h> |
| 311 | #include <__type_traits/is_floating_point.h> |
| 312 | #include <__type_traits/is_integral.h> |
| 313 | #include <__type_traits/is_same.h> |
Nikolas Klauser | 6c8f712 | 2022-07-24 16:03:12 +0200 | [diff] [blame] | 314 | #include <__type_traits/promote.h> |
Arthur O'Dwyer | 65077c0 | 2022-01-07 09:45:05 -0500 | [diff] [blame] | 315 | #include <limits> |
Eric Fiselier | 6c9e1a7 | 2020-02-15 18:55:07 -0500 | [diff] [blame] | 316 | #include <stdlib.h> |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 317 | |
Nikolas Klauser | ae1fbc4 | 2022-11-04 20:19:20 +0100 | [diff] [blame] | 318 | |
| 319 | # ifdef fpclassify |
| 320 | # undef fpclassify |
| 321 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 322 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 323 | # ifdef signbit |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 324 | # undef signbit |
Nikolas Klauser | ae1fbc4 | 2022-11-04 20:19:20 +0100 | [diff] [blame] | 325 | # endif |
| 326 | |
| 327 | # ifdef isfinite |
| 328 | # undef isfinite |
| 329 | # endif |
| 330 | |
| 331 | # ifdef isinf |
| 332 | # undef isinf |
| 333 | # endif |
| 334 | |
| 335 | # ifdef isnan |
| 336 | # undef isnan |
| 337 | # endif |
| 338 | |
| 339 | # ifdef isnormal |
| 340 | # undef isnormal |
| 341 | # endif |
| 342 | |
| 343 | # ifdef isgreater |
| 344 | # undef isgreater |
| 345 | # endif |
| 346 | |
| 347 | # ifdef isgreaterequal |
| 348 | # undef isgreaterequal |
| 349 | # endif |
| 350 | |
| 351 | # ifdef isless |
| 352 | # undef isless |
| 353 | # endif |
| 354 | |
| 355 | # ifdef islessequal |
| 356 | # undef islessequal |
| 357 | # endif |
| 358 | |
| 359 | # ifdef islessgreater |
| 360 | # undef islessgreater |
| 361 | # endif |
| 362 | |
| 363 | # ifdef isunordered |
| 364 | # undef isunordered |
| 365 | # endif |
| 366 | |
| 367 | // signbit |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 368 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 369 | template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0> |
| 370 | inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 371 | return __builtin_signbit(__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 372 | } |
| 373 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 374 | template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && std::is_signed<_A1>::value, int> = 0> |
| 375 | inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 376 | return __x < 0; |
| 377 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 378 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 379 | template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && !std::is_signed<_A1>::value, int> = 0> |
| 380 | inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT { |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 381 | return false; |
| 382 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 383 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 384 | // fpclassify |
| 385 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 386 | template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0> |
| 387 | inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 388 | return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 389 | } |
| 390 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 391 | template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> |
| 392 | inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 393 | return __x == 0 ? FP_ZERO : FP_NORMAL; |
| 394 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 395 | |
Nikolas Klauser | ae1fbc4 | 2022-11-04 20:19:20 +0100 | [diff] [blame] | 396 | // The MSVC runtime already provides these functions as templates |
| 397 | #ifndef _LIBCPP_MSVCRT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 398 | |
Nikolas Klauser | ae1fbc4 | 2022-11-04 20:19:20 +0100 | [diff] [blame] | 399 | // isfinite |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 400 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 401 | template <class _A1, |
| 402 | std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0> |
Nikolas Klauser | dfc04a3 | 2022-12-19 00:02:44 +0100 | [diff] [blame] | 403 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 404 | return __builtin_isfinite((typename std::__promote<_A1>::type)__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 405 | } |
| 406 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 407 | template <class _A1, |
| 408 | std::__enable_if_t<std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, int> = 0> |
Nikolas Klauser | dfc04a3 | 2022-12-19 00:02:44 +0100 | [diff] [blame] | 409 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT { |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 410 | return true; |
| 411 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 412 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 413 | // isinf |
| 414 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 415 | template <class _A1, |
| 416 | std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0> |
Nikolas Klauser | dfc04a3 | 2022-12-19 00:02:44 +0100 | [diff] [blame] | 417 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 418 | return __builtin_isinf((typename std::__promote<_A1>::type)__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 419 | } |
| 420 | |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 421 | template <class _A1> |
Nikolas Klauser | dfc04a3 | 2022-12-19 00:02:44 +0100 | [diff] [blame] | 422 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 423 | typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type |
| 424 | isinf(_A1) _NOEXCEPT { |
| 425 | return false; |
| 426 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 427 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 428 | # ifdef _LIBCPP_PREFERRED_OVERLOAD |
Nikolas Klauser | dfc04a3 | 2022-12-19 00:02:44 +0100 | [diff] [blame] | 429 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { |
| 430 | return __builtin_isinf(__x); |
| 431 | } |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 432 | |
Nikolas Klauser | dfc04a3 | 2022-12-19 00:02:44 +0100 | [diff] [blame] | 433 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT { |
| 434 | return __builtin_isinf(__x); |
| 435 | } |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 436 | |
Nikolas Klauser | dfc04a3 | 2022-12-19 00:02:44 +0100 | [diff] [blame] | 437 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { |
| 438 | return __builtin_isinf(__x); |
| 439 | } |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 440 | # endif |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 441 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 442 | // isnan |
| 443 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 444 | template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0> |
Nikolas Klauser | dfc04a3 | 2022-12-19 00:02:44 +0100 | [diff] [blame] | 445 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 446 | return __builtin_isnan(__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 447 | } |
| 448 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 449 | template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> |
Nikolas Klauser | dfc04a3 | 2022-12-19 00:02:44 +0100 | [diff] [blame] | 450 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT { |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 451 | return false; |
| 452 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 453 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 454 | # ifdef _LIBCPP_PREFERRED_OVERLOAD |
Nikolas Klauser | dfc04a3 | 2022-12-19 00:02:44 +0100 | [diff] [blame] | 455 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { |
| 456 | return __builtin_isnan(__x); |
| 457 | } |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 458 | |
Nikolas Klauser | dfc04a3 | 2022-12-19 00:02:44 +0100 | [diff] [blame] | 459 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT { |
| 460 | return __builtin_isnan(__x); |
| 461 | } |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 462 | |
Nikolas Klauser | dfc04a3 | 2022-12-19 00:02:44 +0100 | [diff] [blame] | 463 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { |
| 464 | return __builtin_isnan(__x); |
| 465 | } |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 466 | # endif |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 467 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 468 | // isnormal |
| 469 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 470 | template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0> |
Nikolas Klauser | dfc04a3 | 2022-12-19 00:02:44 +0100 | [diff] [blame] | 471 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 472 | return __builtin_isnormal(__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 473 | } |
| 474 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 475 | template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> |
Nikolas Klauser | dfc04a3 | 2022-12-19 00:02:44 +0100 | [diff] [blame] | 476 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 477 | return __x != 0; |
| 478 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 479 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 480 | // isgreater |
| 481 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 482 | template <class _A1, |
| 483 | class _A2, |
| 484 | std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> |
| 485 | inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT { |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 486 | typedef typename std::__promote<_A1, _A2>::type type; |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 487 | return __builtin_isgreater((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 488 | } |
| 489 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 490 | // isgreaterequal |
| 491 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 492 | template <class _A1, |
| 493 | class _A2, |
| 494 | std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> |
| 495 | inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 496 | typedef typename std::__promote<_A1, _A2>::type type; |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 497 | return __builtin_isgreaterequal((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 498 | } |
| 499 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 500 | // isless |
| 501 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 502 | template <class _A1, |
| 503 | class _A2, |
| 504 | std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> |
| 505 | inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT { |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 506 | typedef typename std::__promote<_A1, _A2>::type type; |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 507 | return __builtin_isless((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 508 | } |
| 509 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 510 | // islessequal |
| 511 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 512 | template <class _A1, |
| 513 | class _A2, |
| 514 | std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> |
| 515 | inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT { |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 516 | typedef typename std::__promote<_A1, _A2>::type type; |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 517 | return __builtin_islessequal((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 518 | } |
| 519 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 520 | // islessgreater |
| 521 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 522 | template <class _A1, |
| 523 | class _A2, |
| 524 | std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> |
| 525 | inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 526 | typedef typename std::__promote<_A1, _A2>::type type; |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 527 | return __builtin_islessgreater((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 528 | } |
| 529 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 530 | // isunordered |
| 531 | |
Nikolas Klauser | e96070f | 2022-11-04 20:08:56 +0100 | [diff] [blame] | 532 | template <class _A1, |
| 533 | class _A2, |
| 534 | std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> |
| 535 | inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT { |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 536 | typedef typename std::__promote<_A1, _A2>::type type; |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 537 | return __builtin_isunordered((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 538 | } |
| 539 | |
Nikolas Klauser | ae1fbc4 | 2022-11-04 20:19:20 +0100 | [diff] [blame] | 540 | #endif // _LIBCPP_MSVCRT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 541 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 542 | // abs |
Eric Fiselier | 6c9e1a7 | 2020-02-15 18:55:07 -0500 | [diff] [blame] | 543 | // |
| 544 | // handled in stdlib.h |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 545 | |
Eric Fiselier | 2b85c6e | 2019-04-23 18:01:58 +0000 | [diff] [blame] | 546 | // div |
Eric Fiselier | 6c9e1a7 | 2020-02-15 18:55:07 -0500 | [diff] [blame] | 547 | // |
| 548 | // handled in stdlib.h |
Eric Fiselier | 2b85c6e | 2019-04-23 18:01:58 +0000 | [diff] [blame] | 549 | |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 550 | // We have to provide double overloads for <math.h> to work on platforms that don't provide the full set of math |
| 551 | // functions. To make the overload set work with multiple functions that take the same arguments, we make our overloads |
| 552 | // templates. Functions are preferred over function templates during overload resolution, which means that our overload |
| 553 | // will only be selected when the C library doesn't provide one. |
| 554 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 555 | // acos |
| 556 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 557 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 558 | inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return __builtin_acosf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 559 | |
| 560 | template <class = int> |
| 561 | _LIBCPP_HIDE_FROM_ABI double acos(double __x) _NOEXCEPT { |
| 562 | return __builtin_acos(__x); |
| 563 | } |
| 564 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 565 | inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT {return __builtin_acosl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 566 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 567 | |
| 568 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 569 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 570 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 571 | acos(_A1 __x) _NOEXCEPT {return __builtin_acos((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 572 | |
| 573 | // asin |
| 574 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 575 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 576 | inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return __builtin_asinf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 577 | |
| 578 | template <class = int> |
| 579 | _LIBCPP_HIDE_FROM_ABI double asin(double __x) _NOEXCEPT { |
| 580 | return __builtin_asin(__x); |
| 581 | } |
| 582 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 583 | inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT {return __builtin_asinl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 584 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 585 | |
| 586 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 587 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 588 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 589 | asin(_A1 __x) _NOEXCEPT {return __builtin_asin((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 590 | |
| 591 | // atan |
| 592 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 593 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 594 | inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return __builtin_atanf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 595 | |
| 596 | template <class = int> |
| 597 | _LIBCPP_HIDE_FROM_ABI double atan(double __x) _NOEXCEPT { |
| 598 | return __builtin_atan(__x); |
| 599 | } |
| 600 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 601 | inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT {return __builtin_atanl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 602 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 603 | |
| 604 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 605 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 606 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 607 | atan(_A1 __x) _NOEXCEPT {return __builtin_atan((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 608 | |
| 609 | // atan2 |
| 610 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 611 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 612 | inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return __builtin_atan2f(__y, __x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 613 | |
| 614 | template <class = int> |
| 615 | _LIBCPP_HIDE_FROM_ABI double atan2(double __x, double __y) _NOEXCEPT { |
| 616 | return __builtin_atan2(__x, __y); |
| 617 | } |
| 618 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 619 | inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) _NOEXCEPT {return __builtin_atan2l(__y, __x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 620 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 621 | |
| 622 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 623 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 624 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 625 | < |
| 626 | std::is_arithmetic<_A1>::value && |
| 627 | std::is_arithmetic<_A2>::value, |
| 628 | std::__promote<_A1, _A2> |
| 629 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 630 | atan2(_A1 __y, _A2 __x) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 631 | { |
| 632 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 633 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 634 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 635 | return ::atan2((__result_type)__y, (__result_type)__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 636 | } |
| 637 | |
| 638 | // ceil |
| 639 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 640 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 641 | inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return __builtin_ceilf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 642 | |
| 643 | template <class = int> |
| 644 | _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT { |
| 645 | return __builtin_ceil(__x); |
| 646 | } |
| 647 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 648 | inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return __builtin_ceill(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 649 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 650 | |
| 651 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 652 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 653 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 654 | ceil(_A1 __x) _NOEXCEPT {return __builtin_ceil((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 655 | |
| 656 | // cos |
| 657 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 658 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 659 | inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return __builtin_cosf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 660 | |
| 661 | template <class = int> |
| 662 | _LIBCPP_HIDE_FROM_ABI double cos(double __x) _NOEXCEPT { |
| 663 | return __builtin_cos(__x); |
| 664 | } |
| 665 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 666 | inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT {return __builtin_cosl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 667 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 668 | |
| 669 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 670 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 671 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 672 | cos(_A1 __x) _NOEXCEPT {return __builtin_cos((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 673 | |
| 674 | // cosh |
| 675 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 676 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 677 | inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return __builtin_coshf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 678 | |
| 679 | template <class = int> |
| 680 | _LIBCPP_HIDE_FROM_ABI double cosh(double __x) _NOEXCEPT { |
| 681 | return __builtin_cosh(__x); |
| 682 | } |
| 683 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 684 | inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT {return __builtin_coshl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 685 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 686 | |
| 687 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 688 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 689 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 690 | cosh(_A1 __x) _NOEXCEPT {return __builtin_cosh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 691 | |
| 692 | // exp |
| 693 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 694 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 695 | inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return __builtin_expf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 696 | |
| 697 | template <class = int> |
| 698 | _LIBCPP_HIDE_FROM_ABI double exp(double __x) _NOEXCEPT { |
| 699 | return __builtin_exp(__x); |
| 700 | } |
| 701 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 702 | inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT {return __builtin_expl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 703 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 704 | |
| 705 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 706 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 707 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 708 | exp(_A1 __x) _NOEXCEPT {return __builtin_exp((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 709 | |
| 710 | // fabs |
| 711 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 712 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 713 | inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return __builtin_fabsf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 714 | |
| 715 | template <class = int> |
| 716 | _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT { |
| 717 | return __builtin_fabs(__x); |
| 718 | } |
| 719 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 720 | inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return __builtin_fabsl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 721 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 722 | |
| 723 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 724 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 725 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 726 | fabs(_A1 __x) _NOEXCEPT {return __builtin_fabs((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 727 | |
| 728 | // floor |
| 729 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 730 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 731 | inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return __builtin_floorf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 732 | |
| 733 | template <class = int> |
| 734 | _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT { |
| 735 | return __builtin_floor(__x); |
| 736 | } |
| 737 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 738 | inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return __builtin_floorl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 739 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 740 | |
| 741 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 742 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 743 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 744 | floor(_A1 __x) _NOEXCEPT {return __builtin_floor((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 745 | |
| 746 | // fmod |
| 747 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 748 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 749 | inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return __builtin_fmodf(__x, __y);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 750 | |
| 751 | template <class = int> |
| 752 | _LIBCPP_HIDE_FROM_ABI double fmod(double __x, double __y) _NOEXCEPT { |
| 753 | return __builtin_fmod(__x, __y); |
| 754 | } |
| 755 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 756 | inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) _NOEXCEPT {return __builtin_fmodl(__x, __y);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 757 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 758 | |
| 759 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 760 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 761 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 762 | < |
| 763 | std::is_arithmetic<_A1>::value && |
| 764 | std::is_arithmetic<_A2>::value, |
| 765 | std::__promote<_A1, _A2> |
| 766 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 767 | fmod(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 768 | { |
| 769 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 770 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 771 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 772 | return ::fmod((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 773 | } |
| 774 | |
| 775 | // frexp |
| 776 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 777 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 778 | inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return __builtin_frexpf(__x, __e);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 779 | |
| 780 | template <class = int> |
| 781 | _LIBCPP_HIDE_FROM_ABI double frexp(double __x, int* __e) _NOEXCEPT { |
| 782 | return __builtin_frexp(__x, __e); |
| 783 | } |
| 784 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 785 | inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {return __builtin_frexpl(__x, __e);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 786 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 787 | |
| 788 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 789 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 790 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 791 | frexp(_A1 __x, int* __e) _NOEXCEPT {return __builtin_frexp((double)__x, __e);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 792 | |
| 793 | // ldexp |
| 794 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 795 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 796 | inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return __builtin_ldexpf(__x, __e);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 797 | |
| 798 | template <class = int> |
| 799 | _LIBCPP_HIDE_FROM_ABI double ldexp(double __x, int __e) _NOEXCEPT { |
| 800 | return __builtin_ldexp(__x, __e); |
| 801 | } |
| 802 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 803 | inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {return __builtin_ldexpl(__x, __e);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 804 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 805 | |
| 806 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 807 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 808 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 809 | ldexp(_A1 __x, int __e) _NOEXCEPT {return __builtin_ldexp((double)__x, __e);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 810 | |
| 811 | // log |
| 812 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 813 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 814 | inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return __builtin_logf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 815 | |
| 816 | template <class = int> |
| 817 | _LIBCPP_HIDE_FROM_ABI double log(double __x) _NOEXCEPT { |
| 818 | return __builtin_log(__x); |
| 819 | } |
| 820 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 821 | inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT {return __builtin_logl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 822 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 823 | |
| 824 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 825 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 826 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 827 | log(_A1 __x) _NOEXCEPT {return __builtin_log((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 828 | |
| 829 | // log10 |
| 830 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 831 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 832 | inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return __builtin_log10f(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 833 | |
| 834 | |
| 835 | template <class = int> |
| 836 | _LIBCPP_HIDE_FROM_ABI double log10(double __x) _NOEXCEPT { |
| 837 | return __builtin_log10(__x); |
| 838 | } |
| 839 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 840 | inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT {return __builtin_log10l(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 841 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 842 | |
| 843 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 844 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 845 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 846 | log10(_A1 __x) _NOEXCEPT {return __builtin_log10((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 847 | |
| 848 | // modf |
| 849 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 850 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 851 | inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return __builtin_modff(__x, __y);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 852 | |
| 853 | template <class = int> |
| 854 | _LIBCPP_HIDE_FROM_ABI double modf(double __x, double* __y) _NOEXCEPT { |
| 855 | return __builtin_modf(__x, __y); |
| 856 | } |
| 857 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 858 | inline _LIBCPP_HIDE_FROM_ABI long double modf(long double __x, long double* __y) _NOEXCEPT {return __builtin_modfl(__x, __y);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 859 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 860 | |
| 861 | // pow |
| 862 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 863 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 864 | inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return __builtin_powf(__x, __y);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 865 | |
| 866 | template <class = int> |
| 867 | _LIBCPP_HIDE_FROM_ABI double pow(double __x, double __y) _NOEXCEPT { |
| 868 | return __builtin_pow(__x, __y); |
| 869 | } |
| 870 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 871 | inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _NOEXCEPT {return __builtin_powl(__x, __y);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 872 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 873 | |
| 874 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 875 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 876 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 877 | < |
| 878 | std::is_arithmetic<_A1>::value && |
| 879 | std::is_arithmetic<_A2>::value, |
| 880 | std::__promote<_A1, _A2> |
| 881 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 882 | pow(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 883 | { |
| 884 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 885 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 886 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 887 | return ::pow((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 888 | } |
| 889 | |
| 890 | // sin |
| 891 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 892 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 893 | inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return __builtin_sinf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 894 | |
| 895 | template <class = int> |
| 896 | _LIBCPP_HIDE_FROM_ABI double sin(double __x) _NOEXCEPT { |
| 897 | return __builtin_sin(__x); |
| 898 | } |
| 899 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 900 | inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT {return __builtin_sinl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 901 | #endif |
| 902 | |
| 903 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 904 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 905 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 906 | sin(_A1 __x) _NOEXCEPT {return __builtin_sin((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 907 | |
| 908 | // sinh |
| 909 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 910 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 911 | inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return __builtin_sinhf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 912 | |
| 913 | template <class = int> |
| 914 | _LIBCPP_HIDE_FROM_ABI double sinh(double __x) _NOEXCEPT { |
| 915 | return __builtin_sinh(__x); |
| 916 | } |
| 917 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 918 | inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT {return __builtin_sinhl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 919 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 920 | |
| 921 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 922 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 923 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 924 | sinh(_A1 __x) _NOEXCEPT {return __builtin_sinh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 925 | |
| 926 | // sqrt |
| 927 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 928 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 929 | inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return __builtin_sqrtf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 930 | |
| 931 | template <class = int> |
| 932 | _LIBCPP_HIDE_FROM_ABI double sqrt(double __x) _NOEXCEPT { |
| 933 | return __builtin_sqrt(__x); |
| 934 | } |
| 935 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 936 | inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT {return __builtin_sqrtl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 937 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 938 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 939 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 940 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 941 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 942 | sqrt(_A1 __x) _NOEXCEPT {return __builtin_sqrt((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 943 | |
| 944 | // tan |
| 945 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 946 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 947 | inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return __builtin_tanf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 948 | |
| 949 | template <class = int> |
| 950 | _LIBCPP_HIDE_FROM_ABI double tan(double __x) _NOEXCEPT { |
| 951 | return __builtin_tan(__x); |
| 952 | } |
| 953 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 954 | inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT {return __builtin_tanl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 955 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 956 | |
| 957 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 958 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 959 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 960 | tan(_A1 __x) _NOEXCEPT {return __builtin_tan((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 961 | |
| 962 | // tanh |
| 963 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 964 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 965 | inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return __builtin_tanhf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 966 | |
| 967 | template <class = int> |
| 968 | _LIBCPP_HIDE_FROM_ABI double tanh(double __x) _NOEXCEPT { |
| 969 | return __builtin_tanh(__x); |
| 970 | } |
| 971 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 972 | inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT {return __builtin_tanhl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 973 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 974 | |
| 975 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 976 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 977 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 978 | tanh(_A1 __x) _NOEXCEPT {return __builtin_tanh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 979 | |
| 980 | // acosh |
| 981 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 982 | inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return __builtin_acoshf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 983 | |
| 984 | template <class = int> |
| 985 | _LIBCPP_HIDE_FROM_ABI double acosh(double __x) _NOEXCEPT { |
| 986 | return __builtin_acosh(__x); |
| 987 | } |
| 988 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 989 | inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT {return __builtin_acoshl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 990 | |
| 991 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 992 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 993 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 994 | acosh(_A1 __x) _NOEXCEPT {return __builtin_acosh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 995 | |
| 996 | // asinh |
| 997 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 998 | inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return __builtin_asinhf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 999 | |
| 1000 | template <class = int> |
| 1001 | _LIBCPP_HIDE_FROM_ABI double asinh(double __x) _NOEXCEPT { |
| 1002 | return __builtin_asinh(__x); |
| 1003 | } |
| 1004 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1005 | inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT {return __builtin_asinhl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1006 | |
| 1007 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1008 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1009 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1010 | asinh(_A1 __x) _NOEXCEPT {return __builtin_asinh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1011 | |
| 1012 | // atanh |
| 1013 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1014 | inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return __builtin_atanhf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1015 | |
| 1016 | template <class = int> |
| 1017 | _LIBCPP_HIDE_FROM_ABI double atanh(double __x) _NOEXCEPT { |
| 1018 | return __builtin_atanh(__x); |
| 1019 | } |
| 1020 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1021 | inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT {return __builtin_atanhl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1022 | |
| 1023 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1024 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1025 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1026 | atanh(_A1 __x) _NOEXCEPT {return __builtin_atanh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1027 | |
| 1028 | // cbrt |
| 1029 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1030 | inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return __builtin_cbrtf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1031 | |
| 1032 | template <class = int> |
| 1033 | _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT { |
| 1034 | return __builtin_cbrt(__x); |
| 1035 | } |
| 1036 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1037 | inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {return __builtin_cbrtl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1038 | |
| 1039 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1040 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1041 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1042 | cbrt(_A1 __x) _NOEXCEPT {return __builtin_cbrt((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1043 | |
| 1044 | // copysign |
| 1045 | |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1046 | _LIBCPP_CONSTEXPR |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1047 | inline _LIBCPP_HIDE_FROM_ABI float __libcpp_copysign(float __x, float __y) _NOEXCEPT { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1048 | return __builtin_copysignf(__x, __y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1049 | } |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1050 | |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1051 | _LIBCPP_CONSTEXPR |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1052 | inline _LIBCPP_HIDE_FROM_ABI double __libcpp_copysign(double __x, double __y) _NOEXCEPT { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1053 | return __builtin_copysign(__x, __y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1054 | } |
| 1055 | |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1056 | _LIBCPP_CONSTEXPR |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1057 | inline _LIBCPP_HIDE_FROM_ABI long double __libcpp_copysign(long double __x, long double __y) _NOEXCEPT { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1058 | return __builtin_copysignl(__x, __y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1059 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1060 | |
| 1061 | template <class _A1, class _A2> |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1062 | _LIBCPP_CONSTEXPR |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1063 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1064 | typename std::__enable_if_t |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1065 | < |
| 1066 | std::is_arithmetic<_A1>::value && |
| 1067 | std::is_arithmetic<_A2>::value, |
| 1068 | std::__promote<_A1, _A2> |
| 1069 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1070 | __libcpp_copysign(_A1 __x, _A2 __y) _NOEXCEPT { |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1071 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
| 1072 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1073 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1074 | return __builtin_copysign((__result_type)__x, (__result_type)__y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1075 | } |
| 1076 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1077 | inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT { |
| 1078 | return ::__libcpp_copysign(__x, __y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1079 | } |
| 1080 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1081 | inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT { |
| 1082 | return ::__libcpp_copysign(__x, __y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1083 | } |
| 1084 | |
| 1085 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1086 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1087 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1088 | < |
| 1089 | std::is_arithmetic<_A1>::value && |
| 1090 | std::is_arithmetic<_A2>::value, |
| 1091 | std::__promote<_A1, _A2> |
| 1092 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1093 | copysign(_A1 __x, _A2 __y) _NOEXCEPT { |
| 1094 | return ::__libcpp_copysign(__x, __y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1095 | } |
| 1096 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1097 | // erf |
| 1098 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1099 | inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return __builtin_erff(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1100 | |
| 1101 | template <class = int> |
| 1102 | _LIBCPP_HIDE_FROM_ABI double erf(double __x) _NOEXCEPT { |
| 1103 | return __builtin_erf(__x); |
| 1104 | } |
| 1105 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1106 | inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT {return __builtin_erfl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1107 | |
| 1108 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1109 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1110 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1111 | erf(_A1 __x) _NOEXCEPT {return __builtin_erf((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1112 | |
| 1113 | // erfc |
| 1114 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1115 | inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return __builtin_erfcf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1116 | |
| 1117 | template <class = int> |
| 1118 | _LIBCPP_HIDE_FROM_ABI double erfc(double __x) _NOEXCEPT { |
| 1119 | return __builtin_erfc(__x); |
| 1120 | } |
| 1121 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1122 | inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT {return __builtin_erfcl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1123 | |
| 1124 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1125 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1126 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1127 | erfc(_A1 __x) _NOEXCEPT {return __builtin_erfc((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1128 | |
| 1129 | // exp2 |
| 1130 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1131 | inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return __builtin_exp2f(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1132 | |
| 1133 | template <class = int> |
| 1134 | _LIBCPP_HIDE_FROM_ABI double exp2(double __x) _NOEXCEPT { |
| 1135 | return __builtin_exp2(__x); |
| 1136 | } |
| 1137 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1138 | inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT {return __builtin_exp2l(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1139 | |
| 1140 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1141 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1142 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1143 | exp2(_A1 __x) _NOEXCEPT {return __builtin_exp2((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1144 | |
| 1145 | // expm1 |
| 1146 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1147 | inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return __builtin_expm1f(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1148 | |
| 1149 | template <class = int> |
| 1150 | _LIBCPP_HIDE_FROM_ABI double expm1(double __x) _NOEXCEPT { |
| 1151 | return __builtin_expm1(__x); |
| 1152 | } |
| 1153 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1154 | inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT {return __builtin_expm1l(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1155 | |
| 1156 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1157 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1158 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1159 | expm1(_A1 __x) _NOEXCEPT {return __builtin_expm1((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1160 | |
| 1161 | // fdim |
| 1162 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1163 | inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return __builtin_fdimf(__x, __y);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1164 | |
| 1165 | template <class = int> |
| 1166 | _LIBCPP_HIDE_FROM_ABI double fdim(double __x, double __y) _NOEXCEPT { |
| 1167 | return __builtin_fdim(__x, __y); |
| 1168 | } |
| 1169 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1170 | inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) _NOEXCEPT {return __builtin_fdiml(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1171 | |
| 1172 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1173 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1174 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1175 | < |
| 1176 | std::is_arithmetic<_A1>::value && |
| 1177 | std::is_arithmetic<_A2>::value, |
| 1178 | std::__promote<_A1, _A2> |
| 1179 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1180 | fdim(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1181 | { |
| 1182 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1183 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1184 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1185 | return ::fdim((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1186 | } |
| 1187 | |
| 1188 | // fma |
| 1189 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1190 | inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1191 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1192 | return __builtin_fmaf(__x, __y, __z); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1193 | } |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1194 | |
| 1195 | |
| 1196 | template <class = int> |
| 1197 | _LIBCPP_HIDE_FROM_ABI double fma(double __x, double __y, double __z) _NOEXCEPT { |
| 1198 | return __builtin_fma(__x, __y, __z); |
| 1199 | } |
| 1200 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1201 | inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1202 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1203 | return __builtin_fmal(__x, __y, __z); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1204 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1205 | |
| 1206 | template <class _A1, class _A2, class _A3> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1207 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1208 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1209 | < |
| 1210 | std::is_arithmetic<_A1>::value && |
| 1211 | std::is_arithmetic<_A2>::value && |
| 1212 | std::is_arithmetic<_A3>::value, |
| 1213 | std::__promote<_A1, _A2, _A3> |
| 1214 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1215 | fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1216 | { |
| 1217 | typedef typename std::__promote<_A1, _A2, _A3>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1218 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1219 | std::_IsSame<_A2, __result_type>::value && |
| 1220 | std::_IsSame<_A3, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1221 | return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1222 | } |
| 1223 | |
| 1224 | // fmax |
| 1225 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1226 | inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return __builtin_fmaxf(__x, __y);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1227 | |
| 1228 | template <class = int> |
| 1229 | _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT { |
| 1230 | return __builtin_fmax(__x, __y); |
| 1231 | } |
| 1232 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1233 | inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT {return __builtin_fmaxl(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1234 | |
| 1235 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1236 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1237 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1238 | < |
| 1239 | std::is_arithmetic<_A1>::value && |
| 1240 | std::is_arithmetic<_A2>::value, |
| 1241 | std::__promote<_A1, _A2> |
| 1242 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1243 | fmax(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1244 | { |
| 1245 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1246 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1247 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1248 | return ::fmax((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1249 | } |
| 1250 | |
| 1251 | // fmin |
| 1252 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1253 | inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return __builtin_fminf(__x, __y);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1254 | |
| 1255 | template <class = int> |
| 1256 | _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT { |
| 1257 | return __builtin_fmin(__x, __y); |
| 1258 | } |
| 1259 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1260 | inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT {return __builtin_fminl(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1261 | |
| 1262 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1263 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1264 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1265 | < |
| 1266 | std::is_arithmetic<_A1>::value && |
| 1267 | std::is_arithmetic<_A2>::value, |
| 1268 | std::__promote<_A1, _A2> |
| 1269 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1270 | fmin(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1271 | { |
| 1272 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1273 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1274 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1275 | return ::fmin((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1276 | } |
| 1277 | |
| 1278 | // hypot |
| 1279 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1280 | inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return __builtin_hypotf(__x, __y);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1281 | |
| 1282 | template <class = int> |
| 1283 | _LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y) _NOEXCEPT { |
| 1284 | return __builtin_hypot(__x, __y); |
| 1285 | } |
| 1286 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1287 | inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) _NOEXCEPT {return __builtin_hypotl(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1288 | |
| 1289 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1290 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1291 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1292 | < |
| 1293 | std::is_arithmetic<_A1>::value && |
| 1294 | std::is_arithmetic<_A2>::value, |
| 1295 | std::__promote<_A1, _A2> |
| 1296 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1297 | hypot(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1298 | { |
| 1299 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1300 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1301 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1302 | return ::hypot((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1303 | } |
| 1304 | |
| 1305 | // ilogb |
| 1306 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1307 | inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return __builtin_ilogbf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1308 | |
| 1309 | template <class = int> |
| 1310 | _LIBCPP_HIDE_FROM_ABI double ilogb(double __x) _NOEXCEPT { |
| 1311 | return __builtin_ilogb(__x); |
| 1312 | } |
| 1313 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1314 | inline _LIBCPP_HIDE_FROM_ABI int ilogb(long double __x) _NOEXCEPT {return __builtin_ilogbl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1315 | |
| 1316 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1317 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1318 | typename std::enable_if<std::is_integral<_A1>::value, int>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1319 | ilogb(_A1 __x) _NOEXCEPT {return __builtin_ilogb((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1320 | |
| 1321 | // lgamma |
| 1322 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1323 | inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return __builtin_lgammaf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1324 | |
| 1325 | template <class = int> |
| 1326 | _LIBCPP_HIDE_FROM_ABI double lgamma(double __x) _NOEXCEPT { |
| 1327 | return __builtin_lgamma(__x); |
| 1328 | } |
| 1329 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1330 | inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT {return __builtin_lgammal(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1331 | |
| 1332 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1333 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1334 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1335 | lgamma(_A1 __x) _NOEXCEPT {return __builtin_lgamma((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1336 | |
| 1337 | // llrint |
| 1338 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1339 | inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1340 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1341 | return __builtin_llrintf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1342 | } |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1343 | |
| 1344 | template <class = int> |
| 1345 | _LIBCPP_HIDE_FROM_ABI long long llrint(double __x) _NOEXCEPT { |
| 1346 | return __builtin_llrint(__x); |
| 1347 | } |
| 1348 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1349 | inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1350 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1351 | return __builtin_llrintl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1352 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1353 | |
| 1354 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1355 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1356 | typename std::enable_if<std::is_integral<_A1>::value, long long>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1357 | llrint(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1358 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1359 | return __builtin_llrint((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1360 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1361 | |
| 1362 | // llround |
| 1363 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1364 | inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1365 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1366 | return __builtin_llroundf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1367 | } |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1368 | |
| 1369 | template <class = int> |
| 1370 | _LIBCPP_HIDE_FROM_ABI long long llround(double __x) _NOEXCEPT { |
| 1371 | return __builtin_llround(__x); |
| 1372 | } |
| 1373 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1374 | inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1375 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1376 | return __builtin_llroundl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1377 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1378 | |
| 1379 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1380 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1381 | typename std::enable_if<std::is_integral<_A1>::value, long long>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1382 | llround(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1383 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1384 | return __builtin_llround((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1385 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1386 | |
| 1387 | // log1p |
| 1388 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1389 | inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return __builtin_log1pf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1390 | |
| 1391 | template <class = int> |
| 1392 | _LIBCPP_HIDE_FROM_ABI double log1p(double __x) _NOEXCEPT { |
| 1393 | return __builtin_log1p(__x); |
| 1394 | } |
| 1395 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1396 | inline _LIBCPP_HIDE_FROM_ABI long double log1p(long double __x) _NOEXCEPT {return __builtin_log1pl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1397 | |
| 1398 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1399 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1400 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1401 | log1p(_A1 __x) _NOEXCEPT {return __builtin_log1p((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1402 | |
| 1403 | // log2 |
| 1404 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1405 | inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return __builtin_log2f(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1406 | |
| 1407 | template <class = int> |
| 1408 | _LIBCPP_HIDE_FROM_ABI double log2(double __x) _NOEXCEPT { |
| 1409 | return __builtin_log2(__x); |
| 1410 | } |
| 1411 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1412 | inline _LIBCPP_HIDE_FROM_ABI long double log2(long double __x) _NOEXCEPT {return __builtin_log2l(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1413 | |
| 1414 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1415 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1416 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1417 | log2(_A1 __x) _NOEXCEPT {return __builtin_log2((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1418 | |
| 1419 | // logb |
| 1420 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1421 | inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return __builtin_logbf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1422 | |
| 1423 | template <class = int> |
| 1424 | _LIBCPP_HIDE_FROM_ABI double logb(double __x) _NOEXCEPT { |
| 1425 | return __builtin_logb(__x); |
| 1426 | } |
| 1427 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1428 | inline _LIBCPP_HIDE_FROM_ABI long double logb(long double __x) _NOEXCEPT {return __builtin_logbl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1429 | |
| 1430 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1431 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1432 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1433 | logb(_A1 __x) _NOEXCEPT {return __builtin_logb((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1434 | |
| 1435 | // lrint |
| 1436 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1437 | inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1438 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1439 | return __builtin_lrintf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1440 | } |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1441 | |
| 1442 | template <class = int> |
| 1443 | _LIBCPP_HIDE_FROM_ABI long lrint(double __x) _NOEXCEPT { |
| 1444 | return __builtin_lrint(__x); |
| 1445 | } |
| 1446 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1447 | inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1448 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1449 | return __builtin_lrintl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1450 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1451 | |
| 1452 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1453 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1454 | typename std::enable_if<std::is_integral<_A1>::value, long>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1455 | lrint(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1456 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1457 | return __builtin_lrint((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1458 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1459 | |
| 1460 | // lround |
| 1461 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1462 | inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1463 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1464 | return __builtin_lroundf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1465 | } |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1466 | |
| 1467 | template <class = int> |
| 1468 | _LIBCPP_HIDE_FROM_ABI long lround(double __x) _NOEXCEPT { |
| 1469 | return __builtin_lround(__x); |
| 1470 | } |
| 1471 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1472 | inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1473 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1474 | return __builtin_lroundl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1475 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1476 | |
| 1477 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1478 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1479 | typename std::enable_if<std::is_integral<_A1>::value, long>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1480 | lround(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1481 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1482 | return __builtin_lround((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1483 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1484 | |
| 1485 | // nan |
| 1486 | |
| 1487 | // nearbyint |
| 1488 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1489 | inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return __builtin_nearbyintf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1490 | |
| 1491 | template <class = int> |
| 1492 | _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT { |
| 1493 | return __builtin_nearbyint(__x); |
| 1494 | } |
| 1495 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1496 | inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {return __builtin_nearbyintl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1497 | |
| 1498 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1499 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1500 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1501 | nearbyint(_A1 __x) _NOEXCEPT {return __builtin_nearbyint((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1502 | |
| 1503 | // nextafter |
| 1504 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1505 | inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return __builtin_nextafterf(__x, __y);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1506 | |
| 1507 | template <class = int> |
| 1508 | _LIBCPP_HIDE_FROM_ABI double nextafter(double __x, double __y) _NOEXCEPT { |
| 1509 | return __builtin_nextafter(__x, __y); |
| 1510 | } |
| 1511 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1512 | inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double __y) _NOEXCEPT {return __builtin_nextafterl(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1513 | |
| 1514 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1515 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1516 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1517 | < |
| 1518 | std::is_arithmetic<_A1>::value && |
| 1519 | std::is_arithmetic<_A2>::value, |
| 1520 | std::__promote<_A1, _A2> |
| 1521 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1522 | nextafter(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1523 | { |
| 1524 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1525 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1526 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1527 | return ::nextafter((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1528 | } |
| 1529 | |
| 1530 | // nexttoward |
| 1531 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1532 | inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return __builtin_nexttowardf(__x, __y);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1533 | |
| 1534 | template <class = int> |
| 1535 | _LIBCPP_HIDE_FROM_ABI double nexttoward(double __x, long double __y) _NOEXCEPT { |
| 1536 | return __builtin_nexttoward(__x, __y); |
| 1537 | } |
| 1538 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1539 | inline _LIBCPP_HIDE_FROM_ABI long double nexttoward(long double __x, long double __y) _NOEXCEPT {return __builtin_nexttowardl(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1540 | |
| 1541 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1542 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1543 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1544 | nexttoward(_A1 __x, long double __y) _NOEXCEPT {return __builtin_nexttoward((double)__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1545 | |
| 1546 | // remainder |
| 1547 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1548 | inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return __builtin_remainderf(__x, __y);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1549 | |
| 1550 | template <class = int> |
| 1551 | _LIBCPP_HIDE_FROM_ABI double remainder(double __x, double __y) _NOEXCEPT { |
| 1552 | return __builtin_remainder(__x, __y); |
| 1553 | } |
| 1554 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1555 | inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double __y) _NOEXCEPT {return __builtin_remainderl(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1556 | |
| 1557 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1558 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1559 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1560 | < |
| 1561 | std::is_arithmetic<_A1>::value && |
| 1562 | std::is_arithmetic<_A2>::value, |
| 1563 | std::__promote<_A1, _A2> |
| 1564 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1565 | remainder(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1566 | { |
| 1567 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1568 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1569 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1570 | return ::remainder((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1571 | } |
| 1572 | |
| 1573 | // remquo |
| 1574 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1575 | inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return __builtin_remquof(__x, __y, __z);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1576 | |
| 1577 | template <class = int> |
| 1578 | _LIBCPP_HIDE_FROM_ABI double remquo(double __x, double __y, int* __z) _NOEXCEPT { |
| 1579 | return __builtin_remquo(__x, __y, __z); |
| 1580 | } |
| 1581 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1582 | inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y, int* __z) _NOEXCEPT {return __builtin_remquol(__x, __y, __z);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1583 | |
| 1584 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1585 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1586 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1587 | < |
| 1588 | std::is_arithmetic<_A1>::value && |
| 1589 | std::is_arithmetic<_A2>::value, |
| 1590 | std::__promote<_A1, _A2> |
| 1591 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1592 | remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1593 | { |
| 1594 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1595 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1596 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1597 | return ::remquo((__result_type)__x, (__result_type)__y, __z); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1598 | } |
| 1599 | |
| 1600 | // rint |
| 1601 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1602 | inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1603 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1604 | return __builtin_rintf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1605 | } |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1606 | |
| 1607 | template <class = int> |
| 1608 | _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT { |
| 1609 | return __builtin_rint(__x); |
| 1610 | } |
| 1611 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1612 | inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1613 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1614 | return __builtin_rintl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1615 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1616 | |
| 1617 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1618 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1619 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1620 | rint(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1621 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1622 | return __builtin_rint((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1623 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1624 | |
| 1625 | // round |
| 1626 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1627 | inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1628 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1629 | return __builtin_round(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1630 | } |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1631 | |
| 1632 | template <class = int> |
| 1633 | _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT { |
| 1634 | return __builtin_round(__x); |
| 1635 | } |
| 1636 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1637 | inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1638 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1639 | return __builtin_roundl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1640 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1641 | |
| 1642 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1643 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1644 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1645 | round(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1646 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1647 | return __builtin_round((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1648 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1649 | |
| 1650 | // scalbln |
| 1651 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1652 | inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return __builtin_scalblnf(__x, __y);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1653 | |
| 1654 | template <class = int> |
| 1655 | _LIBCPP_HIDE_FROM_ABI double scalbln(double __x, long __y) _NOEXCEPT { |
| 1656 | return __builtin_scalbln(__x, __y); |
| 1657 | } |
| 1658 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1659 | inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT {return __builtin_scalblnl(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1660 | |
| 1661 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1662 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1663 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1664 | scalbln(_A1 __x, long __y) _NOEXCEPT {return __builtin_scalbln((double)__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1665 | |
| 1666 | // scalbn |
| 1667 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1668 | inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return __builtin_scalbnf(__x, __y);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1669 | |
| 1670 | template <class = int> |
| 1671 | _LIBCPP_HIDE_FROM_ABI double scalbn(double __x, int __y) _NOEXCEPT { |
| 1672 | return __builtin_scalbn(__x, __y); |
| 1673 | } |
| 1674 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1675 | inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT {return __builtin_scalbnl(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1676 | |
| 1677 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1678 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1679 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1680 | scalbn(_A1 __x, int __y) _NOEXCEPT {return __builtin_scalbn((double)__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1681 | |
| 1682 | // tgamma |
| 1683 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1684 | inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return __builtin_tgammaf(__x);} |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1685 | |
| 1686 | template <class = int> |
| 1687 | _LIBCPP_HIDE_FROM_ABI double tgamma(double __x) _NOEXCEPT { |
| 1688 | return __builtin_tgamma(__x); |
| 1689 | } |
| 1690 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1691 | inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT {return __builtin_tgammal(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1692 | |
| 1693 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1694 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1695 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1696 | tgamma(_A1 __x) _NOEXCEPT {return __builtin_tgamma((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1697 | |
| 1698 | // trunc |
| 1699 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1700 | inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1701 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1702 | return __builtin_trunc(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1703 | } |
Nikolas Klauser | 5239965 | 2022-11-01 22:29:57 +0100 | [diff] [blame] | 1704 | |
| 1705 | template <class = int> |
| 1706 | _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT { |
| 1707 | return __builtin_trunc(__x); |
| 1708 | } |
| 1709 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1710 | inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1711 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1712 | return __builtin_truncl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1713 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1714 | |
| 1715 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1716 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1717 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1718 | trunc(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1719 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1720 | return __builtin_trunc((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1721 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1722 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1723 | } // extern "C++" |
| 1724 | |
| 1725 | #endif // __cplusplus |
| 1726 | |
Mikhail Maltsev | 34b4f97 | 2018-02-22 09:34:08 +0000 | [diff] [blame] | 1727 | #else // _LIBCPP_MATH_H |
| 1728 | |
| 1729 | // This include lives outside the header guard in order to support an MSVC |
| 1730 | // extension which allows users to do: |
| 1731 | // |
| 1732 | // #define _USE_MATH_DEFINES |
| 1733 | // #include <math.h> |
| 1734 | // |
| 1735 | // and receive the definitions of mathematical constants, even if <math.h> |
| 1736 | // has previously been included. |
| 1737 | #if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES) |
| 1738 | #include_next <math.h> |
| 1739 | #endif |
| 1740 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1741 | #endif // _LIBCPP_MATH_H |