blob: 8cbbc54a623fa1b9eea9bc59cfcdb195cecccd44 [file] [log] [blame]
Richard Smith081bb592015-10-08 20:40:34 +00001// -*- C++ -*-
2//===---------------------------- math.h ----------------------------------===//
3//
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)
297#pragma GCC system_header
298#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
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500308#include <stdlib.h>
Richard Smith081bb592015-10-08 20:40:34 +0000309#include <type_traits>
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000310#include <limits>
Richard Smith081bb592015-10-08 20:40:34 +0000311
Richard Smith081bb592015-10-08 20:40:34 +0000312// signbit
313
314#ifdef signbit
315
316template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000317_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000318bool
319__libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT
320{
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500321#if __has_builtin(__builtin_signbit)
322 return __builtin_signbit(__lcpp_x);
323#else
Richard Smith081bb592015-10-08 20:40:34 +0000324 return signbit(__lcpp_x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500325#endif
Richard Smith081bb592015-10-08 20:40:34 +0000326}
327
328#undef signbit
329
330template <class _A1>
331inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000332typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000333signbit(_A1 __lcpp_x) _NOEXCEPT
334{
335 return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
336}
337
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000338template <class _A1>
339inline _LIBCPP_INLINE_VISIBILITY
340typename std::enable_if<
341 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
342signbit(_A1 __lcpp_x) _NOEXCEPT
343{ return __lcpp_x < 0; }
344
345template <class _A1>
346inline _LIBCPP_INLINE_VISIBILITY
347typename std::enable_if<
348 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
349signbit(_A1) _NOEXCEPT
350{ return false; }
351
Shoaib Meenai159375f2017-04-07 02:20:52 +0000352#elif defined(_LIBCPP_MSVCRT)
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000353
354template <typename _A1>
355inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000356typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000357signbit(_A1 __lcpp_x) _NOEXCEPT
358{
359 return ::signbit(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
360}
361
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000362template <class _A1>
363inline _LIBCPP_INLINE_VISIBILITY
364typename std::enable_if<
365 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
366signbit(_A1 __lcpp_x) _NOEXCEPT
367{ return __lcpp_x < 0; }
368
369template <class _A1>
370inline _LIBCPP_INLINE_VISIBILITY
371typename std::enable_if<
372 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
373signbit(_A1) _NOEXCEPT
374{ return false; }
375
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400376#endif // signbit
Richard Smith081bb592015-10-08 20:40:34 +0000377
378// fpclassify
379
380#ifdef fpclassify
381
382template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000383_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000384int
385__libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT
386{
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500387#if __has_builtin(__builtin_fpclassify)
388 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
389 FP_ZERO, __lcpp_x);
390#else
Richard Smith081bb592015-10-08 20:40:34 +0000391 return fpclassify(__lcpp_x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500392#endif
Richard Smith081bb592015-10-08 20:40:34 +0000393}
394
395#undef fpclassify
396
397template <class _A1>
398inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000399typename std::enable_if<std::is_floating_point<_A1>::value, int>::type
Richard Smith081bb592015-10-08 20:40:34 +0000400fpclassify(_A1 __lcpp_x) _NOEXCEPT
401{
402 return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
403}
404
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000405template <class _A1>
406inline _LIBCPP_INLINE_VISIBILITY
407typename std::enable_if<std::is_integral<_A1>::value, int>::type
408fpclassify(_A1 __lcpp_x) _NOEXCEPT
409{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
410
Shoaib Meenai159375f2017-04-07 02:20:52 +0000411#elif defined(_LIBCPP_MSVCRT)
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000412
413template <typename _A1>
414inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000415typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000416fpclassify(_A1 __lcpp_x) _NOEXCEPT
417{
418 return ::fpclassify(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
419}
420
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000421template <class _A1>
422inline _LIBCPP_INLINE_VISIBILITY
423typename std::enable_if<std::is_integral<_A1>::value, int>::type
424fpclassify(_A1 __lcpp_x) _NOEXCEPT
425{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
426
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400427#endif // fpclassify
Richard Smith081bb592015-10-08 20:40:34 +0000428
429// isfinite
430
431#ifdef isfinite
432
433template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000434_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000435bool
436__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
437{
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500438#if __has_builtin(__builtin_isfinite)
439 return __builtin_isfinite(__lcpp_x);
440#else
Richard Smith081bb592015-10-08 20:40:34 +0000441 return isfinite(__lcpp_x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500442#endif
Richard Smith081bb592015-10-08 20:40:34 +0000443}
444
445#undef isfinite
446
447template <class _A1>
448inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000449typename std::enable_if<
450 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
451 bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000452isfinite(_A1 __lcpp_x) _NOEXCEPT
453{
454 return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x);
455}
456
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000457template <class _A1>
458inline _LIBCPP_INLINE_VISIBILITY
459typename std::enable_if<
460 std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
461 bool>::type
462isfinite(_A1) _NOEXCEPT
463{ return true; }
464
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400465#endif // isfinite
Richard Smith081bb592015-10-08 20:40:34 +0000466
467// isinf
468
469#ifdef isinf
470
471template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000472_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000473bool
474__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
475{
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500476#if __has_builtin(__builtin_isinf)
477 return __builtin_isinf(__lcpp_x);
478#else
Richard Smith081bb592015-10-08 20:40:34 +0000479 return isinf(__lcpp_x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500480#endif
Richard Smith081bb592015-10-08 20:40:34 +0000481}
482
483#undef isinf
484
485template <class _A1>
486inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000487typename std::enable_if<
488 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
489 bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000490isinf(_A1 __lcpp_x) _NOEXCEPT
491{
492 return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x);
493}
494
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000495template <class _A1>
496inline _LIBCPP_INLINE_VISIBILITY
497typename std::enable_if<
498 std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
499 bool>::type
500isinf(_A1) _NOEXCEPT
501{ return false; }
502
Richard Smithafccfd32018-05-01 03:05:40 +0000503#ifdef _LIBCPP_PREFERRED_OVERLOAD
504inline _LIBCPP_INLINE_VISIBILITY
505bool
506isinf(float __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
507
508inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
509bool
510isinf(double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
511
512inline _LIBCPP_INLINE_VISIBILITY
513bool
514isinf(long double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
515#endif
516
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400517#endif // isinf
Richard Smith081bb592015-10-08 20:40:34 +0000518
519// isnan
520
521#ifdef isnan
522
523template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000524_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000525bool
526__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
527{
Ilya Tokar6caf83a2019-11-15 12:29:02 -0500528#if __has_builtin(__builtin_isnan)
529 return __builtin_isnan(__lcpp_x);
530#else
Richard Smith081bb592015-10-08 20:40:34 +0000531 return isnan(__lcpp_x);
Ilya Tokar6caf83a2019-11-15 12:29:02 -0500532#endif
Richard Smith081bb592015-10-08 20:40:34 +0000533}
534
535#undef isnan
536
537template <class _A1>
538inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000539typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000540isnan(_A1 __lcpp_x) _NOEXCEPT
541{
542 return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);
543}
544
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000545template <class _A1>
546inline _LIBCPP_INLINE_VISIBILITY
547typename std::enable_if<std::is_integral<_A1>::value, bool>::type
548isnan(_A1) _NOEXCEPT
549{ return false; }
550
Richard Smithafccfd32018-05-01 03:05:40 +0000551#ifdef _LIBCPP_PREFERRED_OVERLOAD
552inline _LIBCPP_INLINE_VISIBILITY
553bool
554isnan(float __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
555
556inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
557bool
558isnan(double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
559
560inline _LIBCPP_INLINE_VISIBILITY
561bool
562isnan(long double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
563#endif
564
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400565#endif // isnan
Richard Smith081bb592015-10-08 20:40:34 +0000566
567// isnormal
568
569#ifdef isnormal
570
571template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000572_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000573bool
574__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT
575{
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500576#if __has_builtin(__builtin_isnormal)
577 return __builtin_isnormal(__lcpp_x);
578#else
Richard Smith081bb592015-10-08 20:40:34 +0000579 return isnormal(__lcpp_x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500580#endif
Richard Smith081bb592015-10-08 20:40:34 +0000581}
582
583#undef isnormal
584
585template <class _A1>
586inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000587typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000588isnormal(_A1 __lcpp_x) _NOEXCEPT
589{
590 return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x);
591}
592
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000593template <class _A1>
594inline _LIBCPP_INLINE_VISIBILITY
595typename std::enable_if<std::is_integral<_A1>::value, bool>::type
596isnormal(_A1 __lcpp_x) _NOEXCEPT
597{ return __lcpp_x != 0; }
598
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400599#endif // isnormal
Richard Smith081bb592015-10-08 20:40:34 +0000600
601// isgreater
602
603#ifdef isgreater
604
605template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000606_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000607bool
608__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
609{
610 return isgreater(__lcpp_x, __lcpp_y);
611}
612
613#undef isgreater
614
615template <class _A1, class _A2>
616inline _LIBCPP_INLINE_VISIBILITY
617typename std::enable_if
618<
619 std::is_arithmetic<_A1>::value &&
620 std::is_arithmetic<_A2>::value,
621 bool
622>::type
623isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
624{
625 typedef typename std::__promote<_A1, _A2>::type type;
626 return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y);
627}
628
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400629#endif // isgreater
Richard Smith081bb592015-10-08 20:40:34 +0000630
631// isgreaterequal
632
633#ifdef isgreaterequal
634
635template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000636_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000637bool
638__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
639{
640 return isgreaterequal(__lcpp_x, __lcpp_y);
641}
642
643#undef isgreaterequal
644
645template <class _A1, class _A2>
646inline _LIBCPP_INLINE_VISIBILITY
647typename std::enable_if
648<
649 std::is_arithmetic<_A1>::value &&
650 std::is_arithmetic<_A2>::value,
651 bool
652>::type
653isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
654{
655 typedef typename std::__promote<_A1, _A2>::type type;
656 return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y);
657}
658
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400659#endif // isgreaterequal
Richard Smith081bb592015-10-08 20:40:34 +0000660
661// isless
662
663#ifdef isless
664
665template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000666_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000667bool
668__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
669{
670 return isless(__lcpp_x, __lcpp_y);
671}
672
673#undef isless
674
675template <class _A1, class _A2>
676inline _LIBCPP_INLINE_VISIBILITY
677typename std::enable_if
678<
679 std::is_arithmetic<_A1>::value &&
680 std::is_arithmetic<_A2>::value,
681 bool
682>::type
683isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
684{
685 typedef typename std::__promote<_A1, _A2>::type type;
686 return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y);
687}
688
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400689#endif // isless
Richard Smith081bb592015-10-08 20:40:34 +0000690
691// islessequal
692
693#ifdef islessequal
694
695template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000696_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000697bool
698__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
699{
700 return islessequal(__lcpp_x, __lcpp_y);
701}
702
703#undef islessequal
704
705template <class _A1, class _A2>
706inline _LIBCPP_INLINE_VISIBILITY
707typename std::enable_if
708<
709 std::is_arithmetic<_A1>::value &&
710 std::is_arithmetic<_A2>::value,
711 bool
712>::type
713islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
714{
715 typedef typename std::__promote<_A1, _A2>::type type;
716 return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y);
717}
718
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400719#endif // islessequal
Richard Smith081bb592015-10-08 20:40:34 +0000720
721// islessgreater
722
723#ifdef islessgreater
724
725template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000726_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000727bool
728__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
729{
730 return islessgreater(__lcpp_x, __lcpp_y);
731}
732
733#undef islessgreater
734
735template <class _A1, class _A2>
736inline _LIBCPP_INLINE_VISIBILITY
737typename std::enable_if
738<
739 std::is_arithmetic<_A1>::value &&
740 std::is_arithmetic<_A2>::value,
741 bool
742>::type
743islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
744{
745 typedef typename std::__promote<_A1, _A2>::type type;
746 return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y);
747}
748
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400749#endif // islessgreater
Richard Smith081bb592015-10-08 20:40:34 +0000750
751// isunordered
752
753#ifdef isunordered
754
755template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000756_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000757bool
758__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
759{
760 return isunordered(__lcpp_x, __lcpp_y);
761}
762
763#undef isunordered
764
765template <class _A1, class _A2>
766inline _LIBCPP_INLINE_VISIBILITY
767typename std::enable_if
768<
769 std::is_arithmetic<_A1>::value &&
770 std::is_arithmetic<_A2>::value,
771 bool
772>::type
773isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
774{
775 typedef typename std::__promote<_A1, _A2>::type type;
776 return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y);
777}
778
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400779#endif // isunordered
Richard Smith081bb592015-10-08 20:40:34 +0000780
Richard Smith081bb592015-10-08 20:40:34 +0000781// abs
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500782//
783// handled in stdlib.h
Richard Smith081bb592015-10-08 20:40:34 +0000784
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000785// div
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500786//
787// handled in stdlib.h
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000788
Richard Smith081bb592015-10-08 20:40:34 +0000789// acos
790
Shoaib Meenai159375f2017-04-07 02:20:52 +0000791#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000792inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return ::acosf(__lcpp_x);}
793inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000794#endif
795
796template <class _A1>
797inline _LIBCPP_INLINE_VISIBILITY
798typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000799acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000800
801// asin
802
Shoaib Meenai159375f2017-04-07 02:20:52 +0000803#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000804inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return ::asinf(__lcpp_x);}
805inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000806#endif
807
808template <class _A1>
809inline _LIBCPP_INLINE_VISIBILITY
810typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000811asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000812
813// atan
814
Shoaib Meenai159375f2017-04-07 02:20:52 +0000815#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000816inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return ::atanf(__lcpp_x);}
817inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000818#endif
819
820template <class _A1>
821inline _LIBCPP_INLINE_VISIBILITY
822typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000823atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000824
825// atan2
826
Shoaib Meenai159375f2017-04-07 02:20:52 +0000827#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000828inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);}
829inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return ::atan2l(__lcpp_y, __lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000830#endif
831
832template <class _A1, class _A2>
833inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -0400834typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000835<
836 std::is_arithmetic<_A1>::value &&
837 std::is_arithmetic<_A2>::value,
838 std::__promote<_A1, _A2>
839>::type
840atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT
841{
842 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000843 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
844 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +0000845 return ::atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
Richard Smith081bb592015-10-08 20:40:34 +0000846}
847
848// ceil
849
Shoaib Meenai159375f2017-04-07 02:20:52 +0000850#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000851inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ::ceilf(__lcpp_x);}
852inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ::ceill(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000853#endif
854
855template <class _A1>
856inline _LIBCPP_INLINE_VISIBILITY
857typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000858ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000859
860// cos
861
Shoaib Meenai159375f2017-04-07 02:20:52 +0000862#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000863inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return ::cosf(__lcpp_x);}
864inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return ::cosl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000865#endif
866
867template <class _A1>
868inline _LIBCPP_INLINE_VISIBILITY
869typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000870cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000871
872// cosh
873
Shoaib Meenai159375f2017-04-07 02:20:52 +0000874#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000875inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return ::coshf(__lcpp_x);}
876inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return ::coshl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000877#endif
878
879template <class _A1>
880inline _LIBCPP_INLINE_VISIBILITY
881typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000882cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000883
884// exp
885
Shoaib Meenai159375f2017-04-07 02:20:52 +0000886#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000887inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return ::expf(__lcpp_x);}
888inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return ::expl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000889#endif
890
891template <class _A1>
892inline _LIBCPP_INLINE_VISIBILITY
893typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000894exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000895
896// fabs
897
Shoaib Meenai159375f2017-04-07 02:20:52 +0000898#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000899inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
900inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000901#endif
902
903template <class _A1>
904inline _LIBCPP_INLINE_VISIBILITY
905typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000906fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000907
908// floor
909
Shoaib Meenai159375f2017-04-07 02:20:52 +0000910#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000911inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return ::floorf(__lcpp_x);}
912inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return ::floorl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000913#endif
914
915template <class _A1>
916inline _LIBCPP_INLINE_VISIBILITY
917typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000918floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000919
920// fmod
921
Shoaib Meenai159375f2017-04-07 02:20:52 +0000922#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000923inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmodf(__lcpp_x, __lcpp_y);}
924inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmodl(__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +0000925#endif
926
927template <class _A1, class _A2>
928inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -0400929typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000930<
931 std::is_arithmetic<_A1>::value &&
932 std::is_arithmetic<_A2>::value,
933 std::__promote<_A1, _A2>
934>::type
935fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
936{
937 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000938 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
939 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +0000940 return ::fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +0000941}
942
943// frexp
944
Shoaib Meenai159375f2017-04-07 02:20:52 +0000945#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000946inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpf(__lcpp_x, __lcpp_e);}
947inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpl(__lcpp_x, __lcpp_e);}
Richard Smith081bb592015-10-08 20:40:34 +0000948#endif
949
950template <class _A1>
951inline _LIBCPP_INLINE_VISIBILITY
952typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000953frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexp((double)__lcpp_x, __lcpp_e);}
Richard Smith081bb592015-10-08 20:40:34 +0000954
955// ldexp
956
Shoaib Meenai159375f2017-04-07 02:20:52 +0000957#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000958inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpf(__lcpp_x, __lcpp_e);}
959inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpl(__lcpp_x, __lcpp_e);}
Richard Smith081bb592015-10-08 20:40:34 +0000960#endif
961
962template <class _A1>
963inline _LIBCPP_INLINE_VISIBILITY
964typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000965ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexp((double)__lcpp_x, __lcpp_e);}
Richard Smith081bb592015-10-08 20:40:34 +0000966
967// log
968
Shoaib Meenai159375f2017-04-07 02:20:52 +0000969#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000970inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return ::logf(__lcpp_x);}
971inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return ::logl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000972#endif
973
974template <class _A1>
975inline _LIBCPP_INLINE_VISIBILITY
976typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000977log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000978
979// log10
980
Shoaib Meenai159375f2017-04-07 02:20:52 +0000981#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000982inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return ::log10f(__lcpp_x);}
983inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return ::log10l(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000984#endif
985
986template <class _A1>
987inline _LIBCPP_INLINE_VISIBILITY
988typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000989log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000990
991// modf
992
Shoaib Meenai159375f2017-04-07 02:20:52 +0000993#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000994inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return ::modff(__lcpp_x, __lcpp_y);}
995inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return ::modfl(__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +0000996#endif
997
998// pow
999
Shoaib Meenai159375f2017-04-07 02:20:52 +00001000#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001001inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::powf(__lcpp_x, __lcpp_y);}
1002inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::powl(__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001003#endif
1004
1005template <class _A1, class _A2>
1006inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001007typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001008<
1009 std::is_arithmetic<_A1>::value &&
1010 std::is_arithmetic<_A2>::value,
1011 std::__promote<_A1, _A2>
1012>::type
1013pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1014{
1015 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001016 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1017 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001018 return ::pow((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001019}
1020
1021// sin
1022
Shoaib Meenai159375f2017-04-07 02:20:52 +00001023#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001024inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return ::sinf(__lcpp_x);}
1025inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return ::sinl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001026#endif
1027
1028template <class _A1>
1029inline _LIBCPP_INLINE_VISIBILITY
1030typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001031sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001032
1033// sinh
1034
Shoaib Meenai159375f2017-04-07 02:20:52 +00001035#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001036inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return ::sinhf(__lcpp_x);}
1037inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return ::sinhl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001038#endif
1039
1040template <class _A1>
1041inline _LIBCPP_INLINE_VISIBILITY
1042typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001043sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001044
1045// sqrt
1046
Shoaib Meenai159375f2017-04-07 02:20:52 +00001047#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001048inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return ::sqrtf(__lcpp_x);}
1049inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return ::sqrtl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001050#endif
1051
Richard Smith081bb592015-10-08 20:40:34 +00001052template <class _A1>
1053inline _LIBCPP_INLINE_VISIBILITY
1054typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001055sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001056
1057// tan
1058
Shoaib Meenai159375f2017-04-07 02:20:52 +00001059#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001060inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return ::tanf(__lcpp_x);}
1061inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return ::tanl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001062#endif
1063
1064template <class _A1>
1065inline _LIBCPP_INLINE_VISIBILITY
1066typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001067tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001068
1069// tanh
1070
Shoaib Meenai159375f2017-04-07 02:20:52 +00001071#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001072inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return ::tanhf(__lcpp_x);}
1073inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return ::tanhl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001074#endif
1075
1076template <class _A1>
1077inline _LIBCPP_INLINE_VISIBILITY
1078typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001079tanh(_A1 __lcpp_x) _NOEXCEPT {return ::tanh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001080
1081// acosh
1082
Mehdi Aminib3da6322017-02-10 02:44:23 +00001083inline _LIBCPP_INLINE_VISIBILITY float acosh(float __lcpp_x) _NOEXCEPT {return ::acoshf(__lcpp_x);}
1084inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return ::acoshl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001085
1086template <class _A1>
1087inline _LIBCPP_INLINE_VISIBILITY
1088typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001089acosh(_A1 __lcpp_x) _NOEXCEPT {return ::acosh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001090
1091// asinh
1092
Mehdi Aminib3da6322017-02-10 02:44:23 +00001093inline _LIBCPP_INLINE_VISIBILITY float asinh(float __lcpp_x) _NOEXCEPT {return ::asinhf(__lcpp_x);}
1094inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return ::asinhl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001095
1096template <class _A1>
1097inline _LIBCPP_INLINE_VISIBILITY
1098typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001099asinh(_A1 __lcpp_x) _NOEXCEPT {return ::asinh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001100
1101// atanh
1102
Mehdi Aminib3da6322017-02-10 02:44:23 +00001103inline _LIBCPP_INLINE_VISIBILITY float atanh(float __lcpp_x) _NOEXCEPT {return ::atanhf(__lcpp_x);}
1104inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return ::atanhl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001105
1106template <class _A1>
1107inline _LIBCPP_INLINE_VISIBILITY
1108typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001109atanh(_A1 __lcpp_x) _NOEXCEPT {return ::atanh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001110
1111// cbrt
1112
Mehdi Aminib3da6322017-02-10 02:44:23 +00001113inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __lcpp_x) _NOEXCEPT {return ::cbrtf(__lcpp_x);}
1114inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return ::cbrtl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001115
1116template <class _A1>
1117inline _LIBCPP_INLINE_VISIBILITY
1118typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001119cbrt(_A1 __lcpp_x) _NOEXCEPT {return ::cbrt((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001120
1121// copysign
1122
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001123#if __has_builtin(__builtin_copysignf)
1124_LIBCPP_CONSTEXPR
1125#endif
1126inline _LIBCPP_INLINE_VISIBILITY float __libcpp_copysign(float __lcpp_x, float __lcpp_y) _NOEXCEPT {
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001127#if __has_builtin(__builtin_copysignf)
1128 return __builtin_copysignf(__lcpp_x, __lcpp_y);
1129#else
Mehdi Aminib3da6322017-02-10 02:44:23 +00001130 return ::copysignf(__lcpp_x, __lcpp_y);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001131#endif
Richard Smith081bb592015-10-08 20:40:34 +00001132}
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001133
1134#if __has_builtin(__builtin_copysign)
1135_LIBCPP_CONSTEXPR
1136#endif
1137inline _LIBCPP_INLINE_VISIBILITY double __libcpp_copysign(double __lcpp_x, double __lcpp_y) _NOEXCEPT {
1138#if __has_builtin(__builtin_copysign)
1139 return __builtin_copysign(__lcpp_x, __lcpp_y);
1140#else
1141 return ::copysign(__lcpp_x, __lcpp_y);
1142#endif
1143}
1144
1145#if __has_builtin(__builtin_copysignl)
1146_LIBCPP_CONSTEXPR
1147#endif
1148inline _LIBCPP_INLINE_VISIBILITY long double __libcpp_copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001149#if __has_builtin(__builtin_copysignl)
1150 return __builtin_copysignl(__lcpp_x, __lcpp_y);
1151#else
Mehdi Aminib3da6322017-02-10 02:44:23 +00001152 return ::copysignl(__lcpp_x, __lcpp_y);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001153#endif
Richard Smith081bb592015-10-08 20:40:34 +00001154}
Richard Smith081bb592015-10-08 20:40:34 +00001155
1156template <class _A1, class _A2>
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001157#if __has_builtin(__builtin_copysign)
1158_LIBCPP_CONSTEXPR
1159#endif
1160inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001161typename std::__enable_if_t
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001162<
1163 std::is_arithmetic<_A1>::value &&
1164 std::is_arithmetic<_A2>::value,
1165 std::__promote<_A1, _A2>
1166>::type
1167__libcpp_copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT {
1168 typedef typename std::__promote<_A1, _A2>::type __result_type;
1169 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1170 std::_IsSame<_A2, __result_type>::value)), "");
1171#if __has_builtin(__builtin_copysign)
1172 return __builtin_copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1173#else
1174 return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1175#endif
1176}
1177
1178inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x, float __lcpp_y) _NOEXCEPT {
1179 return ::__libcpp_copysign(__lcpp_x, __lcpp_y);
1180}
1181
1182inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
1183 return ::__libcpp_copysign(__lcpp_x, __lcpp_y);
1184}
1185
1186template <class _A1, class _A2>
Richard Smith081bb592015-10-08 20:40:34 +00001187inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001188typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001189<
1190 std::is_arithmetic<_A1>::value &&
1191 std::is_arithmetic<_A2>::value,
1192 std::__promote<_A1, _A2>
1193>::type
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001194 copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT {
1195 return ::__libcpp_copysign(__lcpp_x, __lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001196}
1197
Richard Smith081bb592015-10-08 20:40:34 +00001198// erf
1199
Mehdi Aminib3da6322017-02-10 02:44:23 +00001200inline _LIBCPP_INLINE_VISIBILITY float erf(float __lcpp_x) _NOEXCEPT {return ::erff(__lcpp_x);}
1201inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return ::erfl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001202
1203template <class _A1>
1204inline _LIBCPP_INLINE_VISIBILITY
1205typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001206erf(_A1 __lcpp_x) _NOEXCEPT {return ::erf((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001207
1208// erfc
1209
Mehdi Aminib3da6322017-02-10 02:44:23 +00001210inline _LIBCPP_INLINE_VISIBILITY float erfc(float __lcpp_x) _NOEXCEPT {return ::erfcf(__lcpp_x);}
1211inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return ::erfcl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001212
1213template <class _A1>
1214inline _LIBCPP_INLINE_VISIBILITY
1215typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001216erfc(_A1 __lcpp_x) _NOEXCEPT {return ::erfc((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001217
1218// exp2
1219
Mehdi Aminib3da6322017-02-10 02:44:23 +00001220inline _LIBCPP_INLINE_VISIBILITY float exp2(float __lcpp_x) _NOEXCEPT {return ::exp2f(__lcpp_x);}
1221inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return ::exp2l(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001222
1223template <class _A1>
1224inline _LIBCPP_INLINE_VISIBILITY
1225typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001226exp2(_A1 __lcpp_x) _NOEXCEPT {return ::exp2((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001227
1228// expm1
1229
Mehdi Aminib3da6322017-02-10 02:44:23 +00001230inline _LIBCPP_INLINE_VISIBILITY float expm1(float __lcpp_x) _NOEXCEPT {return ::expm1f(__lcpp_x);}
1231inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return ::expm1l(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001232
1233template <class _A1>
1234inline _LIBCPP_INLINE_VISIBILITY
1235typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001236expm1(_A1 __lcpp_x) _NOEXCEPT {return ::expm1((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001237
1238// fdim
1239
Mehdi Aminib3da6322017-02-10 02:44:23 +00001240inline _LIBCPP_INLINE_VISIBILITY float fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fdimf(__lcpp_x, __lcpp_y);}
1241inline _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 +00001242
1243template <class _A1, class _A2>
1244inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001245typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001246<
1247 std::is_arithmetic<_A1>::value &&
1248 std::is_arithmetic<_A2>::value,
1249 std::__promote<_A1, _A2>
1250>::type
1251fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1252{
1253 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001254 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1255 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001256 return ::fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001257}
1258
1259// fma
1260
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001261inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT
1262{
1263#if __has_builtin(__builtin_fmaf)
1264 return __builtin_fmaf(__lcpp_x, __lcpp_y, __lcpp_z);
1265#else
1266 return ::fmaf(__lcpp_x, __lcpp_y, __lcpp_z);
1267#endif
1268}
1269inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT
1270{
1271#if __has_builtin(__builtin_fmal)
1272 return __builtin_fmal(__lcpp_x, __lcpp_y, __lcpp_z);
1273#else
1274 return ::fmal(__lcpp_x, __lcpp_y, __lcpp_z);
1275#endif
1276}
Richard Smith081bb592015-10-08 20:40:34 +00001277
1278template <class _A1, class _A2, class _A3>
1279inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001280typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001281<
1282 std::is_arithmetic<_A1>::value &&
1283 std::is_arithmetic<_A2>::value &&
1284 std::is_arithmetic<_A3>::value,
1285 std::__promote<_A1, _A2, _A3>
1286>::type
1287fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
1288{
1289 typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001290 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1291 std::_IsSame<_A2, __result_type>::value &&
1292 std::_IsSame<_A3, __result_type>::value)), "");
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001293#if __has_builtin(__builtin_fma)
1294 return __builtin_fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
1295#else
Mehdi Aminib3da6322017-02-10 02:44:23 +00001296 return ::fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001297#endif
Richard Smith081bb592015-10-08 20:40:34 +00001298}
1299
1300// fmax
1301
Mehdi Aminib3da6322017-02-10 02:44:23 +00001302inline _LIBCPP_INLINE_VISIBILITY float fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmaxf(__lcpp_x, __lcpp_y);}
1303inline _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 +00001304
1305template <class _A1, class _A2>
1306inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001307typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001308<
1309 std::is_arithmetic<_A1>::value &&
1310 std::is_arithmetic<_A2>::value,
1311 std::__promote<_A1, _A2>
1312>::type
1313fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1314{
1315 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001316 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1317 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001318 return ::fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001319}
1320
1321// fmin
1322
Mehdi Aminib3da6322017-02-10 02:44:23 +00001323inline _LIBCPP_INLINE_VISIBILITY float fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fminf(__lcpp_x, __lcpp_y);}
1324inline _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 +00001325
1326template <class _A1, class _A2>
1327inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001328typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001329<
1330 std::is_arithmetic<_A1>::value &&
1331 std::is_arithmetic<_A2>::value,
1332 std::__promote<_A1, _A2>
1333>::type
1334fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1335{
1336 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001337 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1338 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001339 return ::fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001340}
1341
1342// hypot
1343
Mehdi Aminib3da6322017-02-10 02:44:23 +00001344inline _LIBCPP_INLINE_VISIBILITY float hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::hypotf(__lcpp_x, __lcpp_y);}
1345inline _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 +00001346
1347template <class _A1, class _A2>
1348inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001349typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001350<
1351 std::is_arithmetic<_A1>::value &&
1352 std::is_arithmetic<_A2>::value,
1353 std::__promote<_A1, _A2>
1354>::type
1355hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1356{
1357 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001358 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1359 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001360 return ::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001361}
1362
1363// ilogb
1364
Mehdi Aminib3da6322017-02-10 02:44:23 +00001365inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT {return ::ilogbf(__lcpp_x);}
1366inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ::ilogbl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001367
1368template <class _A1>
1369inline _LIBCPP_INLINE_VISIBILITY
1370typename std::enable_if<std::is_integral<_A1>::value, int>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001371ilogb(_A1 __lcpp_x) _NOEXCEPT {return ::ilogb((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001372
1373// lgamma
1374
Mehdi Aminib3da6322017-02-10 02:44:23 +00001375inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __lcpp_x) _NOEXCEPT {return ::lgammaf(__lcpp_x);}
1376inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return ::lgammal(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001377
1378template <class _A1>
1379inline _LIBCPP_INLINE_VISIBILITY
1380typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001381lgamma(_A1 __lcpp_x) _NOEXCEPT {return ::lgamma((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001382
1383// llrint
1384
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001385inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT
1386{
1387#if __has_builtin(__builtin_llrintf)
1388 return __builtin_llrintf(__lcpp_x);
1389#else
1390 return ::llrintf(__lcpp_x);
1391#endif
1392}
1393inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT
1394{
1395#if __has_builtin(__builtin_llrintl)
1396 return __builtin_llrintl(__lcpp_x);
1397#else
1398 return ::llrintl(__lcpp_x);
1399#endif
1400}
Richard Smith081bb592015-10-08 20:40:34 +00001401
1402template <class _A1>
1403inline _LIBCPP_INLINE_VISIBILITY
1404typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001405llrint(_A1 __lcpp_x) _NOEXCEPT
1406{
1407#if __has_builtin(__builtin_llrint)
1408 return __builtin_llrint((double)__lcpp_x);
1409#else
1410 return ::llrint((double)__lcpp_x);
1411#endif
1412}
Richard Smith081bb592015-10-08 20:40:34 +00001413
1414// llround
1415
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001416inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT
1417{
1418#if __has_builtin(__builtin_llroundf)
1419 return __builtin_llroundf(__lcpp_x);
1420#else
1421 return ::llroundf(__lcpp_x);
1422#endif
1423}
1424inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT
1425{
1426#if __has_builtin(__builtin_llroundl)
1427 return __builtin_llroundl(__lcpp_x);
1428#else
1429 return ::llroundl(__lcpp_x);
1430#endif
1431}
Richard Smith081bb592015-10-08 20:40:34 +00001432
1433template <class _A1>
1434inline _LIBCPP_INLINE_VISIBILITY
1435typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001436llround(_A1 __lcpp_x) _NOEXCEPT
1437{
1438#if __has_builtin(__builtin_llround)
1439 return __builtin_llround((double)__lcpp_x);
1440#else
1441 return ::llround((double)__lcpp_x);
1442#endif
1443}
Richard Smith081bb592015-10-08 20:40:34 +00001444
1445// log1p
1446
Mehdi Aminib3da6322017-02-10 02:44:23 +00001447inline _LIBCPP_INLINE_VISIBILITY float log1p(float __lcpp_x) _NOEXCEPT {return ::log1pf(__lcpp_x);}
1448inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return ::log1pl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001449
1450template <class _A1>
1451inline _LIBCPP_INLINE_VISIBILITY
1452typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001453log1p(_A1 __lcpp_x) _NOEXCEPT {return ::log1p((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001454
1455// log2
1456
Mehdi Aminib3da6322017-02-10 02:44:23 +00001457inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return ::log2f(__lcpp_x);}
1458inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return ::log2l(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001459
1460template <class _A1>
1461inline _LIBCPP_INLINE_VISIBILITY
1462typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001463log2(_A1 __lcpp_x) _NOEXCEPT {return ::log2((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001464
1465// logb
1466
Mehdi Aminib3da6322017-02-10 02:44:23 +00001467inline _LIBCPP_INLINE_VISIBILITY float logb(float __lcpp_x) _NOEXCEPT {return ::logbf(__lcpp_x);}
1468inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return ::logbl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001469
1470template <class _A1>
1471inline _LIBCPP_INLINE_VISIBILITY
1472typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001473logb(_A1 __lcpp_x) _NOEXCEPT {return ::logb((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001474
1475// lrint
1476
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001477inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT
1478{
1479#if __has_builtin(__builtin_lrintf)
1480 return __builtin_lrintf(__lcpp_x);
1481#else
1482 return ::lrintf(__lcpp_x);
1483#endif
1484}
1485inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT
1486{
1487#if __has_builtin(__builtin_lrintl)
1488 return __builtin_lrintl(__lcpp_x);
1489#else
1490 return ::lrintl(__lcpp_x);
1491#endif
1492}
Richard Smith081bb592015-10-08 20:40:34 +00001493
1494template <class _A1>
1495inline _LIBCPP_INLINE_VISIBILITY
1496typename std::enable_if<std::is_integral<_A1>::value, long>::type
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001497lrint(_A1 __lcpp_x) _NOEXCEPT
1498{
1499#if __has_builtin(__builtin_lrint)
1500 return __builtin_lrint((double)__lcpp_x);
1501#else
1502 return ::lrint((double)__lcpp_x);
1503#endif
1504}
Richard Smith081bb592015-10-08 20:40:34 +00001505
1506// lround
1507
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001508inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT
1509{
1510#if __has_builtin(__builtin_lroundf)
1511 return __builtin_lroundf(__lcpp_x);
1512#else
1513 return ::lroundf(__lcpp_x);
1514#endif
1515}
1516inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT
1517{
1518#if __has_builtin(__builtin_lroundl)
1519 return __builtin_lroundl(__lcpp_x);
1520#else
1521 return ::lroundl(__lcpp_x);
1522#endif
1523}
Richard Smith081bb592015-10-08 20:40:34 +00001524
1525template <class _A1>
1526inline _LIBCPP_INLINE_VISIBILITY
1527typename std::enable_if<std::is_integral<_A1>::value, long>::type
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001528lround(_A1 __lcpp_x) _NOEXCEPT
1529{
1530#if __has_builtin(__builtin_lround)
1531 return __builtin_lround((double)__lcpp_x);
1532#else
1533 return ::lround((double)__lcpp_x);
1534#endif
1535}
Richard Smith081bb592015-10-08 20:40:34 +00001536
1537// nan
1538
1539// nearbyint
1540
Mehdi Aminib3da6322017-02-10 02:44:23 +00001541inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __lcpp_x) _NOEXCEPT {return ::nearbyintf(__lcpp_x);}
1542inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return ::nearbyintl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001543
1544template <class _A1>
1545inline _LIBCPP_INLINE_VISIBILITY
1546typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001547nearbyint(_A1 __lcpp_x) _NOEXCEPT {return ::nearbyint((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001548
1549// nextafter
1550
Mehdi Aminib3da6322017-02-10 02:44:23 +00001551inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::nextafterf(__lcpp_x, __lcpp_y);}
1552inline _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 +00001553
1554template <class _A1, class _A2>
1555inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001556typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001557<
1558 std::is_arithmetic<_A1>::value &&
1559 std::is_arithmetic<_A2>::value,
1560 std::__promote<_A1, _A2>
1561>::type
1562nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1563{
1564 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001565 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1566 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001567 return ::nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001568}
1569
1570// nexttoward
1571
Mehdi Aminib3da6322017-02-10 02:44:23 +00001572inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardf(__lcpp_x, __lcpp_y);}
1573inline _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 +00001574
1575template <class _A1>
1576inline _LIBCPP_INLINE_VISIBILITY
1577typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001578nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttoward((double)__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001579
1580// remainder
1581
Mehdi Aminib3da6322017-02-10 02:44:23 +00001582inline _LIBCPP_INLINE_VISIBILITY float remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::remainderf(__lcpp_x, __lcpp_y);}
1583inline _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 +00001584
1585template <class _A1, class _A2>
1586inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001587typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001588<
1589 std::is_arithmetic<_A1>::value &&
1590 std::is_arithmetic<_A2>::value,
1591 std::__promote<_A1, _A2>
1592>::type
1593remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1594{
1595 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001596 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1597 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001598 return ::remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001599}
1600
1601// remquo
1602
Mehdi Aminib3da6322017-02-10 02:44:23 +00001603inline _LIBCPP_INLINE_VISIBILITY float remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT {return ::remquof(__lcpp_x, __lcpp_y, __lcpp_z);}
1604inline _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 +00001605
1606template <class _A1, class _A2>
1607inline _LIBCPP_INLINE_VISIBILITY
Louis Dionne9ce598d2021-09-08 09:14:43 -04001608typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001609<
1610 std::is_arithmetic<_A1>::value &&
1611 std::is_arithmetic<_A2>::value,
1612 std::__promote<_A1, _A2>
1613>::type
1614remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT
1615{
1616 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001617 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1618 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001619 return ::remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z);
Richard Smith081bb592015-10-08 20:40:34 +00001620}
1621
1622// rint
1623
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001624inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT
1625{
1626#if __has_builtin(__builtin_rintf)
1627 return __builtin_rintf(__lcpp_x);
1628#else
1629 return ::rintf(__lcpp_x);
1630#endif
1631}
1632inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT
1633{
1634#if __has_builtin(__builtin_rintl)
1635 return __builtin_rintl(__lcpp_x);
1636#else
1637 return ::rintl(__lcpp_x);
1638#endif
1639}
Richard Smith081bb592015-10-08 20:40:34 +00001640
1641template <class _A1>
1642inline _LIBCPP_INLINE_VISIBILITY
1643typename std::enable_if<std::is_integral<_A1>::value, double>::type
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001644rint(_A1 __lcpp_x) _NOEXCEPT
1645{
1646#if __has_builtin(__builtin_rint)
1647 return __builtin_rint((double)__lcpp_x);
1648#else
1649 return ::rint((double)__lcpp_x);
1650#endif
1651}
Richard Smith081bb592015-10-08 20:40:34 +00001652
1653// round
1654
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001655inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT
1656{
1657#if __has_builtin(__builtin_round)
1658 return __builtin_round(__lcpp_x);
1659#else
1660 return ::round(__lcpp_x);
1661#endif
1662}
1663inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT
1664{
1665#if __has_builtin(__builtin_roundl)
1666 return __builtin_roundl(__lcpp_x);
1667#else
1668 return ::roundl(__lcpp_x);
1669#endif
1670}
Richard Smith081bb592015-10-08 20:40:34 +00001671
1672template <class _A1>
1673inline _LIBCPP_INLINE_VISIBILITY
1674typename std::enable_if<std::is_integral<_A1>::value, double>::type
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001675round(_A1 __lcpp_x) _NOEXCEPT
1676{
1677#if __has_builtin(__builtin_round)
1678 return __builtin_round((double)__lcpp_x);
1679#else
1680 return ::round((double)__lcpp_x);
1681#endif
1682}
Richard Smith081bb592015-10-08 20:40:34 +00001683
1684// scalbln
1685
Mehdi Aminib3da6322017-02-10 02:44:23 +00001686inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnf(__lcpp_x, __lcpp_y);}
1687inline _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 +00001688
1689template <class _A1>
1690inline _LIBCPP_INLINE_VISIBILITY
1691typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001692scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalbln((double)__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001693
1694// scalbn
1695
Mehdi Aminib3da6322017-02-10 02:44:23 +00001696inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnf(__lcpp_x, __lcpp_y);}
1697inline _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 +00001698
1699template <class _A1>
1700inline _LIBCPP_INLINE_VISIBILITY
1701typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001702scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbn((double)__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001703
1704// tgamma
1705
Mehdi Aminib3da6322017-02-10 02:44:23 +00001706inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __lcpp_x) _NOEXCEPT {return ::tgammaf(__lcpp_x);}
1707inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return ::tgammal(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001708
1709template <class _A1>
1710inline _LIBCPP_INLINE_VISIBILITY
1711typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001712tgamma(_A1 __lcpp_x) _NOEXCEPT {return ::tgamma((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001713
1714// trunc
1715
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001716inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT
1717{
1718#if __has_builtin(__builtin_trunc)
1719 return __builtin_trunc(__lcpp_x);
1720#else
1721 return ::trunc(__lcpp_x);
1722#endif
1723}
1724inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT
1725{
1726#if __has_builtin(__builtin_truncl)
1727 return __builtin_truncl(__lcpp_x);
1728#else
1729 return ::truncl(__lcpp_x);
1730#endif
1731}
Richard Smith081bb592015-10-08 20:40:34 +00001732
1733template <class _A1>
1734inline _LIBCPP_INLINE_VISIBILITY
1735typename std::enable_if<std::is_integral<_A1>::value, double>::type
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001736trunc(_A1 __lcpp_x) _NOEXCEPT
1737{
1738#if __has_builtin(__builtin_trunc)
1739 return __builtin_trunc((double)__lcpp_x);
1740#else
1741 return ::trunc((double)__lcpp_x);
1742#endif
1743}
Richard Smith081bb592015-10-08 20:40:34 +00001744
Richard Smith081bb592015-10-08 20:40:34 +00001745} // extern "C++"
1746
1747#endif // __cplusplus
1748
Mikhail Maltsev34b4f972018-02-22 09:34:08 +00001749#else // _LIBCPP_MATH_H
1750
1751// This include lives outside the header guard in order to support an MSVC
1752// extension which allows users to do:
1753//
1754// #define _USE_MATH_DEFINES
1755// #include <math.h>
1756//
1757// and receive the definitions of mathematical constants, even if <math.h>
1758// has previously been included.
1759#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
1760#include_next <math.h>
1761#endif
1762
Louis Dionne2b1ceaa2021-04-20 12:03:32 -04001763#endif // _LIBCPP_MATH_H