blob: 0ec584af9dbedacdac4b7500d0082e074d2a7888 [file] [log] [blame]
Richard Smith081bb592015-10-08 20:40:34 +00001// -*- C++ -*-
Louis Dionne9bd93882021-11-17 16:25:01 -05002//===----------------------------------------------------------------------===//
Richard Smith081bb592015-10-08 20:40:34 +00003//
Chandler Carruthd2012102019-01-19 10:56:40 +00004// 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 Smith081bb592015-10-08 20:40:34 +00007//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_MATH_H
11#define _LIBCPP_MATH_H
12
13/*
14 math.h synopsis
15
16Macros:
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
37Types:
38
39 float_t // C99
40 double_t // C99
41
42// C90
43
44floating_point abs(floating_point x);
45
46floating_point acos (arithmetic x);
47float acosf(float x);
48long double acosl(long double x);
49
50floating_point asin (arithmetic x);
51float asinf(float x);
52long double asinl(long double x);
53
54floating_point atan (arithmetic x);
55float atanf(float x);
56long double atanl(long double x);
57
58floating_point atan2 (arithmetic y, arithmetic x);
59float atan2f(float y, float x);
60long double atan2l(long double y, long double x);
61
62floating_point ceil (arithmetic x);
63float ceilf(float x);
64long double ceill(long double x);
65
66floating_point cos (arithmetic x);
67float cosf(float x);
68long double cosl(long double x);
69
70floating_point cosh (arithmetic x);
71float coshf(float x);
72long double coshl(long double x);
73
74floating_point exp (arithmetic x);
75float expf(float x);
76long double expl(long double x);
77
78floating_point fabs (arithmetic x);
79float fabsf(float x);
80long double fabsl(long double x);
81
82floating_point floor (arithmetic x);
83float floorf(float x);
84long double floorl(long double x);
85
86floating_point fmod (arithmetic x, arithmetic y);
87float fmodf(float x, float y);
88long double fmodl(long double x, long double y);
89
90floating_point frexp (arithmetic value, int* exp);
91float frexpf(float value, int* exp);
92long double frexpl(long double value, int* exp);
93
94floating_point ldexp (arithmetic value, int exp);
95float ldexpf(float value, int exp);
96long double ldexpl(long double value, int exp);
97
98floating_point log (arithmetic x);
99float logf(float x);
100long double logl(long double x);
101
102floating_point log10 (arithmetic x);
103float log10f(float x);
104long double log10l(long double x);
105
106floating_point modf (floating_point value, floating_point* iptr);
107float modff(float value, float* iptr);
108long double modfl(long double value, long double* iptr);
109
110floating_point pow (arithmetic x, arithmetic y);
111float powf(float x, float y);
112long double powl(long double x, long double y);
113
114floating_point sin (arithmetic x);
115float sinf(float x);
116long double sinl(long double x);
117
118floating_point sinh (arithmetic x);
119float sinhf(float x);
120long double sinhl(long double x);
121
122floating_point sqrt (arithmetic x);
123float sqrtf(float x);
124long double sqrtl(long double x);
125
126floating_point tan (arithmetic x);
127float tanf(float x);
128long double tanl(long double x);
129
130floating_point tanh (arithmetic x);
131float tanhf(float x);
132long double tanhl(long double x);
133
134// C99
135
136bool signbit(arithmetic x);
137
138int fpclassify(arithmetic x);
139
140bool isfinite(arithmetic x);
141bool isinf(arithmetic x);
142bool isnan(arithmetic x);
143bool isnormal(arithmetic x);
144
145bool isgreater(arithmetic x, arithmetic y);
146bool isgreaterequal(arithmetic x, arithmetic y);
147bool isless(arithmetic x, arithmetic y);
148bool islessequal(arithmetic x, arithmetic y);
149bool islessgreater(arithmetic x, arithmetic y);
150bool isunordered(arithmetic x, arithmetic y);
151
152floating_point acosh (arithmetic x);
153float acoshf(float x);
154long double acoshl(long double x);
155
156floating_point asinh (arithmetic x);
157float asinhf(float x);
158long double asinhl(long double x);
159
160floating_point atanh (arithmetic x);
161float atanhf(float x);
162long double atanhl(long double x);
163
164floating_point cbrt (arithmetic x);
165float cbrtf(float x);
166long double cbrtl(long double x);
167
168floating_point copysign (arithmetic x, arithmetic y);
169float copysignf(float x, float y);
170long double copysignl(long double x, long double y);
171
172floating_point erf (arithmetic x);
173float erff(float x);
174long double erfl(long double x);
175
176floating_point erfc (arithmetic x);
177float erfcf(float x);
178long double erfcl(long double x);
179
180floating_point exp2 (arithmetic x);
181float exp2f(float x);
182long double exp2l(long double x);
183
184floating_point expm1 (arithmetic x);
185float expm1f(float x);
186long double expm1l(long double x);
187
188floating_point fdim (arithmetic x, arithmetic y);
189float fdimf(float x, float y);
190long double fdiml(long double x, long double y);
191
192floating_point fma (arithmetic x, arithmetic y, arithmetic z);
193float fmaf(float x, float y, float z);
194long double fmal(long double x, long double y, long double z);
195
196floating_point fmax (arithmetic x, arithmetic y);
197float fmaxf(float x, float y);
198long double fmaxl(long double x, long double y);
199
200floating_point fmin (arithmetic x, arithmetic y);
201float fminf(float x, float y);
202long double fminl(long double x, long double y);
203
204floating_point hypot (arithmetic x, arithmetic y);
205float hypotf(float x, float y);
206long double hypotl(long double x, long double y);
207
208int ilogb (arithmetic x);
209int ilogbf(float x);
210int ilogbl(long double x);
211
212floating_point lgamma (arithmetic x);
213float lgammaf(float x);
214long double lgammal(long double x);
215
216long long llrint (arithmetic x);
217long long llrintf(float x);
218long long llrintl(long double x);
219
220long long llround (arithmetic x);
221long long llroundf(float x);
222long long llroundl(long double x);
223
224floating_point log1p (arithmetic x);
225float log1pf(float x);
226long double log1pl(long double x);
227
228floating_point log2 (arithmetic x);
229float log2f(float x);
230long double log2l(long double x);
231
232floating_point logb (arithmetic x);
233float logbf(float x);
234long double logbl(long double x);
235
236long lrint (arithmetic x);
237long lrintf(float x);
238long lrintl(long double x);
239
240long lround (arithmetic x);
241long lroundf(float x);
242long lroundl(long double x);
243
244double nan (const char* str);
245float nanf(const char* str);
246long double nanl(const char* str);
247
248floating_point nearbyint (arithmetic x);
249float nearbyintf(float x);
250long double nearbyintl(long double x);
251
252floating_point nextafter (arithmetic x, arithmetic y);
253float nextafterf(float x, float y);
254long double nextafterl(long double x, long double y);
255
256floating_point nexttoward (arithmetic x, long double y);
257float nexttowardf(float x, long double y);
258long double nexttowardl(long double x, long double y);
259
260floating_point remainder (arithmetic x, arithmetic y);
261float remainderf(float x, float y);
262long double remainderl(long double x, long double y);
263
264floating_point remquo (arithmetic x, arithmetic y, int* pquo);
265float remquof(float x, float y, int* pquo);
266long double remquol(long double x, long double y, int* pquo);
267
268floating_point rint (arithmetic x);
269float rintf(float x);
270long double rintl(long double x);
271
272floating_point round (arithmetic x);
273float roundf(float x);
274long double roundl(long double x);
275
276floating_point scalbln (arithmetic x, long ex);
277float scalblnf(float x, long ex);
278long double scalblnl(long double x, long ex);
279
280floating_point scalbn (arithmetic x, int ex);
281float scalbnf(float x, int ex);
282long double scalbnl(long double x, int ex);
283
284floating_point tgamma (arithmetic x);
285float tgammaf(float x);
286long double tgammal(long double x);
287
288floating_point trunc (arithmetic x);
289float truncf(float x);
290long double truncl(long double x);
291
292*/
293
294#include <__config>
Richard Smith081bb592015-10-08 20:40:34 +0000295
296#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Arthur O'Dwyer6eeaa002022-02-01 20:16:40 -0500297# pragma GCC system_header
Richard Smith081bb592015-10-08 20:40:34 +0000298#endif
299
Mikhail Maltsev34b4f972018-02-22 09:34:08 +0000300#include_next <math.h>
301
Richard Smith081bb592015-10-08 20:40:34 +0000302#ifdef __cplusplus
303
304// We support including .h headers inside 'extern "C"' contexts, so switch
305// back to C++ linkage before including these C++ headers.
306extern "C++" {
307
Nikolas Klauser6c8f7122022-07-24 16:03:12 +0200308#include <__type_traits/promote.h>
Arthur O'Dwyer65077c02022-01-07 09:45:05 -0500309#include <limits>
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500310#include <stdlib.h>
Richard Smith081bb592015-10-08 20:40:34 +0000311#include <type_traits>
312
Richard Smith081bb592015-10-08 20:40:34 +0000313// signbit
314
315#ifdef signbit
316
317template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000318_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000319bool
320__libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT
321{
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500322#if __has_builtin(__builtin_signbit)
323 return __builtin_signbit(__lcpp_x);
324#else
Richard Smith081bb592015-10-08 20:40:34 +0000325 return signbit(__lcpp_x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500326#endif
Richard Smith081bb592015-10-08 20:40:34 +0000327}
328
329#undef signbit
330
331template <class _A1>
332inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000333typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000334signbit(_A1 __lcpp_x) _NOEXCEPT
335{
336 return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
337}
338
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000339template <class _A1>
340inline _LIBCPP_INLINE_VISIBILITY
341typename std::enable_if<
342 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
343signbit(_A1 __lcpp_x) _NOEXCEPT
344{ return __lcpp_x < 0; }
345
346template <class _A1>
347inline _LIBCPP_INLINE_VISIBILITY
348typename std::enable_if<
349 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
350signbit(_A1) _NOEXCEPT
351{ return false; }
352
Shoaib Meenai159375f2017-04-07 02:20:52 +0000353#elif defined(_LIBCPP_MSVCRT)
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000354
355template <typename _A1>
356inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000357typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000358signbit(_A1 __lcpp_x) _NOEXCEPT
359{
360 return ::signbit(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
361}
362
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000363template <class _A1>
364inline _LIBCPP_INLINE_VISIBILITY
365typename std::enable_if<
366 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
367signbit(_A1 __lcpp_x) _NOEXCEPT
368{ return __lcpp_x < 0; }
369
370template <class _A1>
371inline _LIBCPP_INLINE_VISIBILITY
372typename std::enable_if<
373 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
374signbit(_A1) _NOEXCEPT
375{ return false; }
376
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400377#endif // signbit
Richard Smith081bb592015-10-08 20:40:34 +0000378
379// fpclassify
380
381#ifdef fpclassify
382
383template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000384_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000385int
386__libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT
387{
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500388#if __has_builtin(__builtin_fpclassify)
389 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
390 FP_ZERO, __lcpp_x);
391#else
Richard Smith081bb592015-10-08 20:40:34 +0000392 return fpclassify(__lcpp_x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500393#endif
Richard Smith081bb592015-10-08 20:40:34 +0000394}
395
396#undef fpclassify
397
398template <class _A1>
399inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000400typename std::enable_if<std::is_floating_point<_A1>::value, int>::type
Richard Smith081bb592015-10-08 20:40:34 +0000401fpclassify(_A1 __lcpp_x) _NOEXCEPT
402{
403 return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
404}
405
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000406template <class _A1>
407inline _LIBCPP_INLINE_VISIBILITY
408typename std::enable_if<std::is_integral<_A1>::value, int>::type
409fpclassify(_A1 __lcpp_x) _NOEXCEPT
410{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
411
Shoaib Meenai159375f2017-04-07 02:20:52 +0000412#elif defined(_LIBCPP_MSVCRT)
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000413
414template <typename _A1>
415inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000416typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000417fpclassify(_A1 __lcpp_x) _NOEXCEPT
418{
419 return ::fpclassify(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
420}
421
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000422template <class _A1>
423inline _LIBCPP_INLINE_VISIBILITY
424typename std::enable_if<std::is_integral<_A1>::value, int>::type
425fpclassify(_A1 __lcpp_x) _NOEXCEPT
426{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
427
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400428#endif // fpclassify
Richard Smith081bb592015-10-08 20:40:34 +0000429
430// isfinite
431
432#ifdef isfinite
433
434template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000435_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000436bool
437__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
438{
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500439#if __has_builtin(__builtin_isfinite)
440 return __builtin_isfinite(__lcpp_x);
441#else
Richard Smith081bb592015-10-08 20:40:34 +0000442 return isfinite(__lcpp_x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500443#endif
Richard Smith081bb592015-10-08 20:40:34 +0000444}
445
446#undef isfinite
447
448template <class _A1>
449inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000450typename std::enable_if<
451 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
452 bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000453isfinite(_A1 __lcpp_x) _NOEXCEPT
454{
455 return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x);
456}
457
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000458template <class _A1>
459inline _LIBCPP_INLINE_VISIBILITY
460typename std::enable_if<
461 std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
462 bool>::type
463isfinite(_A1) _NOEXCEPT
464{ return true; }
465
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400466#endif // isfinite
Richard Smith081bb592015-10-08 20:40:34 +0000467
468// isinf
469
470#ifdef isinf
471
472template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000473_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000474bool
475__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
476{
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500477#if __has_builtin(__builtin_isinf)
478 return __builtin_isinf(__lcpp_x);
479#else
Richard Smith081bb592015-10-08 20:40:34 +0000480 return isinf(__lcpp_x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500481#endif
Richard Smith081bb592015-10-08 20:40:34 +0000482}
483
484#undef isinf
485
486template <class _A1>
487inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000488typename std::enable_if<
489 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
490 bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000491isinf(_A1 __lcpp_x) _NOEXCEPT
492{
493 return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x);
494}
495
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000496template <class _A1>
497inline _LIBCPP_INLINE_VISIBILITY
498typename std::enable_if<
499 std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
500 bool>::type
501isinf(_A1) _NOEXCEPT
502{ return false; }
503
Richard Smithafccfd32018-05-01 03:05:40 +0000504#ifdef _LIBCPP_PREFERRED_OVERLOAD
505inline _LIBCPP_INLINE_VISIBILITY
506bool
507isinf(float __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
508
509inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
510bool
511isinf(double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
512
513inline _LIBCPP_INLINE_VISIBILITY
514bool
515isinf(long double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
516#endif
517
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400518#endif // isinf
Richard Smith081bb592015-10-08 20:40:34 +0000519
520// isnan
521
522#ifdef isnan
523
524template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000525_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000526bool
527__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
528{
Ilya Tokar6caf83a2019-11-15 12:29:02 -0500529#if __has_builtin(__builtin_isnan)
530 return __builtin_isnan(__lcpp_x);
531#else
Richard Smith081bb592015-10-08 20:40:34 +0000532 return isnan(__lcpp_x);
Ilya Tokar6caf83a2019-11-15 12:29:02 -0500533#endif
Richard Smith081bb592015-10-08 20:40:34 +0000534}
535
536#undef isnan
537
538template <class _A1>
539inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000540typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000541isnan(_A1 __lcpp_x) _NOEXCEPT
542{
543 return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);
544}
545
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000546template <class _A1>
547inline _LIBCPP_INLINE_VISIBILITY
548typename std::enable_if<std::is_integral<_A1>::value, bool>::type
549isnan(_A1) _NOEXCEPT
550{ return false; }
551
Richard Smithafccfd32018-05-01 03:05:40 +0000552#ifdef _LIBCPP_PREFERRED_OVERLOAD
553inline _LIBCPP_INLINE_VISIBILITY
554bool
555isnan(float __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
556
557inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
558bool
559isnan(double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
560
561inline _LIBCPP_INLINE_VISIBILITY
562bool
563isnan(long double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
564#endif
565
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400566#endif // isnan
Richard Smith081bb592015-10-08 20:40:34 +0000567
568// isnormal
569
570#ifdef isnormal
571
572template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000573_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000574bool
575__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT
576{
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500577#if __has_builtin(__builtin_isnormal)
578 return __builtin_isnormal(__lcpp_x);
579#else
Richard Smith081bb592015-10-08 20:40:34 +0000580 return isnormal(__lcpp_x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500581#endif
Richard Smith081bb592015-10-08 20:40:34 +0000582}
583
584#undef isnormal
585
586template <class _A1>
587inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000588typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000589isnormal(_A1 __lcpp_x) _NOEXCEPT
590{
591 return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x);
592}
593
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000594template <class _A1>
595inline _LIBCPP_INLINE_VISIBILITY
596typename std::enable_if<std::is_integral<_A1>::value, bool>::type
597isnormal(_A1 __lcpp_x) _NOEXCEPT
598{ return __lcpp_x != 0; }
599
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400600#endif // isnormal
Richard Smith081bb592015-10-08 20:40:34 +0000601
602// isgreater
603
604#ifdef isgreater
605
606template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000607_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000608bool
609__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
610{
611 return isgreater(__lcpp_x, __lcpp_y);
612}
613
614#undef isgreater
615
616template <class _A1, class _A2>
617inline _LIBCPP_INLINE_VISIBILITY
618typename std::enable_if
619<
620 std::is_arithmetic<_A1>::value &&
621 std::is_arithmetic<_A2>::value,
622 bool
623>::type
624isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
625{
626 typedef typename std::__promote<_A1, _A2>::type type;
627 return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y);
628}
629
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400630#endif // isgreater
Richard Smith081bb592015-10-08 20:40:34 +0000631
632// isgreaterequal
633
634#ifdef isgreaterequal
635
636template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000637_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000638bool
639__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
640{
641 return isgreaterequal(__lcpp_x, __lcpp_y);
642}
643
644#undef isgreaterequal
645
646template <class _A1, class _A2>
647inline _LIBCPP_INLINE_VISIBILITY
648typename std::enable_if
649<
650 std::is_arithmetic<_A1>::value &&
651 std::is_arithmetic<_A2>::value,
652 bool
653>::type
654isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
655{
656 typedef typename std::__promote<_A1, _A2>::type type;
657 return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y);
658}
659
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400660#endif // isgreaterequal
Richard Smith081bb592015-10-08 20:40:34 +0000661
662// isless
663
664#ifdef isless
665
666template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000667_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000668bool
669__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
670{
671 return isless(__lcpp_x, __lcpp_y);
672}
673
674#undef isless
675
676template <class _A1, class _A2>
677inline _LIBCPP_INLINE_VISIBILITY
678typename std::enable_if
679<
680 std::is_arithmetic<_A1>::value &&
681 std::is_arithmetic<_A2>::value,
682 bool
683>::type
684isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
685{
686 typedef typename std::__promote<_A1, _A2>::type type;
687 return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y);
688}
689
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400690#endif // isless
Richard Smith081bb592015-10-08 20:40:34 +0000691
692// islessequal
693
694#ifdef islessequal
695
696template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000697_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000698bool
699__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
700{
701 return islessequal(__lcpp_x, __lcpp_y);
702}
703
704#undef islessequal
705
706template <class _A1, class _A2>
707inline _LIBCPP_INLINE_VISIBILITY
708typename std::enable_if
709<
710 std::is_arithmetic<_A1>::value &&
711 std::is_arithmetic<_A2>::value,
712 bool
713>::type
714islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
715{
716 typedef typename std::__promote<_A1, _A2>::type type;
717 return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y);
718}
719
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400720#endif // islessequal
Richard Smith081bb592015-10-08 20:40:34 +0000721
722// islessgreater
723
724#ifdef islessgreater
725
726template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000727_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000728bool
729__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
730{
731 return islessgreater(__lcpp_x, __lcpp_y);
732}
733
734#undef islessgreater
735
736template <class _A1, class _A2>
737inline _LIBCPP_INLINE_VISIBILITY
738typename std::enable_if
739<
740 std::is_arithmetic<_A1>::value &&
741 std::is_arithmetic<_A2>::value,
742 bool
743>::type
744islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
745{
746 typedef typename std::__promote<_A1, _A2>::type type;
747 return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y);
748}
749
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400750#endif // islessgreater
Richard Smith081bb592015-10-08 20:40:34 +0000751
752// isunordered
753
754#ifdef isunordered
755
756template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000757_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000758bool
759__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
760{
761 return isunordered(__lcpp_x, __lcpp_y);
762}
763
764#undef isunordered
765
766template <class _A1, class _A2>
767inline _LIBCPP_INLINE_VISIBILITY
768typename std::enable_if
769<
770 std::is_arithmetic<_A1>::value &&
771 std::is_arithmetic<_A2>::value,
772 bool
773>::type
774isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
775{
776 typedef typename std::__promote<_A1, _A2>::type type;
777 return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y);
778}
779
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400780#endif // isunordered
Richard Smith081bb592015-10-08 20:40:34 +0000781
Richard Smith081bb592015-10-08 20:40:34 +0000782// abs
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500783//
784// handled in stdlib.h
Richard Smith081bb592015-10-08 20:40:34 +0000785
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000786// div
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500787//
788// handled in stdlib.h
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000789
Richard Smith081bb592015-10-08 20:40:34 +0000790// acos
791
David Tenty7249ac92022-02-07 18:22:35 -0500792# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +0000793inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return ::acosf(__lcpp_x);}
794inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);}
David Tenty7249ac92022-02-07 18:22:35 -0500795# endif
Richard Smith081bb592015-10-08 20:40:34 +0000796
797template <class _A1>
798inline _LIBCPP_INLINE_VISIBILITY
799typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000800acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000801
802// asin
803
David Tenty7249ac92022-02-07 18:22:35 -0500804# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +0000805inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return ::asinf(__lcpp_x);}
806inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);}
David Tenty7249ac92022-02-07 18:22:35 -0500807# endif
Richard Smith081bb592015-10-08 20:40:34 +0000808
809template <class _A1>
810inline _LIBCPP_INLINE_VISIBILITY
811typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000812asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000813
814// atan
815
David Tenty7249ac92022-02-07 18:22:35 -0500816# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +0000817inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return ::atanf(__lcpp_x);}
818inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_x);}
David Tenty7249ac92022-02-07 18:22:35 -0500819# endif
Richard Smith081bb592015-10-08 20:40:34 +0000820
821template <class _A1>
822inline _LIBCPP_INLINE_VISIBILITY
823typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000824atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000825
826// atan2
827
David Tenty7249ac92022-02-07 18:22:35 -0500828# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +0000829inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);}
830inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return ::atan2l(__lcpp_y, __lcpp_x);}
David Tenty7249ac92022-02-07 18:22:35 -0500831# endif
Richard Smith081bb592015-10-08 20:40:34 +0000832
833template <class _A1, class _A2>
834inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -0400835typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000836<
837 std::is_arithmetic<_A1>::value &&
838 std::is_arithmetic<_A2>::value,
839 std::__promote<_A1, _A2>
840>::type
841atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT
842{
843 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000844 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
845 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +0000846 return ::atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
Richard Smith081bb592015-10-08 20:40:34 +0000847}
848
849// ceil
850
David Tenty7249ac92022-02-07 18:22:35 -0500851# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +0000852inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ::ceilf(__lcpp_x);}
853inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ::ceill(__lcpp_x);}
David Tenty7249ac92022-02-07 18:22:35 -0500854# endif
Richard Smith081bb592015-10-08 20:40:34 +0000855
856template <class _A1>
857inline _LIBCPP_INLINE_VISIBILITY
858typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000859ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000860
861// cos
862
David Tenty7249ac92022-02-07 18:22:35 -0500863# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +0000864inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return ::cosf(__lcpp_x);}
865inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return ::cosl(__lcpp_x);}
David Tenty7249ac92022-02-07 18:22:35 -0500866# endif
Richard Smith081bb592015-10-08 20:40:34 +0000867
868template <class _A1>
869inline _LIBCPP_INLINE_VISIBILITY
870typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000871cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000872
873// cosh
874
David Tenty7249ac92022-02-07 18:22:35 -0500875# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +0000876inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return ::coshf(__lcpp_x);}
877inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return ::coshl(__lcpp_x);}
David Tenty7249ac92022-02-07 18:22:35 -0500878# endif
Richard Smith081bb592015-10-08 20:40:34 +0000879
880template <class _A1>
881inline _LIBCPP_INLINE_VISIBILITY
882typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000883cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000884
885// exp
886
David Tenty7249ac92022-02-07 18:22:35 -0500887# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +0000888inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return ::expf(__lcpp_x);}
889inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return ::expl(__lcpp_x);}
David Tenty7249ac92022-02-07 18:22:35 -0500890# endif
Richard Smith081bb592015-10-08 20:40:34 +0000891
892template <class _A1>
893inline _LIBCPP_INLINE_VISIBILITY
894typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000895exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000896
897// fabs
898
David Tenty7249ac92022-02-07 18:22:35 -0500899# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +0000900inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
901inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
David Tenty7249ac92022-02-07 18:22:35 -0500902# endif
Richard Smith081bb592015-10-08 20:40:34 +0000903
904template <class _A1>
905inline _LIBCPP_INLINE_VISIBILITY
906typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000907fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000908
909// floor
910
David Tenty7249ac92022-02-07 18:22:35 -0500911# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +0000912inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return ::floorf(__lcpp_x);}
913inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return ::floorl(__lcpp_x);}
David Tenty7249ac92022-02-07 18:22:35 -0500914# endif
Richard Smith081bb592015-10-08 20:40:34 +0000915
916template <class _A1>
917inline _LIBCPP_INLINE_VISIBILITY
918typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000919floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000920
921// fmod
922
David Tenty7249ac92022-02-07 18:22:35 -0500923# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +0000924inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmodf(__lcpp_x, __lcpp_y);}
925inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmodl(__lcpp_x, __lcpp_y);}
David Tenty7249ac92022-02-07 18:22:35 -0500926# endif
Richard Smith081bb592015-10-08 20:40:34 +0000927
928template <class _A1, class _A2>
929inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -0400930typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000931<
932 std::is_arithmetic<_A1>::value &&
933 std::is_arithmetic<_A2>::value,
934 std::__promote<_A1, _A2>
935>::type
936fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
937{
938 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000939 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
940 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +0000941 return ::fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +0000942}
943
944// frexp
945
David Tenty7249ac92022-02-07 18:22:35 -0500946# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +0000947inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpf(__lcpp_x, __lcpp_e);}
948inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpl(__lcpp_x, __lcpp_e);}
David Tenty7249ac92022-02-07 18:22:35 -0500949# endif
Richard Smith081bb592015-10-08 20:40:34 +0000950
951template <class _A1>
952inline _LIBCPP_INLINE_VISIBILITY
953typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000954frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexp((double)__lcpp_x, __lcpp_e);}
Richard Smith081bb592015-10-08 20:40:34 +0000955
956// ldexp
957
David Tenty7249ac92022-02-07 18:22:35 -0500958# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +0000959inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpf(__lcpp_x, __lcpp_e);}
960inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpl(__lcpp_x, __lcpp_e);}
David Tenty7249ac92022-02-07 18:22:35 -0500961# endif
Richard Smith081bb592015-10-08 20:40:34 +0000962
963template <class _A1>
964inline _LIBCPP_INLINE_VISIBILITY
965typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000966ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexp((double)__lcpp_x, __lcpp_e);}
Richard Smith081bb592015-10-08 20:40:34 +0000967
968// log
969
David Tenty7249ac92022-02-07 18:22:35 -0500970# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +0000971inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return ::logf(__lcpp_x);}
972inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return ::logl(__lcpp_x);}
David Tenty7249ac92022-02-07 18:22:35 -0500973# endif
Richard Smith081bb592015-10-08 20:40:34 +0000974
975template <class _A1>
976inline _LIBCPP_INLINE_VISIBILITY
977typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000978log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000979
980// log10
981
David Tenty7249ac92022-02-07 18:22:35 -0500982# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +0000983inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return ::log10f(__lcpp_x);}
984inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return ::log10l(__lcpp_x);}
David Tenty7249ac92022-02-07 18:22:35 -0500985# endif
Richard Smith081bb592015-10-08 20:40:34 +0000986
987template <class _A1>
988inline _LIBCPP_INLINE_VISIBILITY
989typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000990log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000991
992// modf
993
David Tenty7249ac92022-02-07 18:22:35 -0500994# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +0000995inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return ::modff(__lcpp_x, __lcpp_y);}
996inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return ::modfl(__lcpp_x, __lcpp_y);}
David Tenty7249ac92022-02-07 18:22:35 -0500997# endif
Richard Smith081bb592015-10-08 20:40:34 +0000998
999// pow
1000
David Tenty7249ac92022-02-07 18:22:35 -05001001# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +00001002inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::powf(__lcpp_x, __lcpp_y);}
1003inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::powl(__lcpp_x, __lcpp_y);}
David Tenty7249ac92022-02-07 18:22:35 -05001004# endif
Richard Smith081bb592015-10-08 20:40:34 +00001005
1006template <class _A1, class _A2>
1007inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001008typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001009<
1010 std::is_arithmetic<_A1>::value &&
1011 std::is_arithmetic<_A2>::value,
1012 std::__promote<_A1, _A2>
1013>::type
1014pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1015{
1016 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001017 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1018 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001019 return ::pow((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001020}
1021
1022// sin
1023
David Tenty7249ac92022-02-07 18:22:35 -05001024# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +00001025inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return ::sinf(__lcpp_x);}
1026inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return ::sinl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001027#endif
1028
1029template <class _A1>
1030inline _LIBCPP_INLINE_VISIBILITY
1031typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001032sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001033
1034// sinh
1035
David Tenty7249ac92022-02-07 18:22:35 -05001036# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +00001037inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return ::sinhf(__lcpp_x);}
1038inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return ::sinhl(__lcpp_x);}
David Tenty7249ac92022-02-07 18:22:35 -05001039# endif
Richard Smith081bb592015-10-08 20:40:34 +00001040
1041template <class _A1>
1042inline _LIBCPP_INLINE_VISIBILITY
1043typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001044sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001045
1046// sqrt
1047
David Tenty7249ac92022-02-07 18:22:35 -05001048# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +00001049inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return ::sqrtf(__lcpp_x);}
1050inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return ::sqrtl(__lcpp_x);}
David Tenty7249ac92022-02-07 18:22:35 -05001051# endif
Richard Smith081bb592015-10-08 20:40:34 +00001052
Richard Smith081bb592015-10-08 20:40:34 +00001053template <class _A1>
1054inline _LIBCPP_INLINE_VISIBILITY
1055typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001056sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001057
1058// tan
1059
David Tenty7249ac92022-02-07 18:22:35 -05001060# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +00001061inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return ::tanf(__lcpp_x);}
1062inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return ::tanl(__lcpp_x);}
David Tenty7249ac92022-02-07 18:22:35 -05001063# endif
Richard Smith081bb592015-10-08 20:40:34 +00001064
1065template <class _A1>
1066inline _LIBCPP_INLINE_VISIBILITY
1067typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001068tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001069
1070// tanh
1071
David Tenty7249ac92022-02-07 18:22:35 -05001072# if !defined(__sun__)
Mehdi Aminib3da6322017-02-10 02:44:23 +00001073inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return ::tanhf(__lcpp_x);}
1074inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return ::tanhl(__lcpp_x);}
David Tenty7249ac92022-02-07 18:22:35 -05001075# endif
Richard Smith081bb592015-10-08 20:40:34 +00001076
1077template <class _A1>
1078inline _LIBCPP_INLINE_VISIBILITY
1079typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001080tanh(_A1 __lcpp_x) _NOEXCEPT {return ::tanh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001081
1082// acosh
1083
Mehdi Aminib3da6322017-02-10 02:44:23 +00001084inline _LIBCPP_INLINE_VISIBILITY float acosh(float __lcpp_x) _NOEXCEPT {return ::acoshf(__lcpp_x);}
1085inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return ::acoshl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001086
1087template <class _A1>
1088inline _LIBCPP_INLINE_VISIBILITY
1089typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001090acosh(_A1 __lcpp_x) _NOEXCEPT {return ::acosh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001091
1092// asinh
1093
Mehdi Aminib3da6322017-02-10 02:44:23 +00001094inline _LIBCPP_INLINE_VISIBILITY float asinh(float __lcpp_x) _NOEXCEPT {return ::asinhf(__lcpp_x);}
1095inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return ::asinhl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001096
1097template <class _A1>
1098inline _LIBCPP_INLINE_VISIBILITY
1099typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001100asinh(_A1 __lcpp_x) _NOEXCEPT {return ::asinh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001101
1102// atanh
1103
Mehdi Aminib3da6322017-02-10 02:44:23 +00001104inline _LIBCPP_INLINE_VISIBILITY float atanh(float __lcpp_x) _NOEXCEPT {return ::atanhf(__lcpp_x);}
1105inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return ::atanhl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001106
1107template <class _A1>
1108inline _LIBCPP_INLINE_VISIBILITY
1109typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001110atanh(_A1 __lcpp_x) _NOEXCEPT {return ::atanh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001111
1112// cbrt
1113
Mehdi Aminib3da6322017-02-10 02:44:23 +00001114inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __lcpp_x) _NOEXCEPT {return ::cbrtf(__lcpp_x);}
1115inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return ::cbrtl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001116
1117template <class _A1>
1118inline _LIBCPP_INLINE_VISIBILITY
1119typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001120cbrt(_A1 __lcpp_x) _NOEXCEPT {return ::cbrt((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001121
1122// copysign
1123
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001124#if __has_builtin(__builtin_copysignf)
1125_LIBCPP_CONSTEXPR
1126#endif
1127inline _LIBCPP_INLINE_VISIBILITY float __libcpp_copysign(float __lcpp_x, float __lcpp_y) _NOEXCEPT {
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001128#if __has_builtin(__builtin_copysignf)
1129 return __builtin_copysignf(__lcpp_x, __lcpp_y);
1130#else
Mehdi Aminib3da6322017-02-10 02:44:23 +00001131 return ::copysignf(__lcpp_x, __lcpp_y);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001132#endif
Richard Smith081bb592015-10-08 20:40:34 +00001133}
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001134
1135#if __has_builtin(__builtin_copysign)
1136_LIBCPP_CONSTEXPR
1137#endif
1138inline _LIBCPP_INLINE_VISIBILITY double __libcpp_copysign(double __lcpp_x, double __lcpp_y) _NOEXCEPT {
1139#if __has_builtin(__builtin_copysign)
1140 return __builtin_copysign(__lcpp_x, __lcpp_y);
1141#else
1142 return ::copysign(__lcpp_x, __lcpp_y);
1143#endif
1144}
1145
1146#if __has_builtin(__builtin_copysignl)
1147_LIBCPP_CONSTEXPR
1148#endif
1149inline _LIBCPP_INLINE_VISIBILITY long double __libcpp_copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001150#if __has_builtin(__builtin_copysignl)
1151 return __builtin_copysignl(__lcpp_x, __lcpp_y);
1152#else
Mehdi Aminib3da6322017-02-10 02:44:23 +00001153 return ::copysignl(__lcpp_x, __lcpp_y);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001154#endif
Richard Smith081bb592015-10-08 20:40:34 +00001155}
Richard Smith081bb592015-10-08 20:40:34 +00001156
1157template <class _A1, class _A2>
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001158#if __has_builtin(__builtin_copysign)
1159_LIBCPP_CONSTEXPR
1160#endif
1161inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001162typename std::__enable_if_t
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001163<
1164 std::is_arithmetic<_A1>::value &&
1165 std::is_arithmetic<_A2>::value,
1166 std::__promote<_A1, _A2>
1167>::type
1168__libcpp_copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT {
1169 typedef typename std::__promote<_A1, _A2>::type __result_type;
1170 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1171 std::_IsSame<_A2, __result_type>::value)), "");
1172#if __has_builtin(__builtin_copysign)
1173 return __builtin_copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1174#else
1175 return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1176#endif
1177}
1178
1179inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x, float __lcpp_y) _NOEXCEPT {
1180 return ::__libcpp_copysign(__lcpp_x, __lcpp_y);
1181}
1182
1183inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
1184 return ::__libcpp_copysign(__lcpp_x, __lcpp_y);
1185}
1186
1187template <class _A1, class _A2>
Richard Smith081bb592015-10-08 20:40:34 +00001188inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001189typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001190<
1191 std::is_arithmetic<_A1>::value &&
1192 std::is_arithmetic<_A2>::value,
1193 std::__promote<_A1, _A2>
1194>::type
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001195 copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT {
1196 return ::__libcpp_copysign(__lcpp_x, __lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001197}
1198
Richard Smith081bb592015-10-08 20:40:34 +00001199// erf
1200
Mehdi Aminib3da6322017-02-10 02:44:23 +00001201inline _LIBCPP_INLINE_VISIBILITY float erf(float __lcpp_x) _NOEXCEPT {return ::erff(__lcpp_x);}
1202inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return ::erfl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001203
1204template <class _A1>
1205inline _LIBCPP_INLINE_VISIBILITY
1206typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001207erf(_A1 __lcpp_x) _NOEXCEPT {return ::erf((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001208
1209// erfc
1210
Mehdi Aminib3da6322017-02-10 02:44:23 +00001211inline _LIBCPP_INLINE_VISIBILITY float erfc(float __lcpp_x) _NOEXCEPT {return ::erfcf(__lcpp_x);}
1212inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return ::erfcl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001213
1214template <class _A1>
1215inline _LIBCPP_INLINE_VISIBILITY
1216typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001217erfc(_A1 __lcpp_x) _NOEXCEPT {return ::erfc((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001218
1219// exp2
1220
Mehdi Aminib3da6322017-02-10 02:44:23 +00001221inline _LIBCPP_INLINE_VISIBILITY float exp2(float __lcpp_x) _NOEXCEPT {return ::exp2f(__lcpp_x);}
1222inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return ::exp2l(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001223
1224template <class _A1>
1225inline _LIBCPP_INLINE_VISIBILITY
1226typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001227exp2(_A1 __lcpp_x) _NOEXCEPT {return ::exp2((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001228
1229// expm1
1230
Mehdi Aminib3da6322017-02-10 02:44:23 +00001231inline _LIBCPP_INLINE_VISIBILITY float expm1(float __lcpp_x) _NOEXCEPT {return ::expm1f(__lcpp_x);}
1232inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return ::expm1l(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001233
1234template <class _A1>
1235inline _LIBCPP_INLINE_VISIBILITY
1236typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001237expm1(_A1 __lcpp_x) _NOEXCEPT {return ::expm1((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001238
1239// fdim
1240
Mehdi Aminib3da6322017-02-10 02:44:23 +00001241inline _LIBCPP_INLINE_VISIBILITY float fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fdimf(__lcpp_x, __lcpp_y);}
1242inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fdiml(__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001243
1244template <class _A1, class _A2>
1245inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001246typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001247<
1248 std::is_arithmetic<_A1>::value &&
1249 std::is_arithmetic<_A2>::value,
1250 std::__promote<_A1, _A2>
1251>::type
1252fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1253{
1254 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001255 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1256 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001257 return ::fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001258}
1259
1260// fma
1261
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001262inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT
1263{
1264#if __has_builtin(__builtin_fmaf)
1265 return __builtin_fmaf(__lcpp_x, __lcpp_y, __lcpp_z);
1266#else
1267 return ::fmaf(__lcpp_x, __lcpp_y, __lcpp_z);
1268#endif
1269}
1270inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT
1271{
1272#if __has_builtin(__builtin_fmal)
1273 return __builtin_fmal(__lcpp_x, __lcpp_y, __lcpp_z);
1274#else
1275 return ::fmal(__lcpp_x, __lcpp_y, __lcpp_z);
1276#endif
1277}
Richard Smith081bb592015-10-08 20:40:34 +00001278
1279template <class _A1, class _A2, class _A3>
1280inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001281typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001282<
1283 std::is_arithmetic<_A1>::value &&
1284 std::is_arithmetic<_A2>::value &&
1285 std::is_arithmetic<_A3>::value,
1286 std::__promote<_A1, _A2, _A3>
1287>::type
1288fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
1289{
1290 typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001291 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1292 std::_IsSame<_A2, __result_type>::value &&
1293 std::_IsSame<_A3, __result_type>::value)), "");
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001294#if __has_builtin(__builtin_fma)
1295 return __builtin_fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
1296#else
Mehdi Aminib3da6322017-02-10 02:44:23 +00001297 return ::fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001298#endif
Richard Smith081bb592015-10-08 20:40:34 +00001299}
1300
1301// fmax
1302
Mehdi Aminib3da6322017-02-10 02:44:23 +00001303inline _LIBCPP_INLINE_VISIBILITY float fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmaxf(__lcpp_x, __lcpp_y);}
1304inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmaxl(__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001305
1306template <class _A1, class _A2>
1307inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001308typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001309<
1310 std::is_arithmetic<_A1>::value &&
1311 std::is_arithmetic<_A2>::value,
1312 std::__promote<_A1, _A2>
1313>::type
1314fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1315{
1316 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001317 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1318 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001319 return ::fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001320}
1321
1322// fmin
1323
Mehdi Aminib3da6322017-02-10 02:44:23 +00001324inline _LIBCPP_INLINE_VISIBILITY float fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fminf(__lcpp_x, __lcpp_y);}
1325inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fminl(__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001326
1327template <class _A1, class _A2>
1328inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001329typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001330<
1331 std::is_arithmetic<_A1>::value &&
1332 std::is_arithmetic<_A2>::value,
1333 std::__promote<_A1, _A2>
1334>::type
1335fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1336{
1337 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001338 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1339 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001340 return ::fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001341}
1342
1343// hypot
1344
Mehdi Aminib3da6322017-02-10 02:44:23 +00001345inline _LIBCPP_INLINE_VISIBILITY float hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::hypotf(__lcpp_x, __lcpp_y);}
1346inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::hypotl(__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001347
1348template <class _A1, class _A2>
1349inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001350typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001351<
1352 std::is_arithmetic<_A1>::value &&
1353 std::is_arithmetic<_A2>::value,
1354 std::__promote<_A1, _A2>
1355>::type
1356hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1357{
1358 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001359 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1360 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001361 return ::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001362}
1363
1364// ilogb
1365
Mehdi Aminib3da6322017-02-10 02:44:23 +00001366inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT {return ::ilogbf(__lcpp_x);}
1367inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ::ilogbl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001368
1369template <class _A1>
1370inline _LIBCPP_INLINE_VISIBILITY
1371typename std::enable_if<std::is_integral<_A1>::value, int>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001372ilogb(_A1 __lcpp_x) _NOEXCEPT {return ::ilogb((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001373
1374// lgamma
1375
Mehdi Aminib3da6322017-02-10 02:44:23 +00001376inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __lcpp_x) _NOEXCEPT {return ::lgammaf(__lcpp_x);}
1377inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return ::lgammal(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001378
1379template <class _A1>
1380inline _LIBCPP_INLINE_VISIBILITY
1381typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001382lgamma(_A1 __lcpp_x) _NOEXCEPT {return ::lgamma((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001383
1384// llrint
1385
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001386inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT
1387{
1388#if __has_builtin(__builtin_llrintf)
1389 return __builtin_llrintf(__lcpp_x);
1390#else
1391 return ::llrintf(__lcpp_x);
1392#endif
1393}
1394inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT
1395{
1396#if __has_builtin(__builtin_llrintl)
1397 return __builtin_llrintl(__lcpp_x);
1398#else
1399 return ::llrintl(__lcpp_x);
1400#endif
1401}
Richard Smith081bb592015-10-08 20:40:34 +00001402
1403template <class _A1>
1404inline _LIBCPP_INLINE_VISIBILITY
1405typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001406llrint(_A1 __lcpp_x) _NOEXCEPT
1407{
1408#if __has_builtin(__builtin_llrint)
1409 return __builtin_llrint((double)__lcpp_x);
1410#else
1411 return ::llrint((double)__lcpp_x);
1412#endif
1413}
Richard Smith081bb592015-10-08 20:40:34 +00001414
1415// llround
1416
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001417inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT
1418{
1419#if __has_builtin(__builtin_llroundf)
1420 return __builtin_llroundf(__lcpp_x);
1421#else
1422 return ::llroundf(__lcpp_x);
1423#endif
1424}
1425inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT
1426{
1427#if __has_builtin(__builtin_llroundl)
1428 return __builtin_llroundl(__lcpp_x);
1429#else
1430 return ::llroundl(__lcpp_x);
1431#endif
1432}
Richard Smith081bb592015-10-08 20:40:34 +00001433
1434template <class _A1>
1435inline _LIBCPP_INLINE_VISIBILITY
1436typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001437llround(_A1 __lcpp_x) _NOEXCEPT
1438{
1439#if __has_builtin(__builtin_llround)
1440 return __builtin_llround((double)__lcpp_x);
1441#else
1442 return ::llround((double)__lcpp_x);
1443#endif
1444}
Richard Smith081bb592015-10-08 20:40:34 +00001445
1446// log1p
1447
Mehdi Aminib3da6322017-02-10 02:44:23 +00001448inline _LIBCPP_INLINE_VISIBILITY float log1p(float __lcpp_x) _NOEXCEPT {return ::log1pf(__lcpp_x);}
1449inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return ::log1pl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001450
1451template <class _A1>
1452inline _LIBCPP_INLINE_VISIBILITY
1453typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001454log1p(_A1 __lcpp_x) _NOEXCEPT {return ::log1p((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001455
1456// log2
1457
Mehdi Aminib3da6322017-02-10 02:44:23 +00001458inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return ::log2f(__lcpp_x);}
1459inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return ::log2l(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001460
1461template <class _A1>
1462inline _LIBCPP_INLINE_VISIBILITY
1463typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001464log2(_A1 __lcpp_x) _NOEXCEPT {return ::log2((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001465
1466// logb
1467
Mehdi Aminib3da6322017-02-10 02:44:23 +00001468inline _LIBCPP_INLINE_VISIBILITY float logb(float __lcpp_x) _NOEXCEPT {return ::logbf(__lcpp_x);}
1469inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return ::logbl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001470
1471template <class _A1>
1472inline _LIBCPP_INLINE_VISIBILITY
1473typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001474logb(_A1 __lcpp_x) _NOEXCEPT {return ::logb((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001475
1476// lrint
1477
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001478inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT
1479{
1480#if __has_builtin(__builtin_lrintf)
1481 return __builtin_lrintf(__lcpp_x);
1482#else
1483 return ::lrintf(__lcpp_x);
1484#endif
1485}
1486inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT
1487{
1488#if __has_builtin(__builtin_lrintl)
1489 return __builtin_lrintl(__lcpp_x);
1490#else
1491 return ::lrintl(__lcpp_x);
1492#endif
1493}
Richard Smith081bb592015-10-08 20:40:34 +00001494
1495template <class _A1>
1496inline _LIBCPP_INLINE_VISIBILITY
1497typename std::enable_if<std::is_integral<_A1>::value, long>::type
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001498lrint(_A1 __lcpp_x) _NOEXCEPT
1499{
1500#if __has_builtin(__builtin_lrint)
1501 return __builtin_lrint((double)__lcpp_x);
1502#else
1503 return ::lrint((double)__lcpp_x);
1504#endif
1505}
Richard Smith081bb592015-10-08 20:40:34 +00001506
1507// lround
1508
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001509inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT
1510{
1511#if __has_builtin(__builtin_lroundf)
1512 return __builtin_lroundf(__lcpp_x);
1513#else
1514 return ::lroundf(__lcpp_x);
1515#endif
1516}
1517inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT
1518{
1519#if __has_builtin(__builtin_lroundl)
1520 return __builtin_lroundl(__lcpp_x);
1521#else
1522 return ::lroundl(__lcpp_x);
1523#endif
1524}
Richard Smith081bb592015-10-08 20:40:34 +00001525
1526template <class _A1>
1527inline _LIBCPP_INLINE_VISIBILITY
1528typename std::enable_if<std::is_integral<_A1>::value, long>::type
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001529lround(_A1 __lcpp_x) _NOEXCEPT
1530{
1531#if __has_builtin(__builtin_lround)
1532 return __builtin_lround((double)__lcpp_x);
1533#else
1534 return ::lround((double)__lcpp_x);
1535#endif
1536}
Richard Smith081bb592015-10-08 20:40:34 +00001537
1538// nan
1539
1540// nearbyint
1541
Mehdi Aminib3da6322017-02-10 02:44:23 +00001542inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __lcpp_x) _NOEXCEPT {return ::nearbyintf(__lcpp_x);}
1543inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return ::nearbyintl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001544
1545template <class _A1>
1546inline _LIBCPP_INLINE_VISIBILITY
1547typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001548nearbyint(_A1 __lcpp_x) _NOEXCEPT {return ::nearbyint((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001549
1550// nextafter
1551
Mehdi Aminib3da6322017-02-10 02:44:23 +00001552inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::nextafterf(__lcpp_x, __lcpp_y);}
1553inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nextafterl(__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001554
1555template <class _A1, class _A2>
1556inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001557typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001558<
1559 std::is_arithmetic<_A1>::value &&
1560 std::is_arithmetic<_A2>::value,
1561 std::__promote<_A1, _A2>
1562>::type
1563nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1564{
1565 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001566 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1567 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001568 return ::nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001569}
1570
1571// nexttoward
1572
Mehdi Aminib3da6322017-02-10 02:44:23 +00001573inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardf(__lcpp_x, __lcpp_y);}
1574inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardl(__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001575
1576template <class _A1>
1577inline _LIBCPP_INLINE_VISIBILITY
1578typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001579nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttoward((double)__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001580
1581// remainder
1582
Mehdi Aminib3da6322017-02-10 02:44:23 +00001583inline _LIBCPP_INLINE_VISIBILITY float remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::remainderf(__lcpp_x, __lcpp_y);}
1584inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::remainderl(__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001585
1586template <class _A1, class _A2>
1587inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001588typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001589<
1590 std::is_arithmetic<_A1>::value &&
1591 std::is_arithmetic<_A2>::value,
1592 std::__promote<_A1, _A2>
1593>::type
1594remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1595{
1596 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001597 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1598 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001599 return ::remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001600}
1601
1602// remquo
1603
Mehdi Aminib3da6322017-02-10 02:44:23 +00001604inline _LIBCPP_INLINE_VISIBILITY float remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT {return ::remquof(__lcpp_x, __lcpp_y, __lcpp_z);}
1605inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long double __lcpp_y, int* __lcpp_z) _NOEXCEPT {return ::remquol(__lcpp_x, __lcpp_y, __lcpp_z);}
Richard Smith081bb592015-10-08 20:40:34 +00001606
1607template <class _A1, class _A2>
1608inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001609typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001610<
1611 std::is_arithmetic<_A1>::value &&
1612 std::is_arithmetic<_A2>::value,
1613 std::__promote<_A1, _A2>
1614>::type
1615remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT
1616{
1617 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001618 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1619 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001620 return ::remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z);
Richard Smith081bb592015-10-08 20:40:34 +00001621}
1622
1623// rint
1624
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001625inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT
1626{
1627#if __has_builtin(__builtin_rintf)
1628 return __builtin_rintf(__lcpp_x);
1629#else
1630 return ::rintf(__lcpp_x);
1631#endif
1632}
1633inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT
1634{
1635#if __has_builtin(__builtin_rintl)
1636 return __builtin_rintl(__lcpp_x);
1637#else
1638 return ::rintl(__lcpp_x);
1639#endif
1640}
Richard Smith081bb592015-10-08 20:40:34 +00001641
1642template <class _A1>
1643inline _LIBCPP_INLINE_VISIBILITY
1644typename std::enable_if<std::is_integral<_A1>::value, double>::type
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001645rint(_A1 __lcpp_x) _NOEXCEPT
1646{
1647#if __has_builtin(__builtin_rint)
1648 return __builtin_rint((double)__lcpp_x);
1649#else
1650 return ::rint((double)__lcpp_x);
1651#endif
1652}
Richard Smith081bb592015-10-08 20:40:34 +00001653
1654// round
1655
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001656inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT
1657{
1658#if __has_builtin(__builtin_round)
1659 return __builtin_round(__lcpp_x);
1660#else
1661 return ::round(__lcpp_x);
1662#endif
1663}
1664inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT
1665{
1666#if __has_builtin(__builtin_roundl)
1667 return __builtin_roundl(__lcpp_x);
1668#else
1669 return ::roundl(__lcpp_x);
1670#endif
1671}
Richard Smith081bb592015-10-08 20:40:34 +00001672
1673template <class _A1>
1674inline _LIBCPP_INLINE_VISIBILITY
1675typename std::enable_if<std::is_integral<_A1>::value, double>::type
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001676round(_A1 __lcpp_x) _NOEXCEPT
1677{
1678#if __has_builtin(__builtin_round)
1679 return __builtin_round((double)__lcpp_x);
1680#else
1681 return ::round((double)__lcpp_x);
1682#endif
1683}
Richard Smith081bb592015-10-08 20:40:34 +00001684
1685// scalbln
1686
Mehdi Aminib3da6322017-02-10 02:44:23 +00001687inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnf(__lcpp_x, __lcpp_y);}
1688inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnl(__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001689
1690template <class _A1>
1691inline _LIBCPP_INLINE_VISIBILITY
1692typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001693scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalbln((double)__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001694
1695// scalbn
1696
Mehdi Aminib3da6322017-02-10 02:44:23 +00001697inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnf(__lcpp_x, __lcpp_y);}
1698inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnl(__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001699
1700template <class _A1>
1701inline _LIBCPP_INLINE_VISIBILITY
1702typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001703scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbn((double)__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001704
1705// tgamma
1706
Mehdi Aminib3da6322017-02-10 02:44:23 +00001707inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __lcpp_x) _NOEXCEPT {return ::tgammaf(__lcpp_x);}
1708inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return ::tgammal(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001709
1710template <class _A1>
1711inline _LIBCPP_INLINE_VISIBILITY
1712typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001713tgamma(_A1 __lcpp_x) _NOEXCEPT {return ::tgamma((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001714
1715// trunc
1716
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001717inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT
1718{
1719#if __has_builtin(__builtin_trunc)
1720 return __builtin_trunc(__lcpp_x);
1721#else
1722 return ::trunc(__lcpp_x);
1723#endif
1724}
1725inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT
1726{
1727#if __has_builtin(__builtin_truncl)
1728 return __builtin_truncl(__lcpp_x);
1729#else
1730 return ::truncl(__lcpp_x);
1731#endif
1732}
Richard Smith081bb592015-10-08 20:40:34 +00001733
1734template <class _A1>
1735inline _LIBCPP_INLINE_VISIBILITY
1736typename std::enable_if<std::is_integral<_A1>::value, double>::type
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001737trunc(_A1 __lcpp_x) _NOEXCEPT
1738{
1739#if __has_builtin(__builtin_trunc)
1740 return __builtin_trunc((double)__lcpp_x);
1741#else
1742 return ::trunc((double)__lcpp_x);
1743#endif
1744}
Richard Smith081bb592015-10-08 20:40:34 +00001745
Richard Smith081bb592015-10-08 20:40:34 +00001746} // extern "C++"
1747
1748#endif // __cplusplus
1749
Mikhail Maltsev34b4f972018-02-22 09:34:08 +00001750#else // _LIBCPP_MATH_H
1751
1752// This include lives outside the header guard in order to support an MSVC
1753// extension which allows users to do:
1754//
1755// #define _USE_MATH_DEFINES
1756// #include <math.h>
1757//
1758// and receive the definitions of mathematical constants, even if <math.h>
1759// has previously been included.
1760#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
1761#include_next <math.h>
1762#endif
1763
Louis Dionne2b1ceaa2021-04-20 12:03:32 -04001764#endif // _LIBCPP_MATH_H