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