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 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 535 | // acos |
| 536 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 537 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 538 | inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return __builtin_acosf(__x);} |
| 539 | 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] | 540 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 541 | |
| 542 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 543 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 544 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 545 | acos(_A1 __x) _NOEXCEPT {return __builtin_acos((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 546 | |
| 547 | // asin |
| 548 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 549 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 550 | inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return __builtin_asinf(__x);} |
| 551 | 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] | 552 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 553 | |
| 554 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 555 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 556 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 557 | asin(_A1 __x) _NOEXCEPT {return __builtin_asin((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 558 | |
| 559 | // atan |
| 560 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 561 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 562 | inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return __builtin_atanf(__x);} |
| 563 | 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] | 564 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 565 | |
| 566 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 567 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 568 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 569 | atan(_A1 __x) _NOEXCEPT {return __builtin_atan((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 570 | |
| 571 | // atan2 |
| 572 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 573 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 574 | inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return __builtin_atan2f(__y, __x);} |
| 575 | 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] | 576 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 577 | |
| 578 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 579 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 580 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 581 | < |
| 582 | std::is_arithmetic<_A1>::value && |
| 583 | std::is_arithmetic<_A2>::value, |
| 584 | std::__promote<_A1, _A2> |
| 585 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 586 | atan2(_A1 __y, _A2 __x) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 587 | { |
| 588 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 589 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 590 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 591 | return ::atan2((__result_type)__y, (__result_type)__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | // ceil |
| 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 ceil(float __x) _NOEXCEPT {return __builtin_ceilf(__x);} |
| 598 | 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] | 599 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 600 | |
| 601 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 602 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 603 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 604 | ceil(_A1 __x) _NOEXCEPT {return __builtin_ceil((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 605 | |
| 606 | // cos |
| 607 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 608 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 609 | inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return __builtin_cosf(__x);} |
| 610 | 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] | 611 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 612 | |
| 613 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 614 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 615 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 616 | cos(_A1 __x) _NOEXCEPT {return __builtin_cos((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 617 | |
| 618 | // cosh |
| 619 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 620 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 621 | inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return __builtin_coshf(__x);} |
| 622 | 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] | 623 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 624 | |
| 625 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 626 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 627 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 628 | cosh(_A1 __x) _NOEXCEPT {return __builtin_cosh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 629 | |
| 630 | // exp |
| 631 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 632 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 633 | inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return __builtin_expf(__x);} |
| 634 | 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] | 635 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 636 | |
| 637 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 638 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 639 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 640 | exp(_A1 __x) _NOEXCEPT {return __builtin_exp((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 641 | |
| 642 | // fabs |
| 643 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 644 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 645 | inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return __builtin_fabsf(__x);} |
| 646 | 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] | 647 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 648 | |
| 649 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 650 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 651 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 652 | fabs(_A1 __x) _NOEXCEPT {return __builtin_fabs((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 653 | |
| 654 | // floor |
| 655 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 656 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 657 | inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return __builtin_floorf(__x);} |
| 658 | 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] | 659 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 660 | |
| 661 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 662 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 663 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 664 | floor(_A1 __x) _NOEXCEPT {return __builtin_floor((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 665 | |
| 666 | // fmod |
| 667 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 668 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 669 | inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return __builtin_fmodf(__x, __y);} |
| 670 | 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] | 671 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 672 | |
| 673 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 674 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 675 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 676 | < |
| 677 | std::is_arithmetic<_A1>::value && |
| 678 | std::is_arithmetic<_A2>::value, |
| 679 | std::__promote<_A1, _A2> |
| 680 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 681 | fmod(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 682 | { |
| 683 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 684 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 685 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 686 | return ::fmod((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 687 | } |
| 688 | |
| 689 | // frexp |
| 690 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 691 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 692 | inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return __builtin_frexpf(__x, __e);} |
| 693 | 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] | 694 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 695 | |
| 696 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 697 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 698 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 699 | frexp(_A1 __x, int* __e) _NOEXCEPT {return __builtin_frexp((double)__x, __e);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 700 | |
| 701 | // ldexp |
| 702 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 703 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 704 | inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return __builtin_ldexpf(__x, __e);} |
| 705 | 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] | 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 | ldexp(_A1 __x, int __e) _NOEXCEPT {return __builtin_ldexp((double)__x, __e);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 712 | |
| 713 | // log |
| 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 log(float __x) _NOEXCEPT {return __builtin_logf(__x);} |
| 717 | 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] | 718 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 719 | |
| 720 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 721 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 722 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 723 | log(_A1 __x) _NOEXCEPT {return __builtin_log((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 724 | |
| 725 | // log10 |
| 726 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 727 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 728 | inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return __builtin_log10f(__x);} |
| 729 | 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] | 730 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 731 | |
| 732 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 733 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 734 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 735 | log10(_A1 __x) _NOEXCEPT {return __builtin_log10((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 736 | |
| 737 | // modf |
| 738 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 739 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 740 | inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return __builtin_modff(__x, __y);} |
| 741 | 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] | 742 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 743 | |
| 744 | // pow |
| 745 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 746 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 747 | inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return __builtin_powf(__x, __y);} |
| 748 | 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] | 749 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 750 | |
| 751 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 752 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 753 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 754 | < |
| 755 | std::is_arithmetic<_A1>::value && |
| 756 | std::is_arithmetic<_A2>::value, |
| 757 | std::__promote<_A1, _A2> |
| 758 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 759 | pow(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 760 | { |
| 761 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 762 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 763 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 764 | return ::pow((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 765 | } |
| 766 | |
| 767 | // sin |
| 768 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 769 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 770 | inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return __builtin_sinf(__x);} |
| 771 | 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] | 772 | #endif |
| 773 | |
| 774 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 775 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 776 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 777 | sin(_A1 __x) _NOEXCEPT {return __builtin_sin((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 778 | |
| 779 | // sinh |
| 780 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 781 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 782 | inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return __builtin_sinhf(__x);} |
| 783 | 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] | 784 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 785 | |
| 786 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 787 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 788 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 789 | sinh(_A1 __x) _NOEXCEPT {return __builtin_sinh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 790 | |
| 791 | // sqrt |
| 792 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 793 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 794 | inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return __builtin_sqrtf(__x);} |
| 795 | 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] | 796 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 797 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 798 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 799 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 800 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 801 | sqrt(_A1 __x) _NOEXCEPT {return __builtin_sqrt((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 802 | |
| 803 | // tan |
| 804 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 805 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 806 | inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return __builtin_tanf(__x);} |
| 807 | 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] | 808 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 809 | |
| 810 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 811 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 812 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 813 | tan(_A1 __x) _NOEXCEPT {return __builtin_tan((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 814 | |
| 815 | // tanh |
| 816 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 817 | # if !defined(__sun__) |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 818 | inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return __builtin_tanhf(__x);} |
| 819 | 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] | 820 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 821 | |
| 822 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 823 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 824 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 825 | tanh(_A1 __x) _NOEXCEPT {return __builtin_tanh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 826 | |
| 827 | // acosh |
| 828 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 829 | inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return __builtin_acoshf(__x);} |
| 830 | 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] | 831 | |
| 832 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 833 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 834 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 835 | acosh(_A1 __x) _NOEXCEPT {return __builtin_acosh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 836 | |
| 837 | // asinh |
| 838 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 839 | inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return __builtin_asinhf(__x);} |
| 840 | 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] | 841 | |
| 842 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 843 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 844 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 845 | asinh(_A1 __x) _NOEXCEPT {return __builtin_asinh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 846 | |
| 847 | // atanh |
| 848 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 849 | inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return __builtin_atanhf(__x);} |
| 850 | 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] | 851 | |
| 852 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 853 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 854 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 855 | atanh(_A1 __x) _NOEXCEPT {return __builtin_atanh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 856 | |
| 857 | // cbrt |
| 858 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 859 | inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return __builtin_cbrtf(__x);} |
| 860 | 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] | 861 | |
| 862 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 863 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 864 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 865 | cbrt(_A1 __x) _NOEXCEPT {return __builtin_cbrt((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 866 | |
| 867 | // copysign |
| 868 | |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 869 | _LIBCPP_CONSTEXPR |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 870 | 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] | 871 | return __builtin_copysignf(__x, __y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 872 | } |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 873 | |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 874 | _LIBCPP_CONSTEXPR |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 875 | 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] | 876 | return __builtin_copysign(__x, __y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 877 | } |
| 878 | |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 879 | _LIBCPP_CONSTEXPR |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 880 | 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] | 881 | return __builtin_copysignl(__x, __y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 882 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 883 | |
| 884 | template <class _A1, class _A2> |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 885 | _LIBCPP_CONSTEXPR |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 886 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 887 | typename std::__enable_if_t |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 888 | < |
| 889 | std::is_arithmetic<_A1>::value && |
| 890 | std::is_arithmetic<_A2>::value, |
| 891 | std::__promote<_A1, _A2> |
| 892 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 893 | __libcpp_copysign(_A1 __x, _A2 __y) _NOEXCEPT { |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 894 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
| 895 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 896 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 897 | return __builtin_copysign((__result_type)__x, (__result_type)__y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 898 | } |
| 899 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 900 | inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT { |
| 901 | return ::__libcpp_copysign(__x, __y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 902 | } |
| 903 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 904 | inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT { |
| 905 | return ::__libcpp_copysign(__x, __y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 906 | } |
| 907 | |
| 908 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 909 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 910 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 911 | < |
| 912 | std::is_arithmetic<_A1>::value && |
| 913 | std::is_arithmetic<_A2>::value, |
| 914 | std::__promote<_A1, _A2> |
| 915 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 916 | copysign(_A1 __x, _A2 __y) _NOEXCEPT { |
| 917 | return ::__libcpp_copysign(__x, __y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 918 | } |
| 919 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 920 | // erf |
| 921 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 922 | inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return __builtin_erff(__x);} |
| 923 | 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] | 924 | |
| 925 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 926 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 927 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 928 | erf(_A1 __x) _NOEXCEPT {return __builtin_erf((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 929 | |
| 930 | // erfc |
| 931 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 932 | inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return __builtin_erfcf(__x);} |
| 933 | 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] | 934 | |
| 935 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 936 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 937 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 938 | erfc(_A1 __x) _NOEXCEPT {return __builtin_erfc((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 939 | |
| 940 | // exp2 |
| 941 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 942 | inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return __builtin_exp2f(__x);} |
| 943 | 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] | 944 | |
| 945 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 946 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 947 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 948 | exp2(_A1 __x) _NOEXCEPT {return __builtin_exp2((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 949 | |
| 950 | // expm1 |
| 951 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 952 | inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return __builtin_expm1f(__x);} |
| 953 | 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] | 954 | |
| 955 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 956 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 957 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 958 | expm1(_A1 __x) _NOEXCEPT {return __builtin_expm1((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 959 | |
| 960 | // fdim |
| 961 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 962 | inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return __builtin_fdimf(__x, __y);} |
| 963 | 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] | 964 | |
| 965 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 966 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 967 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 968 | < |
| 969 | std::is_arithmetic<_A1>::value && |
| 970 | std::is_arithmetic<_A2>::value, |
| 971 | std::__promote<_A1, _A2> |
| 972 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 973 | fdim(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 974 | { |
| 975 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 976 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 977 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 978 | return ::fdim((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 979 | } |
| 980 | |
| 981 | // fma |
| 982 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 983 | 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] | 984 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 985 | return __builtin_fmaf(__x, __y, __z); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 986 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 987 | 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] | 988 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 989 | return __builtin_fmal(__x, __y, __z); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 990 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 991 | |
| 992 | template <class _A1, class _A2, class _A3> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 993 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 994 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 995 | < |
| 996 | std::is_arithmetic<_A1>::value && |
| 997 | std::is_arithmetic<_A2>::value && |
| 998 | std::is_arithmetic<_A3>::value, |
| 999 | std::__promote<_A1, _A2, _A3> |
| 1000 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1001 | fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1002 | { |
| 1003 | typedef typename std::__promote<_A1, _A2, _A3>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1004 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1005 | std::_IsSame<_A2, __result_type>::value && |
| 1006 | std::_IsSame<_A3, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1007 | return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1008 | } |
| 1009 | |
| 1010 | // fmax |
| 1011 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1012 | inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return __builtin_fmaxf(__x, __y);} |
| 1013 | 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] | 1014 | |
| 1015 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1016 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1017 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1018 | < |
| 1019 | std::is_arithmetic<_A1>::value && |
| 1020 | std::is_arithmetic<_A2>::value, |
| 1021 | std::__promote<_A1, _A2> |
| 1022 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1023 | fmax(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1024 | { |
| 1025 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1026 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1027 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1028 | return ::fmax((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1029 | } |
| 1030 | |
| 1031 | // fmin |
| 1032 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1033 | inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return __builtin_fminf(__x, __y);} |
| 1034 | 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] | 1035 | |
| 1036 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1037 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1038 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1039 | < |
| 1040 | std::is_arithmetic<_A1>::value && |
| 1041 | std::is_arithmetic<_A2>::value, |
| 1042 | std::__promote<_A1, _A2> |
| 1043 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1044 | fmin(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1045 | { |
| 1046 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1047 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1048 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1049 | return ::fmin((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1050 | } |
| 1051 | |
| 1052 | // hypot |
| 1053 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1054 | inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return __builtin_hypotf(__x, __y);} |
| 1055 | 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] | 1056 | |
| 1057 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1058 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1059 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1060 | < |
| 1061 | std::is_arithmetic<_A1>::value && |
| 1062 | std::is_arithmetic<_A2>::value, |
| 1063 | std::__promote<_A1, _A2> |
| 1064 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1065 | hypot(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1066 | { |
| 1067 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1068 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1069 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1070 | return ::hypot((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1071 | } |
| 1072 | |
| 1073 | // ilogb |
| 1074 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1075 | inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return __builtin_ilogbf(__x);} |
| 1076 | 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] | 1077 | |
| 1078 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1079 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1080 | typename std::enable_if<std::is_integral<_A1>::value, int>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1081 | ilogb(_A1 __x) _NOEXCEPT {return __builtin_ilogb((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1082 | |
| 1083 | // lgamma |
| 1084 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1085 | inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return __builtin_lgammaf(__x);} |
| 1086 | 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] | 1087 | |
| 1088 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1089 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1090 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1091 | lgamma(_A1 __x) _NOEXCEPT {return __builtin_lgamma((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1092 | |
| 1093 | // llrint |
| 1094 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1095 | inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1096 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1097 | return __builtin_llrintf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1098 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1099 | inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1100 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1101 | return __builtin_llrintl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1102 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1103 | |
| 1104 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1105 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1106 | typename std::enable_if<std::is_integral<_A1>::value, long long>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1107 | llrint(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1108 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1109 | return __builtin_llrint((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1110 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1111 | |
| 1112 | // llround |
| 1113 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1114 | inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1115 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1116 | return __builtin_llroundf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1117 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1118 | inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1119 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1120 | return __builtin_llroundl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1121 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1122 | |
| 1123 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1124 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1125 | typename std::enable_if<std::is_integral<_A1>::value, long long>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1126 | llround(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1127 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1128 | return __builtin_llround((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1129 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1130 | |
| 1131 | // log1p |
| 1132 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1133 | inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return __builtin_log1pf(__x);} |
| 1134 | 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] | 1135 | |
| 1136 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1137 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1138 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1139 | log1p(_A1 __x) _NOEXCEPT {return __builtin_log1p((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1140 | |
| 1141 | // log2 |
| 1142 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1143 | inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return __builtin_log2f(__x);} |
| 1144 | 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] | 1145 | |
| 1146 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1147 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1148 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1149 | log2(_A1 __x) _NOEXCEPT {return __builtin_log2((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1150 | |
| 1151 | // logb |
| 1152 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1153 | inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return __builtin_logbf(__x);} |
| 1154 | 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] | 1155 | |
| 1156 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1157 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1158 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1159 | logb(_A1 __x) _NOEXCEPT {return __builtin_logb((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1160 | |
| 1161 | // lrint |
| 1162 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1163 | inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1164 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1165 | return __builtin_lrintf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1166 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1167 | inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1168 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1169 | return __builtin_lrintl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1170 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1171 | |
| 1172 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1173 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1174 | typename std::enable_if<std::is_integral<_A1>::value, long>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1175 | lrint(_A1 __x) _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_lrint((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1178 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1179 | |
| 1180 | // lround |
| 1181 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1182 | inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1183 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1184 | return __builtin_lroundf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1185 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1186 | inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _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_lroundl(__x); |
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> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1192 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1193 | typename std::enable_if<std::is_integral<_A1>::value, long>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1194 | lround(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1195 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1196 | return __builtin_lround((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1197 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1198 | |
| 1199 | // nan |
| 1200 | |
| 1201 | // nearbyint |
| 1202 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1203 | inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return __builtin_nearbyintf(__x);} |
| 1204 | 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] | 1205 | |
| 1206 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1207 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1208 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1209 | nearbyint(_A1 __x) _NOEXCEPT {return __builtin_nearbyint((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1210 | |
| 1211 | // nextafter |
| 1212 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1213 | inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return __builtin_nextafterf(__x, __y);} |
| 1214 | 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] | 1215 | |
| 1216 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1217 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1218 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1219 | < |
| 1220 | std::is_arithmetic<_A1>::value && |
| 1221 | std::is_arithmetic<_A2>::value, |
| 1222 | std::__promote<_A1, _A2> |
| 1223 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1224 | nextafter(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1225 | { |
| 1226 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1227 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1228 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1229 | return ::nextafter((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1230 | } |
| 1231 | |
| 1232 | // nexttoward |
| 1233 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1234 | inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return __builtin_nexttowardf(__x, __y);} |
| 1235 | 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] | 1236 | |
| 1237 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1238 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1239 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1240 | 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] | 1241 | |
| 1242 | // remainder |
| 1243 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1244 | inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return __builtin_remainderf(__x, __y);} |
| 1245 | 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] | 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 | remainder(_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 ::remainder((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1261 | } |
| 1262 | |
| 1263 | // remquo |
| 1264 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1265 | inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return __builtin_remquof(__x, __y, __z);} |
| 1266 | 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] | 1267 | |
| 1268 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1269 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1270 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1271 | < |
| 1272 | std::is_arithmetic<_A1>::value && |
| 1273 | std::is_arithmetic<_A2>::value, |
| 1274 | std::__promote<_A1, _A2> |
| 1275 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1276 | remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1277 | { |
| 1278 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1279 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1280 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1281 | return ::remquo((__result_type)__x, (__result_type)__y, __z); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1282 | } |
| 1283 | |
| 1284 | // rint |
| 1285 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1286 | inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1287 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1288 | return __builtin_rintf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1289 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1290 | inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1291 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1292 | return __builtin_rintl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1293 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1294 | |
| 1295 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1296 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1297 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1298 | rint(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1299 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1300 | return __builtin_rint((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1301 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1302 | |
| 1303 | // round |
| 1304 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1305 | inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1306 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1307 | return __builtin_round(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1308 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1309 | inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1310 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1311 | return __builtin_roundl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1312 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1313 | |
| 1314 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1315 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1316 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1317 | round(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1318 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1319 | return __builtin_round((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1320 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1321 | |
| 1322 | // scalbln |
| 1323 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1324 | inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return __builtin_scalblnf(__x, __y);} |
| 1325 | 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] | 1326 | |
| 1327 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1328 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1329 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1330 | scalbln(_A1 __x, long __y) _NOEXCEPT {return __builtin_scalbln((double)__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1331 | |
| 1332 | // scalbn |
| 1333 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1334 | inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return __builtin_scalbnf(__x, __y);} |
| 1335 | 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] | 1336 | |
| 1337 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1338 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1339 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1340 | scalbn(_A1 __x, int __y) _NOEXCEPT {return __builtin_scalbn((double)__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1341 | |
| 1342 | // tgamma |
| 1343 | |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1344 | inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return __builtin_tgammaf(__x);} |
| 1345 | 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] | 1346 | |
| 1347 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1348 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1349 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 0400595 | 2022-10-21 01:41:22 +0200 | [diff] [blame] | 1350 | tgamma(_A1 __x) _NOEXCEPT {return __builtin_tgamma((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1351 | |
| 1352 | // trunc |
| 1353 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1354 | inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1355 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1356 | return __builtin_trunc(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1357 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1358 | inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1359 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1360 | return __builtin_truncl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1361 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1362 | |
| 1363 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1364 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1365 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1366 | trunc(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1367 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1368 | return __builtin_trunc((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1369 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1370 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1371 | } // extern "C++" |
| 1372 | |
| 1373 | #endif // __cplusplus |
| 1374 | |
Mikhail Maltsev | 34b4f97 | 2018-02-22 09:34:08 +0000 | [diff] [blame] | 1375 | #else // _LIBCPP_MATH_H |
| 1376 | |
| 1377 | // This include lives outside the header guard in order to support an MSVC |
| 1378 | // extension which allows users to do: |
| 1379 | // |
| 1380 | // #define _USE_MATH_DEFINES |
| 1381 | // #include <math.h> |
| 1382 | // |
| 1383 | // and receive the definitions of mathematical constants, even if <math.h> |
| 1384 | // has previously been included. |
| 1385 | #if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES) |
| 1386 | #include_next <math.h> |
| 1387 | #endif |
| 1388 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1389 | #endif // _LIBCPP_MATH_H |