Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
Louis Dionne | 9bd9388 | 2021-11-17 16:25:01 -0500 | [diff] [blame] | 2 | //===----------------------------------------------------------------------===// |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 3 | // |
Chandler Carruth | d201210 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_MATH_H |
| 11 | #define _LIBCPP_MATH_H |
| 12 | |
| 13 | /* |
| 14 | math.h synopsis |
| 15 | |
| 16 | Macros: |
| 17 | |
| 18 | HUGE_VAL |
| 19 | HUGE_VALF // C99 |
| 20 | HUGE_VALL // C99 |
| 21 | INFINITY // C99 |
| 22 | NAN // C99 |
| 23 | FP_INFINITE // C99 |
| 24 | FP_NAN // C99 |
| 25 | FP_NORMAL // C99 |
| 26 | FP_SUBNORMAL // C99 |
| 27 | FP_ZERO // C99 |
| 28 | FP_FAST_FMA // C99 |
| 29 | FP_FAST_FMAF // C99 |
| 30 | FP_FAST_FMAL // C99 |
| 31 | FP_ILOGB0 // C99 |
| 32 | FP_ILOGBNAN // C99 |
| 33 | MATH_ERRNO // C99 |
| 34 | MATH_ERREXCEPT // C99 |
| 35 | math_errhandling // C99 |
| 36 | |
| 37 | Types: |
| 38 | |
| 39 | float_t // C99 |
| 40 | double_t // C99 |
| 41 | |
| 42 | // C90 |
| 43 | |
| 44 | floating_point abs(floating_point x); |
| 45 | |
| 46 | floating_point acos (arithmetic x); |
| 47 | float acosf(float x); |
| 48 | long double acosl(long double x); |
| 49 | |
| 50 | floating_point asin (arithmetic x); |
| 51 | float asinf(float x); |
| 52 | long double asinl(long double x); |
| 53 | |
| 54 | floating_point atan (arithmetic x); |
| 55 | float atanf(float x); |
| 56 | long double atanl(long double x); |
| 57 | |
| 58 | floating_point atan2 (arithmetic y, arithmetic x); |
| 59 | float atan2f(float y, float x); |
| 60 | long double atan2l(long double y, long double x); |
| 61 | |
| 62 | floating_point ceil (arithmetic x); |
| 63 | float ceilf(float x); |
| 64 | long double ceill(long double x); |
| 65 | |
| 66 | floating_point cos (arithmetic x); |
| 67 | float cosf(float x); |
| 68 | long double cosl(long double x); |
| 69 | |
| 70 | floating_point cosh (arithmetic x); |
| 71 | float coshf(float x); |
| 72 | long double coshl(long double x); |
| 73 | |
| 74 | floating_point exp (arithmetic x); |
| 75 | float expf(float x); |
| 76 | long double expl(long double x); |
| 77 | |
| 78 | floating_point fabs (arithmetic x); |
| 79 | float fabsf(float x); |
| 80 | long double fabsl(long double x); |
| 81 | |
| 82 | floating_point floor (arithmetic x); |
| 83 | float floorf(float x); |
| 84 | long double floorl(long double x); |
| 85 | |
| 86 | floating_point fmod (arithmetic x, arithmetic y); |
| 87 | float fmodf(float x, float y); |
| 88 | long double fmodl(long double x, long double y); |
| 89 | |
| 90 | floating_point frexp (arithmetic value, int* exp); |
| 91 | float frexpf(float value, int* exp); |
| 92 | long double frexpl(long double value, int* exp); |
| 93 | |
| 94 | floating_point ldexp (arithmetic value, int exp); |
| 95 | float ldexpf(float value, int exp); |
| 96 | long double ldexpl(long double value, int exp); |
| 97 | |
| 98 | floating_point log (arithmetic x); |
| 99 | float logf(float x); |
| 100 | long double logl(long double x); |
| 101 | |
| 102 | floating_point log10 (arithmetic x); |
| 103 | float log10f(float x); |
| 104 | long double log10l(long double x); |
| 105 | |
| 106 | floating_point modf (floating_point value, floating_point* iptr); |
| 107 | float modff(float value, float* iptr); |
| 108 | long double modfl(long double value, long double* iptr); |
| 109 | |
| 110 | floating_point pow (arithmetic x, arithmetic y); |
| 111 | float powf(float x, float y); |
| 112 | long double powl(long double x, long double y); |
| 113 | |
| 114 | floating_point sin (arithmetic x); |
| 115 | float sinf(float x); |
| 116 | long double sinl(long double x); |
| 117 | |
| 118 | floating_point sinh (arithmetic x); |
| 119 | float sinhf(float x); |
| 120 | long double sinhl(long double x); |
| 121 | |
| 122 | floating_point sqrt (arithmetic x); |
| 123 | float sqrtf(float x); |
| 124 | long double sqrtl(long double x); |
| 125 | |
| 126 | floating_point tan (arithmetic x); |
| 127 | float tanf(float x); |
| 128 | long double tanl(long double x); |
| 129 | |
| 130 | floating_point tanh (arithmetic x); |
| 131 | float tanhf(float x); |
| 132 | long double tanhl(long double x); |
| 133 | |
| 134 | // C99 |
| 135 | |
| 136 | bool signbit(arithmetic x); |
| 137 | |
| 138 | int fpclassify(arithmetic x); |
| 139 | |
| 140 | bool isfinite(arithmetic x); |
| 141 | bool isinf(arithmetic x); |
| 142 | bool isnan(arithmetic x); |
| 143 | bool isnormal(arithmetic x); |
| 144 | |
| 145 | bool isgreater(arithmetic x, arithmetic y); |
| 146 | bool isgreaterequal(arithmetic x, arithmetic y); |
| 147 | bool isless(arithmetic x, arithmetic y); |
| 148 | bool islessequal(arithmetic x, arithmetic y); |
| 149 | bool islessgreater(arithmetic x, arithmetic y); |
| 150 | bool isunordered(arithmetic x, arithmetic y); |
| 151 | |
| 152 | floating_point acosh (arithmetic x); |
| 153 | float acoshf(float x); |
| 154 | long double acoshl(long double x); |
| 155 | |
| 156 | floating_point asinh (arithmetic x); |
| 157 | float asinhf(float x); |
| 158 | long double asinhl(long double x); |
| 159 | |
| 160 | floating_point atanh (arithmetic x); |
| 161 | float atanhf(float x); |
| 162 | long double atanhl(long double x); |
| 163 | |
| 164 | floating_point cbrt (arithmetic x); |
| 165 | float cbrtf(float x); |
| 166 | long double cbrtl(long double x); |
| 167 | |
| 168 | floating_point copysign (arithmetic x, arithmetic y); |
| 169 | float copysignf(float x, float y); |
| 170 | long double copysignl(long double x, long double y); |
| 171 | |
| 172 | floating_point erf (arithmetic x); |
| 173 | float erff(float x); |
| 174 | long double erfl(long double x); |
| 175 | |
| 176 | floating_point erfc (arithmetic x); |
| 177 | float erfcf(float x); |
| 178 | long double erfcl(long double x); |
| 179 | |
| 180 | floating_point exp2 (arithmetic x); |
| 181 | float exp2f(float x); |
| 182 | long double exp2l(long double x); |
| 183 | |
| 184 | floating_point expm1 (arithmetic x); |
| 185 | float expm1f(float x); |
| 186 | long double expm1l(long double x); |
| 187 | |
| 188 | floating_point fdim (arithmetic x, arithmetic y); |
| 189 | float fdimf(float x, float y); |
| 190 | long double fdiml(long double x, long double y); |
| 191 | |
| 192 | floating_point fma (arithmetic x, arithmetic y, arithmetic z); |
| 193 | float fmaf(float x, float y, float z); |
| 194 | long double fmal(long double x, long double y, long double z); |
| 195 | |
| 196 | floating_point fmax (arithmetic x, arithmetic y); |
| 197 | float fmaxf(float x, float y); |
| 198 | long double fmaxl(long double x, long double y); |
| 199 | |
| 200 | floating_point fmin (arithmetic x, arithmetic y); |
| 201 | float fminf(float x, float y); |
| 202 | long double fminl(long double x, long double y); |
| 203 | |
| 204 | floating_point hypot (arithmetic x, arithmetic y); |
| 205 | float hypotf(float x, float y); |
| 206 | long double hypotl(long double x, long double y); |
| 207 | |
| 208 | int ilogb (arithmetic x); |
| 209 | int ilogbf(float x); |
| 210 | int ilogbl(long double x); |
| 211 | |
| 212 | floating_point lgamma (arithmetic x); |
| 213 | float lgammaf(float x); |
| 214 | long double lgammal(long double x); |
| 215 | |
| 216 | long long llrint (arithmetic x); |
| 217 | long long llrintf(float x); |
| 218 | long long llrintl(long double x); |
| 219 | |
| 220 | long long llround (arithmetic x); |
| 221 | long long llroundf(float x); |
| 222 | long long llroundl(long double x); |
| 223 | |
| 224 | floating_point log1p (arithmetic x); |
| 225 | float log1pf(float x); |
| 226 | long double log1pl(long double x); |
| 227 | |
| 228 | floating_point log2 (arithmetic x); |
| 229 | float log2f(float x); |
| 230 | long double log2l(long double x); |
| 231 | |
| 232 | floating_point logb (arithmetic x); |
| 233 | float logbf(float x); |
| 234 | long double logbl(long double x); |
| 235 | |
| 236 | long lrint (arithmetic x); |
| 237 | long lrintf(float x); |
| 238 | long lrintl(long double x); |
| 239 | |
| 240 | long lround (arithmetic x); |
| 241 | long lroundf(float x); |
| 242 | long lroundl(long double x); |
| 243 | |
| 244 | double nan (const char* str); |
| 245 | float nanf(const char* str); |
| 246 | long double nanl(const char* str); |
| 247 | |
| 248 | floating_point nearbyint (arithmetic x); |
| 249 | float nearbyintf(float x); |
| 250 | long double nearbyintl(long double x); |
| 251 | |
| 252 | floating_point nextafter (arithmetic x, arithmetic y); |
| 253 | float nextafterf(float x, float y); |
| 254 | long double nextafterl(long double x, long double y); |
| 255 | |
| 256 | floating_point nexttoward (arithmetic x, long double y); |
| 257 | float nexttowardf(float x, long double y); |
| 258 | long double nexttowardl(long double x, long double y); |
| 259 | |
| 260 | floating_point remainder (arithmetic x, arithmetic y); |
| 261 | float remainderf(float x, float y); |
| 262 | long double remainderl(long double x, long double y); |
| 263 | |
| 264 | floating_point remquo (arithmetic x, arithmetic y, int* pquo); |
| 265 | float remquof(float x, float y, int* pquo); |
| 266 | long double remquol(long double x, long double y, int* pquo); |
| 267 | |
| 268 | floating_point rint (arithmetic x); |
| 269 | float rintf(float x); |
| 270 | long double rintl(long double x); |
| 271 | |
| 272 | floating_point round (arithmetic x); |
| 273 | float roundf(float x); |
| 274 | long double roundl(long double x); |
| 275 | |
| 276 | floating_point scalbln (arithmetic x, long ex); |
| 277 | float scalblnf(float x, long ex); |
| 278 | long double scalblnl(long double x, long ex); |
| 279 | |
| 280 | floating_point scalbn (arithmetic x, int ex); |
| 281 | float scalbnf(float x, int ex); |
| 282 | long double scalbnl(long double x, int ex); |
| 283 | |
| 284 | floating_point tgamma (arithmetic x); |
| 285 | float tgammaf(float x); |
| 286 | long double tgammal(long double x); |
| 287 | |
| 288 | floating_point trunc (arithmetic x); |
| 289 | float truncf(float x); |
| 290 | long double truncl(long double x); |
| 291 | |
| 292 | */ |
| 293 | |
| 294 | #include <__config> |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 295 | |
| 296 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Arthur O'Dwyer | 6eeaa00 | 2022-02-01 20:16:40 -0500 | [diff] [blame] | 297 | # pragma GCC system_header |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 298 | #endif |
| 299 | |
Louis Dionne | be1aa9e | 2022-11-15 17:08:01 -0500 | [diff] [blame] | 300 | # if __has_include_next(<math.h>) |
| 301 | # include_next <math.h> |
| 302 | # endif |
Mikhail Maltsev | 34b4f97 | 2018-02-22 09:34:08 +0000 | [diff] [blame] | 303 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 304 | #ifdef __cplusplus |
| 305 | |
| 306 | // We support including .h headers inside 'extern "C"' contexts, so switch |
| 307 | // back to C++ linkage before including these C++ headers. |
| 308 | extern "C++" { |
| 309 | |
Nikolas Klauser | 6c8f712 | 2022-07-24 16:03:12 +0200 | [diff] [blame] | 310 | #include <__type_traits/promote.h> |
Arthur O'Dwyer | 65077c0 | 2022-01-07 09:45:05 -0500 | [diff] [blame] | 311 | #include <limits> |
Eric Fiselier | 6c9e1a7 | 2020-02-15 18:55:07 -0500 | [diff] [blame] | 312 | #include <stdlib.h> |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 313 | #include <type_traits> |
| 314 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 315 | // signbit |
| 316 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 317 | # ifdef signbit |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 318 | |
| 319 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 320 | _LIBCPP_HIDE_FROM_ABI bool __libcpp_signbit(_A1 __x) _NOEXCEPT { |
| 321 | # if __has_builtin(__builtin_signbit) |
| 322 | return __builtin_signbit(__x); |
| 323 | # else |
| 324 | return signbit(__x); |
| 325 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 326 | } |
| 327 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 328 | # undef signbit |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 329 | |
| 330 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 331 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type |
| 332 | signbit(_A1 __x) _NOEXCEPT { |
| 333 | return __libcpp_signbit(__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 334 | } |
| 335 | |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 336 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 337 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 338 | typename std::enable_if< std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type |
| 339 | signbit(_A1 __x) _NOEXCEPT { |
| 340 | return __x < 0; |
| 341 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 342 | |
| 343 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 344 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 345 | typename std::enable_if< std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type |
| 346 | signbit(_A1) _NOEXCEPT { |
| 347 | return false; |
| 348 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 349 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 350 | # elif defined(_LIBCPP_MSVCRT) |
Saleem Abdulrasool | 257256b | 2017-02-18 19:28:38 +0000 | [diff] [blame] | 351 | |
| 352 | template <typename _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 353 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type |
| 354 | signbit(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 37a5b4f | 2022-10-27 20:01:13 +0200 | [diff] [blame] | 355 | return ::signbit(__x); |
Saleem Abdulrasool | 257256b | 2017-02-18 19:28:38 +0000 | [diff] [blame] | 356 | } |
| 357 | |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 358 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 359 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 360 | typename std::enable_if< std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type |
| 361 | signbit(_A1 __x) _NOEXCEPT { |
| 362 | return __x < 0; |
| 363 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 364 | |
| 365 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 366 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 367 | typename std::enable_if< std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type |
| 368 | signbit(_A1) _NOEXCEPT { |
| 369 | return false; |
| 370 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 371 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 372 | # endif // signbit |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 373 | |
| 374 | // fpclassify |
| 375 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 376 | # ifdef fpclassify |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 377 | |
| 378 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 379 | _LIBCPP_HIDE_FROM_ABI int __libcpp_fpclassify(_A1 __x) _NOEXCEPT { |
| 380 | # if __has_builtin(__builtin_fpclassify) |
| 381 | return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); |
| 382 | # else |
| 383 | return fpclassify(__x); |
| 384 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 385 | } |
| 386 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 387 | # undef fpclassify |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 388 | |
| 389 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 390 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, int>::type |
| 391 | fpclassify(_A1 __x) _NOEXCEPT { |
| 392 | return __libcpp_fpclassify(__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 393 | } |
| 394 | |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 395 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 396 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, int>::type |
| 397 | fpclassify(_A1 __x) _NOEXCEPT { |
| 398 | return __x == 0 ? FP_ZERO : FP_NORMAL; |
| 399 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 400 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 401 | # elif defined(_LIBCPP_MSVCRT) |
Saleem Abdulrasool | 257256b | 2017-02-18 19:28:38 +0000 | [diff] [blame] | 402 | |
| 403 | template <typename _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 404 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type |
| 405 | fpclassify(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 37a5b4f | 2022-10-27 20:01:13 +0200 | [diff] [blame] | 406 | return ::fpclassify(__x); |
Saleem Abdulrasool | 257256b | 2017-02-18 19:28:38 +0000 | [diff] [blame] | 407 | } |
| 408 | |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 409 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 410 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, int>::type |
| 411 | fpclassify(_A1 __x) _NOEXCEPT { |
| 412 | return __x == 0 ? FP_ZERO : FP_NORMAL; |
| 413 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 414 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 415 | # endif // fpclassify |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 416 | |
| 417 | // isfinite |
| 418 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 419 | # ifdef isfinite |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 420 | |
| 421 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 422 | _LIBCPP_HIDE_FROM_ABI bool __libcpp_isfinite(_A1 __x) _NOEXCEPT { |
| 423 | # if __has_builtin(__builtin_isfinite) |
| 424 | return __builtin_isfinite(__x); |
| 425 | # else |
| 426 | return isfinite(__x); |
| 427 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 428 | } |
| 429 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 430 | # undef isfinite |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 431 | |
| 432 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 433 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 434 | typename std::enable_if< std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, bool>::type |
| 435 | isfinite(_A1 __x) _NOEXCEPT { |
| 436 | return __libcpp_isfinite((typename std::__promote<_A1>::type)__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 437 | } |
| 438 | |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 439 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 440 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 441 | typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type |
| 442 | isfinite(_A1) _NOEXCEPT { |
| 443 | return true; |
| 444 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 445 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 446 | # endif // isfinite |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 447 | |
| 448 | // isinf |
| 449 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 450 | # ifdef isinf |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 451 | |
| 452 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 453 | _LIBCPP_HIDE_FROM_ABI bool __libcpp_isinf(_A1 __x) _NOEXCEPT { |
| 454 | # if __has_builtin(__builtin_isinf) |
| 455 | return __builtin_isinf(__x); |
| 456 | # else |
| 457 | return isinf(__x); |
| 458 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 459 | } |
| 460 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 461 | # undef isinf |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 462 | |
| 463 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 464 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 465 | typename std::enable_if< std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, bool>::type |
| 466 | isinf(_A1 __x) _NOEXCEPT { |
| 467 | return __libcpp_isinf((typename std::__promote<_A1>::type)__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 468 | } |
| 469 | |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 470 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 471 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 472 | typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type |
| 473 | isinf(_A1) _NOEXCEPT { |
| 474 | return false; |
| 475 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 476 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 477 | # ifdef _LIBCPP_PREFERRED_OVERLOAD |
| 478 | inline _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { return __libcpp_isinf(__x); } |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 479 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 480 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT { return __libcpp_isinf(__x); } |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 481 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 482 | inline _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { return __libcpp_isinf(__x); } |
| 483 | # endif |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 484 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 485 | # endif // isinf |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 486 | |
| 487 | // isnan |
| 488 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 489 | # ifdef isnan |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 490 | |
| 491 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 492 | _LIBCPP_HIDE_FROM_ABI bool __libcpp_isnan(_A1 __x) _NOEXCEPT { |
| 493 | # if __has_builtin(__builtin_isnan) |
| 494 | return __builtin_isnan(__x); |
| 495 | # else |
| 496 | return isnan(__x); |
| 497 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 498 | } |
| 499 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 500 | # undef isnan |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 501 | |
| 502 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 503 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type |
| 504 | isnan(_A1 __x) _NOEXCEPT { |
| 505 | return __libcpp_isnan(__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 506 | } |
| 507 | |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 508 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 509 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, bool>::type isnan(_A1) _NOEXCEPT { |
| 510 | return false; |
| 511 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 512 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 513 | # ifdef _LIBCPP_PREFERRED_OVERLOAD |
| 514 | inline _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { return __libcpp_isnan(__x); } |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 515 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 516 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT { return __libcpp_isnan(__x); } |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 517 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 518 | inline _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { return __libcpp_isnan(__x); } |
| 519 | # endif |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 520 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 521 | # endif // isnan |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 522 | |
| 523 | // isnormal |
| 524 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 525 | # ifdef isnormal |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 526 | |
| 527 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 528 | _LIBCPP_HIDE_FROM_ABI bool __libcpp_isnormal(_A1 __x) _NOEXCEPT { |
| 529 | # if __has_builtin(__builtin_isnormal) |
| 530 | return __builtin_isnormal(__x); |
| 531 | # else |
| 532 | return isnormal(__x); |
| 533 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 534 | } |
| 535 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 536 | # undef isnormal |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 537 | |
| 538 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 539 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type |
| 540 | isnormal(_A1 __x) _NOEXCEPT { |
| 541 | return __libcpp_isnormal(__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 542 | } |
| 543 | |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 544 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 545 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, bool>::type |
| 546 | isnormal(_A1 __x) _NOEXCEPT { |
| 547 | return __x != 0; |
| 548 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 549 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 550 | # endif // isnormal |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 551 | |
| 552 | // isgreater |
| 553 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 554 | # ifdef isgreater |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 555 | |
| 556 | template <class _A1, class _A2> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 557 | _LIBCPP_HIDE_FROM_ABI bool __libcpp_isgreater(_A1 __x, _A2 __y) _NOEXCEPT { |
| 558 | return isgreater(__x, __y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 559 | } |
| 560 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 561 | # undef isgreater |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 562 | |
| 563 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 564 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 565 | typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type |
| 566 | isgreater(_A1 __x, _A2 __y) _NOEXCEPT { |
| 567 | typedef typename std::__promote<_A1, _A2>::type type; |
| 568 | return __libcpp_isgreater((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 569 | } |
| 570 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 571 | # endif // isgreater |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 572 | |
| 573 | // isgreaterequal |
| 574 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 575 | # ifdef isgreaterequal |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 576 | |
| 577 | template <class _A1, class _A2> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 578 | _LIBCPP_HIDE_FROM_ABI bool __libcpp_isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { |
| 579 | return isgreaterequal(__x, __y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 580 | } |
| 581 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 582 | # undef isgreaterequal |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 583 | |
| 584 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 585 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 586 | typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type |
| 587 | isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { |
| 588 | typedef typename std::__promote<_A1, _A2>::type type; |
| 589 | return __libcpp_isgreaterequal((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 590 | } |
| 591 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 592 | # endif // isgreaterequal |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 593 | |
| 594 | // isless |
| 595 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 596 | # ifdef isless |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 597 | |
| 598 | template <class _A1, class _A2> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 599 | _LIBCPP_HIDE_FROM_ABI bool __libcpp_isless(_A1 __x, _A2 __y) _NOEXCEPT { |
| 600 | return isless(__x, __y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 601 | } |
| 602 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 603 | # undef isless |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 604 | |
| 605 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 606 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 607 | typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type |
| 608 | isless(_A1 __x, _A2 __y) _NOEXCEPT { |
| 609 | typedef typename std::__promote<_A1, _A2>::type type; |
| 610 | return __libcpp_isless((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 611 | } |
| 612 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 613 | # endif // isless |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 614 | |
| 615 | // islessequal |
| 616 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 617 | # ifdef islessequal |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 618 | |
| 619 | template <class _A1, class _A2> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 620 | _LIBCPP_HIDE_FROM_ABI bool __libcpp_islessequal(_A1 __x, _A2 __y) _NOEXCEPT { |
| 621 | return islessequal(__x, __y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 622 | } |
| 623 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 624 | # undef islessequal |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 625 | |
| 626 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 627 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 628 | typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type |
| 629 | islessequal(_A1 __x, _A2 __y) _NOEXCEPT { |
| 630 | typedef typename std::__promote<_A1, _A2>::type type; |
| 631 | return __libcpp_islessequal((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 632 | } |
| 633 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 634 | # endif // islessequal |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 635 | |
| 636 | // islessgreater |
| 637 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 638 | # ifdef islessgreater |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 639 | |
| 640 | template <class _A1, class _A2> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 641 | _LIBCPP_HIDE_FROM_ABI bool __libcpp_islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { |
| 642 | return islessgreater(__x, __y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 643 | } |
| 644 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 645 | # undef islessgreater |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 646 | |
| 647 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 648 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 649 | typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type |
| 650 | islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { |
| 651 | typedef typename std::__promote<_A1, _A2>::type type; |
| 652 | return __libcpp_islessgreater((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 653 | } |
| 654 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 655 | # endif // islessgreater |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 656 | |
| 657 | // isunordered |
| 658 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 659 | # ifdef isunordered |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 660 | |
| 661 | template <class _A1, class _A2> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 662 | _LIBCPP_HIDE_FROM_ABI bool __libcpp_isunordered(_A1 __x, _A2 __y) _NOEXCEPT { |
| 663 | return isunordered(__x, __y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 664 | } |
| 665 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 666 | # undef isunordered |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 667 | |
| 668 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 669 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 670 | typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type |
| 671 | isunordered(_A1 __x, _A2 __y) _NOEXCEPT { |
| 672 | typedef typename std::__promote<_A1, _A2>::type type; |
| 673 | return __libcpp_isunordered((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 674 | } |
| 675 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame^] | 676 | # endif // isunordered |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 677 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 678 | // abs |
Eric Fiselier | 6c9e1a7 | 2020-02-15 18:55:07 -0500 | [diff] [blame] | 679 | // |
| 680 | // handled in stdlib.h |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 681 | |
Eric Fiselier | 2b85c6e | 2019-04-23 18:01:58 +0000 | [diff] [blame] | 682 | // div |
Eric Fiselier | 6c9e1a7 | 2020-02-15 18:55:07 -0500 | [diff] [blame] | 683 | // |
| 684 | // handled in stdlib.h |
Eric Fiselier | 2b85c6e | 2019-04-23 18:01:58 +0000 | [diff] [blame] | 685 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 686 | // acos |
| 687 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 688 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 689 | inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return ::acosf(__x);} |
| 690 | inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT {return ::acosl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 691 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 692 | |
| 693 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 694 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 695 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 696 | acos(_A1 __x) _NOEXCEPT {return ::acos((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 697 | |
| 698 | // asin |
| 699 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 700 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 701 | inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return ::asinf(__x);} |
| 702 | inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT {return ::asinl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 703 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 704 | |
| 705 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 706 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 707 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 708 | asin(_A1 __x) _NOEXCEPT {return ::asin((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 709 | |
| 710 | // atan |
| 711 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 712 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 713 | inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return ::atanf(__x);} |
| 714 | inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT {return ::atanl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 715 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 716 | |
| 717 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 718 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 719 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 720 | atan(_A1 __x) _NOEXCEPT {return ::atan((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 721 | |
| 722 | // atan2 |
| 723 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 724 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 725 | inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return ::atan2f(__y, __x);} |
| 726 | inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) _NOEXCEPT {return ::atan2l(__y, __x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 727 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 728 | |
| 729 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 730 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 731 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 732 | < |
| 733 | std::is_arithmetic<_A1>::value && |
| 734 | std::is_arithmetic<_A2>::value, |
| 735 | std::__promote<_A1, _A2> |
| 736 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 737 | atan2(_A1 __y, _A2 __x) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 738 | { |
| 739 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 740 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 741 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 742 | return ::atan2((__result_type)__y, (__result_type)__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 743 | } |
| 744 | |
| 745 | // ceil |
| 746 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 747 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 748 | inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return ::ceilf(__x);} |
| 749 | inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return ::ceill(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 750 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 751 | |
| 752 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 753 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 754 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 755 | ceil(_A1 __x) _NOEXCEPT {return ::ceil((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 756 | |
| 757 | // cos |
| 758 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 759 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 760 | inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return ::cosf(__x);} |
| 761 | inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT {return ::cosl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 762 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 763 | |
| 764 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 765 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 766 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 767 | cos(_A1 __x) _NOEXCEPT {return ::cos((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 768 | |
| 769 | // cosh |
| 770 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 771 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 772 | inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return ::coshf(__x);} |
| 773 | inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT {return ::coshl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 774 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 775 | |
| 776 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 777 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 778 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 779 | cosh(_A1 __x) _NOEXCEPT {return ::cosh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 780 | |
| 781 | // exp |
| 782 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 783 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 784 | inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return ::expf(__x);} |
| 785 | inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT {return ::expl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 786 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 787 | |
| 788 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 789 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 790 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 791 | exp(_A1 __x) _NOEXCEPT {return ::exp((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 792 | |
| 793 | // fabs |
| 794 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 795 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 796 | inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return ::fabsf(__x);} |
| 797 | inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return ::fabsl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 798 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 799 | |
| 800 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 801 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 802 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 803 | fabs(_A1 __x) _NOEXCEPT {return ::fabs((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 804 | |
| 805 | // floor |
| 806 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 807 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 808 | inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return ::floorf(__x);} |
| 809 | inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return ::floorl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 810 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 811 | |
| 812 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 813 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 814 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 815 | floor(_A1 __x) _NOEXCEPT {return ::floor((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 816 | |
| 817 | // fmod |
| 818 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 819 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 820 | inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return ::fmodf(__x, __y);} |
| 821 | inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) _NOEXCEPT {return ::fmodl(__x, __y);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 822 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 823 | |
| 824 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 825 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 826 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 827 | < |
| 828 | std::is_arithmetic<_A1>::value && |
| 829 | std::is_arithmetic<_A2>::value, |
| 830 | std::__promote<_A1, _A2> |
| 831 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 832 | fmod(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 833 | { |
| 834 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 835 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 836 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 837 | return ::fmod((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 838 | } |
| 839 | |
| 840 | // frexp |
| 841 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 842 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 843 | inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return ::frexpf(__x, __e);} |
| 844 | inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {return ::frexpl(__x, __e);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 845 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 846 | |
| 847 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 848 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 849 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 850 | frexp(_A1 __x, int* __e) _NOEXCEPT {return ::frexp((double)__x, __e);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 851 | |
| 852 | // ldexp |
| 853 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 854 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 855 | inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return ::ldexpf(__x, __e);} |
| 856 | inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {return ::ldexpl(__x, __e);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 857 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 858 | |
| 859 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 860 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 861 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 862 | ldexp(_A1 __x, int __e) _NOEXCEPT {return ::ldexp((double)__x, __e);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 863 | |
| 864 | // log |
| 865 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 866 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 867 | inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return ::logf(__x);} |
| 868 | inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT {return ::logl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 869 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 870 | |
| 871 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 872 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 873 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 874 | log(_A1 __x) _NOEXCEPT {return ::log((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 875 | |
| 876 | // log10 |
| 877 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 878 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 879 | inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return ::log10f(__x);} |
| 880 | inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT {return ::log10l(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 881 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 882 | |
| 883 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 884 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 885 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 886 | log10(_A1 __x) _NOEXCEPT {return ::log10((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 887 | |
| 888 | // modf |
| 889 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 890 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 891 | inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return ::modff(__x, __y);} |
| 892 | inline _LIBCPP_HIDE_FROM_ABI long double modf(long double __x, long double* __y) _NOEXCEPT {return ::modfl(__x, __y);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 893 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 894 | |
| 895 | // pow |
| 896 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 897 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 898 | inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return ::powf(__x, __y);} |
| 899 | inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _NOEXCEPT {return ::powl(__x, __y);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 900 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 901 | |
| 902 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 903 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 904 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 905 | < |
| 906 | std::is_arithmetic<_A1>::value && |
| 907 | std::is_arithmetic<_A2>::value, |
| 908 | std::__promote<_A1, _A2> |
| 909 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 910 | pow(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 911 | { |
| 912 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 913 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 914 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 915 | return ::pow((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 916 | } |
| 917 | |
| 918 | // sin |
| 919 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 920 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 921 | inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return ::sinf(__x);} |
| 922 | inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT {return ::sinl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 923 | #endif |
| 924 | |
| 925 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 926 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 927 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 928 | sin(_A1 __x) _NOEXCEPT {return ::sin((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 929 | |
| 930 | // sinh |
| 931 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 932 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 933 | inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return ::sinhf(__x);} |
| 934 | inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT {return ::sinhl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 935 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 936 | |
| 937 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 938 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 939 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 940 | sinh(_A1 __x) _NOEXCEPT {return ::sinh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 941 | |
| 942 | // sqrt |
| 943 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 944 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 945 | inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return ::sqrtf(__x);} |
| 946 | inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT {return ::sqrtl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 947 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 948 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 949 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 950 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 951 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 952 | sqrt(_A1 __x) _NOEXCEPT {return ::sqrt((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 953 | |
| 954 | // tan |
| 955 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 956 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 957 | inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return ::tanf(__x);} |
| 958 | inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT {return ::tanl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 959 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 960 | |
| 961 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 962 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 963 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 964 | tan(_A1 __x) _NOEXCEPT {return ::tan((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 965 | |
| 966 | // tanh |
| 967 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 968 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 969 | inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return ::tanhf(__x);} |
| 970 | inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT {return ::tanhl(__x);} |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 971 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 972 | |
| 973 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 974 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 975 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 976 | tanh(_A1 __x) _NOEXCEPT {return ::tanh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 977 | |
| 978 | // acosh |
| 979 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 980 | inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return ::acoshf(__x);} |
| 981 | inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT {return ::acoshl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 982 | |
| 983 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 984 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 985 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 986 | acosh(_A1 __x) _NOEXCEPT {return ::acosh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 987 | |
| 988 | // asinh |
| 989 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 990 | inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return ::asinhf(__x);} |
| 991 | inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT {return ::asinhl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 992 | |
| 993 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 994 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 995 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 996 | asinh(_A1 __x) _NOEXCEPT {return ::asinh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 997 | |
| 998 | // atanh |
| 999 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1000 | inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return ::atanhf(__x);} |
| 1001 | inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT {return ::atanhl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1002 | |
| 1003 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1004 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1005 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1006 | atanh(_A1 __x) _NOEXCEPT {return ::atanh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1007 | |
| 1008 | // cbrt |
| 1009 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1010 | inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return ::cbrtf(__x);} |
| 1011 | inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {return ::cbrtl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1012 | |
| 1013 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1014 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1015 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1016 | cbrt(_A1 __x) _NOEXCEPT {return ::cbrt((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1017 | |
| 1018 | // copysign |
| 1019 | |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1020 | #if __has_builtin(__builtin_copysignf) |
| 1021 | _LIBCPP_CONSTEXPR |
| 1022 | #endif |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1023 | inline _LIBCPP_HIDE_FROM_ABI float __libcpp_copysign(float __x, float __y) _NOEXCEPT { |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1024 | #if __has_builtin(__builtin_copysignf) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1025 | return __builtin_copysignf(__x, __y); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1026 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1027 | return ::copysignf(__x, __y); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1028 | #endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1029 | } |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1030 | |
| 1031 | #if __has_builtin(__builtin_copysign) |
| 1032 | _LIBCPP_CONSTEXPR |
| 1033 | #endif |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1034 | inline _LIBCPP_HIDE_FROM_ABI double __libcpp_copysign(double __x, double __y) _NOEXCEPT { |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1035 | #if __has_builtin(__builtin_copysign) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1036 | return __builtin_copysign(__x, __y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1037 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1038 | return ::copysign(__x, __y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1039 | #endif |
| 1040 | } |
| 1041 | |
| 1042 | #if __has_builtin(__builtin_copysignl) |
| 1043 | _LIBCPP_CONSTEXPR |
| 1044 | #endif |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1045 | inline _LIBCPP_HIDE_FROM_ABI long double __libcpp_copysign(long double __x, long double __y) _NOEXCEPT { |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1046 | #if __has_builtin(__builtin_copysignl) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1047 | return __builtin_copysignl(__x, __y); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1048 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1049 | return ::copysignl(__x, __y); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1050 | #endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1051 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1052 | |
| 1053 | template <class _A1, class _A2> |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1054 | #if __has_builtin(__builtin_copysign) |
| 1055 | _LIBCPP_CONSTEXPR |
| 1056 | #endif |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1057 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1058 | typename std::__enable_if_t |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1059 | < |
| 1060 | std::is_arithmetic<_A1>::value && |
| 1061 | std::is_arithmetic<_A2>::value, |
| 1062 | std::__promote<_A1, _A2> |
| 1063 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1064 | __libcpp_copysign(_A1 __x, _A2 __y) _NOEXCEPT { |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1065 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
| 1066 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1067 | std::_IsSame<_A2, __result_type>::value)), ""); |
| 1068 | #if __has_builtin(__builtin_copysign) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1069 | return __builtin_copysign((__result_type)__x, (__result_type)__y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1070 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1071 | return ::copysign((__result_type)__x, (__result_type)__y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1072 | #endif |
| 1073 | } |
| 1074 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1075 | inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT { |
| 1076 | return ::__libcpp_copysign(__x, __y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1077 | } |
| 1078 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1079 | inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT { |
| 1080 | return ::__libcpp_copysign(__x, __y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 1081 | } |
| 1082 | |
| 1083 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1084 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1085 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1086 | < |
| 1087 | std::is_arithmetic<_A1>::value && |
| 1088 | std::is_arithmetic<_A2>::value, |
| 1089 | std::__promote<_A1, _A2> |
| 1090 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1091 | copysign(_A1 __x, _A2 __y) _NOEXCEPT { |
| 1092 | return ::__libcpp_copysign(__x, __y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1093 | } |
| 1094 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1095 | // erf |
| 1096 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1097 | inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return ::erff(__x);} |
| 1098 | inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT {return ::erfl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1099 | |
| 1100 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1101 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1102 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1103 | erf(_A1 __x) _NOEXCEPT {return ::erf((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1104 | |
| 1105 | // erfc |
| 1106 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1107 | inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return ::erfcf(__x);} |
| 1108 | inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT {return ::erfcl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1109 | |
| 1110 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1111 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1112 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1113 | erfc(_A1 __x) _NOEXCEPT {return ::erfc((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1114 | |
| 1115 | // exp2 |
| 1116 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1117 | inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return ::exp2f(__x);} |
| 1118 | inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT {return ::exp2l(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1119 | |
| 1120 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1121 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1122 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1123 | exp2(_A1 __x) _NOEXCEPT {return ::exp2((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1124 | |
| 1125 | // expm1 |
| 1126 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1127 | inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return ::expm1f(__x);} |
| 1128 | inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT {return ::expm1l(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1129 | |
| 1130 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1131 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1132 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1133 | expm1(_A1 __x) _NOEXCEPT {return ::expm1((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1134 | |
| 1135 | // fdim |
| 1136 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1137 | inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return ::fdimf(__x, __y);} |
| 1138 | inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) _NOEXCEPT {return ::fdiml(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1139 | |
| 1140 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1141 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1142 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1143 | < |
| 1144 | std::is_arithmetic<_A1>::value && |
| 1145 | std::is_arithmetic<_A2>::value, |
| 1146 | std::__promote<_A1, _A2> |
| 1147 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1148 | fdim(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1149 | { |
| 1150 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1151 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1152 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1153 | return ::fdim((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1154 | } |
| 1155 | |
| 1156 | // fma |
| 1157 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1158 | inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1159 | { |
| 1160 | #if __has_builtin(__builtin_fmaf) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1161 | return __builtin_fmaf(__x, __y, __z); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1162 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1163 | return ::fmaf(__x, __y, __z); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1164 | #endif |
| 1165 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1166 | inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1167 | { |
| 1168 | #if __has_builtin(__builtin_fmal) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1169 | return __builtin_fmal(__x, __y, __z); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1170 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1171 | return ::fmal(__x, __y, __z); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1172 | #endif |
| 1173 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1174 | |
| 1175 | template <class _A1, class _A2, class _A3> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1176 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1177 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1178 | < |
| 1179 | std::is_arithmetic<_A1>::value && |
| 1180 | std::is_arithmetic<_A2>::value && |
| 1181 | std::is_arithmetic<_A3>::value, |
| 1182 | std::__promote<_A1, _A2, _A3> |
| 1183 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1184 | fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1185 | { |
| 1186 | typedef typename std::__promote<_A1, _A2, _A3>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1187 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1188 | std::_IsSame<_A2, __result_type>::value && |
| 1189 | std::_IsSame<_A3, __result_type>::value)), ""); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1190 | #if __has_builtin(__builtin_fma) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1191 | return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1192 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1193 | return ::fma((__result_type)__x, (__result_type)__y, (__result_type)__z); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1194 | #endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1195 | } |
| 1196 | |
| 1197 | // fmax |
| 1198 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1199 | inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return ::fmaxf(__x, __y);} |
| 1200 | inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT {return ::fmaxl(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1201 | |
| 1202 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1203 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1204 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1205 | < |
| 1206 | std::is_arithmetic<_A1>::value && |
| 1207 | std::is_arithmetic<_A2>::value, |
| 1208 | std::__promote<_A1, _A2> |
| 1209 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1210 | fmax(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1211 | { |
| 1212 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1213 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1214 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1215 | return ::fmax((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1216 | } |
| 1217 | |
| 1218 | // fmin |
| 1219 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1220 | inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return ::fminf(__x, __y);} |
| 1221 | inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT {return ::fminl(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1222 | |
| 1223 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1224 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1225 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1226 | < |
| 1227 | std::is_arithmetic<_A1>::value && |
| 1228 | std::is_arithmetic<_A2>::value, |
| 1229 | std::__promote<_A1, _A2> |
| 1230 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1231 | fmin(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1232 | { |
| 1233 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1234 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1235 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1236 | return ::fmin((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1237 | } |
| 1238 | |
| 1239 | // hypot |
| 1240 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1241 | inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return ::hypotf(__x, __y);} |
| 1242 | inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) _NOEXCEPT {return ::hypotl(__x, __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 |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1252 | hypot(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 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)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1257 | return ::hypot((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1258 | } |
| 1259 | |
| 1260 | // ilogb |
| 1261 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1262 | inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return ::ilogbf(__x);} |
| 1263 | inline _LIBCPP_HIDE_FROM_ABI int ilogb(long double __x) _NOEXCEPT {return ::ilogbl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1264 | |
| 1265 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1266 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1267 | typename std::enable_if<std::is_integral<_A1>::value, int>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1268 | ilogb(_A1 __x) _NOEXCEPT {return ::ilogb((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1269 | |
| 1270 | // lgamma |
| 1271 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1272 | inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return ::lgammaf(__x);} |
| 1273 | inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT {return ::lgammal(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1274 | |
| 1275 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1276 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1277 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1278 | lgamma(_A1 __x) _NOEXCEPT {return ::lgamma((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1279 | |
| 1280 | // llrint |
| 1281 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1282 | inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1283 | { |
| 1284 | #if __has_builtin(__builtin_llrintf) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1285 | return __builtin_llrintf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1286 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1287 | return ::llrintf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1288 | #endif |
| 1289 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1290 | inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1291 | { |
| 1292 | #if __has_builtin(__builtin_llrintl) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1293 | return __builtin_llrintl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1294 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1295 | return ::llrintl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1296 | #endif |
| 1297 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1298 | |
| 1299 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1300 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1301 | typename std::enable_if<std::is_integral<_A1>::value, long long>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1302 | llrint(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1303 | { |
| 1304 | #if __has_builtin(__builtin_llrint) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1305 | return __builtin_llrint((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1306 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1307 | return ::llrint((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1308 | #endif |
| 1309 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1310 | |
| 1311 | // llround |
| 1312 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1313 | inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1314 | { |
| 1315 | #if __has_builtin(__builtin_llroundf) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1316 | return __builtin_llroundf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1317 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1318 | return ::llroundf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1319 | #endif |
| 1320 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1321 | inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1322 | { |
| 1323 | #if __has_builtin(__builtin_llroundl) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1324 | return __builtin_llroundl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1325 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1326 | return ::llroundl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1327 | #endif |
| 1328 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1329 | |
| 1330 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1331 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1332 | typename std::enable_if<std::is_integral<_A1>::value, long long>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1333 | llround(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1334 | { |
| 1335 | #if __has_builtin(__builtin_llround) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1336 | return __builtin_llround((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1337 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1338 | return ::llround((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1339 | #endif |
| 1340 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1341 | |
| 1342 | // log1p |
| 1343 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1344 | inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return ::log1pf(__x);} |
| 1345 | inline _LIBCPP_HIDE_FROM_ABI long double log1p(long double __x) _NOEXCEPT {return ::log1pl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1346 | |
| 1347 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1348 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1349 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1350 | log1p(_A1 __x) _NOEXCEPT {return ::log1p((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1351 | |
| 1352 | // log2 |
| 1353 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1354 | inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return ::log2f(__x);} |
| 1355 | inline _LIBCPP_HIDE_FROM_ABI long double log2(long double __x) _NOEXCEPT {return ::log2l(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1356 | |
| 1357 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1358 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1359 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1360 | log2(_A1 __x) _NOEXCEPT {return ::log2((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1361 | |
| 1362 | // logb |
| 1363 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1364 | inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return ::logbf(__x);} |
| 1365 | inline _LIBCPP_HIDE_FROM_ABI long double logb(long double __x) _NOEXCEPT {return ::logbl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1366 | |
| 1367 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1368 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1369 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1370 | logb(_A1 __x) _NOEXCEPT {return ::logb((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1371 | |
| 1372 | // lrint |
| 1373 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1374 | inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1375 | { |
| 1376 | #if __has_builtin(__builtin_lrintf) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1377 | return __builtin_lrintf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1378 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1379 | return ::lrintf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1380 | #endif |
| 1381 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1382 | inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1383 | { |
| 1384 | #if __has_builtin(__builtin_lrintl) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1385 | return __builtin_lrintl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1386 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1387 | return ::lrintl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1388 | #endif |
| 1389 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1390 | |
| 1391 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1392 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1393 | typename std::enable_if<std::is_integral<_A1>::value, long>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1394 | lrint(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1395 | { |
| 1396 | #if __has_builtin(__builtin_lrint) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1397 | return __builtin_lrint((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1398 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1399 | return ::lrint((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1400 | #endif |
| 1401 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1402 | |
| 1403 | // lround |
| 1404 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1405 | inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1406 | { |
| 1407 | #if __has_builtin(__builtin_lroundf) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1408 | return __builtin_lroundf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1409 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1410 | return ::lroundf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1411 | #endif |
| 1412 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1413 | inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1414 | { |
| 1415 | #if __has_builtin(__builtin_lroundl) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1416 | return __builtin_lroundl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1417 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1418 | return ::lroundl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1419 | #endif |
| 1420 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1421 | |
| 1422 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1423 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1424 | typename std::enable_if<std::is_integral<_A1>::value, long>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1425 | lround(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1426 | { |
| 1427 | #if __has_builtin(__builtin_lround) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1428 | return __builtin_lround((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1429 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1430 | return ::lround((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1431 | #endif |
| 1432 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1433 | |
| 1434 | // nan |
| 1435 | |
| 1436 | // nearbyint |
| 1437 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1438 | inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return ::nearbyintf(__x);} |
| 1439 | inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {return ::nearbyintl(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1440 | |
| 1441 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1442 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1443 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1444 | nearbyint(_A1 __x) _NOEXCEPT {return ::nearbyint((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1445 | |
| 1446 | // nextafter |
| 1447 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1448 | inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return ::nextafterf(__x, __y);} |
| 1449 | inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double __y) _NOEXCEPT {return ::nextafterl(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1450 | |
| 1451 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1452 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1453 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1454 | < |
| 1455 | std::is_arithmetic<_A1>::value && |
| 1456 | std::is_arithmetic<_A2>::value, |
| 1457 | std::__promote<_A1, _A2> |
| 1458 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1459 | nextafter(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1460 | { |
| 1461 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1462 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1463 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1464 | return ::nextafter((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1465 | } |
| 1466 | |
| 1467 | // nexttoward |
| 1468 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1469 | inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return ::nexttowardf(__x, __y);} |
| 1470 | inline _LIBCPP_HIDE_FROM_ABI long double nexttoward(long double __x, long double __y) _NOEXCEPT {return ::nexttowardl(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1471 | |
| 1472 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1473 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1474 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1475 | nexttoward(_A1 __x, long double __y) _NOEXCEPT {return ::nexttoward((double)__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1476 | |
| 1477 | // remainder |
| 1478 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1479 | inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return ::remainderf(__x, __y);} |
| 1480 | inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double __y) _NOEXCEPT {return ::remainderl(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1481 | |
| 1482 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1483 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1484 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1485 | < |
| 1486 | std::is_arithmetic<_A1>::value && |
| 1487 | std::is_arithmetic<_A2>::value, |
| 1488 | std::__promote<_A1, _A2> |
| 1489 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1490 | remainder(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1491 | { |
| 1492 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1493 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1494 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1495 | return ::remainder((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1496 | } |
| 1497 | |
| 1498 | // remquo |
| 1499 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1500 | inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return ::remquof(__x, __y, __z);} |
| 1501 | inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y, int* __z) _NOEXCEPT {return ::remquol(__x, __y, __z);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1502 | |
| 1503 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1504 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1505 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1506 | < |
| 1507 | std::is_arithmetic<_A1>::value && |
| 1508 | std::is_arithmetic<_A2>::value, |
| 1509 | std::__promote<_A1, _A2> |
| 1510 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1511 | remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1512 | { |
| 1513 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1514 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1515 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1516 | return ::remquo((__result_type)__x, (__result_type)__y, __z); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1517 | } |
| 1518 | |
| 1519 | // rint |
| 1520 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1521 | inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1522 | { |
| 1523 | #if __has_builtin(__builtin_rintf) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1524 | return __builtin_rintf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1525 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1526 | return ::rintf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1527 | #endif |
| 1528 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1529 | inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1530 | { |
| 1531 | #if __has_builtin(__builtin_rintl) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1532 | return __builtin_rintl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1533 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1534 | return ::rintl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1535 | #endif |
| 1536 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1537 | |
| 1538 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1539 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1540 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1541 | rint(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1542 | { |
| 1543 | #if __has_builtin(__builtin_rint) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1544 | return __builtin_rint((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1545 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1546 | return ::rint((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1547 | #endif |
| 1548 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1549 | |
| 1550 | // round |
| 1551 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1552 | inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1553 | { |
| 1554 | #if __has_builtin(__builtin_round) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1555 | return __builtin_round(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1556 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1557 | return ::round(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1558 | #endif |
| 1559 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1560 | inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1561 | { |
| 1562 | #if __has_builtin(__builtin_roundl) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1563 | return __builtin_roundl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1564 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1565 | return ::roundl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1566 | #endif |
| 1567 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1568 | |
| 1569 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1570 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1571 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1572 | round(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1573 | { |
| 1574 | #if __has_builtin(__builtin_round) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1575 | return __builtin_round((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1576 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1577 | return ::round((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1578 | #endif |
| 1579 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1580 | |
| 1581 | // scalbln |
| 1582 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1583 | inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return ::scalblnf(__x, __y);} |
| 1584 | inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT {return ::scalblnl(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1585 | |
| 1586 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1587 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1588 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1589 | scalbln(_A1 __x, long __y) _NOEXCEPT {return ::scalbln((double)__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1590 | |
| 1591 | // scalbn |
| 1592 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1593 | inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return ::scalbnf(__x, __y);} |
| 1594 | inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT {return ::scalbnl(__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1595 | |
| 1596 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1597 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1598 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1599 | scalbn(_A1 __x, int __y) _NOEXCEPT {return ::scalbn((double)__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1600 | |
| 1601 | // tgamma |
| 1602 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1603 | inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return ::tgammaf(__x);} |
| 1604 | inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT {return ::tgammal(__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1605 | |
| 1606 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1607 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1608 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1609 | tgamma(_A1 __x) _NOEXCEPT {return ::tgamma((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1610 | |
| 1611 | // trunc |
| 1612 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1613 | inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1614 | { |
| 1615 | #if __has_builtin(__builtin_trunc) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1616 | return __builtin_trunc(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1617 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1618 | return ::trunc(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1619 | #endif |
| 1620 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1621 | inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1622 | { |
| 1623 | #if __has_builtin(__builtin_truncl) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1624 | return __builtin_truncl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1625 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1626 | return ::truncl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1627 | #endif |
| 1628 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1629 | |
| 1630 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1631 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1632 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1633 | trunc(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1634 | { |
| 1635 | #if __has_builtin(__builtin_trunc) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1636 | return __builtin_trunc((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1637 | #else |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1638 | return ::trunc((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1639 | #endif |
| 1640 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1641 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1642 | } // extern "C++" |
| 1643 | |
| 1644 | #endif // __cplusplus |
| 1645 | |
Mikhail Maltsev | 34b4f97 | 2018-02-22 09:34:08 +0000 | [diff] [blame] | 1646 | #else // _LIBCPP_MATH_H |
| 1647 | |
| 1648 | // This include lives outside the header guard in order to support an MSVC |
| 1649 | // extension which allows users to do: |
| 1650 | // |
| 1651 | // #define _USE_MATH_DEFINES |
| 1652 | // #include <math.h> |
| 1653 | // |
| 1654 | // and receive the definitions of mathematical constants, even if <math.h> |
| 1655 | // has previously been included. |
| 1656 | #if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES) |
| 1657 | #include_next <math.h> |
| 1658 | #endif |
| 1659 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1660 | #endif // _LIBCPP_MATH_H |