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 |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 318 | # undef signbit |
Nikolas Klauser | 88b1e94 | 2022-11-04 17:01:22 +0100 | [diff] [blame^] | 319 | # endif // signbit |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 320 | |
| 321 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 322 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type |
| 323 | signbit(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 324 | return __builtin_signbit(__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 325 | } |
| 326 | |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 327 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 328 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 329 | typename std::enable_if< std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type |
| 330 | signbit(_A1 __x) _NOEXCEPT { |
| 331 | return __x < 0; |
| 332 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 333 | |
| 334 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 335 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 336 | typename std::enable_if< std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type |
| 337 | signbit(_A1) _NOEXCEPT { |
| 338 | return false; |
| 339 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 340 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 341 | // fpclassify |
| 342 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 343 | # ifdef fpclassify |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 344 | # undef fpclassify |
Nikolas Klauser | 88b1e94 | 2022-11-04 17:01:22 +0100 | [diff] [blame^] | 345 | # endif // fpclassify |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 346 | |
| 347 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 348 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, int>::type |
| 349 | fpclassify(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 350 | return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 351 | } |
| 352 | |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 353 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 354 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, int>::type |
| 355 | fpclassify(_A1 __x) _NOEXCEPT { |
| 356 | return __x == 0 ? FP_ZERO : FP_NORMAL; |
| 357 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 358 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 359 | // isfinite |
| 360 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 361 | # ifdef isfinite |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 362 | # undef isfinite |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 363 | |
| 364 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 365 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 366 | typename std::enable_if< std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, bool>::type |
| 367 | isfinite(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 368 | return __builtin_isfinite((typename std::__promote<_A1>::type)__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 369 | } |
| 370 | |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 371 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 372 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 373 | typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type |
| 374 | isfinite(_A1) _NOEXCEPT { |
| 375 | return true; |
| 376 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 377 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 378 | # endif // isfinite |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 379 | |
| 380 | // isinf |
| 381 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 382 | # ifdef isinf |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 383 | # undef isinf |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 384 | |
| 385 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 386 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 387 | typename std::enable_if< std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, bool>::type |
| 388 | isinf(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 389 | return __builtin_isinf((typename std::__promote<_A1>::type)__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 390 | } |
| 391 | |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 392 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 393 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 394 | typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type |
| 395 | isinf(_A1) _NOEXCEPT { |
| 396 | return false; |
| 397 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 398 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 399 | # ifdef _LIBCPP_PREFERRED_OVERLOAD |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 400 | inline _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { return __builtin_isinf(__x); } |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 401 | |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 402 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT { return __builtin_isinf(__x); } |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 403 | |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 404 | inline _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { return __builtin_isinf(__x); } |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 405 | # endif |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 406 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 407 | # endif // isinf |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 408 | |
| 409 | // isnan |
| 410 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 411 | # ifdef isnan |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 412 | # undef isnan |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 413 | |
| 414 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 415 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type |
| 416 | isnan(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 417 | return __builtin_isnan(__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 418 | } |
| 419 | |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 420 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 421 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, bool>::type isnan(_A1) _NOEXCEPT { |
| 422 | return false; |
| 423 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 424 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 425 | # ifdef _LIBCPP_PREFERRED_OVERLOAD |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 426 | inline _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { return __builtin_isnan(__x); } |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 427 | |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 428 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT { return __builtin_isnan(__x); } |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 429 | |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 430 | inline _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { return __builtin_isnan(__x); } |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 431 | # endif |
Richard Smith | afccfd3 | 2018-05-01 03:05:40 +0000 | [diff] [blame] | 432 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 433 | # endif // isnan |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 434 | |
| 435 | // isnormal |
| 436 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 437 | # ifdef isnormal |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 438 | # undef isnormal |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 439 | |
| 440 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 441 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type |
| 442 | isnormal(_A1 __x) _NOEXCEPT { |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 443 | return __builtin_isnormal(__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 444 | } |
| 445 | |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 446 | template <class _A1> |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 447 | inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, bool>::type |
| 448 | isnormal(_A1 __x) _NOEXCEPT { |
| 449 | return __x != 0; |
| 450 | } |
Duncan P. N. Exon Smith | 321d6bf | 2017-04-21 23:14:55 +0000 | [diff] [blame] | 451 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 452 | # endif // isnormal |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 453 | |
| 454 | // isgreater |
| 455 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 456 | # ifdef isgreater |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 457 | # undef isgreater |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 458 | |
| 459 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 460 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 461 | typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type |
| 462 | isgreater(_A1 __x, _A2 __y) _NOEXCEPT { |
| 463 | typedef typename std::__promote<_A1, _A2>::type type; |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 464 | return __builtin_isgreater((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 465 | } |
| 466 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 467 | # endif // isgreater |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 468 | |
| 469 | // isgreaterequal |
| 470 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 471 | # ifdef isgreaterequal |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 472 | # undef isgreaterequal |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 473 | |
| 474 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 475 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 476 | typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type |
| 477 | isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { |
| 478 | typedef typename std::__promote<_A1, _A2>::type type; |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 479 | return __builtin_isgreaterequal((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 480 | } |
| 481 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 482 | # endif // isgreaterequal |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 483 | |
| 484 | // isless |
| 485 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 486 | # ifdef isless |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 487 | # undef isless |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 488 | |
| 489 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 490 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 491 | typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type |
| 492 | isless(_A1 __x, _A2 __y) _NOEXCEPT { |
| 493 | typedef typename std::__promote<_A1, _A2>::type type; |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 494 | return __builtin_isless((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 495 | } |
| 496 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 497 | # endif // isless |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 498 | |
| 499 | // islessequal |
| 500 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 501 | # ifdef islessequal |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 502 | # undef islessequal |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 503 | |
| 504 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 505 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 506 | typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type |
| 507 | islessequal(_A1 __x, _A2 __y) _NOEXCEPT { |
| 508 | typedef typename std::__promote<_A1, _A2>::type type; |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 509 | return __builtin_islessequal((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 510 | } |
| 511 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 512 | # endif // islessequal |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 513 | |
| 514 | // islessgreater |
| 515 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 516 | # ifdef islessgreater |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 517 | # undef islessgreater |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 518 | |
| 519 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 520 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 521 | typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type |
| 522 | islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { |
| 523 | typedef typename std::__promote<_A1, _A2>::type type; |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 524 | return __builtin_islessgreater((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 525 | } |
| 526 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 527 | # endif // islessgreater |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 528 | |
| 529 | // isunordered |
| 530 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 531 | # ifdef isunordered |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 532 | # undef isunordered |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 533 | |
| 534 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 535 | inline _LIBCPP_HIDE_FROM_ABI |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 536 | typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type |
| 537 | isunordered(_A1 __x, _A2 __y) _NOEXCEPT { |
| 538 | typedef typename std::__promote<_A1, _A2>::type type; |
Nikolas Klauser | 25fbc47 | 2022-11-04 16:56:51 +0100 | [diff] [blame] | 539 | return __builtin_isunordered((type)__x, (type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 540 | } |
| 541 | |
Nikolas Klauser | 9a97dd7 | 2022-11-04 16:36:34 +0100 | [diff] [blame] | 542 | # endif // isunordered |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 543 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 544 | // abs |
Eric Fiselier | 6c9e1a7 | 2020-02-15 18:55:07 -0500 | [diff] [blame] | 545 | // |
| 546 | // handled in stdlib.h |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 547 | |
Eric Fiselier | 2b85c6e | 2019-04-23 18:01:58 +0000 | [diff] [blame] | 548 | // div |
Eric Fiselier | 6c9e1a7 | 2020-02-15 18:55:07 -0500 | [diff] [blame] | 549 | // |
| 550 | // handled in stdlib.h |
Eric Fiselier | 2b85c6e | 2019-04-23 18:01:58 +0000 | [diff] [blame] | 551 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 552 | // acos |
| 553 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 554 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 555 | inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return ::acosf(__x);} |
| 556 | 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] | 557 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 558 | |
| 559 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 560 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 561 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 562 | acos(_A1 __x) _NOEXCEPT {return ::acos((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 563 | |
| 564 | // asin |
| 565 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 566 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 567 | inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return ::asinf(__x);} |
| 568 | 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] | 569 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 570 | |
| 571 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 572 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 573 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 574 | asin(_A1 __x) _NOEXCEPT {return ::asin((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 575 | |
| 576 | // atan |
| 577 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 578 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 579 | inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return ::atanf(__x);} |
| 580 | 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] | 581 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 582 | |
| 583 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 584 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 585 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 586 | atan(_A1 __x) _NOEXCEPT {return ::atan((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 587 | |
| 588 | // atan2 |
| 589 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 590 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 591 | inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return ::atan2f(__y, __x);} |
| 592 | 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] | 593 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 594 | |
| 595 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 596 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 597 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 598 | < |
| 599 | std::is_arithmetic<_A1>::value && |
| 600 | std::is_arithmetic<_A2>::value, |
| 601 | std::__promote<_A1, _A2> |
| 602 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 603 | atan2(_A1 __y, _A2 __x) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 604 | { |
| 605 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 606 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 607 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 608 | return ::atan2((__result_type)__y, (__result_type)__x); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | // ceil |
| 612 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 613 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 614 | inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return ::ceilf(__x);} |
| 615 | 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] | 616 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 617 | |
| 618 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 619 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 620 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 621 | ceil(_A1 __x) _NOEXCEPT {return ::ceil((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 622 | |
| 623 | // cos |
| 624 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 625 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 626 | inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return ::cosf(__x);} |
| 627 | 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] | 628 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 629 | |
| 630 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 631 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 632 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 633 | cos(_A1 __x) _NOEXCEPT {return ::cos((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 634 | |
| 635 | // cosh |
| 636 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 637 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 638 | inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return ::coshf(__x);} |
| 639 | 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] | 640 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 641 | |
| 642 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 643 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 644 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 645 | cosh(_A1 __x) _NOEXCEPT {return ::cosh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 646 | |
| 647 | // exp |
| 648 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 649 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 650 | inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return ::expf(__x);} |
| 651 | 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] | 652 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 653 | |
| 654 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 655 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 656 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 657 | exp(_A1 __x) _NOEXCEPT {return ::exp((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 658 | |
| 659 | // fabs |
| 660 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 661 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 662 | inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return ::fabsf(__x);} |
| 663 | 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] | 664 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 665 | |
| 666 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 667 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 668 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 669 | fabs(_A1 __x) _NOEXCEPT {return ::fabs((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 670 | |
| 671 | // floor |
| 672 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 673 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 674 | inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return ::floorf(__x);} |
| 675 | 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] | 676 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 677 | |
| 678 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 679 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 680 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 681 | floor(_A1 __x) _NOEXCEPT {return ::floor((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 682 | |
| 683 | // fmod |
| 684 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 685 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 686 | inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return ::fmodf(__x, __y);} |
| 687 | 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] | 688 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 689 | |
| 690 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 691 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 692 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 693 | < |
| 694 | std::is_arithmetic<_A1>::value && |
| 695 | std::is_arithmetic<_A2>::value, |
| 696 | std::__promote<_A1, _A2> |
| 697 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 698 | fmod(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 699 | { |
| 700 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 701 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 702 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 703 | return ::fmod((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 704 | } |
| 705 | |
| 706 | // frexp |
| 707 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 708 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 709 | inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return ::frexpf(__x, __e);} |
| 710 | 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] | 711 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 712 | |
| 713 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 714 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 715 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 716 | frexp(_A1 __x, int* __e) _NOEXCEPT {return ::frexp((double)__x, __e);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 717 | |
| 718 | // ldexp |
| 719 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 720 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 721 | inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return ::ldexpf(__x, __e);} |
| 722 | 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] | 723 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 724 | |
| 725 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 726 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 727 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 728 | ldexp(_A1 __x, int __e) _NOEXCEPT {return ::ldexp((double)__x, __e);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 729 | |
| 730 | // log |
| 731 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 732 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 733 | inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return ::logf(__x);} |
| 734 | 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] | 735 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 736 | |
| 737 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 738 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 739 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 740 | log(_A1 __x) _NOEXCEPT {return ::log((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 741 | |
| 742 | // log10 |
| 743 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 744 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 745 | inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return ::log10f(__x);} |
| 746 | 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] | 747 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 748 | |
| 749 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 750 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 751 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 752 | log10(_A1 __x) _NOEXCEPT {return ::log10((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 753 | |
| 754 | // modf |
| 755 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 756 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 757 | inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return ::modff(__x, __y);} |
| 758 | 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] | 759 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 760 | |
| 761 | // pow |
| 762 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 763 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 764 | inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return ::powf(__x, __y);} |
| 765 | 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] | 766 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 767 | |
| 768 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 769 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 770 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 771 | < |
| 772 | std::is_arithmetic<_A1>::value && |
| 773 | std::is_arithmetic<_A2>::value, |
| 774 | std::__promote<_A1, _A2> |
| 775 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 776 | pow(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 777 | { |
| 778 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 779 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 780 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 781 | return ::pow((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 782 | } |
| 783 | |
| 784 | // sin |
| 785 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 786 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 787 | inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return ::sinf(__x);} |
| 788 | 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] | 789 | #endif |
| 790 | |
| 791 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 792 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 793 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 794 | sin(_A1 __x) _NOEXCEPT {return ::sin((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 795 | |
| 796 | // sinh |
| 797 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 798 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 799 | inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return ::sinhf(__x);} |
| 800 | 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] | 801 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 802 | |
| 803 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 804 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 805 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 806 | sinh(_A1 __x) _NOEXCEPT {return ::sinh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 807 | |
| 808 | // sqrt |
| 809 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 810 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 811 | inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return ::sqrtf(__x);} |
| 812 | 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] | 813 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 814 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 815 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 816 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 817 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 818 | sqrt(_A1 __x) _NOEXCEPT {return ::sqrt((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 819 | |
| 820 | // tan |
| 821 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 822 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 823 | inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return ::tanf(__x);} |
| 824 | 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] | 825 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 826 | |
| 827 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 828 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 829 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 830 | tan(_A1 __x) _NOEXCEPT {return ::tan((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 831 | |
| 832 | // tanh |
| 833 | |
David Tenty | 7249ac9 | 2022-02-07 18:22:35 -0500 | [diff] [blame] | 834 | # if !defined(__sun__) |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 835 | inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return ::tanhf(__x);} |
| 836 | 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] | 837 | # endif |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 838 | |
| 839 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 840 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 841 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 842 | tanh(_A1 __x) _NOEXCEPT {return ::tanh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 843 | |
| 844 | // acosh |
| 845 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 846 | inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return ::acoshf(__x);} |
| 847 | 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] | 848 | |
| 849 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 850 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 851 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 852 | acosh(_A1 __x) _NOEXCEPT {return ::acosh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 853 | |
| 854 | // asinh |
| 855 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 856 | inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return ::asinhf(__x);} |
| 857 | 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] | 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 | asinh(_A1 __x) _NOEXCEPT {return ::asinh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 863 | |
| 864 | // atanh |
| 865 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 866 | inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return ::atanhf(__x);} |
| 867 | 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] | 868 | |
| 869 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 870 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 871 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 872 | atanh(_A1 __x) _NOEXCEPT {return ::atanh((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 873 | |
| 874 | // cbrt |
| 875 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 876 | inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return ::cbrtf(__x);} |
| 877 | 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] | 878 | |
| 879 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 880 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 881 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 882 | cbrt(_A1 __x) _NOEXCEPT {return ::cbrt((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 883 | |
| 884 | // copysign |
| 885 | |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 886 | _LIBCPP_CONSTEXPR |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 887 | inline _LIBCPP_HIDE_FROM_ABI float __libcpp_copysign(float __x, float __y) _NOEXCEPT { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 888 | return __builtin_copysignf(__x, __y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 889 | } |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 890 | |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 891 | _LIBCPP_CONSTEXPR |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 892 | inline _LIBCPP_HIDE_FROM_ABI double __libcpp_copysign(double __x, double __y) _NOEXCEPT { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 893 | return __builtin_copysign(__x, __y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 894 | } |
| 895 | |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 896 | _LIBCPP_CONSTEXPR |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 897 | inline _LIBCPP_HIDE_FROM_ABI long double __libcpp_copysign(long double __x, long double __y) _NOEXCEPT { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 898 | return __builtin_copysignl(__x, __y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 899 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 900 | |
| 901 | template <class _A1, class _A2> |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 902 | _LIBCPP_CONSTEXPR |
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 |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [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 | __libcpp_copysign(_A1 __x, _A2 __y) _NOEXCEPT { |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 911 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
| 912 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 913 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 914 | return __builtin_copysign((__result_type)__x, (__result_type)__y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 915 | } |
| 916 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 917 | inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT { |
| 918 | return ::__libcpp_copysign(__x, __y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 919 | } |
| 920 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 921 | inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT { |
| 922 | return ::__libcpp_copysign(__x, __y); |
Marek Kurdej | a933f0d | 2021-07-21 15:58:17 +0200 | [diff] [blame] | 923 | } |
| 924 | |
| 925 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 926 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 927 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 928 | < |
| 929 | std::is_arithmetic<_A1>::value && |
| 930 | std::is_arithmetic<_A2>::value, |
| 931 | std::__promote<_A1, _A2> |
| 932 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 933 | copysign(_A1 __x, _A2 __y) _NOEXCEPT { |
| 934 | return ::__libcpp_copysign(__x, __y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 935 | } |
| 936 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 937 | // erf |
| 938 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 939 | inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return ::erff(__x);} |
| 940 | 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] | 941 | |
| 942 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 943 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 944 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 945 | erf(_A1 __x) _NOEXCEPT {return ::erf((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 946 | |
| 947 | // erfc |
| 948 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 949 | inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return ::erfcf(__x);} |
| 950 | 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] | 951 | |
| 952 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 953 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 954 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 955 | erfc(_A1 __x) _NOEXCEPT {return ::erfc((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 956 | |
| 957 | // exp2 |
| 958 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 959 | inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return ::exp2f(__x);} |
| 960 | 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] | 961 | |
| 962 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 963 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 964 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 965 | exp2(_A1 __x) _NOEXCEPT {return ::exp2((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 966 | |
| 967 | // expm1 |
| 968 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 969 | inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return ::expm1f(__x);} |
| 970 | 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] | 971 | |
| 972 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 973 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 974 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 975 | expm1(_A1 __x) _NOEXCEPT {return ::expm1((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 976 | |
| 977 | // fdim |
| 978 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 979 | inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return ::fdimf(__x, __y);} |
| 980 | 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] | 981 | |
| 982 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 983 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 984 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 985 | < |
| 986 | std::is_arithmetic<_A1>::value && |
| 987 | std::is_arithmetic<_A2>::value, |
| 988 | std::__promote<_A1, _A2> |
| 989 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 990 | fdim(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 991 | { |
| 992 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 993 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 994 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 995 | return ::fdim((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 996 | } |
| 997 | |
| 998 | // fma |
| 999 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1000 | 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] | 1001 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1002 | return __builtin_fmaf(__x, __y, __z); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1003 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1004 | 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] | 1005 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1006 | return __builtin_fmal(__x, __y, __z); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1007 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1008 | |
| 1009 | template <class _A1, class _A2, class _A3> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1010 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1011 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1012 | < |
| 1013 | std::is_arithmetic<_A1>::value && |
| 1014 | std::is_arithmetic<_A2>::value && |
| 1015 | std::is_arithmetic<_A3>::value, |
| 1016 | std::__promote<_A1, _A2, _A3> |
| 1017 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1018 | fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1019 | { |
| 1020 | typedef typename std::__promote<_A1, _A2, _A3>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1021 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1022 | std::_IsSame<_A2, __result_type>::value && |
| 1023 | std::_IsSame<_A3, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1024 | return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1025 | } |
| 1026 | |
| 1027 | // fmax |
| 1028 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1029 | inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return ::fmaxf(__x, __y);} |
| 1030 | 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] | 1031 | |
| 1032 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1033 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1034 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1035 | < |
| 1036 | std::is_arithmetic<_A1>::value && |
| 1037 | std::is_arithmetic<_A2>::value, |
| 1038 | std::__promote<_A1, _A2> |
| 1039 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1040 | fmax(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1041 | { |
| 1042 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1043 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1044 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1045 | return ::fmax((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1046 | } |
| 1047 | |
| 1048 | // fmin |
| 1049 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1050 | inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return ::fminf(__x, __y);} |
| 1051 | 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] | 1052 | |
| 1053 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1054 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1055 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1056 | < |
| 1057 | std::is_arithmetic<_A1>::value && |
| 1058 | std::is_arithmetic<_A2>::value, |
| 1059 | std::__promote<_A1, _A2> |
| 1060 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1061 | fmin(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1062 | { |
| 1063 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1064 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1065 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1066 | return ::fmin((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1067 | } |
| 1068 | |
| 1069 | // hypot |
| 1070 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1071 | inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return ::hypotf(__x, __y);} |
| 1072 | 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] | 1073 | |
| 1074 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1075 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1076 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1077 | < |
| 1078 | std::is_arithmetic<_A1>::value && |
| 1079 | std::is_arithmetic<_A2>::value, |
| 1080 | std::__promote<_A1, _A2> |
| 1081 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1082 | hypot(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1083 | { |
| 1084 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1085 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1086 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1087 | return ::hypot((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1088 | } |
| 1089 | |
| 1090 | // ilogb |
| 1091 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1092 | inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return ::ilogbf(__x);} |
| 1093 | 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] | 1094 | |
| 1095 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1096 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1097 | typename std::enable_if<std::is_integral<_A1>::value, int>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1098 | ilogb(_A1 __x) _NOEXCEPT {return ::ilogb((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1099 | |
| 1100 | // lgamma |
| 1101 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1102 | inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return ::lgammaf(__x);} |
| 1103 | 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] | 1104 | |
| 1105 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1106 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1107 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1108 | lgamma(_A1 __x) _NOEXCEPT {return ::lgamma((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1109 | |
| 1110 | // llrint |
| 1111 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1112 | inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1113 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1114 | return __builtin_llrintf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1115 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1116 | inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1117 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1118 | return __builtin_llrintl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1119 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1120 | |
| 1121 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1122 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1123 | typename std::enable_if<std::is_integral<_A1>::value, long long>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1124 | llrint(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1125 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1126 | return __builtin_llrint((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1127 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1128 | |
| 1129 | // llround |
| 1130 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1131 | inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1132 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1133 | return __builtin_llroundf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1134 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1135 | inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1136 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1137 | return __builtin_llroundl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1138 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1139 | |
| 1140 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1141 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1142 | typename std::enable_if<std::is_integral<_A1>::value, long long>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1143 | llround(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1144 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1145 | return __builtin_llround((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1146 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1147 | |
| 1148 | // log1p |
| 1149 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1150 | inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return ::log1pf(__x);} |
| 1151 | 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] | 1152 | |
| 1153 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1154 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1155 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1156 | log1p(_A1 __x) _NOEXCEPT {return ::log1p((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1157 | |
| 1158 | // log2 |
| 1159 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1160 | inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return ::log2f(__x);} |
| 1161 | 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] | 1162 | |
| 1163 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1164 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1165 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1166 | log2(_A1 __x) _NOEXCEPT {return ::log2((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1167 | |
| 1168 | // logb |
| 1169 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1170 | inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return ::logbf(__x);} |
| 1171 | 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] | 1172 | |
| 1173 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1174 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1175 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1176 | logb(_A1 __x) _NOEXCEPT {return ::logb((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1177 | |
| 1178 | // lrint |
| 1179 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1180 | inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1181 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1182 | return __builtin_lrintf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1183 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1184 | inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1185 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1186 | return __builtin_lrintl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1187 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1188 | |
| 1189 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1190 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1191 | typename std::enable_if<std::is_integral<_A1>::value, long>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1192 | lrint(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1193 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1194 | return __builtin_lrint((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1195 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1196 | |
| 1197 | // lround |
| 1198 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1199 | inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1200 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1201 | return __builtin_lroundf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1202 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1203 | inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1204 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1205 | return __builtin_lroundl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1206 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1207 | |
| 1208 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1209 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1210 | typename std::enable_if<std::is_integral<_A1>::value, long>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1211 | lround(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1212 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1213 | return __builtin_lround((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1214 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1215 | |
| 1216 | // nan |
| 1217 | |
| 1218 | // nearbyint |
| 1219 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1220 | inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return ::nearbyintf(__x);} |
| 1221 | 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] | 1222 | |
| 1223 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1224 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1225 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1226 | nearbyint(_A1 __x) _NOEXCEPT {return ::nearbyint((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1227 | |
| 1228 | // nextafter |
| 1229 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1230 | inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return ::nextafterf(__x, __y);} |
| 1231 | 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] | 1232 | |
| 1233 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1234 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1235 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1236 | < |
| 1237 | std::is_arithmetic<_A1>::value && |
| 1238 | std::is_arithmetic<_A2>::value, |
| 1239 | std::__promote<_A1, _A2> |
| 1240 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1241 | nextafter(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1242 | { |
| 1243 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1244 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1245 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1246 | return ::nextafter((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1247 | } |
| 1248 | |
| 1249 | // nexttoward |
| 1250 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1251 | inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return ::nexttowardf(__x, __y);} |
| 1252 | 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] | 1253 | |
| 1254 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1255 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1256 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1257 | nexttoward(_A1 __x, long double __y) _NOEXCEPT {return ::nexttoward((double)__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1258 | |
| 1259 | // remainder |
| 1260 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1261 | inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return ::remainderf(__x, __y);} |
| 1262 | 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] | 1263 | |
| 1264 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1265 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1266 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1267 | < |
| 1268 | std::is_arithmetic<_A1>::value && |
| 1269 | std::is_arithmetic<_A2>::value, |
| 1270 | std::__promote<_A1, _A2> |
| 1271 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1272 | remainder(_A1 __x, _A2 __y) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1273 | { |
| 1274 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1275 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1276 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1277 | return ::remainder((__result_type)__x, (__result_type)__y); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1278 | } |
| 1279 | |
| 1280 | // remquo |
| 1281 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1282 | inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return ::remquof(__x, __y, __z);} |
| 1283 | 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] | 1284 | |
| 1285 | template <class _A1, class _A2> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1286 | inline _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 9ce598d | 2021-09-08 09:14:43 -0400 | [diff] [blame] | 1287 | typename std::__enable_if_t |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1288 | < |
| 1289 | std::is_arithmetic<_A1>::value && |
| 1290 | std::is_arithmetic<_A2>::value, |
| 1291 | std::__promote<_A1, _A2> |
| 1292 | >::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1293 | remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1294 | { |
| 1295 | typedef typename std::__promote<_A1, _A2>::type __result_type; |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 1296 | static_assert((!(std::_IsSame<_A1, __result_type>::value && |
| 1297 | std::_IsSame<_A2, __result_type>::value)), ""); |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1298 | return ::remquo((__result_type)__x, (__result_type)__y, __z); |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1299 | } |
| 1300 | |
| 1301 | // rint |
| 1302 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1303 | inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1304 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1305 | return __builtin_rintf(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1306 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1307 | inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1308 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1309 | return __builtin_rintl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1310 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1311 | |
| 1312 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1313 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1314 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1315 | rint(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1316 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1317 | return __builtin_rint((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1318 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1319 | |
| 1320 | // round |
| 1321 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1322 | inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1323 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1324 | return __builtin_round(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1325 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1326 | inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1327 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1328 | return __builtin_roundl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1329 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1330 | |
| 1331 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1332 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1333 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1334 | round(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1335 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1336 | return __builtin_round((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1337 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1338 | |
| 1339 | // scalbln |
| 1340 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1341 | inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return ::scalblnf(__x, __y);} |
| 1342 | 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] | 1343 | |
| 1344 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1345 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1346 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1347 | scalbln(_A1 __x, long __y) _NOEXCEPT {return ::scalbln((double)__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1348 | |
| 1349 | // scalbn |
| 1350 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1351 | inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return ::scalbnf(__x, __y);} |
| 1352 | 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] | 1353 | |
| 1354 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1355 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1356 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1357 | scalbn(_A1 __x, int __y) _NOEXCEPT {return ::scalbn((double)__x, __y);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1358 | |
| 1359 | // tgamma |
| 1360 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1361 | inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return ::tgammaf(__x);} |
| 1362 | 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] | 1363 | |
| 1364 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1365 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1366 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1367 | tgamma(_A1 __x) _NOEXCEPT {return ::tgamma((double)__x);} |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1368 | |
| 1369 | // trunc |
| 1370 | |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1371 | inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1372 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1373 | return __builtin_trunc(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1374 | } |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1375 | inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1376 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1377 | return __builtin_truncl(__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1378 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1379 | |
| 1380 | template <class _A1> |
Nikolas Klauser | 4956e72 | 2022-10-12 15:41:22 +0200 | [diff] [blame] | 1381 | inline _LIBCPP_HIDE_FROM_ABI |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1382 | typename std::enable_if<std::is_integral<_A1>::value, double>::type |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1383 | trunc(_A1 __x) _NOEXCEPT |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1384 | { |
Nikolas Klauser | 9806f45 | 2022-10-12 15:45:09 +0200 | [diff] [blame] | 1385 | return __builtin_trunc((double)__x); |
Ilya Tokar | c3abffb | 2021-02-10 13:05:19 -0500 | [diff] [blame] | 1386 | } |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1387 | |
Richard Smith | 081bb59 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 1388 | } // extern "C++" |
| 1389 | |
| 1390 | #endif // __cplusplus |
| 1391 | |
Mikhail Maltsev | 34b4f97 | 2018-02-22 09:34:08 +0000 | [diff] [blame] | 1392 | #else // _LIBCPP_MATH_H |
| 1393 | |
| 1394 | // This include lives outside the header guard in order to support an MSVC |
| 1395 | // extension which allows users to do: |
| 1396 | // |
| 1397 | // #define _USE_MATH_DEFINES |
| 1398 | // #include <math.h> |
| 1399 | // |
| 1400 | // and receive the definitions of mathematical constants, even if <math.h> |
| 1401 | // has previously been included. |
| 1402 | #if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES) |
| 1403 | #include_next <math.h> |
| 1404 | #endif |
| 1405 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1406 | #endif // _LIBCPP_MATH_H |