blob: 94b0a619e0ab58e6420f98828e93c18184f75531 [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
Richard Smith081bb592015-10-08 20:40:34 +0000319
320template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100321inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
322signbit(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100323 return __builtin_signbit(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000324}
325
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000326template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200327inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100328 typename std::enable_if< std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
329 signbit(_A1 __x) _NOEXCEPT {
330 return __x < 0;
331}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000332
333template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200334inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100335 typename std::enable_if< std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
336 signbit(_A1) _NOEXCEPT {
337 return false;
338}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000339
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100340# elif defined(_LIBCPP_MSVCRT)
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000341
342template <typename _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100343inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
344signbit(_A1 __x) _NOEXCEPT {
Nikolas Klauser37a5b4f2022-10-27 20:01:13 +0200345 return ::signbit(__x);
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000346}
347
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000348template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200349inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100350 typename std::enable_if< std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
351 signbit(_A1 __x) _NOEXCEPT {
352 return __x < 0;
353}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000354
355template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200356inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100357 typename std::enable_if< std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
358 signbit(_A1) _NOEXCEPT {
359 return false;
360}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000361
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100362# endif // signbit
Richard Smith081bb592015-10-08 20:40:34 +0000363
364// fpclassify
365
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100366# ifdef fpclassify
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100367# undef fpclassify
Richard Smith081bb592015-10-08 20:40:34 +0000368
369template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100370inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, int>::type
371fpclassify(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100372 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
Richard Smith081bb592015-10-08 20:40:34 +0000373}
374
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000375template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100376inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, int>::type
377fpclassify(_A1 __x) _NOEXCEPT {
378 return __x == 0 ? FP_ZERO : FP_NORMAL;
379}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000380
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100381# elif defined(_LIBCPP_MSVCRT)
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000382
383template <typename _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100384inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
385fpclassify(_A1 __x) _NOEXCEPT {
Nikolas Klauser37a5b4f2022-10-27 20:01:13 +0200386 return ::fpclassify(__x);
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000387}
388
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000389template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100390inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, int>::type
391fpclassify(_A1 __x) _NOEXCEPT {
392 return __x == 0 ? FP_ZERO : FP_NORMAL;
393}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000394
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100395# endif // fpclassify
Richard Smith081bb592015-10-08 20:40:34 +0000396
397// isfinite
398
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100399# ifdef isfinite
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100400# undef isfinite
Richard Smith081bb592015-10-08 20:40:34 +0000401
402template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200403inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100404 typename std::enable_if< std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, bool>::type
405 isfinite(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100406 return __builtin_isfinite((typename std::__promote<_A1>::type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000407}
408
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000409template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200410inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100411 typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type
412 isfinite(_A1) _NOEXCEPT {
413 return true;
414}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000415
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100416# endif // isfinite
Richard Smith081bb592015-10-08 20:40:34 +0000417
418// isinf
419
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100420# ifdef isinf
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100421# undef isinf
Richard Smith081bb592015-10-08 20:40:34 +0000422
423template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200424inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100425 typename std::enable_if< std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, bool>::type
426 isinf(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100427 return __builtin_isinf((typename std::__promote<_A1>::type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000428}
429
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000430template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200431inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100432 typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type
433 isinf(_A1) _NOEXCEPT {
434 return false;
435}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000436
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100437# ifdef _LIBCPP_PREFERRED_OVERLOAD
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100438inline _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { return __builtin_isinf(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000439
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100440inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT { return __builtin_isinf(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000441
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100442inline _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { return __builtin_isinf(__x); }
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100443# endif
Richard Smithafccfd32018-05-01 03:05:40 +0000444
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100445# endif // isinf
Richard Smith081bb592015-10-08 20:40:34 +0000446
447// isnan
448
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100449# ifdef isnan
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100450# undef isnan
Richard Smith081bb592015-10-08 20:40:34 +0000451
452template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100453inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
454isnan(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100455 return __builtin_isnan(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000456}
457
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000458template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100459inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, bool>::type isnan(_A1) _NOEXCEPT {
460 return false;
461}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000462
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100463# ifdef _LIBCPP_PREFERRED_OVERLOAD
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100464inline _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { return __builtin_isnan(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000465
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100466inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT { return __builtin_isnan(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000467
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100468inline _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { return __builtin_isnan(__x); }
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100469# endif
Richard Smithafccfd32018-05-01 03:05:40 +0000470
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100471# endif // isnan
Richard Smith081bb592015-10-08 20:40:34 +0000472
473// isnormal
474
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100475# ifdef isnormal
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100476# undef isnormal
Richard Smith081bb592015-10-08 20:40:34 +0000477
478template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100479inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
480isnormal(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100481 return __builtin_isnormal(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000482}
483
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000484template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100485inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, bool>::type
486isnormal(_A1 __x) _NOEXCEPT {
487 return __x != 0;
488}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000489
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100490# endif // isnormal
Richard Smith081bb592015-10-08 20:40:34 +0000491
492// isgreater
493
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100494# ifdef isgreater
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100495# undef isgreater
Richard Smith081bb592015-10-08 20:40:34 +0000496
497template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200498inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100499 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
500 isgreater(_A1 __x, _A2 __y) _NOEXCEPT {
501 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100502 return __builtin_isgreater((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000503}
504
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100505# endif // isgreater
Richard Smith081bb592015-10-08 20:40:34 +0000506
507// isgreaterequal
508
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100509# ifdef isgreaterequal
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100510# undef isgreaterequal
Richard Smith081bb592015-10-08 20:40:34 +0000511
512template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200513inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100514 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
515 isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {
516 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100517 return __builtin_isgreaterequal((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000518}
519
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100520# endif // isgreaterequal
Richard Smith081bb592015-10-08 20:40:34 +0000521
522// isless
523
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100524# ifdef isless
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100525# undef isless
Richard Smith081bb592015-10-08 20:40:34 +0000526
527template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200528inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100529 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
530 isless(_A1 __x, _A2 __y) _NOEXCEPT {
531 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100532 return __builtin_isless((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000533}
534
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100535# endif // isless
Richard Smith081bb592015-10-08 20:40:34 +0000536
537// islessequal
538
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100539# ifdef islessequal
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100540# undef islessequal
Richard Smith081bb592015-10-08 20:40:34 +0000541
542template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200543inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100544 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
545 islessequal(_A1 __x, _A2 __y) _NOEXCEPT {
546 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100547 return __builtin_islessequal((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000548}
549
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100550# endif // islessequal
Richard Smith081bb592015-10-08 20:40:34 +0000551
552// islessgreater
553
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100554# ifdef islessgreater
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100555# undef islessgreater
Richard Smith081bb592015-10-08 20:40:34 +0000556
557template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200558inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100559 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
560 islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {
561 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100562 return __builtin_islessgreater((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000563}
564
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100565# endif // islessgreater
Richard Smith081bb592015-10-08 20:40:34 +0000566
567// isunordered
568
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100569# ifdef isunordered
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100570# undef isunordered
Richard Smith081bb592015-10-08 20:40:34 +0000571
572template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200573inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100574 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
575 isunordered(_A1 __x, _A2 __y) _NOEXCEPT {
576 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100577 return __builtin_isunordered((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000578}
579
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100580# endif // isunordered
Richard Smith081bb592015-10-08 20:40:34 +0000581
Richard Smith081bb592015-10-08 20:40:34 +0000582// abs
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500583//
584// handled in stdlib.h
Richard Smith081bb592015-10-08 20:40:34 +0000585
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000586// div
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500587//
588// handled in stdlib.h
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000589
Richard Smith081bb592015-10-08 20:40:34 +0000590// acos
591
David Tenty7249ac92022-02-07 18:22:35 -0500592# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200593inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return ::acosf(__x);}
594inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT {return ::acosl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500595# endif
Richard Smith081bb592015-10-08 20:40:34 +0000596
597template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200598inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000599typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200600acos(_A1 __x) _NOEXCEPT {return ::acos((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000601
602// asin
603
David Tenty7249ac92022-02-07 18:22:35 -0500604# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200605inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return ::asinf(__x);}
606inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT {return ::asinl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500607# endif
Richard Smith081bb592015-10-08 20:40:34 +0000608
609template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200610inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000611typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200612asin(_A1 __x) _NOEXCEPT {return ::asin((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000613
614// atan
615
David Tenty7249ac92022-02-07 18:22:35 -0500616# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200617inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return ::atanf(__x);}
618inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT {return ::atanl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500619# endif
Richard Smith081bb592015-10-08 20:40:34 +0000620
621template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200622inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000623typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200624atan(_A1 __x) _NOEXCEPT {return ::atan((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000625
626// atan2
627
David Tenty7249ac92022-02-07 18:22:35 -0500628# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200629inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return ::atan2f(__y, __x);}
630inline _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 -0500631# endif
Richard Smith081bb592015-10-08 20:40:34 +0000632
633template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200634inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400635typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000636<
637 std::is_arithmetic<_A1>::value &&
638 std::is_arithmetic<_A2>::value,
639 std::__promote<_A1, _A2>
640>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200641atan2(_A1 __y, _A2 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000642{
643 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000644 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
645 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200646 return ::atan2((__result_type)__y, (__result_type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000647}
648
649// ceil
650
David Tenty7249ac92022-02-07 18:22:35 -0500651# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200652inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return ::ceilf(__x);}
653inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return ::ceill(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500654# endif
Richard Smith081bb592015-10-08 20:40:34 +0000655
656template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200657inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000658typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200659ceil(_A1 __x) _NOEXCEPT {return ::ceil((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000660
661// cos
662
David Tenty7249ac92022-02-07 18:22:35 -0500663# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200664inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return ::cosf(__x);}
665inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT {return ::cosl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500666# endif
Richard Smith081bb592015-10-08 20:40:34 +0000667
668template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200669inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000670typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200671cos(_A1 __x) _NOEXCEPT {return ::cos((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000672
673// cosh
674
David Tenty7249ac92022-02-07 18:22:35 -0500675# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200676inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return ::coshf(__x);}
677inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT {return ::coshl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500678# endif
Richard Smith081bb592015-10-08 20:40:34 +0000679
680template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200681inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000682typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200683cosh(_A1 __x) _NOEXCEPT {return ::cosh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000684
685// exp
686
David Tenty7249ac92022-02-07 18:22:35 -0500687# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200688inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return ::expf(__x);}
689inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT {return ::expl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500690# endif
Richard Smith081bb592015-10-08 20:40:34 +0000691
692template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200693inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000694typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200695exp(_A1 __x) _NOEXCEPT {return ::exp((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000696
697// fabs
698
David Tenty7249ac92022-02-07 18:22:35 -0500699# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200700inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return ::fabsf(__x);}
701inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return ::fabsl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500702# endif
Richard Smith081bb592015-10-08 20:40:34 +0000703
704template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200705inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000706typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200707fabs(_A1 __x) _NOEXCEPT {return ::fabs((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000708
709// floor
710
David Tenty7249ac92022-02-07 18:22:35 -0500711# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200712inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return ::floorf(__x);}
713inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return ::floorl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500714# endif
Richard Smith081bb592015-10-08 20:40:34 +0000715
716template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200717inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000718typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200719floor(_A1 __x) _NOEXCEPT {return ::floor((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000720
721// fmod
722
David Tenty7249ac92022-02-07 18:22:35 -0500723# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200724inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return ::fmodf(__x, __y);}
725inline _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 -0500726# endif
Richard Smith081bb592015-10-08 20:40:34 +0000727
728template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200729inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400730typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000731<
732 std::is_arithmetic<_A1>::value &&
733 std::is_arithmetic<_A2>::value,
734 std::__promote<_A1, _A2>
735>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200736fmod(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000737{
738 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000739 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
740 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200741 return ::fmod((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000742}
743
744// frexp
745
David Tenty7249ac92022-02-07 18:22:35 -0500746# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200747inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return ::frexpf(__x, __e);}
748inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {return ::frexpl(__x, __e);}
David Tenty7249ac92022-02-07 18:22:35 -0500749# endif
Richard Smith081bb592015-10-08 20:40:34 +0000750
751template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200752inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000753typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200754frexp(_A1 __x, int* __e) _NOEXCEPT {return ::frexp((double)__x, __e);}
Richard Smith081bb592015-10-08 20:40:34 +0000755
756// ldexp
757
David Tenty7249ac92022-02-07 18:22:35 -0500758# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200759inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return ::ldexpf(__x, __e);}
760inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {return ::ldexpl(__x, __e);}
David Tenty7249ac92022-02-07 18:22:35 -0500761# endif
Richard Smith081bb592015-10-08 20:40:34 +0000762
763template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200764inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000765typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200766ldexp(_A1 __x, int __e) _NOEXCEPT {return ::ldexp((double)__x, __e);}
Richard Smith081bb592015-10-08 20:40:34 +0000767
768// log
769
David Tenty7249ac92022-02-07 18:22:35 -0500770# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200771inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return ::logf(__x);}
772inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT {return ::logl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500773# endif
Richard Smith081bb592015-10-08 20:40:34 +0000774
775template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200776inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000777typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200778log(_A1 __x) _NOEXCEPT {return ::log((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000779
780// log10
781
David Tenty7249ac92022-02-07 18:22:35 -0500782# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200783inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return ::log10f(__x);}
784inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT {return ::log10l(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500785# endif
Richard Smith081bb592015-10-08 20:40:34 +0000786
787template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200788inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000789typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200790log10(_A1 __x) _NOEXCEPT {return ::log10((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000791
792// modf
793
David Tenty7249ac92022-02-07 18:22:35 -0500794# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200795inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return ::modff(__x, __y);}
796inline _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 -0500797# endif
Richard Smith081bb592015-10-08 20:40:34 +0000798
799// pow
800
David Tenty7249ac92022-02-07 18:22:35 -0500801# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200802inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return ::powf(__x, __y);}
803inline _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 -0500804# endif
Richard Smith081bb592015-10-08 20:40:34 +0000805
806template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200807inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400808typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000809<
810 std::is_arithmetic<_A1>::value &&
811 std::is_arithmetic<_A2>::value,
812 std::__promote<_A1, _A2>
813>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200814pow(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000815{
816 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000817 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
818 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200819 return ::pow((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000820}
821
822// sin
823
David Tenty7249ac92022-02-07 18:22:35 -0500824# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200825inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return ::sinf(__x);}
826inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT {return ::sinl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000827#endif
828
829template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200830inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000831typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200832sin(_A1 __x) _NOEXCEPT {return ::sin((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000833
834// sinh
835
David Tenty7249ac92022-02-07 18:22:35 -0500836# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200837inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return ::sinhf(__x);}
838inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT {return ::sinhl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500839# endif
Richard Smith081bb592015-10-08 20:40:34 +0000840
841template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200842inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000843typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200844sinh(_A1 __x) _NOEXCEPT {return ::sinh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000845
846// sqrt
847
David Tenty7249ac92022-02-07 18:22:35 -0500848# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200849inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return ::sqrtf(__x);}
850inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT {return ::sqrtl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500851# endif
Richard Smith081bb592015-10-08 20:40:34 +0000852
Richard Smith081bb592015-10-08 20:40:34 +0000853template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200854inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000855typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200856sqrt(_A1 __x) _NOEXCEPT {return ::sqrt((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000857
858// tan
859
David Tenty7249ac92022-02-07 18:22:35 -0500860# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200861inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return ::tanf(__x);}
862inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT {return ::tanl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500863# endif
Richard Smith081bb592015-10-08 20:40:34 +0000864
865template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200866inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000867typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200868tan(_A1 __x) _NOEXCEPT {return ::tan((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000869
870// tanh
871
David Tenty7249ac92022-02-07 18:22:35 -0500872# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200873inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return ::tanhf(__x);}
874inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT {return ::tanhl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500875# endif
Richard Smith081bb592015-10-08 20:40:34 +0000876
877template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200878inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000879typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200880tanh(_A1 __x) _NOEXCEPT {return ::tanh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000881
882// acosh
883
Nikolas Klauser9806f452022-10-12 15:45:09 +0200884inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return ::acoshf(__x);}
885inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT {return ::acoshl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000886
887template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200888inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000889typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200890acosh(_A1 __x) _NOEXCEPT {return ::acosh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000891
892// asinh
893
Nikolas Klauser9806f452022-10-12 15:45:09 +0200894inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return ::asinhf(__x);}
895inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT {return ::asinhl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000896
897template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200898inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000899typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200900asinh(_A1 __x) _NOEXCEPT {return ::asinh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000901
902// atanh
903
Nikolas Klauser9806f452022-10-12 15:45:09 +0200904inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return ::atanhf(__x);}
905inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT {return ::atanhl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000906
907template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200908inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000909typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200910atanh(_A1 __x) _NOEXCEPT {return ::atanh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000911
912// cbrt
913
Nikolas Klauser9806f452022-10-12 15:45:09 +0200914inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return ::cbrtf(__x);}
915inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {return ::cbrtl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000916
917template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200918inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000919typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200920cbrt(_A1 __x) _NOEXCEPT {return ::cbrt((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000921
922// copysign
923
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200924_LIBCPP_CONSTEXPR
Nikolas Klauser9806f452022-10-12 15:45:09 +0200925inline _LIBCPP_HIDE_FROM_ABI float __libcpp_copysign(float __x, float __y) _NOEXCEPT {
Nikolas Klauser9806f452022-10-12 15:45:09 +0200926 return __builtin_copysignf(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000927}
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200928
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200929_LIBCPP_CONSTEXPR
Nikolas Klauser9806f452022-10-12 15:45:09 +0200930inline _LIBCPP_HIDE_FROM_ABI double __libcpp_copysign(double __x, double __y) _NOEXCEPT {
Nikolas Klauser9806f452022-10-12 15:45:09 +0200931 return __builtin_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200932}
933
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200934_LIBCPP_CONSTEXPR
Nikolas Klauser9806f452022-10-12 15:45:09 +0200935inline _LIBCPP_HIDE_FROM_ABI long double __libcpp_copysign(long double __x, long double __y) _NOEXCEPT {
Nikolas Klauser9806f452022-10-12 15:45:09 +0200936 return __builtin_copysignl(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000937}
Richard Smith081bb592015-10-08 20:40:34 +0000938
939template <class _A1, class _A2>
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200940_LIBCPP_CONSTEXPR
Nikolas Klauser4956e722022-10-12 15:41:22 +0200941inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400942typename std::__enable_if_t
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200943<
944 std::is_arithmetic<_A1>::value &&
945 std::is_arithmetic<_A2>::value,
946 std::__promote<_A1, _A2>
947>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200948__libcpp_copysign(_A1 __x, _A2 __y) _NOEXCEPT {
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200949 typedef typename std::__promote<_A1, _A2>::type __result_type;
950 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
951 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200952 return __builtin_copysign((__result_type)__x, (__result_type)__y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200953}
954
Nikolas Klauser9806f452022-10-12 15:45:09 +0200955inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT {
956 return ::__libcpp_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200957}
958
Nikolas Klauser9806f452022-10-12 15:45:09 +0200959inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT {
960 return ::__libcpp_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200961}
962
963template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200964inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400965typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000966<
967 std::is_arithmetic<_A1>::value &&
968 std::is_arithmetic<_A2>::value,
969 std::__promote<_A1, _A2>
970>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200971 copysign(_A1 __x, _A2 __y) _NOEXCEPT {
972 return ::__libcpp_copysign(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000973}
974
Richard Smith081bb592015-10-08 20:40:34 +0000975// erf
976
Nikolas Klauser9806f452022-10-12 15:45:09 +0200977inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return ::erff(__x);}
978inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT {return ::erfl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000979
980template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200981inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000982typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200983erf(_A1 __x) _NOEXCEPT {return ::erf((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000984
985// erfc
986
Nikolas Klauser9806f452022-10-12 15:45:09 +0200987inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return ::erfcf(__x);}
988inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT {return ::erfcl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000989
990template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200991inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000992typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200993erfc(_A1 __x) _NOEXCEPT {return ::erfc((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000994
995// exp2
996
Nikolas Klauser9806f452022-10-12 15:45:09 +0200997inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return ::exp2f(__x);}
998inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT {return ::exp2l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000999
1000template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001001inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001002typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001003exp2(_A1 __x) _NOEXCEPT {return ::exp2((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001004
1005// expm1
1006
Nikolas Klauser9806f452022-10-12 15:45:09 +02001007inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return ::expm1f(__x);}
1008inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT {return ::expm1l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001009
1010template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001011inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001012typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001013expm1(_A1 __x) _NOEXCEPT {return ::expm1((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001014
1015// fdim
1016
Nikolas Klauser9806f452022-10-12 15:45:09 +02001017inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return ::fdimf(__x, __y);}
1018inline _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 +00001019
1020template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001021inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001022typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001023<
1024 std::is_arithmetic<_A1>::value &&
1025 std::is_arithmetic<_A2>::value,
1026 std::__promote<_A1, _A2>
1027>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001028fdim(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001029{
1030 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001031 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1032 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001033 return ::fdim((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001034}
1035
1036// fma
1037
Nikolas Klauser9806f452022-10-12 15:45:09 +02001038inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001039{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001040 return __builtin_fmaf(__x, __y, __z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001041}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001042inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001043{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001044 return __builtin_fmal(__x, __y, __z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001045}
Richard Smith081bb592015-10-08 20:40:34 +00001046
1047template <class _A1, class _A2, class _A3>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001048inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001049typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001050<
1051 std::is_arithmetic<_A1>::value &&
1052 std::is_arithmetic<_A2>::value &&
1053 std::is_arithmetic<_A3>::value,
1054 std::__promote<_A1, _A2, _A3>
1055>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001056fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001057{
1058 typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001059 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1060 std::_IsSame<_A2, __result_type>::value &&
1061 std::_IsSame<_A3, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001062 return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
Richard Smith081bb592015-10-08 20:40:34 +00001063}
1064
1065// fmax
1066
Nikolas Klauser9806f452022-10-12 15:45:09 +02001067inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return ::fmaxf(__x, __y);}
1068inline _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 +00001069
1070template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001071inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001072typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001073<
1074 std::is_arithmetic<_A1>::value &&
1075 std::is_arithmetic<_A2>::value,
1076 std::__promote<_A1, _A2>
1077>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001078fmax(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001079{
1080 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001081 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1082 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001083 return ::fmax((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001084}
1085
1086// fmin
1087
Nikolas Klauser9806f452022-10-12 15:45:09 +02001088inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return ::fminf(__x, __y);}
1089inline _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 +00001090
1091template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001092inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001093typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001094<
1095 std::is_arithmetic<_A1>::value &&
1096 std::is_arithmetic<_A2>::value,
1097 std::__promote<_A1, _A2>
1098>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001099fmin(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001100{
1101 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001102 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1103 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001104 return ::fmin((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001105}
1106
1107// hypot
1108
Nikolas Klauser9806f452022-10-12 15:45:09 +02001109inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return ::hypotf(__x, __y);}
1110inline _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 +00001111
1112template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001113inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001114typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001115<
1116 std::is_arithmetic<_A1>::value &&
1117 std::is_arithmetic<_A2>::value,
1118 std::__promote<_A1, _A2>
1119>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001120hypot(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001121{
1122 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001123 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1124 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001125 return ::hypot((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001126}
1127
1128// ilogb
1129
Nikolas Klauser9806f452022-10-12 15:45:09 +02001130inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return ::ilogbf(__x);}
1131inline _LIBCPP_HIDE_FROM_ABI int ilogb(long double __x) _NOEXCEPT {return ::ilogbl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001132
1133template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001134inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001135typename std::enable_if<std::is_integral<_A1>::value, int>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001136ilogb(_A1 __x) _NOEXCEPT {return ::ilogb((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001137
1138// lgamma
1139
Nikolas Klauser9806f452022-10-12 15:45:09 +02001140inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return ::lgammaf(__x);}
1141inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT {return ::lgammal(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001142
1143template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001144inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001145typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001146lgamma(_A1 __x) _NOEXCEPT {return ::lgamma((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001147
1148// llrint
1149
Nikolas Klauser9806f452022-10-12 15:45:09 +02001150inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001151{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001152 return __builtin_llrintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001153}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001154inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001155{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001156 return __builtin_llrintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001157}
Richard Smith081bb592015-10-08 20:40:34 +00001158
1159template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001160inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001161typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001162llrint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001163{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001164 return __builtin_llrint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001165}
Richard Smith081bb592015-10-08 20:40:34 +00001166
1167// llround
1168
Nikolas Klauser9806f452022-10-12 15:45:09 +02001169inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001170{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001171 return __builtin_llroundf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001172}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001173inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001174{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001175 return __builtin_llroundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001176}
Richard Smith081bb592015-10-08 20:40:34 +00001177
1178template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001179inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001180typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001181llround(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001182{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001183 return __builtin_llround((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001184}
Richard Smith081bb592015-10-08 20:40:34 +00001185
1186// log1p
1187
Nikolas Klauser9806f452022-10-12 15:45:09 +02001188inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return ::log1pf(__x);}
1189inline _LIBCPP_HIDE_FROM_ABI long double log1p(long double __x) _NOEXCEPT {return ::log1pl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001190
1191template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001192inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001193typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001194log1p(_A1 __x) _NOEXCEPT {return ::log1p((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001195
1196// log2
1197
Nikolas Klauser9806f452022-10-12 15:45:09 +02001198inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return ::log2f(__x);}
1199inline _LIBCPP_HIDE_FROM_ABI long double log2(long double __x) _NOEXCEPT {return ::log2l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001200
1201template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001202inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001203typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001204log2(_A1 __x) _NOEXCEPT {return ::log2((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001205
1206// logb
1207
Nikolas Klauser9806f452022-10-12 15:45:09 +02001208inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return ::logbf(__x);}
1209inline _LIBCPP_HIDE_FROM_ABI long double logb(long double __x) _NOEXCEPT {return ::logbl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001210
1211template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001212inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001213typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001214logb(_A1 __x) _NOEXCEPT {return ::logb((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001215
1216// lrint
1217
Nikolas Klauser9806f452022-10-12 15:45:09 +02001218inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001219{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001220 return __builtin_lrintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001221}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001222inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001223{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001224 return __builtin_lrintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001225}
Richard Smith081bb592015-10-08 20:40:34 +00001226
1227template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001228inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001229typename std::enable_if<std::is_integral<_A1>::value, long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001230lrint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001231{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001232 return __builtin_lrint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001233}
Richard Smith081bb592015-10-08 20:40:34 +00001234
1235// lround
1236
Nikolas Klauser9806f452022-10-12 15:45:09 +02001237inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001238{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001239 return __builtin_lroundf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001240}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001241inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001242{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001243 return __builtin_lroundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001244}
Richard Smith081bb592015-10-08 20:40:34 +00001245
1246template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001247inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001248typename std::enable_if<std::is_integral<_A1>::value, long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001249lround(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001250{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001251 return __builtin_lround((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001252}
Richard Smith081bb592015-10-08 20:40:34 +00001253
1254// nan
1255
1256// nearbyint
1257
Nikolas Klauser9806f452022-10-12 15:45:09 +02001258inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return ::nearbyintf(__x);}
1259inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {return ::nearbyintl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001260
1261template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001262inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001263typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001264nearbyint(_A1 __x) _NOEXCEPT {return ::nearbyint((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001265
1266// nextafter
1267
Nikolas Klauser9806f452022-10-12 15:45:09 +02001268inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return ::nextafterf(__x, __y);}
1269inline _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 +00001270
1271template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001272inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001273typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001274<
1275 std::is_arithmetic<_A1>::value &&
1276 std::is_arithmetic<_A2>::value,
1277 std::__promote<_A1, _A2>
1278>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001279nextafter(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001280{
1281 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001282 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1283 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001284 return ::nextafter((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001285}
1286
1287// nexttoward
1288
Nikolas Klauser9806f452022-10-12 15:45:09 +02001289inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return ::nexttowardf(__x, __y);}
1290inline _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 +00001291
1292template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001293inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001294typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001295nexttoward(_A1 __x, long double __y) _NOEXCEPT {return ::nexttoward((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001296
1297// remainder
1298
Nikolas Klauser9806f452022-10-12 15:45:09 +02001299inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return ::remainderf(__x, __y);}
1300inline _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 +00001301
1302template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001303inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001304typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001305<
1306 std::is_arithmetic<_A1>::value &&
1307 std::is_arithmetic<_A2>::value,
1308 std::__promote<_A1, _A2>
1309>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001310remainder(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001311{
1312 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001313 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1314 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001315 return ::remainder((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001316}
1317
1318// remquo
1319
Nikolas Klauser9806f452022-10-12 15:45:09 +02001320inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return ::remquof(__x, __y, __z);}
1321inline _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 +00001322
1323template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001324inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001325typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001326<
1327 std::is_arithmetic<_A1>::value &&
1328 std::is_arithmetic<_A2>::value,
1329 std::__promote<_A1, _A2>
1330>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001331remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001332{
1333 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001334 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1335 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001336 return ::remquo((__result_type)__x, (__result_type)__y, __z);
Richard Smith081bb592015-10-08 20:40:34 +00001337}
1338
1339// rint
1340
Nikolas Klauser9806f452022-10-12 15:45:09 +02001341inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001342{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001343 return __builtin_rintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001344}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001345inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001346{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001347 return __builtin_rintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001348}
Richard Smith081bb592015-10-08 20:40:34 +00001349
1350template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001351inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001352typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001353rint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001354{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001355 return __builtin_rint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001356}
Richard Smith081bb592015-10-08 20:40:34 +00001357
1358// round
1359
Nikolas Klauser9806f452022-10-12 15:45:09 +02001360inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001361{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001362 return __builtin_round(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001363}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001364inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001365{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001366 return __builtin_roundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001367}
Richard Smith081bb592015-10-08 20:40:34 +00001368
1369template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001370inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001371typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001372round(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001373{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001374 return __builtin_round((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001375}
Richard Smith081bb592015-10-08 20:40:34 +00001376
1377// scalbln
1378
Nikolas Klauser9806f452022-10-12 15:45:09 +02001379inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return ::scalblnf(__x, __y);}
1380inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT {return ::scalblnl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001381
1382template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001383inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001384typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001385scalbln(_A1 __x, long __y) _NOEXCEPT {return ::scalbln((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001386
1387// scalbn
1388
Nikolas Klauser9806f452022-10-12 15:45:09 +02001389inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return ::scalbnf(__x, __y);}
1390inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT {return ::scalbnl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001391
1392template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001393inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001394typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001395scalbn(_A1 __x, int __y) _NOEXCEPT {return ::scalbn((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001396
1397// tgamma
1398
Nikolas Klauser9806f452022-10-12 15:45:09 +02001399inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return ::tgammaf(__x);}
1400inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT {return ::tgammal(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001401
1402template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001403inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001404typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001405tgamma(_A1 __x) _NOEXCEPT {return ::tgamma((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001406
1407// trunc
1408
Nikolas Klauser9806f452022-10-12 15:45:09 +02001409inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001410{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001411 return __builtin_trunc(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001412}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001413inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001414{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001415 return __builtin_truncl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001416}
Richard Smith081bb592015-10-08 20:40:34 +00001417
1418template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001419inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001420typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001421trunc(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001422{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001423 return __builtin_trunc((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001424}
Richard Smith081bb592015-10-08 20:40:34 +00001425
Richard Smith081bb592015-10-08 20:40:34 +00001426} // extern "C++"
1427
1428#endif // __cplusplus
1429
Mikhail Maltsev34b4f972018-02-22 09:34:08 +00001430#else // _LIBCPP_MATH_H
1431
1432// This include lives outside the header guard in order to support an MSVC
1433// extension which allows users to do:
1434//
1435// #define _USE_MATH_DEFINES
1436// #include <math.h>
1437//
1438// and receive the definitions of mathematical constants, even if <math.h>
1439// has previously been included.
1440#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
1441#include_next <math.h>
1442#endif
1443
Louis Dionne2b1ceaa2021-04-20 12:03:32 -04001444#endif // _LIBCPP_MATH_H