blob: b3990f314046e26f8d800e83609d2708df89c742 [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
Nikolas Klauserae1fbc42022-11-04 20:19:20 +0100315
316# ifdef fpclassify
317# undef fpclassify
318# endif
Richard Smith081bb592015-10-08 20:40:34 +0000319
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100320# ifdef signbit
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100321# undef signbit
Nikolas Klauserae1fbc42022-11-04 20:19:20 +0100322# endif
323
324# ifdef isfinite
325# undef isfinite
326# endif
327
328# ifdef isinf
329# undef isinf
330# endif
331
332# ifdef isnan
333# undef isnan
334# endif
335
336# ifdef isnormal
337# undef isnormal
338# endif
339
340# ifdef isgreater
341# undef isgreater
342# endif
343
344# ifdef isgreaterequal
345# undef isgreaterequal
346# endif
347
348# ifdef isless
349# undef isless
350# endif
351
352# ifdef islessequal
353# undef islessequal
354# endif
355
356# ifdef islessgreater
357# undef islessgreater
358# endif
359
360# ifdef isunordered
361# undef isunordered
362# endif
363
364// signbit
Richard Smith081bb592015-10-08 20:40:34 +0000365
Nikolas Klausere96070f2022-11-04 20:08:56 +0100366template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
367inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100368 return __builtin_signbit(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000369}
370
Nikolas Klausere96070f2022-11-04 20:08:56 +0100371template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && std::is_signed<_A1>::value, int> = 0>
372inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100373 return __x < 0;
374}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000375
Nikolas Klausere96070f2022-11-04 20:08:56 +0100376template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && !std::is_signed<_A1>::value, int> = 0>
377inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100378 return false;
379}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000380
Richard Smith081bb592015-10-08 20:40:34 +0000381// fpclassify
382
Nikolas Klausere96070f2022-11-04 20:08:56 +0100383template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
384inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100385 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
Richard Smith081bb592015-10-08 20:40:34 +0000386}
387
Nikolas Klausere96070f2022-11-04 20:08:56 +0100388template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
389inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100390 return __x == 0 ? FP_ZERO : FP_NORMAL;
391}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000392
Nikolas Klauserae1fbc42022-11-04 20:19:20 +0100393// The MSVC runtime already provides these functions as templates
394#ifndef _LIBCPP_MSVCRT
Richard Smith081bb592015-10-08 20:40:34 +0000395
Nikolas Klauserae1fbc42022-11-04 20:19:20 +0100396// isfinite
Richard Smith081bb592015-10-08 20:40:34 +0000397
Nikolas Klausere96070f2022-11-04 20:08:56 +0100398template <class _A1,
399 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
400inline _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100401 return __builtin_isfinite((typename std::__promote<_A1>::type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000402}
403
Nikolas Klausere96070f2022-11-04 20:08:56 +0100404template <class _A1,
405 std::__enable_if_t<std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, int> = 0>
406inline _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100407 return true;
408}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000409
Richard Smith081bb592015-10-08 20:40:34 +0000410// isinf
411
Nikolas Klausere96070f2022-11-04 20:08:56 +0100412template <class _A1,
413 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
414inline _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100415 return __builtin_isinf((typename std::__promote<_A1>::type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000416}
417
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000418template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200419inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100420 typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type
421 isinf(_A1) _NOEXCEPT {
422 return false;
423}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000424
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100425# ifdef _LIBCPP_PREFERRED_OVERLOAD
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100426inline _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { return __builtin_isinf(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000427
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100428inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT { return __builtin_isinf(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000429
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100430inline _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { return __builtin_isinf(__x); }
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100431# endif
Richard Smithafccfd32018-05-01 03:05:40 +0000432
Richard Smith081bb592015-10-08 20:40:34 +0000433// isnan
434
Nikolas Klausere96070f2022-11-04 20:08:56 +0100435template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
436inline _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100437 return __builtin_isnan(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000438}
439
Nikolas Klausere96070f2022-11-04 20:08:56 +0100440template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
441inline _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100442 return false;
443}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000444
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100445# ifdef _LIBCPP_PREFERRED_OVERLOAD
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100446inline _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { return __builtin_isnan(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000447
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100448inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT { return __builtin_isnan(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000449
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100450inline _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { return __builtin_isnan(__x); }
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100451# endif
Richard Smithafccfd32018-05-01 03:05:40 +0000452
Richard Smith081bb592015-10-08 20:40:34 +0000453// isnormal
454
Nikolas Klausere96070f2022-11-04 20:08:56 +0100455template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
456inline _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100457 return __builtin_isnormal(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000458}
459
Nikolas Klausere96070f2022-11-04 20:08:56 +0100460template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
461inline _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100462 return __x != 0;
463}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000464
Richard Smith081bb592015-10-08 20:40:34 +0000465// isgreater
466
Nikolas Klausere96070f2022-11-04 20:08:56 +0100467template <class _A1,
468 class _A2,
469 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
470inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100471 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100472 return __builtin_isgreater((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000473}
474
Richard Smith081bb592015-10-08 20:40:34 +0000475// isgreaterequal
476
Nikolas Klausere96070f2022-11-04 20:08:56 +0100477template <class _A1,
478 class _A2,
479 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
480inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100481 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100482 return __builtin_isgreaterequal((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000483}
484
Richard Smith081bb592015-10-08 20:40:34 +0000485// isless
486
Nikolas Klausere96070f2022-11-04 20:08:56 +0100487template <class _A1,
488 class _A2,
489 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
490inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100491 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100492 return __builtin_isless((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000493}
494
Richard Smith081bb592015-10-08 20:40:34 +0000495// islessequal
496
Nikolas Klausere96070f2022-11-04 20:08:56 +0100497template <class _A1,
498 class _A2,
499 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
500inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100501 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100502 return __builtin_islessequal((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000503}
504
Richard Smith081bb592015-10-08 20:40:34 +0000505// islessgreater
506
Nikolas Klausere96070f2022-11-04 20:08:56 +0100507template <class _A1,
508 class _A2,
509 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
510inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100511 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100512 return __builtin_islessgreater((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000513}
514
Richard Smith081bb592015-10-08 20:40:34 +0000515// isunordered
516
Nikolas Klausere96070f2022-11-04 20:08:56 +0100517template <class _A1,
518 class _A2,
519 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
520inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100521 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser25fbc472022-11-04 16:56:51 +0100522 return __builtin_isunordered((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000523}
524
Nikolas Klauserae1fbc42022-11-04 20:19:20 +0100525#endif // _LIBCPP_MSVCRT
Richard Smith081bb592015-10-08 20:40:34 +0000526
Richard Smith081bb592015-10-08 20:40:34 +0000527// abs
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500528//
529// handled in stdlib.h
Richard Smith081bb592015-10-08 20:40:34 +0000530
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000531// div
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500532//
533// handled in stdlib.h
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000534
Richard Smith081bb592015-10-08 20:40:34 +0000535// acos
536
David Tenty7249ac92022-02-07 18:22:35 -0500537# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200538inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return __builtin_acosf(__x);}
539inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT {return __builtin_acosl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500540# endif
Richard Smith081bb592015-10-08 20:40:34 +0000541
542template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200543inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000544typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200545acos(_A1 __x) _NOEXCEPT {return __builtin_acos((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000546
547// asin
548
David Tenty7249ac92022-02-07 18:22:35 -0500549# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200550inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return __builtin_asinf(__x);}
551inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT {return __builtin_asinl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500552# endif
Richard Smith081bb592015-10-08 20:40:34 +0000553
554template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200555inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000556typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200557asin(_A1 __x) _NOEXCEPT {return __builtin_asin((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000558
559// atan
560
David Tenty7249ac92022-02-07 18:22:35 -0500561# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200562inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return __builtin_atanf(__x);}
563inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT {return __builtin_atanl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500564# endif
Richard Smith081bb592015-10-08 20:40:34 +0000565
566template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200567inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000568typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200569atan(_A1 __x) _NOEXCEPT {return __builtin_atan((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000570
571// atan2
572
David Tenty7249ac92022-02-07 18:22:35 -0500573# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200574inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return __builtin_atan2f(__y, __x);}
575inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) _NOEXCEPT {return __builtin_atan2l(__y, __x);}
David Tenty7249ac92022-02-07 18:22:35 -0500576# endif
Richard Smith081bb592015-10-08 20:40:34 +0000577
578template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200579inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400580typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000581<
582 std::is_arithmetic<_A1>::value &&
583 std::is_arithmetic<_A2>::value,
584 std::__promote<_A1, _A2>
585>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200586atan2(_A1 __y, _A2 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000587{
588 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000589 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
590 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200591 return ::atan2((__result_type)__y, (__result_type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000592}
593
594// ceil
595
David Tenty7249ac92022-02-07 18:22:35 -0500596# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200597inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return __builtin_ceilf(__x);}
598inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return __builtin_ceill(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500599# endif
Richard Smith081bb592015-10-08 20:40:34 +0000600
601template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200602inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000603typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200604ceil(_A1 __x) _NOEXCEPT {return __builtin_ceil((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000605
606// cos
607
David Tenty7249ac92022-02-07 18:22:35 -0500608# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200609inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return __builtin_cosf(__x);}
610inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT {return __builtin_cosl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500611# endif
Richard Smith081bb592015-10-08 20:40:34 +0000612
613template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200614inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000615typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200616cos(_A1 __x) _NOEXCEPT {return __builtin_cos((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000617
618// cosh
619
David Tenty7249ac92022-02-07 18:22:35 -0500620# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200621inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return __builtin_coshf(__x);}
622inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT {return __builtin_coshl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500623# endif
Richard Smith081bb592015-10-08 20:40:34 +0000624
625template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200626inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000627typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200628cosh(_A1 __x) _NOEXCEPT {return __builtin_cosh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000629
630// exp
631
David Tenty7249ac92022-02-07 18:22:35 -0500632# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200633inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return __builtin_expf(__x);}
634inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT {return __builtin_expl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500635# endif
Richard Smith081bb592015-10-08 20:40:34 +0000636
637template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200638inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000639typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200640exp(_A1 __x) _NOEXCEPT {return __builtin_exp((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000641
642// fabs
643
David Tenty7249ac92022-02-07 18:22:35 -0500644# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200645inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return __builtin_fabsf(__x);}
646inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return __builtin_fabsl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500647# endif
Richard Smith081bb592015-10-08 20:40:34 +0000648
649template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200650inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000651typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200652fabs(_A1 __x) _NOEXCEPT {return __builtin_fabs((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000653
654// floor
655
David Tenty7249ac92022-02-07 18:22:35 -0500656# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200657inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return __builtin_floorf(__x);}
658inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return __builtin_floorl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500659# endif
Richard Smith081bb592015-10-08 20:40:34 +0000660
661template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200662inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000663typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200664floor(_A1 __x) _NOEXCEPT {return __builtin_floor((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000665
666// fmod
667
David Tenty7249ac92022-02-07 18:22:35 -0500668# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200669inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return __builtin_fmodf(__x, __y);}
670inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) _NOEXCEPT {return __builtin_fmodl(__x, __y);}
David Tenty7249ac92022-02-07 18:22:35 -0500671# endif
Richard Smith081bb592015-10-08 20:40:34 +0000672
673template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200674inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400675typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000676<
677 std::is_arithmetic<_A1>::value &&
678 std::is_arithmetic<_A2>::value,
679 std::__promote<_A1, _A2>
680>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200681fmod(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000682{
683 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000684 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
685 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200686 return ::fmod((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000687}
688
689// frexp
690
David Tenty7249ac92022-02-07 18:22:35 -0500691# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200692inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return __builtin_frexpf(__x, __e);}
693inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {return __builtin_frexpl(__x, __e);}
David Tenty7249ac92022-02-07 18:22:35 -0500694# endif
Richard Smith081bb592015-10-08 20:40:34 +0000695
696template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200697inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000698typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200699frexp(_A1 __x, int* __e) _NOEXCEPT {return __builtin_frexp((double)__x, __e);}
Richard Smith081bb592015-10-08 20:40:34 +0000700
701// ldexp
702
David Tenty7249ac92022-02-07 18:22:35 -0500703# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200704inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return __builtin_ldexpf(__x, __e);}
705inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {return __builtin_ldexpl(__x, __e);}
David Tenty7249ac92022-02-07 18:22:35 -0500706# endif
Richard Smith081bb592015-10-08 20:40:34 +0000707
708template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200709inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000710typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200711ldexp(_A1 __x, int __e) _NOEXCEPT {return __builtin_ldexp((double)__x, __e);}
Richard Smith081bb592015-10-08 20:40:34 +0000712
713// log
714
David Tenty7249ac92022-02-07 18:22:35 -0500715# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200716inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return __builtin_logf(__x);}
717inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT {return __builtin_logl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500718# endif
Richard Smith081bb592015-10-08 20:40:34 +0000719
720template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200721inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000722typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200723log(_A1 __x) _NOEXCEPT {return __builtin_log((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000724
725// log10
726
David Tenty7249ac92022-02-07 18:22:35 -0500727# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200728inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return __builtin_log10f(__x);}
729inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT {return __builtin_log10l(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500730# endif
Richard Smith081bb592015-10-08 20:40:34 +0000731
732template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200733inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000734typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200735log10(_A1 __x) _NOEXCEPT {return __builtin_log10((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000736
737// modf
738
David Tenty7249ac92022-02-07 18:22:35 -0500739# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200740inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return __builtin_modff(__x, __y);}
741inline _LIBCPP_HIDE_FROM_ABI long double modf(long double __x, long double* __y) _NOEXCEPT {return __builtin_modfl(__x, __y);}
David Tenty7249ac92022-02-07 18:22:35 -0500742# endif
Richard Smith081bb592015-10-08 20:40:34 +0000743
744// pow
745
David Tenty7249ac92022-02-07 18:22:35 -0500746# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200747inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return __builtin_powf(__x, __y);}
748inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _NOEXCEPT {return __builtin_powl(__x, __y);}
David Tenty7249ac92022-02-07 18:22:35 -0500749# endif
Richard Smith081bb592015-10-08 20:40:34 +0000750
751template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200752inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400753typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000754<
755 std::is_arithmetic<_A1>::value &&
756 std::is_arithmetic<_A2>::value,
757 std::__promote<_A1, _A2>
758>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200759pow(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000760{
761 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000762 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
763 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200764 return ::pow((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000765}
766
767// sin
768
David Tenty7249ac92022-02-07 18:22:35 -0500769# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200770inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return __builtin_sinf(__x);}
771inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT {return __builtin_sinl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000772#endif
773
774template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200775inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000776typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200777sin(_A1 __x) _NOEXCEPT {return __builtin_sin((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000778
779// sinh
780
David Tenty7249ac92022-02-07 18:22:35 -0500781# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200782inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return __builtin_sinhf(__x);}
783inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT {return __builtin_sinhl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500784# endif
Richard Smith081bb592015-10-08 20:40:34 +0000785
786template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200787inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000788typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200789sinh(_A1 __x) _NOEXCEPT {return __builtin_sinh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000790
791// sqrt
792
David Tenty7249ac92022-02-07 18:22:35 -0500793# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200794inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return __builtin_sqrtf(__x);}
795inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT {return __builtin_sqrtl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500796# endif
Richard Smith081bb592015-10-08 20:40:34 +0000797
Richard Smith081bb592015-10-08 20:40:34 +0000798template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200799inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000800typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200801sqrt(_A1 __x) _NOEXCEPT {return __builtin_sqrt((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000802
803// tan
804
David Tenty7249ac92022-02-07 18:22:35 -0500805# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200806inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return __builtin_tanf(__x);}
807inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT {return __builtin_tanl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500808# endif
Richard Smith081bb592015-10-08 20:40:34 +0000809
810template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200811inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000812typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200813tan(_A1 __x) _NOEXCEPT {return __builtin_tan((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000814
815// tanh
816
David Tenty7249ac92022-02-07 18:22:35 -0500817# if !defined(__sun__)
Nikolas Klauser04005952022-10-21 01:41:22 +0200818inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return __builtin_tanhf(__x);}
819inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT {return __builtin_tanhl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500820# endif
Richard Smith081bb592015-10-08 20:40:34 +0000821
822template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200823inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000824typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200825tanh(_A1 __x) _NOEXCEPT {return __builtin_tanh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000826
827// acosh
828
Nikolas Klauser04005952022-10-21 01:41:22 +0200829inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return __builtin_acoshf(__x);}
830inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT {return __builtin_acoshl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000831
832template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200833inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000834typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200835acosh(_A1 __x) _NOEXCEPT {return __builtin_acosh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000836
837// asinh
838
Nikolas Klauser04005952022-10-21 01:41:22 +0200839inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return __builtin_asinhf(__x);}
840inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT {return __builtin_asinhl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000841
842template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200843inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000844typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200845asinh(_A1 __x) _NOEXCEPT {return __builtin_asinh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000846
847// atanh
848
Nikolas Klauser04005952022-10-21 01:41:22 +0200849inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return __builtin_atanhf(__x);}
850inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT {return __builtin_atanhl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000851
852template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200853inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000854typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200855atanh(_A1 __x) _NOEXCEPT {return __builtin_atanh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000856
857// cbrt
858
Nikolas Klauser04005952022-10-21 01:41:22 +0200859inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return __builtin_cbrtf(__x);}
860inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {return __builtin_cbrtl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000861
862template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200863inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000864typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200865cbrt(_A1 __x) _NOEXCEPT {return __builtin_cbrt((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000866
867// copysign
868
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200869_LIBCPP_CONSTEXPR
Nikolas Klauser9806f452022-10-12 15:45:09 +0200870inline _LIBCPP_HIDE_FROM_ABI float __libcpp_copysign(float __x, float __y) _NOEXCEPT {
Nikolas Klauser9806f452022-10-12 15:45:09 +0200871 return __builtin_copysignf(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000872}
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200873
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200874_LIBCPP_CONSTEXPR
Nikolas Klauser9806f452022-10-12 15:45:09 +0200875inline _LIBCPP_HIDE_FROM_ABI double __libcpp_copysign(double __x, double __y) _NOEXCEPT {
Nikolas Klauser9806f452022-10-12 15:45:09 +0200876 return __builtin_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200877}
878
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200879_LIBCPP_CONSTEXPR
Nikolas Klauser9806f452022-10-12 15:45:09 +0200880inline _LIBCPP_HIDE_FROM_ABI long double __libcpp_copysign(long double __x, long double __y) _NOEXCEPT {
Nikolas Klauser9806f452022-10-12 15:45:09 +0200881 return __builtin_copysignl(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000882}
Richard Smith081bb592015-10-08 20:40:34 +0000883
884template <class _A1, class _A2>
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200885_LIBCPP_CONSTEXPR
Nikolas Klauser4956e722022-10-12 15:41:22 +0200886inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400887typename std::__enable_if_t
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200888<
889 std::is_arithmetic<_A1>::value &&
890 std::is_arithmetic<_A2>::value,
891 std::__promote<_A1, _A2>
892>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200893__libcpp_copysign(_A1 __x, _A2 __y) _NOEXCEPT {
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200894 typedef typename std::__promote<_A1, _A2>::type __result_type;
895 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
896 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200897 return __builtin_copysign((__result_type)__x, (__result_type)__y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200898}
899
Nikolas Klauser9806f452022-10-12 15:45:09 +0200900inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT {
901 return ::__libcpp_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200902}
903
Nikolas Klauser9806f452022-10-12 15:45:09 +0200904inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT {
905 return ::__libcpp_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200906}
907
908template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200909inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400910typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000911<
912 std::is_arithmetic<_A1>::value &&
913 std::is_arithmetic<_A2>::value,
914 std::__promote<_A1, _A2>
915>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200916 copysign(_A1 __x, _A2 __y) _NOEXCEPT {
917 return ::__libcpp_copysign(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000918}
919
Richard Smith081bb592015-10-08 20:40:34 +0000920// erf
921
Nikolas Klauser04005952022-10-21 01:41:22 +0200922inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return __builtin_erff(__x);}
923inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT {return __builtin_erfl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000924
925template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200926inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000927typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200928erf(_A1 __x) _NOEXCEPT {return __builtin_erf((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000929
930// erfc
931
Nikolas Klauser04005952022-10-21 01:41:22 +0200932inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return __builtin_erfcf(__x);}
933inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT {return __builtin_erfcl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000934
935template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200936inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000937typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200938erfc(_A1 __x) _NOEXCEPT {return __builtin_erfc((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000939
940// exp2
941
Nikolas Klauser04005952022-10-21 01:41:22 +0200942inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return __builtin_exp2f(__x);}
943inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT {return __builtin_exp2l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000944
945template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200946inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000947typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200948exp2(_A1 __x) _NOEXCEPT {return __builtin_exp2((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000949
950// expm1
951
Nikolas Klauser04005952022-10-21 01:41:22 +0200952inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return __builtin_expm1f(__x);}
953inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT {return __builtin_expm1l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000954
955template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200956inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000957typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +0200958expm1(_A1 __x) _NOEXCEPT {return __builtin_expm1((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000959
960// fdim
961
Nikolas Klauser04005952022-10-21 01:41:22 +0200962inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return __builtin_fdimf(__x, __y);}
963inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) _NOEXCEPT {return __builtin_fdiml(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +0000964
965template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200966inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400967typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000968<
969 std::is_arithmetic<_A1>::value &&
970 std::is_arithmetic<_A2>::value,
971 std::__promote<_A1, _A2>
972>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200973fdim(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000974{
975 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000976 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
977 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200978 return ::fdim((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000979}
980
981// fma
982
Nikolas Klauser9806f452022-10-12 15:45:09 +0200983inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500984{
Nikolas Klauser9806f452022-10-12 15:45:09 +0200985 return __builtin_fmaf(__x, __y, __z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500986}
Nikolas Klauser9806f452022-10-12 15:45:09 +0200987inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500988{
Nikolas Klauser9806f452022-10-12 15:45:09 +0200989 return __builtin_fmal(__x, __y, __z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500990}
Richard Smith081bb592015-10-08 20:40:34 +0000991
992template <class _A1, class _A2, class _A3>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200993inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400994typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000995<
996 std::is_arithmetic<_A1>::value &&
997 std::is_arithmetic<_A2>::value &&
998 std::is_arithmetic<_A3>::value,
999 std::__promote<_A1, _A2, _A3>
1000>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001001fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001002{
1003 typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001004 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1005 std::_IsSame<_A2, __result_type>::value &&
1006 std::_IsSame<_A3, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001007 return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
Richard Smith081bb592015-10-08 20:40:34 +00001008}
1009
1010// fmax
1011
Nikolas Klauser04005952022-10-21 01:41:22 +02001012inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return __builtin_fmaxf(__x, __y);}
1013inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT {return __builtin_fmaxl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001014
1015template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001016inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001017typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001018<
1019 std::is_arithmetic<_A1>::value &&
1020 std::is_arithmetic<_A2>::value,
1021 std::__promote<_A1, _A2>
1022>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001023fmax(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001024{
1025 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001026 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1027 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001028 return ::fmax((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001029}
1030
1031// fmin
1032
Nikolas Klauser04005952022-10-21 01:41:22 +02001033inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return __builtin_fminf(__x, __y);}
1034inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT {return __builtin_fminl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001035
1036template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001037inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001038typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001039<
1040 std::is_arithmetic<_A1>::value &&
1041 std::is_arithmetic<_A2>::value,
1042 std::__promote<_A1, _A2>
1043>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001044fmin(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001045{
1046 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001047 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1048 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001049 return ::fmin((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001050}
1051
1052// hypot
1053
Nikolas Klauser04005952022-10-21 01:41:22 +02001054inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return __builtin_hypotf(__x, __y);}
1055inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) _NOEXCEPT {return __builtin_hypotl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001056
1057template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001058inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001059typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001060<
1061 std::is_arithmetic<_A1>::value &&
1062 std::is_arithmetic<_A2>::value,
1063 std::__promote<_A1, _A2>
1064>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001065hypot(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001066{
1067 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001068 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1069 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001070 return ::hypot((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001071}
1072
1073// ilogb
1074
Nikolas Klauser04005952022-10-21 01:41:22 +02001075inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return __builtin_ilogbf(__x);}
1076inline _LIBCPP_HIDE_FROM_ABI int ilogb(long double __x) _NOEXCEPT {return __builtin_ilogbl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001077
1078template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001079inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001080typename std::enable_if<std::is_integral<_A1>::value, int>::type
Nikolas Klauser04005952022-10-21 01:41:22 +02001081ilogb(_A1 __x) _NOEXCEPT {return __builtin_ilogb((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001082
1083// lgamma
1084
Nikolas Klauser04005952022-10-21 01:41:22 +02001085inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return __builtin_lgammaf(__x);}
1086inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT {return __builtin_lgammal(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001087
1088template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001089inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001090typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +02001091lgamma(_A1 __x) _NOEXCEPT {return __builtin_lgamma((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001092
1093// llrint
1094
Nikolas Klauser9806f452022-10-12 15:45:09 +02001095inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001096{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001097 return __builtin_llrintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001098}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001099inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001100{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001101 return __builtin_llrintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001102}
Richard Smith081bb592015-10-08 20:40:34 +00001103
1104template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001105inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001106typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001107llrint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001108{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001109 return __builtin_llrint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001110}
Richard Smith081bb592015-10-08 20:40:34 +00001111
1112// llround
1113
Nikolas Klauser9806f452022-10-12 15:45:09 +02001114inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001115{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001116 return __builtin_llroundf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001117}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001118inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001119{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001120 return __builtin_llroundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001121}
Richard Smith081bb592015-10-08 20:40:34 +00001122
1123template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001124inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001125typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001126llround(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001127{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001128 return __builtin_llround((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001129}
Richard Smith081bb592015-10-08 20:40:34 +00001130
1131// log1p
1132
Nikolas Klauser04005952022-10-21 01:41:22 +02001133inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return __builtin_log1pf(__x);}
1134inline _LIBCPP_HIDE_FROM_ABI long double log1p(long double __x) _NOEXCEPT {return __builtin_log1pl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001135
1136template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001137inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001138typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +02001139log1p(_A1 __x) _NOEXCEPT {return __builtin_log1p((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001140
1141// log2
1142
Nikolas Klauser04005952022-10-21 01:41:22 +02001143inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return __builtin_log2f(__x);}
1144inline _LIBCPP_HIDE_FROM_ABI long double log2(long double __x) _NOEXCEPT {return __builtin_log2l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001145
1146template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001147inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001148typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +02001149log2(_A1 __x) _NOEXCEPT {return __builtin_log2((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001150
1151// logb
1152
Nikolas Klauser04005952022-10-21 01:41:22 +02001153inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return __builtin_logbf(__x);}
1154inline _LIBCPP_HIDE_FROM_ABI long double logb(long double __x) _NOEXCEPT {return __builtin_logbl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001155
1156template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001157inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001158typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +02001159logb(_A1 __x) _NOEXCEPT {return __builtin_logb((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001160
1161// lrint
1162
Nikolas Klauser9806f452022-10-12 15:45:09 +02001163inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001164{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001165 return __builtin_lrintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001166}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001167inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001168{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001169 return __builtin_lrintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001170}
Richard Smith081bb592015-10-08 20:40:34 +00001171
1172template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001173inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001174typename std::enable_if<std::is_integral<_A1>::value, long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001175lrint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001176{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001177 return __builtin_lrint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001178}
Richard Smith081bb592015-10-08 20:40:34 +00001179
1180// lround
1181
Nikolas Klauser9806f452022-10-12 15:45:09 +02001182inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001183{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001184 return __builtin_lroundf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001185}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001186inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001187{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001188 return __builtin_lroundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001189}
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, long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001194lround(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001195{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001196 return __builtin_lround((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001197}
Richard Smith081bb592015-10-08 20:40:34 +00001198
1199// nan
1200
1201// nearbyint
1202
Nikolas Klauser04005952022-10-21 01:41:22 +02001203inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return __builtin_nearbyintf(__x);}
1204inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {return __builtin_nearbyintl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001205
1206template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001207inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001208typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +02001209nearbyint(_A1 __x) _NOEXCEPT {return __builtin_nearbyint((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001210
1211// nextafter
1212
Nikolas Klauser04005952022-10-21 01:41:22 +02001213inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return __builtin_nextafterf(__x, __y);}
1214inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double __y) _NOEXCEPT {return __builtin_nextafterl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001215
1216template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001217inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001218typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001219<
1220 std::is_arithmetic<_A1>::value &&
1221 std::is_arithmetic<_A2>::value,
1222 std::__promote<_A1, _A2>
1223>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001224nextafter(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001225{
1226 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001227 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1228 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001229 return ::nextafter((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001230}
1231
1232// nexttoward
1233
Nikolas Klauser04005952022-10-21 01:41:22 +02001234inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return __builtin_nexttowardf(__x, __y);}
1235inline _LIBCPP_HIDE_FROM_ABI long double nexttoward(long double __x, long double __y) _NOEXCEPT {return __builtin_nexttowardl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001236
1237template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001238inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001239typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +02001240nexttoward(_A1 __x, long double __y) _NOEXCEPT {return __builtin_nexttoward((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001241
1242// remainder
1243
Nikolas Klauser04005952022-10-21 01:41:22 +02001244inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return __builtin_remainderf(__x, __y);}
1245inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double __y) _NOEXCEPT {return __builtin_remainderl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001246
1247template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001248inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001249typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001250<
1251 std::is_arithmetic<_A1>::value &&
1252 std::is_arithmetic<_A2>::value,
1253 std::__promote<_A1, _A2>
1254>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001255remainder(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001256{
1257 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001258 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1259 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001260 return ::remainder((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001261}
1262
1263// remquo
1264
Nikolas Klauser04005952022-10-21 01:41:22 +02001265inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return __builtin_remquof(__x, __y, __z);}
1266inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y, int* __z) _NOEXCEPT {return __builtin_remquol(__x, __y, __z);}
Richard Smith081bb592015-10-08 20:40:34 +00001267
1268template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001269inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001270typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001271<
1272 std::is_arithmetic<_A1>::value &&
1273 std::is_arithmetic<_A2>::value,
1274 std::__promote<_A1, _A2>
1275>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001276remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001277{
1278 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001279 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1280 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001281 return ::remquo((__result_type)__x, (__result_type)__y, __z);
Richard Smith081bb592015-10-08 20:40:34 +00001282}
1283
1284// rint
1285
Nikolas Klauser9806f452022-10-12 15:45:09 +02001286inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001287{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001288 return __builtin_rintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001289}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001290inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001291{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001292 return __builtin_rintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001293}
Richard Smith081bb592015-10-08 20:40:34 +00001294
1295template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001296inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001297typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001298rint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001299{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001300 return __builtin_rint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001301}
Richard Smith081bb592015-10-08 20:40:34 +00001302
1303// round
1304
Nikolas Klauser9806f452022-10-12 15:45:09 +02001305inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001306{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001307 return __builtin_round(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001308}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001309inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001310{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001311 return __builtin_roundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001312}
Richard Smith081bb592015-10-08 20:40:34 +00001313
1314template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001315inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001316typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001317round(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001318{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001319 return __builtin_round((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001320}
Richard Smith081bb592015-10-08 20:40:34 +00001321
1322// scalbln
1323
Nikolas Klauser04005952022-10-21 01:41:22 +02001324inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return __builtin_scalblnf(__x, __y);}
1325inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT {return __builtin_scalblnl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001326
1327template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001328inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001329typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +02001330scalbln(_A1 __x, long __y) _NOEXCEPT {return __builtin_scalbln((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001331
1332// scalbn
1333
Nikolas Klauser04005952022-10-21 01:41:22 +02001334inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return __builtin_scalbnf(__x, __y);}
1335inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT {return __builtin_scalbnl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001336
1337template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001338inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001339typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +02001340scalbn(_A1 __x, int __y) _NOEXCEPT {return __builtin_scalbn((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001341
1342// tgamma
1343
Nikolas Klauser04005952022-10-21 01:41:22 +02001344inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return __builtin_tgammaf(__x);}
1345inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT {return __builtin_tgammal(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001346
1347template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001348inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001349typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser04005952022-10-21 01:41:22 +02001350tgamma(_A1 __x) _NOEXCEPT {return __builtin_tgamma((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001351
1352// trunc
1353
Nikolas Klauser9806f452022-10-12 15:45:09 +02001354inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001355{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001356 return __builtin_trunc(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001357}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001358inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001359{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001360 return __builtin_truncl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001361}
Richard Smith081bb592015-10-08 20:40:34 +00001362
1363template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001364inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001365typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001366trunc(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001367{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001368 return __builtin_trunc((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001369}
Richard Smith081bb592015-10-08 20:40:34 +00001370
Richard Smith081bb592015-10-08 20:40:34 +00001371} // extern "C++"
1372
1373#endif // __cplusplus
1374
Mikhail Maltsev34b4f972018-02-22 09:34:08 +00001375#else // _LIBCPP_MATH_H
1376
1377// This include lives outside the header guard in order to support an MSVC
1378// extension which allows users to do:
1379//
1380// #define _USE_MATH_DEFINES
1381// #include <math.h>
1382//
1383// and receive the definitions of mathematical constants, even if <math.h>
1384// has previously been included.
1385#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
1386#include_next <math.h>
1387#endif
1388
Louis Dionne2b1ceaa2021-04-20 12:03:32 -04001389#endif // _LIBCPP_MATH_H