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