blob: c4cf661aff01b24fa7e5de0cc914476ced6fa874 [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
Louis Dionnebe1aa9e2022-11-15 17:08:01 -0500300# if __has_include_next(<math.h>)
301# include_next <math.h>
302# endif
Mikhail Maltsev34b4f972018-02-22 09:34:08 +0000303
Richard Smith081bb592015-10-08 20:40:34 +0000304#ifdef __cplusplus
305
306// We support including .h headers inside 'extern "C"' contexts, so switch
307// back to C++ linkage before including these C++ headers.
308extern "C++" {
309
Nikolas Klauser6c8f7122022-07-24 16:03:12 +0200310#include <__type_traits/promote.h>
Arthur O'Dwyer65077c02022-01-07 09:45:05 -0500311#include <limits>
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500312#include <stdlib.h>
Richard Smith081bb592015-10-08 20:40:34 +0000313#include <type_traits>
314
Richard Smith081bb592015-10-08 20:40:34 +0000315// signbit
316
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100317# ifdef signbit
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100318# undef signbit
Nikolas Klauser88b1e942022-11-04 17:01:22 +0100319# endif // signbit
Richard Smith081bb592015-10-08 20:40:34 +0000320
321template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100322inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
323signbit(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100324 return __builtin_signbit(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000325}
326
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000327template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200328inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100329 typename std::enable_if< std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
330 signbit(_A1 __x) _NOEXCEPT {
331 return __x < 0;
332}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000333
334template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200335inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100336 typename std::enable_if< std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
337 signbit(_A1) _NOEXCEPT {
338 return false;
339}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000340
Richard Smith081bb592015-10-08 20:40:34 +0000341// fpclassify
342
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100343# ifdef fpclassify
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100344# undef fpclassify
Nikolas Klauser88b1e942022-11-04 17:01:22 +0100345# endif // fpclassify
Richard Smith081bb592015-10-08 20:40:34 +0000346
347template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100348inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, int>::type
349fpclassify(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100350 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
Richard Smith081bb592015-10-08 20:40:34 +0000351}
352
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000353template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100354inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, int>::type
355fpclassify(_A1 __x) _NOEXCEPT {
356 return __x == 0 ? FP_ZERO : FP_NORMAL;
357}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000358
Richard Smith081bb592015-10-08 20:40:34 +0000359// isfinite
360
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100361# ifdef isfinite
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100362# undef isfinite
Richard Smith081bb592015-10-08 20:40:34 +0000363
364template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200365inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100366 typename std::enable_if< std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, bool>::type
367 isfinite(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100368 return __builtin_isfinite((typename std::__promote<_A1>::type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000369}
370
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000371template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200372inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100373 typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type
374 isfinite(_A1) _NOEXCEPT {
375 return true;
376}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000377
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100378# endif // isfinite
Richard Smith081bb592015-10-08 20:40:34 +0000379
380// isinf
381
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100382# ifdef isinf
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100383# undef isinf
Richard Smith081bb592015-10-08 20:40:34 +0000384
385template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200386inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100387 typename std::enable_if< std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, bool>::type
388 isinf(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100389 return __builtin_isinf((typename std::__promote<_A1>::type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000390}
391
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000392template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200393inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100394 typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type
395 isinf(_A1) _NOEXCEPT {
396 return false;
397}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000398
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100399# ifdef _LIBCPP_PREFERRED_OVERLOAD
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100400inline _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { return __builtin_isinf(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000401
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100402inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT { return __builtin_isinf(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000403
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100404inline _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { return __builtin_isinf(__x); }
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100405# endif
Richard Smithafccfd32018-05-01 03:05:40 +0000406
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100407# endif // isinf
Richard Smith081bb592015-10-08 20:40:34 +0000408
409// isnan
410
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100411# ifdef isnan
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100412# undef isnan
Richard Smith081bb592015-10-08 20:40:34 +0000413
414template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100415inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
416isnan(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100417 return __builtin_isnan(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000418}
419
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000420template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100421inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, bool>::type isnan(_A1) _NOEXCEPT {
422 return false;
423}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000424
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100425# ifdef _LIBCPP_PREFERRED_OVERLOAD
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100426inline _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { return __builtin_isnan(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000427
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100428inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT { return __builtin_isnan(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000429
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100430inline _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { return __builtin_isnan(__x); }
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100431# endif
Richard Smithafccfd32018-05-01 03:05:40 +0000432
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100433# endif // isnan
Richard Smith081bb592015-10-08 20:40:34 +0000434
435// isnormal
436
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100437# ifdef isnormal
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100438# undef isnormal
Richard Smith081bb592015-10-08 20:40:34 +0000439
440template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100441inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
442isnormal(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100443 return __builtin_isnormal(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000444}
445
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000446template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100447inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, bool>::type
448isnormal(_A1 __x) _NOEXCEPT {
449 return __x != 0;
450}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000451
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100452# endif // isnormal
Richard Smith081bb592015-10-08 20:40:34 +0000453
454// isgreater
455
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100456# ifdef isgreater
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100457# undef isgreater
Richard Smith081bb592015-10-08 20:40:34 +0000458
459template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200460inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100461 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
462 isgreater(_A1 __x, _A2 __y) _NOEXCEPT {
463 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100464 return __builtin_isgreater((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000465}
466
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100467# endif // isgreater
Richard Smith081bb592015-10-08 20:40:34 +0000468
469// isgreaterequal
470
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100471# ifdef isgreaterequal
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100472# undef isgreaterequal
Richard Smith081bb592015-10-08 20:40:34 +0000473
474template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200475inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100476 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
477 isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {
478 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100479 return __builtin_isgreaterequal((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000480}
481
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100482# endif // isgreaterequal
Richard Smith081bb592015-10-08 20:40:34 +0000483
484// isless
485
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100486# ifdef isless
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100487# undef isless
Richard Smith081bb592015-10-08 20:40:34 +0000488
489template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200490inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100491 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
492 isless(_A1 __x, _A2 __y) _NOEXCEPT {
493 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100494 return __builtin_isless((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000495}
496
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100497# endif // isless
Richard Smith081bb592015-10-08 20:40:34 +0000498
499// islessequal
500
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100501# ifdef islessequal
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100502# undef islessequal
Richard Smith081bb592015-10-08 20:40:34 +0000503
504template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200505inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100506 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
507 islessequal(_A1 __x, _A2 __y) _NOEXCEPT {
508 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100509 return __builtin_islessequal((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000510}
511
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100512# endif // islessequal
Richard Smith081bb592015-10-08 20:40:34 +0000513
514// islessgreater
515
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100516# ifdef islessgreater
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100517# undef islessgreater
Richard Smith081bb592015-10-08 20:40:34 +0000518
519template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200520inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100521 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
522 islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {
523 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100524 return __builtin_islessgreater((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000525}
526
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100527# endif // islessgreater
Richard Smith081bb592015-10-08 20:40:34 +0000528
529// isunordered
530
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100531# ifdef isunordered
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100532# undef isunordered
Richard Smith081bb592015-10-08 20:40:34 +0000533
534template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200535inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100536 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
537 isunordered(_A1 __x, _A2 __y) _NOEXCEPT {
538 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100539 return __builtin_isunordered((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000540}
541
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100542# endif // isunordered
Richard Smith081bb592015-10-08 20:40:34 +0000543
Richard Smith081bb592015-10-08 20:40:34 +0000544// abs
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500545//
546// handled in stdlib.h
Richard Smith081bb592015-10-08 20:40:34 +0000547
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000548// div
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500549//
550// handled in stdlib.h
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000551
Richard Smith081bb592015-10-08 20:40:34 +0000552// acos
553
David Tenty7249ac92022-02-07 18:22:35 -0500554# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200555inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return ::acosf(__x);}
556inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT {return ::acosl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500557# endif
Richard Smith081bb592015-10-08 20:40:34 +0000558
559template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200560inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000561typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200562acos(_A1 __x) _NOEXCEPT {return ::acos((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000563
564// asin
565
David Tenty7249ac92022-02-07 18:22:35 -0500566# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200567inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return ::asinf(__x);}
568inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT {return ::asinl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500569# endif
Richard Smith081bb592015-10-08 20:40:34 +0000570
571template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200572inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000573typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200574asin(_A1 __x) _NOEXCEPT {return ::asin((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000575
576// atan
577
David Tenty7249ac92022-02-07 18:22:35 -0500578# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200579inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return ::atanf(__x);}
580inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT {return ::atanl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500581# endif
Richard Smith081bb592015-10-08 20:40:34 +0000582
583template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200584inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000585typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200586atan(_A1 __x) _NOEXCEPT {return ::atan((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000587
588// atan2
589
David Tenty7249ac92022-02-07 18:22:35 -0500590# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200591inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return ::atan2f(__y, __x);}
592inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) _NOEXCEPT {return ::atan2l(__y, __x);}
David Tenty7249ac92022-02-07 18:22:35 -0500593# endif
Richard Smith081bb592015-10-08 20:40:34 +0000594
595template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200596inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400597typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000598<
599 std::is_arithmetic<_A1>::value &&
600 std::is_arithmetic<_A2>::value,
601 std::__promote<_A1, _A2>
602>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200603atan2(_A1 __y, _A2 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000604{
605 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000606 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
607 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200608 return ::atan2((__result_type)__y, (__result_type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000609}
610
611// ceil
612
David Tenty7249ac92022-02-07 18:22:35 -0500613# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200614inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return ::ceilf(__x);}
615inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return ::ceill(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500616# endif
Richard Smith081bb592015-10-08 20:40:34 +0000617
618template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200619inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000620typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200621ceil(_A1 __x) _NOEXCEPT {return ::ceil((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000622
623// cos
624
David Tenty7249ac92022-02-07 18:22:35 -0500625# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200626inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return ::cosf(__x);}
627inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT {return ::cosl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500628# endif
Richard Smith081bb592015-10-08 20:40:34 +0000629
630template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200631inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000632typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200633cos(_A1 __x) _NOEXCEPT {return ::cos((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000634
635// cosh
636
David Tenty7249ac92022-02-07 18:22:35 -0500637# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200638inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return ::coshf(__x);}
639inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT {return ::coshl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500640# endif
Richard Smith081bb592015-10-08 20:40:34 +0000641
642template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200643inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000644typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200645cosh(_A1 __x) _NOEXCEPT {return ::cosh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000646
647// exp
648
David Tenty7249ac92022-02-07 18:22:35 -0500649# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200650inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return ::expf(__x);}
651inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT {return ::expl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500652# endif
Richard Smith081bb592015-10-08 20:40:34 +0000653
654template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200655inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000656typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200657exp(_A1 __x) _NOEXCEPT {return ::exp((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000658
659// fabs
660
David Tenty7249ac92022-02-07 18:22:35 -0500661# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200662inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return ::fabsf(__x);}
663inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return ::fabsl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500664# endif
Richard Smith081bb592015-10-08 20:40:34 +0000665
666template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200667inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000668typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200669fabs(_A1 __x) _NOEXCEPT {return ::fabs((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000670
671// floor
672
David Tenty7249ac92022-02-07 18:22:35 -0500673# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200674inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return ::floorf(__x);}
675inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return ::floorl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500676# endif
Richard Smith081bb592015-10-08 20:40:34 +0000677
678template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200679inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000680typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200681floor(_A1 __x) _NOEXCEPT {return ::floor((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000682
683// fmod
684
David Tenty7249ac92022-02-07 18:22:35 -0500685# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200686inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return ::fmodf(__x, __y);}
687inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) _NOEXCEPT {return ::fmodl(__x, __y);}
David Tenty7249ac92022-02-07 18:22:35 -0500688# endif
Richard Smith081bb592015-10-08 20:40:34 +0000689
690template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200691inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400692typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000693<
694 std::is_arithmetic<_A1>::value &&
695 std::is_arithmetic<_A2>::value,
696 std::__promote<_A1, _A2>
697>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200698fmod(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000699{
700 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000701 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
702 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200703 return ::fmod((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000704}
705
706// frexp
707
David Tenty7249ac92022-02-07 18:22:35 -0500708# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200709inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return ::frexpf(__x, __e);}
710inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {return ::frexpl(__x, __e);}
David Tenty7249ac92022-02-07 18:22:35 -0500711# endif
Richard Smith081bb592015-10-08 20:40:34 +0000712
713template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200714inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000715typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200716frexp(_A1 __x, int* __e) _NOEXCEPT {return ::frexp((double)__x, __e);}
Richard Smith081bb592015-10-08 20:40:34 +0000717
718// ldexp
719
David Tenty7249ac92022-02-07 18:22:35 -0500720# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200721inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return ::ldexpf(__x, __e);}
722inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {return ::ldexpl(__x, __e);}
David Tenty7249ac92022-02-07 18:22:35 -0500723# endif
Richard Smith081bb592015-10-08 20:40:34 +0000724
725template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200726inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000727typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200728ldexp(_A1 __x, int __e) _NOEXCEPT {return ::ldexp((double)__x, __e);}
Richard Smith081bb592015-10-08 20:40:34 +0000729
730// log
731
David Tenty7249ac92022-02-07 18:22:35 -0500732# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200733inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return ::logf(__x);}
734inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT {return ::logl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500735# endif
Richard Smith081bb592015-10-08 20:40:34 +0000736
737template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200738inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000739typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200740log(_A1 __x) _NOEXCEPT {return ::log((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000741
742// log10
743
David Tenty7249ac92022-02-07 18:22:35 -0500744# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200745inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return ::log10f(__x);}
746inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT {return ::log10l(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500747# endif
Richard Smith081bb592015-10-08 20:40:34 +0000748
749template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200750inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000751typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200752log10(_A1 __x) _NOEXCEPT {return ::log10((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000753
754// modf
755
David Tenty7249ac92022-02-07 18:22:35 -0500756# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200757inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return ::modff(__x, __y);}
758inline _LIBCPP_HIDE_FROM_ABI long double modf(long double __x, long double* __y) _NOEXCEPT {return ::modfl(__x, __y);}
David Tenty7249ac92022-02-07 18:22:35 -0500759# endif
Richard Smith081bb592015-10-08 20:40:34 +0000760
761// pow
762
David Tenty7249ac92022-02-07 18:22:35 -0500763# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200764inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return ::powf(__x, __y);}
765inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _NOEXCEPT {return ::powl(__x, __y);}
David Tenty7249ac92022-02-07 18:22:35 -0500766# endif
Richard Smith081bb592015-10-08 20:40:34 +0000767
768template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200769inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400770typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000771<
772 std::is_arithmetic<_A1>::value &&
773 std::is_arithmetic<_A2>::value,
774 std::__promote<_A1, _A2>
775>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200776pow(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000777{
778 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000779 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
780 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200781 return ::pow((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000782}
783
784// sin
785
David Tenty7249ac92022-02-07 18:22:35 -0500786# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200787inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return ::sinf(__x);}
788inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT {return ::sinl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000789#endif
790
791template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200792inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000793typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200794sin(_A1 __x) _NOEXCEPT {return ::sin((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000795
796// sinh
797
David Tenty7249ac92022-02-07 18:22:35 -0500798# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200799inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return ::sinhf(__x);}
800inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT {return ::sinhl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500801# endif
Richard Smith081bb592015-10-08 20:40:34 +0000802
803template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200804inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000805typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200806sinh(_A1 __x) _NOEXCEPT {return ::sinh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000807
808// sqrt
809
David Tenty7249ac92022-02-07 18:22:35 -0500810# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200811inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return ::sqrtf(__x);}
812inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT {return ::sqrtl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500813# endif
Richard Smith081bb592015-10-08 20:40:34 +0000814
Richard Smith081bb592015-10-08 20:40:34 +0000815template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200816inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000817typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200818sqrt(_A1 __x) _NOEXCEPT {return ::sqrt((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000819
820// tan
821
David Tenty7249ac92022-02-07 18:22:35 -0500822# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200823inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return ::tanf(__x);}
824inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT {return ::tanl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500825# endif
Richard Smith081bb592015-10-08 20:40:34 +0000826
827template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200828inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000829typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200830tan(_A1 __x) _NOEXCEPT {return ::tan((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000831
832// tanh
833
David Tenty7249ac92022-02-07 18:22:35 -0500834# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200835inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return ::tanhf(__x);}
836inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT {return ::tanhl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500837# endif
Richard Smith081bb592015-10-08 20:40:34 +0000838
839template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200840inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000841typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200842tanh(_A1 __x) _NOEXCEPT {return ::tanh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000843
844// acosh
845
Nikolas Klauser9806f452022-10-12 15:45:09 +0200846inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return ::acoshf(__x);}
847inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT {return ::acoshl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000848
849template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200850inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000851typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200852acosh(_A1 __x) _NOEXCEPT {return ::acosh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000853
854// asinh
855
Nikolas Klauser9806f452022-10-12 15:45:09 +0200856inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return ::asinhf(__x);}
857inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT {return ::asinhl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000858
859template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200860inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000861typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200862asinh(_A1 __x) _NOEXCEPT {return ::asinh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000863
864// atanh
865
Nikolas Klauser9806f452022-10-12 15:45:09 +0200866inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return ::atanhf(__x);}
867inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT {return ::atanhl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000868
869template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200870inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000871typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200872atanh(_A1 __x) _NOEXCEPT {return ::atanh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000873
874// cbrt
875
Nikolas Klauser9806f452022-10-12 15:45:09 +0200876inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return ::cbrtf(__x);}
877inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {return ::cbrtl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000878
879template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200880inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000881typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200882cbrt(_A1 __x) _NOEXCEPT {return ::cbrt((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000883
884// copysign
885
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200886_LIBCPP_CONSTEXPR
Nikolas Klauser9806f452022-10-12 15:45:09 +0200887inline _LIBCPP_HIDE_FROM_ABI float __libcpp_copysign(float __x, float __y) _NOEXCEPT {
Nikolas Klauser9806f452022-10-12 15:45:09 +0200888 return __builtin_copysignf(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000889}
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200890
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200891_LIBCPP_CONSTEXPR
Nikolas Klauser9806f452022-10-12 15:45:09 +0200892inline _LIBCPP_HIDE_FROM_ABI double __libcpp_copysign(double __x, double __y) _NOEXCEPT {
Nikolas Klauser9806f452022-10-12 15:45:09 +0200893 return __builtin_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200894}
895
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200896_LIBCPP_CONSTEXPR
Nikolas Klauser9806f452022-10-12 15:45:09 +0200897inline _LIBCPP_HIDE_FROM_ABI long double __libcpp_copysign(long double __x, long double __y) _NOEXCEPT {
Nikolas Klauser9806f452022-10-12 15:45:09 +0200898 return __builtin_copysignl(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000899}
Richard Smith081bb592015-10-08 20:40:34 +0000900
901template <class _A1, class _A2>
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200902_LIBCPP_CONSTEXPR
Nikolas Klauser4956e722022-10-12 15:41:22 +0200903inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400904typename std::__enable_if_t
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200905<
906 std::is_arithmetic<_A1>::value &&
907 std::is_arithmetic<_A2>::value,
908 std::__promote<_A1, _A2>
909>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200910__libcpp_copysign(_A1 __x, _A2 __y) _NOEXCEPT {
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200911 typedef typename std::__promote<_A1, _A2>::type __result_type;
912 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
913 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200914 return __builtin_copysign((__result_type)__x, (__result_type)__y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200915}
916
Nikolas Klauser9806f452022-10-12 15:45:09 +0200917inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT {
918 return ::__libcpp_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200919}
920
Nikolas Klauser9806f452022-10-12 15:45:09 +0200921inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT {
922 return ::__libcpp_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200923}
924
925template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200926inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400927typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000928<
929 std::is_arithmetic<_A1>::value &&
930 std::is_arithmetic<_A2>::value,
931 std::__promote<_A1, _A2>
932>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200933 copysign(_A1 __x, _A2 __y) _NOEXCEPT {
934 return ::__libcpp_copysign(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000935}
936
Richard Smith081bb592015-10-08 20:40:34 +0000937// erf
938
Nikolas Klauser9806f452022-10-12 15:45:09 +0200939inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return ::erff(__x);}
940inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT {return ::erfl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000941
942template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200943inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000944typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200945erf(_A1 __x) _NOEXCEPT {return ::erf((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000946
947// erfc
948
Nikolas Klauser9806f452022-10-12 15:45:09 +0200949inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return ::erfcf(__x);}
950inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT {return ::erfcl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000951
952template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200953inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000954typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200955erfc(_A1 __x) _NOEXCEPT {return ::erfc((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000956
957// exp2
958
Nikolas Klauser9806f452022-10-12 15:45:09 +0200959inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return ::exp2f(__x);}
960inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT {return ::exp2l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000961
962template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200963inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000964typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200965exp2(_A1 __x) _NOEXCEPT {return ::exp2((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000966
967// expm1
968
Nikolas Klauser9806f452022-10-12 15:45:09 +0200969inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return ::expm1f(__x);}
970inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT {return ::expm1l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000971
972template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200973inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000974typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200975expm1(_A1 __x) _NOEXCEPT {return ::expm1((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000976
977// fdim
978
Nikolas Klauser9806f452022-10-12 15:45:09 +0200979inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return ::fdimf(__x, __y);}
980inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) _NOEXCEPT {return ::fdiml(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +0000981
982template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200983inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400984typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000985<
986 std::is_arithmetic<_A1>::value &&
987 std::is_arithmetic<_A2>::value,
988 std::__promote<_A1, _A2>
989>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200990fdim(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000991{
992 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000993 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
994 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200995 return ::fdim((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000996}
997
998// fma
999
Nikolas Klauser9806f452022-10-12 15:45:09 +02001000inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001001{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001002 return __builtin_fmaf(__x, __y, __z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001003}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001004inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001005{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001006 return __builtin_fmal(__x, __y, __z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001007}
Richard Smith081bb592015-10-08 20:40:34 +00001008
1009template <class _A1, class _A2, class _A3>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001010inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001011typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001012<
1013 std::is_arithmetic<_A1>::value &&
1014 std::is_arithmetic<_A2>::value &&
1015 std::is_arithmetic<_A3>::value,
1016 std::__promote<_A1, _A2, _A3>
1017>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001018fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001019{
1020 typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001021 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1022 std::_IsSame<_A2, __result_type>::value &&
1023 std::_IsSame<_A3, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001024 return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
Richard Smith081bb592015-10-08 20:40:34 +00001025}
1026
1027// fmax
1028
Nikolas Klauser9806f452022-10-12 15:45:09 +02001029inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return ::fmaxf(__x, __y);}
1030inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT {return ::fmaxl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001031
1032template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001033inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001034typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001035<
1036 std::is_arithmetic<_A1>::value &&
1037 std::is_arithmetic<_A2>::value,
1038 std::__promote<_A1, _A2>
1039>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001040fmax(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001041{
1042 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001043 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1044 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001045 return ::fmax((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001046}
1047
1048// fmin
1049
Nikolas Klauser9806f452022-10-12 15:45:09 +02001050inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return ::fminf(__x, __y);}
1051inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT {return ::fminl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001052
1053template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001054inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001055typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001056<
1057 std::is_arithmetic<_A1>::value &&
1058 std::is_arithmetic<_A2>::value,
1059 std::__promote<_A1, _A2>
1060>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001061fmin(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001062{
1063 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001064 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1065 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001066 return ::fmin((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001067}
1068
1069// hypot
1070
Nikolas Klauser9806f452022-10-12 15:45:09 +02001071inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return ::hypotf(__x, __y);}
1072inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) _NOEXCEPT {return ::hypotl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001073
1074template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001075inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001076typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001077<
1078 std::is_arithmetic<_A1>::value &&
1079 std::is_arithmetic<_A2>::value,
1080 std::__promote<_A1, _A2>
1081>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001082hypot(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001083{
1084 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001085 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1086 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001087 return ::hypot((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001088}
1089
1090// ilogb
1091
Nikolas Klauser9806f452022-10-12 15:45:09 +02001092inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return ::ilogbf(__x);}
1093inline _LIBCPP_HIDE_FROM_ABI int ilogb(long double __x) _NOEXCEPT {return ::ilogbl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001094
1095template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001096inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001097typename std::enable_if<std::is_integral<_A1>::value, int>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001098ilogb(_A1 __x) _NOEXCEPT {return ::ilogb((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001099
1100// lgamma
1101
Nikolas Klauser9806f452022-10-12 15:45:09 +02001102inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return ::lgammaf(__x);}
1103inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT {return ::lgammal(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001104
1105template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001106inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001107typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001108lgamma(_A1 __x) _NOEXCEPT {return ::lgamma((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001109
1110// llrint
1111
Nikolas Klauser9806f452022-10-12 15:45:09 +02001112inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001113{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001114 return __builtin_llrintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001115}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001116inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001117{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001118 return __builtin_llrintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001119}
Richard Smith081bb592015-10-08 20:40:34 +00001120
1121template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001122inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001123typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001124llrint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001125{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001126 return __builtin_llrint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001127}
Richard Smith081bb592015-10-08 20:40:34 +00001128
1129// llround
1130
Nikolas Klauser9806f452022-10-12 15:45:09 +02001131inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001132{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001133 return __builtin_llroundf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001134}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001135inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001136{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001137 return __builtin_llroundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001138}
Richard Smith081bb592015-10-08 20:40:34 +00001139
1140template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001141inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001142typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001143llround(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001144{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001145 return __builtin_llround((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001146}
Richard Smith081bb592015-10-08 20:40:34 +00001147
1148// log1p
1149
Nikolas Klauser9806f452022-10-12 15:45:09 +02001150inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return ::log1pf(__x);}
1151inline _LIBCPP_HIDE_FROM_ABI long double log1p(long double __x) _NOEXCEPT {return ::log1pl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001152
1153template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001154inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001155typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001156log1p(_A1 __x) _NOEXCEPT {return ::log1p((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001157
1158// log2
1159
Nikolas Klauser9806f452022-10-12 15:45:09 +02001160inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return ::log2f(__x);}
1161inline _LIBCPP_HIDE_FROM_ABI long double log2(long double __x) _NOEXCEPT {return ::log2l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001162
1163template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001164inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001165typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001166log2(_A1 __x) _NOEXCEPT {return ::log2((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001167
1168// logb
1169
Nikolas Klauser9806f452022-10-12 15:45:09 +02001170inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return ::logbf(__x);}
1171inline _LIBCPP_HIDE_FROM_ABI long double logb(long double __x) _NOEXCEPT {return ::logbl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001172
1173template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001174inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001175typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001176logb(_A1 __x) _NOEXCEPT {return ::logb((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001177
1178// lrint
1179
Nikolas Klauser9806f452022-10-12 15:45:09 +02001180inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001181{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001182 return __builtin_lrintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001183}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001184inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001185{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001186 return __builtin_lrintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001187}
Richard Smith081bb592015-10-08 20:40:34 +00001188
1189template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001190inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001191typename std::enable_if<std::is_integral<_A1>::value, long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001192lrint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001193{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001194 return __builtin_lrint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001195}
Richard Smith081bb592015-10-08 20:40:34 +00001196
1197// lround
1198
Nikolas Klauser9806f452022-10-12 15:45:09 +02001199inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001200{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001201 return __builtin_lroundf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001202}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001203inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001204{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001205 return __builtin_lroundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001206}
Richard Smith081bb592015-10-08 20:40:34 +00001207
1208template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001209inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001210typename std::enable_if<std::is_integral<_A1>::value, long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001211lround(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001212{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001213 return __builtin_lround((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001214}
Richard Smith081bb592015-10-08 20:40:34 +00001215
1216// nan
1217
1218// nearbyint
1219
Nikolas Klauser9806f452022-10-12 15:45:09 +02001220inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return ::nearbyintf(__x);}
1221inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {return ::nearbyintl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001222
1223template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001224inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001225typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001226nearbyint(_A1 __x) _NOEXCEPT {return ::nearbyint((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001227
1228// nextafter
1229
Nikolas Klauser9806f452022-10-12 15:45:09 +02001230inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return ::nextafterf(__x, __y);}
1231inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double __y) _NOEXCEPT {return ::nextafterl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001232
1233template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001234inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001235typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001236<
1237 std::is_arithmetic<_A1>::value &&
1238 std::is_arithmetic<_A2>::value,
1239 std::__promote<_A1, _A2>
1240>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001241nextafter(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001242{
1243 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001244 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1245 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001246 return ::nextafter((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001247}
1248
1249// nexttoward
1250
Nikolas Klauser9806f452022-10-12 15:45:09 +02001251inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return ::nexttowardf(__x, __y);}
1252inline _LIBCPP_HIDE_FROM_ABI long double nexttoward(long double __x, long double __y) _NOEXCEPT {return ::nexttowardl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001253
1254template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001255inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001256typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001257nexttoward(_A1 __x, long double __y) _NOEXCEPT {return ::nexttoward((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001258
1259// remainder
1260
Nikolas Klauser9806f452022-10-12 15:45:09 +02001261inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return ::remainderf(__x, __y);}
1262inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double __y) _NOEXCEPT {return ::remainderl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001263
1264template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001265inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001266typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001267<
1268 std::is_arithmetic<_A1>::value &&
1269 std::is_arithmetic<_A2>::value,
1270 std::__promote<_A1, _A2>
1271>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001272remainder(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001273{
1274 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001275 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1276 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001277 return ::remainder((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001278}
1279
1280// remquo
1281
Nikolas Klauser9806f452022-10-12 15:45:09 +02001282inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return ::remquof(__x, __y, __z);}
1283inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y, int* __z) _NOEXCEPT {return ::remquol(__x, __y, __z);}
Richard Smith081bb592015-10-08 20:40:34 +00001284
1285template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001286inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001287typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001288<
1289 std::is_arithmetic<_A1>::value &&
1290 std::is_arithmetic<_A2>::value,
1291 std::__promote<_A1, _A2>
1292>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001293remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001294{
1295 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001296 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1297 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001298 return ::remquo((__result_type)__x, (__result_type)__y, __z);
Richard Smith081bb592015-10-08 20:40:34 +00001299}
1300
1301// rint
1302
Nikolas Klauser9806f452022-10-12 15:45:09 +02001303inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001304{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001305 return __builtin_rintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001306}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001307inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001308{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001309 return __builtin_rintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001310}
Richard Smith081bb592015-10-08 20:40:34 +00001311
1312template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001313inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001314typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001315rint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001316{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001317 return __builtin_rint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001318}
Richard Smith081bb592015-10-08 20:40:34 +00001319
1320// round
1321
Nikolas Klauser9806f452022-10-12 15:45:09 +02001322inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001323{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001324 return __builtin_round(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001325}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001326inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001327{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001328 return __builtin_roundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001329}
Richard Smith081bb592015-10-08 20:40:34 +00001330
1331template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001332inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001333typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001334round(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001335{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001336 return __builtin_round((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001337}
Richard Smith081bb592015-10-08 20:40:34 +00001338
1339// scalbln
1340
Nikolas Klauser9806f452022-10-12 15:45:09 +02001341inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return ::scalblnf(__x, __y);}
1342inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT {return ::scalblnl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001343
1344template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001345inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001346typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001347scalbln(_A1 __x, long __y) _NOEXCEPT {return ::scalbln((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001348
1349// scalbn
1350
Nikolas Klauser9806f452022-10-12 15:45:09 +02001351inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return ::scalbnf(__x, __y);}
1352inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT {return ::scalbnl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001353
1354template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001355inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001356typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001357scalbn(_A1 __x, int __y) _NOEXCEPT {return ::scalbn((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001358
1359// tgamma
1360
Nikolas Klauser9806f452022-10-12 15:45:09 +02001361inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return ::tgammaf(__x);}
1362inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT {return ::tgammal(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001363
1364template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001365inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001366typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001367tgamma(_A1 __x) _NOEXCEPT {return ::tgamma((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001368
1369// trunc
1370
Nikolas Klauser9806f452022-10-12 15:45:09 +02001371inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001372{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001373 return __builtin_trunc(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001374}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001375inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001376{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001377 return __builtin_truncl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001378}
Richard Smith081bb592015-10-08 20:40:34 +00001379
1380template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001381inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001382typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001383trunc(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001384{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001385 return __builtin_trunc((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001386}
Richard Smith081bb592015-10-08 20:40:34 +00001387
Richard Smith081bb592015-10-08 20:40:34 +00001388} // extern "C++"
1389
1390#endif // __cplusplus
1391
Mikhail Maltsev34b4f972018-02-22 09:34:08 +00001392#else // _LIBCPP_MATH_H
1393
1394// This include lives outside the header guard in order to support an MSVC
1395// extension which allows users to do:
1396//
1397// #define _USE_MATH_DEFINES
1398// #include <math.h>
1399//
1400// and receive the definitions of mathematical constants, even if <math.h>
1401// has previously been included.
1402#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
1403#include_next <math.h>
1404#endif
1405
Louis Dionne2b1ceaa2021-04-20 12:03:32 -04001406#endif // _LIBCPP_MATH_H