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