blob: 46a0a813ed05540c69936c81fbc9d40f60c1d013 [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
Nikolas Klausere96070f2022-11-04 20:08:56 +0100321template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
322inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100323 return __builtin_signbit(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000324}
325
Nikolas Klausere96070f2022-11-04 20:08:56 +0100326template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && std::is_signed<_A1>::value, int> = 0>
327inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100328 return __x < 0;
329}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000330
Nikolas Klausere96070f2022-11-04 20:08:56 +0100331template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && !std::is_signed<_A1>::value, int> = 0>
332inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100333 return false;
334}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000335
Richard Smith081bb592015-10-08 20:40:34 +0000336// fpclassify
337
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100338# ifdef fpclassify
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100339# undef fpclassify
Nikolas Klauser88b1e942022-11-04 17:01:22 +0100340# endif // fpclassify
Richard Smith081bb592015-10-08 20:40:34 +0000341
Nikolas Klausere96070f2022-11-04 20:08:56 +0100342template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
343inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100344 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
Richard Smith081bb592015-10-08 20:40:34 +0000345}
346
Nikolas Klausere96070f2022-11-04 20:08:56 +0100347template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
348inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100349 return __x == 0 ? FP_ZERO : FP_NORMAL;
350}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000351
Richard Smith081bb592015-10-08 20:40:34 +0000352// isfinite
353
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100354# ifdef isfinite
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100355# undef isfinite
Richard Smith081bb592015-10-08 20:40:34 +0000356
Nikolas Klausere96070f2022-11-04 20:08:56 +0100357template <class _A1,
358 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
359inline _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100360 return __builtin_isfinite((typename std::__promote<_A1>::type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000361}
362
Nikolas Klausere96070f2022-11-04 20:08:56 +0100363template <class _A1,
364 std::__enable_if_t<std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, int> = 0>
365inline _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100366 return true;
367}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000368
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100369# endif // isfinite
Richard Smith081bb592015-10-08 20:40:34 +0000370
371// isinf
372
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100373# ifdef isinf
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100374# undef isinf
Richard Smith081bb592015-10-08 20:40:34 +0000375
Nikolas Klausere96070f2022-11-04 20:08:56 +0100376template <class _A1,
377 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
378inline _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100379 return __builtin_isinf((typename std::__promote<_A1>::type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000380}
381
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000382template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200383inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100384 typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type
385 isinf(_A1) _NOEXCEPT {
386 return false;
387}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000388
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100389# ifdef _LIBCPP_PREFERRED_OVERLOAD
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100390inline _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { return __builtin_isinf(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000391
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100392inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT { return __builtin_isinf(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000393
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100394inline _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { return __builtin_isinf(__x); }
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100395# endif
Richard Smithafccfd32018-05-01 03:05:40 +0000396
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100397# endif // isinf
Richard Smith081bb592015-10-08 20:40:34 +0000398
399// isnan
400
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100401# ifdef isnan
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100402# undef isnan
Richard Smith081bb592015-10-08 20:40:34 +0000403
Nikolas Klausere96070f2022-11-04 20:08:56 +0100404template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
405inline _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100406 return __builtin_isnan(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000407}
408
Nikolas Klausere96070f2022-11-04 20:08:56 +0100409template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
410inline _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100411 return false;
412}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000413
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100414# ifdef _LIBCPP_PREFERRED_OVERLOAD
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100415inline _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { return __builtin_isnan(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000416
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100417inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT { return __builtin_isnan(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000418
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100419inline _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { return __builtin_isnan(__x); }
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100420# endif
Richard Smithafccfd32018-05-01 03:05:40 +0000421
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100422# endif // isnan
Richard Smith081bb592015-10-08 20:40:34 +0000423
424// isnormal
425
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100426# ifdef isnormal
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100427# undef isnormal
Richard Smith081bb592015-10-08 20:40:34 +0000428
Nikolas Klausere96070f2022-11-04 20:08:56 +0100429template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
430inline _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100431 return __builtin_isnormal(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000432}
433
Nikolas Klausere96070f2022-11-04 20:08:56 +0100434template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
435inline _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100436 return __x != 0;
437}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000438
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100439# endif // isnormal
Richard Smith081bb592015-10-08 20:40:34 +0000440
441// isgreater
442
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100443# ifdef isgreater
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100444# undef isgreater
Richard Smith081bb592015-10-08 20:40:34 +0000445
Nikolas Klausere96070f2022-11-04 20:08:56 +0100446template <class _A1,
447 class _A2,
448 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
449inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100450 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100451 return __builtin_isgreater((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000452}
453
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100454# endif // isgreater
Richard Smith081bb592015-10-08 20:40:34 +0000455
456// isgreaterequal
457
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100458# ifdef isgreaterequal
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100459# undef isgreaterequal
Richard Smith081bb592015-10-08 20:40:34 +0000460
Nikolas Klausere96070f2022-11-04 20:08:56 +0100461template <class _A1,
462 class _A2,
463 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
464inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100465 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100466 return __builtin_isgreaterequal((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000467}
468
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100469# endif // isgreaterequal
Richard Smith081bb592015-10-08 20:40:34 +0000470
471// isless
472
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100473# ifdef isless
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100474# undef isless
Richard Smith081bb592015-10-08 20:40:34 +0000475
Nikolas Klausere96070f2022-11-04 20:08:56 +0100476template <class _A1,
477 class _A2,
478 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
479inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100480 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100481 return __builtin_isless((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000482}
483
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100484# endif // isless
Richard Smith081bb592015-10-08 20:40:34 +0000485
486// islessequal
487
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100488# ifdef islessequal
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100489# undef islessequal
Richard Smith081bb592015-10-08 20:40:34 +0000490
Nikolas Klausere96070f2022-11-04 20:08:56 +0100491template <class _A1,
492 class _A2,
493 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
494inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100495 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100496 return __builtin_islessequal((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000497}
498
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100499# endif // islessequal
Richard Smith081bb592015-10-08 20:40:34 +0000500
501// islessgreater
502
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100503# ifdef islessgreater
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100504# undef islessgreater
Richard Smith081bb592015-10-08 20:40:34 +0000505
Nikolas Klausere96070f2022-11-04 20:08:56 +0100506template <class _A1,
507 class _A2,
508 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
509inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100510 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100511 return __builtin_islessgreater((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000512}
513
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100514# endif // islessgreater
Richard Smith081bb592015-10-08 20:40:34 +0000515
516// isunordered
517
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100518# ifdef isunordered
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100519# undef isunordered
Richard Smith081bb592015-10-08 20:40:34 +0000520
Nikolas Klausere96070f2022-11-04 20:08:56 +0100521template <class _A1,
522 class _A2,
523 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
524inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100525 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100526 return __builtin_isunordered((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000527}
528
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100529# endif // isunordered
Richard Smith081bb592015-10-08 20:40:34 +0000530
Richard Smith081bb592015-10-08 20:40:34 +0000531// abs
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500532//
533// handled in stdlib.h
Richard Smith081bb592015-10-08 20:40:34 +0000534
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000535// div
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500536//
537// handled in stdlib.h
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000538
Richard Smith081bb592015-10-08 20:40:34 +0000539// acos
540
David Tenty7249ac92022-02-07 18:22:35 -0500541# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200542inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return ::acosf(__x);}
543inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT {return ::acosl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500544# endif
Richard Smith081bb592015-10-08 20:40:34 +0000545
546template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200547inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000548typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200549acos(_A1 __x) _NOEXCEPT {return ::acos((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000550
551// asin
552
David Tenty7249ac92022-02-07 18:22:35 -0500553# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200554inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return ::asinf(__x);}
555inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT {return ::asinl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500556# endif
Richard Smith081bb592015-10-08 20:40:34 +0000557
558template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200559inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000560typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200561asin(_A1 __x) _NOEXCEPT {return ::asin((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000562
563// atan
564
David Tenty7249ac92022-02-07 18:22:35 -0500565# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200566inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return ::atanf(__x);}
567inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT {return ::atanl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500568# endif
Richard Smith081bb592015-10-08 20:40:34 +0000569
570template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200571inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000572typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200573atan(_A1 __x) _NOEXCEPT {return ::atan((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000574
575// atan2
576
David Tenty7249ac92022-02-07 18:22:35 -0500577# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200578inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return ::atan2f(__y, __x);}
579inline _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 -0500580# endif
Richard Smith081bb592015-10-08 20:40:34 +0000581
582template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200583inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400584typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000585<
586 std::is_arithmetic<_A1>::value &&
587 std::is_arithmetic<_A2>::value,
588 std::__promote<_A1, _A2>
589>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200590atan2(_A1 __y, _A2 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000591{
592 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000593 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
594 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200595 return ::atan2((__result_type)__y, (__result_type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000596}
597
598// ceil
599
David Tenty7249ac92022-02-07 18:22:35 -0500600# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200601inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return ::ceilf(__x);}
602inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return ::ceill(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500603# endif
Richard Smith081bb592015-10-08 20:40:34 +0000604
605template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200606inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000607typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200608ceil(_A1 __x) _NOEXCEPT {return ::ceil((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000609
610// cos
611
David Tenty7249ac92022-02-07 18:22:35 -0500612# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200613inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return ::cosf(__x);}
614inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT {return ::cosl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500615# endif
Richard Smith081bb592015-10-08 20:40:34 +0000616
617template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200618inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000619typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200620cos(_A1 __x) _NOEXCEPT {return ::cos((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000621
622// cosh
623
David Tenty7249ac92022-02-07 18:22:35 -0500624# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200625inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return ::coshf(__x);}
626inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT {return ::coshl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500627# endif
Richard Smith081bb592015-10-08 20:40:34 +0000628
629template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200630inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000631typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200632cosh(_A1 __x) _NOEXCEPT {return ::cosh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000633
634// exp
635
David Tenty7249ac92022-02-07 18:22:35 -0500636# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200637inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return ::expf(__x);}
638inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT {return ::expl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500639# endif
Richard Smith081bb592015-10-08 20:40:34 +0000640
641template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200642inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000643typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200644exp(_A1 __x) _NOEXCEPT {return ::exp((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000645
646// fabs
647
David Tenty7249ac92022-02-07 18:22:35 -0500648# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200649inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return ::fabsf(__x);}
650inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return ::fabsl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500651# endif
Richard Smith081bb592015-10-08 20:40:34 +0000652
653template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200654inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000655typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200656fabs(_A1 __x) _NOEXCEPT {return ::fabs((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000657
658// floor
659
David Tenty7249ac92022-02-07 18:22:35 -0500660# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200661inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return ::floorf(__x);}
662inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return ::floorl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500663# endif
Richard Smith081bb592015-10-08 20:40:34 +0000664
665template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200666inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000667typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200668floor(_A1 __x) _NOEXCEPT {return ::floor((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000669
670// fmod
671
David Tenty7249ac92022-02-07 18:22:35 -0500672# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200673inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return ::fmodf(__x, __y);}
674inline _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 -0500675# endif
Richard Smith081bb592015-10-08 20:40:34 +0000676
677template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200678inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400679typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000680<
681 std::is_arithmetic<_A1>::value &&
682 std::is_arithmetic<_A2>::value,
683 std::__promote<_A1, _A2>
684>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200685fmod(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000686{
687 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000688 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
689 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200690 return ::fmod((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000691}
692
693// frexp
694
David Tenty7249ac92022-02-07 18:22:35 -0500695# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200696inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return ::frexpf(__x, __e);}
697inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {return ::frexpl(__x, __e);}
David Tenty7249ac92022-02-07 18:22:35 -0500698# endif
Richard Smith081bb592015-10-08 20:40:34 +0000699
700template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200701inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000702typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200703frexp(_A1 __x, int* __e) _NOEXCEPT {return ::frexp((double)__x, __e);}
Richard Smith081bb592015-10-08 20:40:34 +0000704
705// ldexp
706
David Tenty7249ac92022-02-07 18:22:35 -0500707# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200708inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return ::ldexpf(__x, __e);}
709inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {return ::ldexpl(__x, __e);}
David Tenty7249ac92022-02-07 18:22:35 -0500710# endif
Richard Smith081bb592015-10-08 20:40:34 +0000711
712template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200713inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000714typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200715ldexp(_A1 __x, int __e) _NOEXCEPT {return ::ldexp((double)__x, __e);}
Richard Smith081bb592015-10-08 20:40:34 +0000716
717// log
718
David Tenty7249ac92022-02-07 18:22:35 -0500719# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200720inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return ::logf(__x);}
721inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT {return ::logl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500722# endif
Richard Smith081bb592015-10-08 20:40:34 +0000723
724template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200725inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000726typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200727log(_A1 __x) _NOEXCEPT {return ::log((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000728
729// log10
730
David Tenty7249ac92022-02-07 18:22:35 -0500731# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200732inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return ::log10f(__x);}
733inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT {return ::log10l(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500734# endif
Richard Smith081bb592015-10-08 20:40:34 +0000735
736template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200737inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000738typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200739log10(_A1 __x) _NOEXCEPT {return ::log10((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000740
741// modf
742
David Tenty7249ac92022-02-07 18:22:35 -0500743# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200744inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return ::modff(__x, __y);}
745inline _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 -0500746# endif
Richard Smith081bb592015-10-08 20:40:34 +0000747
748// pow
749
David Tenty7249ac92022-02-07 18:22:35 -0500750# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200751inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return ::powf(__x, __y);}
752inline _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 -0500753# endif
Richard Smith081bb592015-10-08 20:40:34 +0000754
755template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200756inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400757typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000758<
759 std::is_arithmetic<_A1>::value &&
760 std::is_arithmetic<_A2>::value,
761 std::__promote<_A1, _A2>
762>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200763pow(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000764{
765 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000766 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
767 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200768 return ::pow((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000769}
770
771// sin
772
David Tenty7249ac92022-02-07 18:22:35 -0500773# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200774inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return ::sinf(__x);}
775inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT {return ::sinl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000776#endif
777
778template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200779inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000780typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200781sin(_A1 __x) _NOEXCEPT {return ::sin((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000782
783// sinh
784
David Tenty7249ac92022-02-07 18:22:35 -0500785# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200786inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return ::sinhf(__x);}
787inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT {return ::sinhl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500788# endif
Richard Smith081bb592015-10-08 20:40:34 +0000789
790template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200791inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000792typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200793sinh(_A1 __x) _NOEXCEPT {return ::sinh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000794
795// sqrt
796
David Tenty7249ac92022-02-07 18:22:35 -0500797# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200798inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return ::sqrtf(__x);}
799inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT {return ::sqrtl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500800# endif
Richard Smith081bb592015-10-08 20:40:34 +0000801
Richard Smith081bb592015-10-08 20:40:34 +0000802template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200803inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000804typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200805sqrt(_A1 __x) _NOEXCEPT {return ::sqrt((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000806
807// tan
808
David Tenty7249ac92022-02-07 18:22:35 -0500809# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200810inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return ::tanf(__x);}
811inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT {return ::tanl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500812# endif
Richard Smith081bb592015-10-08 20:40:34 +0000813
814template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200815inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000816typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200817tan(_A1 __x) _NOEXCEPT {return ::tan((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000818
819// tanh
820
David Tenty7249ac92022-02-07 18:22:35 -0500821# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200822inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return ::tanhf(__x);}
823inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT {return ::tanhl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500824# endif
Richard Smith081bb592015-10-08 20:40:34 +0000825
826template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200827inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000828typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200829tanh(_A1 __x) _NOEXCEPT {return ::tanh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000830
831// acosh
832
Nikolas Klauser9806f452022-10-12 15:45:09 +0200833inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return ::acoshf(__x);}
834inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT {return ::acoshl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000835
836template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200837inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000838typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200839acosh(_A1 __x) _NOEXCEPT {return ::acosh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000840
841// asinh
842
Nikolas Klauser9806f452022-10-12 15:45:09 +0200843inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return ::asinhf(__x);}
844inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT {return ::asinhl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000845
846template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200847inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000848typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200849asinh(_A1 __x) _NOEXCEPT {return ::asinh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000850
851// atanh
852
Nikolas Klauser9806f452022-10-12 15:45:09 +0200853inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return ::atanhf(__x);}
854inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT {return ::atanhl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000855
856template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200857inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000858typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200859atanh(_A1 __x) _NOEXCEPT {return ::atanh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000860
861// cbrt
862
Nikolas Klauser9806f452022-10-12 15:45:09 +0200863inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return ::cbrtf(__x);}
864inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {return ::cbrtl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000865
866template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200867inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000868typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200869cbrt(_A1 __x) _NOEXCEPT {return ::cbrt((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000870
871// copysign
872
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200873_LIBCPP_CONSTEXPR
Nikolas Klauser9806f452022-10-12 15:45:09 +0200874inline _LIBCPP_HIDE_FROM_ABI float __libcpp_copysign(float __x, float __y) _NOEXCEPT {
Nikolas Klauser9806f452022-10-12 15:45:09 +0200875 return __builtin_copysignf(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000876}
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200877
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200878_LIBCPP_CONSTEXPR
Nikolas Klauser9806f452022-10-12 15:45:09 +0200879inline _LIBCPP_HIDE_FROM_ABI double __libcpp_copysign(double __x, double __y) _NOEXCEPT {
Nikolas Klauser9806f452022-10-12 15:45:09 +0200880 return __builtin_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200881}
882
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200883_LIBCPP_CONSTEXPR
Nikolas Klauser9806f452022-10-12 15:45:09 +0200884inline _LIBCPP_HIDE_FROM_ABI long double __libcpp_copysign(long double __x, long double __y) _NOEXCEPT {
Nikolas Klauser9806f452022-10-12 15:45:09 +0200885 return __builtin_copysignl(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000886}
Richard Smith081bb592015-10-08 20:40:34 +0000887
888template <class _A1, class _A2>
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200889_LIBCPP_CONSTEXPR
Nikolas Klauser4956e722022-10-12 15:41:22 +0200890inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400891typename std::__enable_if_t
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200892<
893 std::is_arithmetic<_A1>::value &&
894 std::is_arithmetic<_A2>::value,
895 std::__promote<_A1, _A2>
896>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200897__libcpp_copysign(_A1 __x, _A2 __y) _NOEXCEPT {
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200898 typedef typename std::__promote<_A1, _A2>::type __result_type;
899 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
900 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200901 return __builtin_copysign((__result_type)__x, (__result_type)__y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200902}
903
Nikolas Klauser9806f452022-10-12 15:45:09 +0200904inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT {
905 return ::__libcpp_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200906}
907
Nikolas Klauser9806f452022-10-12 15:45:09 +0200908inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT {
909 return ::__libcpp_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200910}
911
912template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200913inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400914typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000915<
916 std::is_arithmetic<_A1>::value &&
917 std::is_arithmetic<_A2>::value,
918 std::__promote<_A1, _A2>
919>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200920 copysign(_A1 __x, _A2 __y) _NOEXCEPT {
921 return ::__libcpp_copysign(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000922}
923
Richard Smith081bb592015-10-08 20:40:34 +0000924// erf
925
Nikolas Klauser9806f452022-10-12 15:45:09 +0200926inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return ::erff(__x);}
927inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT {return ::erfl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000928
929template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200930inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000931typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200932erf(_A1 __x) _NOEXCEPT {return ::erf((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000933
934// erfc
935
Nikolas Klauser9806f452022-10-12 15:45:09 +0200936inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return ::erfcf(__x);}
937inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT {return ::erfcl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000938
939template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200940inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000941typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200942erfc(_A1 __x) _NOEXCEPT {return ::erfc((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000943
944// exp2
945
Nikolas Klauser9806f452022-10-12 15:45:09 +0200946inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return ::exp2f(__x);}
947inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT {return ::exp2l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000948
949template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200950inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000951typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200952exp2(_A1 __x) _NOEXCEPT {return ::exp2((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000953
954// expm1
955
Nikolas Klauser9806f452022-10-12 15:45:09 +0200956inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return ::expm1f(__x);}
957inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT {return ::expm1l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000958
959template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200960inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000961typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200962expm1(_A1 __x) _NOEXCEPT {return ::expm1((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000963
964// fdim
965
Nikolas Klauser9806f452022-10-12 15:45:09 +0200966inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return ::fdimf(__x, __y);}
967inline _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 +0000968
969template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200970inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400971typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000972<
973 std::is_arithmetic<_A1>::value &&
974 std::is_arithmetic<_A2>::value,
975 std::__promote<_A1, _A2>
976>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200977fdim(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000978{
979 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000980 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
981 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200982 return ::fdim((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000983}
984
985// fma
986
Nikolas Klauser9806f452022-10-12 15:45:09 +0200987inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500988{
Nikolas Klauser9806f452022-10-12 15:45:09 +0200989 return __builtin_fmaf(__x, __y, __z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500990}
Nikolas Klauser9806f452022-10-12 15:45:09 +0200991inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500992{
Nikolas Klauser9806f452022-10-12 15:45:09 +0200993 return __builtin_fmal(__x, __y, __z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500994}
Richard Smith081bb592015-10-08 20:40:34 +0000995
996template <class _A1, class _A2, class _A3>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200997inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400998typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000999<
1000 std::is_arithmetic<_A1>::value &&
1001 std::is_arithmetic<_A2>::value &&
1002 std::is_arithmetic<_A3>::value,
1003 std::__promote<_A1, _A2, _A3>
1004>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001005fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001006{
1007 typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001008 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1009 std::_IsSame<_A2, __result_type>::value &&
1010 std::_IsSame<_A3, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001011 return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
Richard Smith081bb592015-10-08 20:40:34 +00001012}
1013
1014// fmax
1015
Nikolas Klauser9806f452022-10-12 15:45:09 +02001016inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return ::fmaxf(__x, __y);}
1017inline _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 +00001018
1019template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001020inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001021typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001022<
1023 std::is_arithmetic<_A1>::value &&
1024 std::is_arithmetic<_A2>::value,
1025 std::__promote<_A1, _A2>
1026>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001027fmax(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001028{
1029 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001030 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1031 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001032 return ::fmax((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001033}
1034
1035// fmin
1036
Nikolas Klauser9806f452022-10-12 15:45:09 +02001037inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return ::fminf(__x, __y);}
1038inline _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 +00001039
1040template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001041inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001042typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001043<
1044 std::is_arithmetic<_A1>::value &&
1045 std::is_arithmetic<_A2>::value,
1046 std::__promote<_A1, _A2>
1047>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001048fmin(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001049{
1050 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001051 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1052 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001053 return ::fmin((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001054}
1055
1056// hypot
1057
Nikolas Klauser9806f452022-10-12 15:45:09 +02001058inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return ::hypotf(__x, __y);}
1059inline _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 +00001060
1061template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001062inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001063typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001064<
1065 std::is_arithmetic<_A1>::value &&
1066 std::is_arithmetic<_A2>::value,
1067 std::__promote<_A1, _A2>
1068>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001069hypot(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001070{
1071 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001072 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1073 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001074 return ::hypot((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001075}
1076
1077// ilogb
1078
Nikolas Klauser9806f452022-10-12 15:45:09 +02001079inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return ::ilogbf(__x);}
1080inline _LIBCPP_HIDE_FROM_ABI int ilogb(long double __x) _NOEXCEPT {return ::ilogbl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001081
1082template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001083inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001084typename std::enable_if<std::is_integral<_A1>::value, int>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001085ilogb(_A1 __x) _NOEXCEPT {return ::ilogb((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001086
1087// lgamma
1088
Nikolas Klauser9806f452022-10-12 15:45:09 +02001089inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return ::lgammaf(__x);}
1090inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT {return ::lgammal(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001091
1092template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001093inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001094typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001095lgamma(_A1 __x) _NOEXCEPT {return ::lgamma((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001096
1097// llrint
1098
Nikolas Klauser9806f452022-10-12 15:45:09 +02001099inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001100{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001101 return __builtin_llrintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001102}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001103inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001104{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001105 return __builtin_llrintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001106}
Richard Smith081bb592015-10-08 20:40:34 +00001107
1108template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001109inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001110typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001111llrint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001112{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001113 return __builtin_llrint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001114}
Richard Smith081bb592015-10-08 20:40:34 +00001115
1116// llround
1117
Nikolas Klauser9806f452022-10-12 15:45:09 +02001118inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001119{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001120 return __builtin_llroundf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001121}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001122inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001123{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001124 return __builtin_llroundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001125}
Richard Smith081bb592015-10-08 20:40:34 +00001126
1127template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001128inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001129typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001130llround(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001131{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001132 return __builtin_llround((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001133}
Richard Smith081bb592015-10-08 20:40:34 +00001134
1135// log1p
1136
Nikolas Klauser9806f452022-10-12 15:45:09 +02001137inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return ::log1pf(__x);}
1138inline _LIBCPP_HIDE_FROM_ABI long double log1p(long double __x) _NOEXCEPT {return ::log1pl(__x);}
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, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001143log1p(_A1 __x) _NOEXCEPT {return ::log1p((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001144
1145// log2
1146
Nikolas Klauser9806f452022-10-12 15:45:09 +02001147inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return ::log2f(__x);}
1148inline _LIBCPP_HIDE_FROM_ABI long double log2(long double __x) _NOEXCEPT {return ::log2l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001149
1150template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001151inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001152typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001153log2(_A1 __x) _NOEXCEPT {return ::log2((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001154
1155// logb
1156
Nikolas Klauser9806f452022-10-12 15:45:09 +02001157inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return ::logbf(__x);}
1158inline _LIBCPP_HIDE_FROM_ABI long double logb(long double __x) _NOEXCEPT {return ::logbl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001159
1160template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001161inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001162typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001163logb(_A1 __x) _NOEXCEPT {return ::logb((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001164
1165// lrint
1166
Nikolas Klauser9806f452022-10-12 15:45:09 +02001167inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001168{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001169 return __builtin_lrintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001170}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001171inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001172{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001173 return __builtin_lrintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001174}
Richard Smith081bb592015-10-08 20:40:34 +00001175
1176template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001177inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001178typename std::enable_if<std::is_integral<_A1>::value, long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001179lrint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001180{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001181 return __builtin_lrint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001182}
Richard Smith081bb592015-10-08 20:40:34 +00001183
1184// lround
1185
Nikolas Klauser9806f452022-10-12 15:45:09 +02001186inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001187{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001188 return __builtin_lroundf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001189}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001190inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001191{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001192 return __builtin_lroundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001193}
Richard Smith081bb592015-10-08 20:40:34 +00001194
1195template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001196inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001197typename std::enable_if<std::is_integral<_A1>::value, long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001198lround(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001199{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001200 return __builtin_lround((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001201}
Richard Smith081bb592015-10-08 20:40:34 +00001202
1203// nan
1204
1205// nearbyint
1206
Nikolas Klauser9806f452022-10-12 15:45:09 +02001207inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return ::nearbyintf(__x);}
1208inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {return ::nearbyintl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001209
1210template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001211inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001212typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001213nearbyint(_A1 __x) _NOEXCEPT {return ::nearbyint((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001214
1215// nextafter
1216
Nikolas Klauser9806f452022-10-12 15:45:09 +02001217inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return ::nextafterf(__x, __y);}
1218inline _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 +00001219
1220template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001221inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001222typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001223<
1224 std::is_arithmetic<_A1>::value &&
1225 std::is_arithmetic<_A2>::value,
1226 std::__promote<_A1, _A2>
1227>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001228nextafter(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001229{
1230 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001231 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1232 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001233 return ::nextafter((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001234}
1235
1236// nexttoward
1237
Nikolas Klauser9806f452022-10-12 15:45:09 +02001238inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return ::nexttowardf(__x, __y);}
1239inline _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 +00001240
1241template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001242inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001243typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001244nexttoward(_A1 __x, long double __y) _NOEXCEPT {return ::nexttoward((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001245
1246// remainder
1247
Nikolas Klauser9806f452022-10-12 15:45:09 +02001248inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return ::remainderf(__x, __y);}
1249inline _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 +00001250
1251template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001252inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001253typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001254<
1255 std::is_arithmetic<_A1>::value &&
1256 std::is_arithmetic<_A2>::value,
1257 std::__promote<_A1, _A2>
1258>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001259remainder(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001260{
1261 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001262 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1263 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001264 return ::remainder((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001265}
1266
1267// remquo
1268
Nikolas Klauser9806f452022-10-12 15:45:09 +02001269inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return ::remquof(__x, __y, __z);}
1270inline _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 +00001271
1272template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001273inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001274typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001275<
1276 std::is_arithmetic<_A1>::value &&
1277 std::is_arithmetic<_A2>::value,
1278 std::__promote<_A1, _A2>
1279>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001280remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001281{
1282 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001283 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1284 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001285 return ::remquo((__result_type)__x, (__result_type)__y, __z);
Richard Smith081bb592015-10-08 20:40:34 +00001286}
1287
1288// rint
1289
Nikolas Klauser9806f452022-10-12 15:45:09 +02001290inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001291{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001292 return __builtin_rintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001293}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001294inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001295{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001296 return __builtin_rintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001297}
Richard Smith081bb592015-10-08 20:40:34 +00001298
1299template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001300inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001301typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001302rint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001303{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001304 return __builtin_rint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001305}
Richard Smith081bb592015-10-08 20:40:34 +00001306
1307// round
1308
Nikolas Klauser9806f452022-10-12 15:45:09 +02001309inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001310{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001311 return __builtin_round(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001312}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001313inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001314{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001315 return __builtin_roundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001316}
Richard Smith081bb592015-10-08 20:40:34 +00001317
1318template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001319inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001320typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001321round(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001322{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001323 return __builtin_round((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001324}
Richard Smith081bb592015-10-08 20:40:34 +00001325
1326// scalbln
1327
Nikolas Klauser9806f452022-10-12 15:45:09 +02001328inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return ::scalblnf(__x, __y);}
1329inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT {return ::scalblnl(__x, __y);}
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 +02001334scalbln(_A1 __x, long __y) _NOEXCEPT {return ::scalbln((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001335
1336// scalbn
1337
Nikolas Klauser9806f452022-10-12 15:45:09 +02001338inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return ::scalbnf(__x, __y);}
1339inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT {return ::scalbnl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001340
1341template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001342inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001343typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001344scalbn(_A1 __x, int __y) _NOEXCEPT {return ::scalbn((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001345
1346// tgamma
1347
Nikolas Klauser9806f452022-10-12 15:45:09 +02001348inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return ::tgammaf(__x);}
1349inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT {return ::tgammal(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001350
1351template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001352inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001353typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001354tgamma(_A1 __x) _NOEXCEPT {return ::tgamma((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001355
1356// trunc
1357
Nikolas Klauser9806f452022-10-12 15:45:09 +02001358inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001359{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001360 return __builtin_trunc(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001361}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001362inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001363{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001364 return __builtin_truncl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001365}
Richard Smith081bb592015-10-08 20:40:34 +00001366
1367template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001368inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001369typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001370trunc(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001371{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001372 return __builtin_trunc((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001373}
Richard Smith081bb592015-10-08 20:40:34 +00001374
Richard Smith081bb592015-10-08 20:40:34 +00001375} // extern "C++"
1376
1377#endif // __cplusplus
1378
Mikhail Maltsev34b4f972018-02-22 09:34:08 +00001379#else // _LIBCPP_MATH_H
1380
1381// This include lives outside the header guard in order to support an MSVC
1382// extension which allows users to do:
1383//
1384// #define _USE_MATH_DEFINES
1385// #include <math.h>
1386//
1387// and receive the definitions of mathematical constants, even if <math.h>
1388// has previously been included.
1389#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
1390#include_next <math.h>
1391#endif
1392
Louis Dionne2b1ceaa2021-04-20 12:03:32 -04001393#endif // _LIBCPP_MATH_H