blob: d60943086036fb6df9c3339620938c604d0382b2 [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
317#ifdef signbit
318
319template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200320_LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000321bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200322__libcpp_signbit(_A1 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000323{
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500324#if __has_builtin(__builtin_signbit)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200325 return __builtin_signbit(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500326#else
Nikolas Klauser9806f452022-10-12 15:45:09 +0200327 return signbit(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500328#endif
Richard Smith081bb592015-10-08 20:40:34 +0000329}
330
331#undef signbit
332
333template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200334inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000335typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200336signbit(_A1 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000337{
Nikolas Klauser37a5b4f2022-10-27 20:01:13 +0200338 return __libcpp_signbit(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000339}
340
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000341template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200342inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000343typename std::enable_if<
344 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200345signbit(_A1 __x) _NOEXCEPT
346{ return __x < 0; }
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000347
348template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200349inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000350typename std::enable_if<
351 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
352signbit(_A1) _NOEXCEPT
353{ return false; }
354
Shoaib Meenai159375f2017-04-07 02:20:52 +0000355#elif defined(_LIBCPP_MSVCRT)
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000356
357template <typename _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200358inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000359typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200360signbit(_A1 __x) _NOEXCEPT
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000361{
Nikolas Klauser37a5b4f2022-10-27 20:01:13 +0200362 return ::signbit(__x);
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000363}
364
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000365template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200366inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000367typename std::enable_if<
368 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200369signbit(_A1 __x) _NOEXCEPT
370{ return __x < 0; }
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000371
372template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200373inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000374typename std::enable_if<
375 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
376signbit(_A1) _NOEXCEPT
377{ return false; }
378
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400379#endif // signbit
Richard Smith081bb592015-10-08 20:40:34 +0000380
381// fpclassify
382
383#ifdef fpclassify
384
385template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200386_LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000387int
Nikolas Klauser9806f452022-10-12 15:45:09 +0200388__libcpp_fpclassify(_A1 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000389{
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500390#if __has_builtin(__builtin_fpclassify)
391 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
Nikolas Klauser9806f452022-10-12 15:45:09 +0200392 FP_ZERO, __x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500393#else
Nikolas Klauser9806f452022-10-12 15:45:09 +0200394 return fpclassify(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500395#endif
Richard Smith081bb592015-10-08 20:40:34 +0000396}
397
398#undef fpclassify
399
400template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200401inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000402typename std::enable_if<std::is_floating_point<_A1>::value, int>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200403fpclassify(_A1 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000404{
Nikolas Klauser37a5b4f2022-10-27 20:01:13 +0200405 return __libcpp_fpclassify(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000406}
407
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000408template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200409inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000410typename std::enable_if<std::is_integral<_A1>::value, int>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200411fpclassify(_A1 __x) _NOEXCEPT
412{ return __x == 0 ? FP_ZERO : FP_NORMAL; }
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000413
Shoaib Meenai159375f2017-04-07 02:20:52 +0000414#elif defined(_LIBCPP_MSVCRT)
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000415
416template <typename _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200417inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000418typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200419fpclassify(_A1 __x) _NOEXCEPT
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000420{
Nikolas Klauser37a5b4f2022-10-27 20:01:13 +0200421 return ::fpclassify(__x);
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000422}
423
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000424template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200425inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000426typename std::enable_if<std::is_integral<_A1>::value, int>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200427fpclassify(_A1 __x) _NOEXCEPT
428{ return __x == 0 ? FP_ZERO : FP_NORMAL; }
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000429
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400430#endif // fpclassify
Richard Smith081bb592015-10-08 20:40:34 +0000431
432// isfinite
433
434#ifdef isfinite
435
436template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200437_LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000438bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200439__libcpp_isfinite(_A1 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000440{
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500441#if __has_builtin(__builtin_isfinite)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200442 return __builtin_isfinite(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500443#else
Nikolas Klauser9806f452022-10-12 15:45:09 +0200444 return isfinite(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500445#endif
Richard Smith081bb592015-10-08 20:40:34 +0000446}
447
448#undef isfinite
449
450template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200451inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000452typename std::enable_if<
453 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
454 bool>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200455isfinite(_A1 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000456{
Nikolas Klauser9806f452022-10-12 15:45:09 +0200457 return __libcpp_isfinite((typename std::__promote<_A1>::type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000458}
459
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000460template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200461inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000462typename std::enable_if<
463 std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
464 bool>::type
465isfinite(_A1) _NOEXCEPT
466{ return true; }
467
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400468#endif // isfinite
Richard Smith081bb592015-10-08 20:40:34 +0000469
470// isinf
471
472#ifdef isinf
473
474template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200475_LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000476bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200477__libcpp_isinf(_A1 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000478{
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500479#if __has_builtin(__builtin_isinf)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200480 return __builtin_isinf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500481#else
Nikolas Klauser9806f452022-10-12 15:45:09 +0200482 return isinf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500483#endif
Richard Smith081bb592015-10-08 20:40:34 +0000484}
485
486#undef isinf
487
488template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200489inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000490typename std::enable_if<
491 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
492 bool>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200493isinf(_A1 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000494{
Nikolas Klauser9806f452022-10-12 15:45:09 +0200495 return __libcpp_isinf((typename std::__promote<_A1>::type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000496}
497
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000498template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200499inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000500typename std::enable_if<
501 std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
502 bool>::type
503isinf(_A1) _NOEXCEPT
504{ return false; }
505
Richard Smithafccfd32018-05-01 03:05:40 +0000506#ifdef _LIBCPP_PREFERRED_OVERLOAD
Nikolas Klauser4956e722022-10-12 15:41:22 +0200507inline _LIBCPP_HIDE_FROM_ABI
Richard Smithafccfd32018-05-01 03:05:40 +0000508bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200509isinf(float __x) _NOEXCEPT { return __libcpp_isinf(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000510
Nikolas Klauser4956e722022-10-12 15:41:22 +0200511inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD
Richard Smithafccfd32018-05-01 03:05:40 +0000512bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200513isinf(double __x) _NOEXCEPT { return __libcpp_isinf(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000514
Nikolas Klauser4956e722022-10-12 15:41:22 +0200515inline _LIBCPP_HIDE_FROM_ABI
Richard Smithafccfd32018-05-01 03:05:40 +0000516bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200517isinf(long double __x) _NOEXCEPT { return __libcpp_isinf(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000518#endif
519
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400520#endif // isinf
Richard Smith081bb592015-10-08 20:40:34 +0000521
522// isnan
523
524#ifdef isnan
525
526template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200527_LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000528bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200529__libcpp_isnan(_A1 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000530{
Ilya Tokar6caf83a2019-11-15 12:29:02 -0500531#if __has_builtin(__builtin_isnan)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200532 return __builtin_isnan(__x);
Ilya Tokar6caf83a2019-11-15 12:29:02 -0500533#else
Nikolas Klauser9806f452022-10-12 15:45:09 +0200534 return isnan(__x);
Ilya Tokar6caf83a2019-11-15 12:29:02 -0500535#endif
Richard Smith081bb592015-10-08 20:40:34 +0000536}
537
538#undef isnan
539
540template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200541inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000542typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200543isnan(_A1 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000544{
Nikolas Klauser37a5b4f2022-10-27 20:01:13 +0200545 return __libcpp_isnan(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000546}
547
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000548template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200549inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000550typename std::enable_if<std::is_integral<_A1>::value, bool>::type
551isnan(_A1) _NOEXCEPT
552{ return false; }
553
Richard Smithafccfd32018-05-01 03:05:40 +0000554#ifdef _LIBCPP_PREFERRED_OVERLOAD
Nikolas Klauser4956e722022-10-12 15:41:22 +0200555inline _LIBCPP_HIDE_FROM_ABI
Richard Smithafccfd32018-05-01 03:05:40 +0000556bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200557isnan(float __x) _NOEXCEPT { return __libcpp_isnan(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000558
Nikolas Klauser4956e722022-10-12 15:41:22 +0200559inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD
Richard Smithafccfd32018-05-01 03:05:40 +0000560bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200561isnan(double __x) _NOEXCEPT { return __libcpp_isnan(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000562
Nikolas Klauser4956e722022-10-12 15:41:22 +0200563inline _LIBCPP_HIDE_FROM_ABI
Richard Smithafccfd32018-05-01 03:05:40 +0000564bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200565isnan(long double __x) _NOEXCEPT { return __libcpp_isnan(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000566#endif
567
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400568#endif // isnan
Richard Smith081bb592015-10-08 20:40:34 +0000569
570// isnormal
571
572#ifdef isnormal
573
574template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200575_LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000576bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200577__libcpp_isnormal(_A1 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000578{
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500579#if __has_builtin(__builtin_isnormal)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200580 return __builtin_isnormal(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500581#else
Nikolas Klauser9806f452022-10-12 15:45:09 +0200582 return isnormal(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -0500583#endif
Richard Smith081bb592015-10-08 20:40:34 +0000584}
585
586#undef isnormal
587
588template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200589inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000590typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200591isnormal(_A1 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000592{
Nikolas Klauser37a5b4f2022-10-27 20:01:13 +0200593 return __libcpp_isnormal(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000594}
595
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000596template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200597inline _LIBCPP_HIDE_FROM_ABI
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000598typename std::enable_if<std::is_integral<_A1>::value, bool>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200599isnormal(_A1 __x) _NOEXCEPT
600{ return __x != 0; }
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000601
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400602#endif // isnormal
Richard Smith081bb592015-10-08 20:40:34 +0000603
604// isgreater
605
606#ifdef isgreater
607
608template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200609_LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000610bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200611__libcpp_isgreater(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000612{
Nikolas Klauser9806f452022-10-12 15:45:09 +0200613 return isgreater(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000614}
615
616#undef isgreater
617
618template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200619inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000620typename std::enable_if
621<
622 std::is_arithmetic<_A1>::value &&
623 std::is_arithmetic<_A2>::value,
624 bool
625>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200626isgreater(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000627{
628 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser9806f452022-10-12 15:45:09 +0200629 return __libcpp_isgreater((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000630}
631
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400632#endif // isgreater
Richard Smith081bb592015-10-08 20:40:34 +0000633
634// isgreaterequal
635
636#ifdef isgreaterequal
637
638template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200639_LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000640bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200641__libcpp_isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000642{
Nikolas Klauser9806f452022-10-12 15:45:09 +0200643 return isgreaterequal(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000644}
645
646#undef isgreaterequal
647
648template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200649inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000650typename std::enable_if
651<
652 std::is_arithmetic<_A1>::value &&
653 std::is_arithmetic<_A2>::value,
654 bool
655>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200656isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000657{
658 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser9806f452022-10-12 15:45:09 +0200659 return __libcpp_isgreaterequal((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000660}
661
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400662#endif // isgreaterequal
Richard Smith081bb592015-10-08 20:40:34 +0000663
664// isless
665
666#ifdef isless
667
668template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200669_LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000670bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200671__libcpp_isless(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000672{
Nikolas Klauser9806f452022-10-12 15:45:09 +0200673 return isless(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000674}
675
676#undef isless
677
678template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200679inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000680typename std::enable_if
681<
682 std::is_arithmetic<_A1>::value &&
683 std::is_arithmetic<_A2>::value,
684 bool
685>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200686isless(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000687{
688 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser9806f452022-10-12 15:45:09 +0200689 return __libcpp_isless((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000690}
691
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400692#endif // isless
Richard Smith081bb592015-10-08 20:40:34 +0000693
694// islessequal
695
696#ifdef islessequal
697
698template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200699_LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000700bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200701__libcpp_islessequal(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000702{
Nikolas Klauser9806f452022-10-12 15:45:09 +0200703 return islessequal(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000704}
705
706#undef islessequal
707
708template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200709inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000710typename std::enable_if
711<
712 std::is_arithmetic<_A1>::value &&
713 std::is_arithmetic<_A2>::value,
714 bool
715>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200716islessequal(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000717{
718 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser9806f452022-10-12 15:45:09 +0200719 return __libcpp_islessequal((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000720}
721
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400722#endif // islessequal
Richard Smith081bb592015-10-08 20:40:34 +0000723
724// islessgreater
725
726#ifdef islessgreater
727
728template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200729_LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000730bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200731__libcpp_islessgreater(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000732{
Nikolas Klauser9806f452022-10-12 15:45:09 +0200733 return islessgreater(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000734}
735
736#undef islessgreater
737
738template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200739inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000740typename std::enable_if
741<
742 std::is_arithmetic<_A1>::value &&
743 std::is_arithmetic<_A2>::value,
744 bool
745>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200746islessgreater(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000747{
748 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser9806f452022-10-12 15:45:09 +0200749 return __libcpp_islessgreater((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000750}
751
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400752#endif // islessgreater
Richard Smith081bb592015-10-08 20:40:34 +0000753
754// isunordered
755
756#ifdef isunordered
757
758template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200759_LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000760bool
Nikolas Klauser9806f452022-10-12 15:45:09 +0200761__libcpp_isunordered(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000762{
Nikolas Klauser9806f452022-10-12 15:45:09 +0200763 return isunordered(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000764}
765
766#undef isunordered
767
768template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200769inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000770typename std::enable_if
771<
772 std::is_arithmetic<_A1>::value &&
773 std::is_arithmetic<_A2>::value,
774 bool
775>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200776isunordered(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000777{
778 typedef typename std::__promote<_A1, _A2>::type type;
Nikolas Klauser9806f452022-10-12 15:45:09 +0200779 return __libcpp_isunordered((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000780}
781
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400782#endif // isunordered
Richard Smith081bb592015-10-08 20:40:34 +0000783
Richard Smith081bb592015-10-08 20:40:34 +0000784// abs
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500785//
786// handled in stdlib.h
Richard Smith081bb592015-10-08 20:40:34 +0000787
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000788// div
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500789//
790// handled in stdlib.h
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000791
Richard Smith081bb592015-10-08 20:40:34 +0000792// acos
793
David Tenty7249ac92022-02-07 18:22:35 -0500794# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200795inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return ::acosf(__x);}
796inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT {return ::acosl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500797# endif
Richard Smith081bb592015-10-08 20:40:34 +0000798
799template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200800inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000801typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200802acos(_A1 __x) _NOEXCEPT {return ::acos((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000803
804// asin
805
David Tenty7249ac92022-02-07 18:22:35 -0500806# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200807inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return ::asinf(__x);}
808inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT {return ::asinl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500809# endif
Richard Smith081bb592015-10-08 20:40:34 +0000810
811template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200812inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000813typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200814asin(_A1 __x) _NOEXCEPT {return ::asin((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000815
816// atan
817
David Tenty7249ac92022-02-07 18:22:35 -0500818# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200819inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return ::atanf(__x);}
820inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT {return ::atanl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500821# endif
Richard Smith081bb592015-10-08 20:40:34 +0000822
823template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200824inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000825typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200826atan(_A1 __x) _NOEXCEPT {return ::atan((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000827
828// atan2
829
David Tenty7249ac92022-02-07 18:22:35 -0500830# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200831inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return ::atan2f(__y, __x);}
832inline _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 -0500833# endif
Richard Smith081bb592015-10-08 20:40:34 +0000834
835template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200836inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400837typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000838<
839 std::is_arithmetic<_A1>::value &&
840 std::is_arithmetic<_A2>::value,
841 std::__promote<_A1, _A2>
842>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200843atan2(_A1 __y, _A2 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000844{
845 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000846 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
847 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200848 return ::atan2((__result_type)__y, (__result_type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000849}
850
851// ceil
852
David Tenty7249ac92022-02-07 18:22:35 -0500853# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200854inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return ::ceilf(__x);}
855inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return ::ceill(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500856# endif
Richard Smith081bb592015-10-08 20:40:34 +0000857
858template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200859inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000860typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200861ceil(_A1 __x) _NOEXCEPT {return ::ceil((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000862
863// cos
864
David Tenty7249ac92022-02-07 18:22:35 -0500865# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200866inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return ::cosf(__x);}
867inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT {return ::cosl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500868# endif
Richard Smith081bb592015-10-08 20:40:34 +0000869
870template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200871inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000872typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200873cos(_A1 __x) _NOEXCEPT {return ::cos((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000874
875// cosh
876
David Tenty7249ac92022-02-07 18:22:35 -0500877# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200878inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return ::coshf(__x);}
879inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT {return ::coshl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500880# endif
Richard Smith081bb592015-10-08 20:40:34 +0000881
882template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200883inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000884typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200885cosh(_A1 __x) _NOEXCEPT {return ::cosh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000886
887// exp
888
David Tenty7249ac92022-02-07 18:22:35 -0500889# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200890inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return ::expf(__x);}
891inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT {return ::expl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500892# endif
Richard Smith081bb592015-10-08 20:40:34 +0000893
894template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200895inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000896typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200897exp(_A1 __x) _NOEXCEPT {return ::exp((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000898
899// fabs
900
David Tenty7249ac92022-02-07 18:22:35 -0500901# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200902inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return ::fabsf(__x);}
903inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return ::fabsl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500904# endif
Richard Smith081bb592015-10-08 20:40:34 +0000905
906template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200907inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000908typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200909fabs(_A1 __x) _NOEXCEPT {return ::fabs((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000910
911// floor
912
David Tenty7249ac92022-02-07 18:22:35 -0500913# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200914inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return ::floorf(__x);}
915inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return ::floorl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500916# endif
Richard Smith081bb592015-10-08 20:40:34 +0000917
918template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200919inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000920typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200921floor(_A1 __x) _NOEXCEPT {return ::floor((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000922
923// fmod
924
David Tenty7249ac92022-02-07 18:22:35 -0500925# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200926inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return ::fmodf(__x, __y);}
927inline _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 -0500928# endif
Richard Smith081bb592015-10-08 20:40:34 +0000929
930template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200931inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400932typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000933<
934 std::is_arithmetic<_A1>::value &&
935 std::is_arithmetic<_A2>::value,
936 std::__promote<_A1, _A2>
937>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200938fmod(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000939{
940 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000941 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
942 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200943 return ::fmod((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000944}
945
946// frexp
947
David Tenty7249ac92022-02-07 18:22:35 -0500948# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200949inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return ::frexpf(__x, __e);}
950inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {return ::frexpl(__x, __e);}
David Tenty7249ac92022-02-07 18:22:35 -0500951# endif
Richard Smith081bb592015-10-08 20:40:34 +0000952
953template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200954inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000955typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200956frexp(_A1 __x, int* __e) _NOEXCEPT {return ::frexp((double)__x, __e);}
Richard Smith081bb592015-10-08 20:40:34 +0000957
958// ldexp
959
David Tenty7249ac92022-02-07 18:22:35 -0500960# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200961inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return ::ldexpf(__x, __e);}
962inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {return ::ldexpl(__x, __e);}
David Tenty7249ac92022-02-07 18:22:35 -0500963# endif
Richard Smith081bb592015-10-08 20:40:34 +0000964
965template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200966inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000967typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200968ldexp(_A1 __x, int __e) _NOEXCEPT {return ::ldexp((double)__x, __e);}
Richard Smith081bb592015-10-08 20:40:34 +0000969
970// log
971
David Tenty7249ac92022-02-07 18:22:35 -0500972# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200973inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return ::logf(__x);}
974inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT {return ::logl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500975# endif
Richard Smith081bb592015-10-08 20:40:34 +0000976
977template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200978inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000979typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200980log(_A1 __x) _NOEXCEPT {return ::log((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000981
982// log10
983
David Tenty7249ac92022-02-07 18:22:35 -0500984# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200985inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return ::log10f(__x);}
986inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT {return ::log10l(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500987# endif
Richard Smith081bb592015-10-08 20:40:34 +0000988
989template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200990inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000991typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200992log10(_A1 __x) _NOEXCEPT {return ::log10((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000993
994// modf
995
David Tenty7249ac92022-02-07 18:22:35 -0500996# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200997inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return ::modff(__x, __y);}
998inline _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 -0500999# endif
Richard Smith081bb592015-10-08 20:40:34 +00001000
1001// pow
1002
David Tenty7249ac92022-02-07 18:22:35 -05001003# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001004inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return ::powf(__x, __y);}
1005inline _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 -05001006# endif
Richard Smith081bb592015-10-08 20:40:34 +00001007
1008template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001009inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001010typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001011<
1012 std::is_arithmetic<_A1>::value &&
1013 std::is_arithmetic<_A2>::value,
1014 std::__promote<_A1, _A2>
1015>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001016pow(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001017{
1018 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001019 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1020 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001021 return ::pow((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001022}
1023
1024// sin
1025
David Tenty7249ac92022-02-07 18:22:35 -05001026# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001027inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return ::sinf(__x);}
1028inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT {return ::sinl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001029#endif
1030
1031template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001032inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001033typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001034sin(_A1 __x) _NOEXCEPT {return ::sin((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001035
1036// sinh
1037
David Tenty7249ac92022-02-07 18:22:35 -05001038# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001039inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return ::sinhf(__x);}
1040inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT {return ::sinhl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -05001041# endif
Richard Smith081bb592015-10-08 20:40:34 +00001042
1043template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001044inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001045typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001046sinh(_A1 __x) _NOEXCEPT {return ::sinh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001047
1048// sqrt
1049
David Tenty7249ac92022-02-07 18:22:35 -05001050# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001051inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return ::sqrtf(__x);}
1052inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT {return ::sqrtl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -05001053# endif
Richard Smith081bb592015-10-08 20:40:34 +00001054
Richard Smith081bb592015-10-08 20:40:34 +00001055template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001056inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001057typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001058sqrt(_A1 __x) _NOEXCEPT {return ::sqrt((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001059
1060// tan
1061
David Tenty7249ac92022-02-07 18:22:35 -05001062# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001063inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return ::tanf(__x);}
1064inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT {return ::tanl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -05001065# endif
Richard Smith081bb592015-10-08 20:40:34 +00001066
1067template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001068inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001069typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001070tan(_A1 __x) _NOEXCEPT {return ::tan((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001071
1072// tanh
1073
David Tenty7249ac92022-02-07 18:22:35 -05001074# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001075inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return ::tanhf(__x);}
1076inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT {return ::tanhl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -05001077# endif
Richard Smith081bb592015-10-08 20:40:34 +00001078
1079template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001080inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001081typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001082tanh(_A1 __x) _NOEXCEPT {return ::tanh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001083
1084// acosh
1085
Nikolas Klauser9806f452022-10-12 15:45:09 +02001086inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return ::acoshf(__x);}
1087inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT {return ::acoshl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001088
1089template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001090inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001091typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001092acosh(_A1 __x) _NOEXCEPT {return ::acosh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001093
1094// asinh
1095
Nikolas Klauser9806f452022-10-12 15:45:09 +02001096inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return ::asinhf(__x);}
1097inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT {return ::asinhl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001098
1099template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001100inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001101typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001102asinh(_A1 __x) _NOEXCEPT {return ::asinh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001103
1104// atanh
1105
Nikolas Klauser9806f452022-10-12 15:45:09 +02001106inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return ::atanhf(__x);}
1107inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT {return ::atanhl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001108
1109template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001110inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001111typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001112atanh(_A1 __x) _NOEXCEPT {return ::atanh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001113
1114// cbrt
1115
Nikolas Klauser9806f452022-10-12 15:45:09 +02001116inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return ::cbrtf(__x);}
1117inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {return ::cbrtl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001118
1119template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001120inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001121typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001122cbrt(_A1 __x) _NOEXCEPT {return ::cbrt((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001123
1124// copysign
1125
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001126#if __has_builtin(__builtin_copysignf)
1127_LIBCPP_CONSTEXPR
1128#endif
Nikolas Klauser9806f452022-10-12 15:45:09 +02001129inline _LIBCPP_HIDE_FROM_ABI float __libcpp_copysign(float __x, float __y) _NOEXCEPT {
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001130#if __has_builtin(__builtin_copysignf)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001131 return __builtin_copysignf(__x, __y);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001132#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001133 return ::copysignf(__x, __y);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001134#endif
Richard Smith081bb592015-10-08 20:40:34 +00001135}
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001136
1137#if __has_builtin(__builtin_copysign)
1138_LIBCPP_CONSTEXPR
1139#endif
Nikolas Klauser9806f452022-10-12 15:45:09 +02001140inline _LIBCPP_HIDE_FROM_ABI double __libcpp_copysign(double __x, double __y) _NOEXCEPT {
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001141#if __has_builtin(__builtin_copysign)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001142 return __builtin_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001143#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001144 return ::copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001145#endif
1146}
1147
1148#if __has_builtin(__builtin_copysignl)
1149_LIBCPP_CONSTEXPR
1150#endif
Nikolas Klauser9806f452022-10-12 15:45:09 +02001151inline _LIBCPP_HIDE_FROM_ABI long double __libcpp_copysign(long double __x, long double __y) _NOEXCEPT {
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001152#if __has_builtin(__builtin_copysignl)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001153 return __builtin_copysignl(__x, __y);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001154#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001155 return ::copysignl(__x, __y);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001156#endif
Richard Smith081bb592015-10-08 20:40:34 +00001157}
Richard Smith081bb592015-10-08 20:40:34 +00001158
1159template <class _A1, class _A2>
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001160#if __has_builtin(__builtin_copysign)
1161_LIBCPP_CONSTEXPR
1162#endif
Nikolas Klauser4956e722022-10-12 15:41:22 +02001163inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001164typename std::__enable_if_t
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001165<
1166 std::is_arithmetic<_A1>::value &&
1167 std::is_arithmetic<_A2>::value,
1168 std::__promote<_A1, _A2>
1169>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001170__libcpp_copysign(_A1 __x, _A2 __y) _NOEXCEPT {
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001171 typedef typename std::__promote<_A1, _A2>::type __result_type;
1172 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1173 std::_IsSame<_A2, __result_type>::value)), "");
1174#if __has_builtin(__builtin_copysign)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001175 return __builtin_copysign((__result_type)__x, (__result_type)__y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001176#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001177 return ::copysign((__result_type)__x, (__result_type)__y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001178#endif
1179}
1180
Nikolas Klauser9806f452022-10-12 15:45:09 +02001181inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT {
1182 return ::__libcpp_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001183}
1184
Nikolas Klauser9806f452022-10-12 15:45:09 +02001185inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT {
1186 return ::__libcpp_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001187}
1188
1189template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001190inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001191typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001192<
1193 std::is_arithmetic<_A1>::value &&
1194 std::is_arithmetic<_A2>::value,
1195 std::__promote<_A1, _A2>
1196>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001197 copysign(_A1 __x, _A2 __y) _NOEXCEPT {
1198 return ::__libcpp_copysign(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +00001199}
1200
Richard Smith081bb592015-10-08 20:40:34 +00001201// erf
1202
Nikolas Klauser9806f452022-10-12 15:45:09 +02001203inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return ::erff(__x);}
1204inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT {return ::erfl(__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 Klauser9806f452022-10-12 15:45:09 +02001209erf(_A1 __x) _NOEXCEPT {return ::erf((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001210
1211// erfc
1212
Nikolas Klauser9806f452022-10-12 15:45:09 +02001213inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return ::erfcf(__x);}
1214inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT {return ::erfcl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001215
1216template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001217inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001218typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001219erfc(_A1 __x) _NOEXCEPT {return ::erfc((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001220
1221// exp2
1222
Nikolas Klauser9806f452022-10-12 15:45:09 +02001223inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return ::exp2f(__x);}
1224inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT {return ::exp2l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001225
1226template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001227inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001228typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001229exp2(_A1 __x) _NOEXCEPT {return ::exp2((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001230
1231// expm1
1232
Nikolas Klauser9806f452022-10-12 15:45:09 +02001233inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return ::expm1f(__x);}
1234inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT {return ::expm1l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001235
1236template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001237inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001238typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001239expm1(_A1 __x) _NOEXCEPT {return ::expm1((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001240
1241// fdim
1242
Nikolas Klauser9806f452022-10-12 15:45:09 +02001243inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return ::fdimf(__x, __y);}
1244inline _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 +00001245
1246template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001247inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001248typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001249<
1250 std::is_arithmetic<_A1>::value &&
1251 std::is_arithmetic<_A2>::value,
1252 std::__promote<_A1, _A2>
1253>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001254fdim(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001255{
1256 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001257 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1258 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001259 return ::fdim((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001260}
1261
1262// fma
1263
Nikolas Klauser9806f452022-10-12 15:45:09 +02001264inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001265{
1266#if __has_builtin(__builtin_fmaf)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001267 return __builtin_fmaf(__x, __y, __z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001268#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001269 return ::fmaf(__x, __y, __z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001270#endif
1271}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001272inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001273{
1274#if __has_builtin(__builtin_fmal)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001275 return __builtin_fmal(__x, __y, __z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001276#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001277 return ::fmal(__x, __y, __z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001278#endif
1279}
Richard Smith081bb592015-10-08 20:40:34 +00001280
1281template <class _A1, class _A2, class _A3>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001282inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001283typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001284<
1285 std::is_arithmetic<_A1>::value &&
1286 std::is_arithmetic<_A2>::value &&
1287 std::is_arithmetic<_A3>::value,
1288 std::__promote<_A1, _A2, _A3>
1289>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001290fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001291{
1292 typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001293 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1294 std::_IsSame<_A2, __result_type>::value &&
1295 std::_IsSame<_A3, __result_type>::value)), "");
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001296#if __has_builtin(__builtin_fma)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001297 return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001298#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001299 return ::fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001300#endif
Richard Smith081bb592015-10-08 20:40:34 +00001301}
1302
1303// fmax
1304
Nikolas Klauser9806f452022-10-12 15:45:09 +02001305inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return ::fmaxf(__x, __y);}
1306inline _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 +00001307
1308template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001309inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001310typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001311<
1312 std::is_arithmetic<_A1>::value &&
1313 std::is_arithmetic<_A2>::value,
1314 std::__promote<_A1, _A2>
1315>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001316fmax(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001317{
1318 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001319 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1320 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001321 return ::fmax((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001322}
1323
1324// fmin
1325
Nikolas Klauser9806f452022-10-12 15:45:09 +02001326inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return ::fminf(__x, __y);}
1327inline _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 +00001328
1329template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001330inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001331typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001332<
1333 std::is_arithmetic<_A1>::value &&
1334 std::is_arithmetic<_A2>::value,
1335 std::__promote<_A1, _A2>
1336>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001337fmin(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001338{
1339 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001340 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1341 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001342 return ::fmin((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001343}
1344
1345// hypot
1346
Nikolas Klauser9806f452022-10-12 15:45:09 +02001347inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return ::hypotf(__x, __y);}
1348inline _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 +00001349
1350template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001351inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001352typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001353<
1354 std::is_arithmetic<_A1>::value &&
1355 std::is_arithmetic<_A2>::value,
1356 std::__promote<_A1, _A2>
1357>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001358hypot(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001359{
1360 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001361 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1362 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001363 return ::hypot((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001364}
1365
1366// ilogb
1367
Nikolas Klauser9806f452022-10-12 15:45:09 +02001368inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return ::ilogbf(__x);}
1369inline _LIBCPP_HIDE_FROM_ABI int ilogb(long double __x) _NOEXCEPT {return ::ilogbl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001370
1371template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001372inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001373typename std::enable_if<std::is_integral<_A1>::value, int>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001374ilogb(_A1 __x) _NOEXCEPT {return ::ilogb((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001375
1376// lgamma
1377
Nikolas Klauser9806f452022-10-12 15:45:09 +02001378inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return ::lgammaf(__x);}
1379inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT {return ::lgammal(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001380
1381template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001382inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001383typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001384lgamma(_A1 __x) _NOEXCEPT {return ::lgamma((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001385
1386// llrint
1387
Nikolas Klauser9806f452022-10-12 15:45:09 +02001388inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001389{
1390#if __has_builtin(__builtin_llrintf)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001391 return __builtin_llrintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001392#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001393 return ::llrintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001394#endif
1395}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001396inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001397{
1398#if __has_builtin(__builtin_llrintl)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001399 return __builtin_llrintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001400#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001401 return ::llrintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001402#endif
1403}
Richard Smith081bb592015-10-08 20:40:34 +00001404
1405template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001406inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001407typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001408llrint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001409{
1410#if __has_builtin(__builtin_llrint)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001411 return __builtin_llrint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001412#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001413 return ::llrint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001414#endif
1415}
Richard Smith081bb592015-10-08 20:40:34 +00001416
1417// llround
1418
Nikolas Klauser9806f452022-10-12 15:45:09 +02001419inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001420{
1421#if __has_builtin(__builtin_llroundf)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001422 return __builtin_llroundf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001423#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001424 return ::llroundf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001425#endif
1426}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001427inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001428{
1429#if __has_builtin(__builtin_llroundl)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001430 return __builtin_llroundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001431#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001432 return ::llroundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001433#endif
1434}
Richard Smith081bb592015-10-08 20:40:34 +00001435
1436template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001437inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001438typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001439llround(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001440{
1441#if __has_builtin(__builtin_llround)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001442 return __builtin_llround((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001443#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001444 return ::llround((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001445#endif
1446}
Richard Smith081bb592015-10-08 20:40:34 +00001447
1448// log1p
1449
Nikolas Klauser9806f452022-10-12 15:45:09 +02001450inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return ::log1pf(__x);}
1451inline _LIBCPP_HIDE_FROM_ABI long double log1p(long double __x) _NOEXCEPT {return ::log1pl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001452
1453template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001454inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001455typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001456log1p(_A1 __x) _NOEXCEPT {return ::log1p((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001457
1458// log2
1459
Nikolas Klauser9806f452022-10-12 15:45:09 +02001460inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return ::log2f(__x);}
1461inline _LIBCPP_HIDE_FROM_ABI long double log2(long double __x) _NOEXCEPT {return ::log2l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001462
1463template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001464inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001465typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001466log2(_A1 __x) _NOEXCEPT {return ::log2((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001467
1468// logb
1469
Nikolas Klauser9806f452022-10-12 15:45:09 +02001470inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return ::logbf(__x);}
1471inline _LIBCPP_HIDE_FROM_ABI long double logb(long double __x) _NOEXCEPT {return ::logbl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001472
1473template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001474inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001475typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001476logb(_A1 __x) _NOEXCEPT {return ::logb((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001477
1478// lrint
1479
Nikolas Klauser9806f452022-10-12 15:45:09 +02001480inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001481{
1482#if __has_builtin(__builtin_lrintf)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001483 return __builtin_lrintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001484#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001485 return ::lrintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001486#endif
1487}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001488inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001489{
1490#if __has_builtin(__builtin_lrintl)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001491 return __builtin_lrintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001492#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001493 return ::lrintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001494#endif
1495}
Richard Smith081bb592015-10-08 20:40:34 +00001496
1497template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001498inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001499typename std::enable_if<std::is_integral<_A1>::value, long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001500lrint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001501{
1502#if __has_builtin(__builtin_lrint)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001503 return __builtin_lrint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001504#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001505 return ::lrint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001506#endif
1507}
Richard Smith081bb592015-10-08 20:40:34 +00001508
1509// lround
1510
Nikolas Klauser9806f452022-10-12 15:45:09 +02001511inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001512{
1513#if __has_builtin(__builtin_lroundf)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001514 return __builtin_lroundf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001515#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001516 return ::lroundf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001517#endif
1518}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001519inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001520{
1521#if __has_builtin(__builtin_lroundl)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001522 return __builtin_lroundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001523#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001524 return ::lroundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001525#endif
1526}
Richard Smith081bb592015-10-08 20:40:34 +00001527
1528template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001529inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001530typename std::enable_if<std::is_integral<_A1>::value, long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001531lround(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001532{
1533#if __has_builtin(__builtin_lround)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001534 return __builtin_lround((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001535#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001536 return ::lround((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001537#endif
1538}
Richard Smith081bb592015-10-08 20:40:34 +00001539
1540// nan
1541
1542// nearbyint
1543
Nikolas Klauser9806f452022-10-12 15:45:09 +02001544inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return ::nearbyintf(__x);}
1545inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {return ::nearbyintl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001546
1547template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001548inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001549typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001550nearbyint(_A1 __x) _NOEXCEPT {return ::nearbyint((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001551
1552// nextafter
1553
Nikolas Klauser9806f452022-10-12 15:45:09 +02001554inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return ::nextafterf(__x, __y);}
1555inline _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 +00001556
1557template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001558inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001559typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001560<
1561 std::is_arithmetic<_A1>::value &&
1562 std::is_arithmetic<_A2>::value,
1563 std::__promote<_A1, _A2>
1564>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001565nextafter(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001566{
1567 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001568 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1569 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001570 return ::nextafter((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001571}
1572
1573// nexttoward
1574
Nikolas Klauser9806f452022-10-12 15:45:09 +02001575inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return ::nexttowardf(__x, __y);}
1576inline _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 +00001577
1578template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001579inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001580typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001581nexttoward(_A1 __x, long double __y) _NOEXCEPT {return ::nexttoward((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001582
1583// remainder
1584
Nikolas Klauser9806f452022-10-12 15:45:09 +02001585inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return ::remainderf(__x, __y);}
1586inline _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 +00001587
1588template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001589inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001590typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001591<
1592 std::is_arithmetic<_A1>::value &&
1593 std::is_arithmetic<_A2>::value,
1594 std::__promote<_A1, _A2>
1595>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001596remainder(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001597{
1598 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001599 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1600 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001601 return ::remainder((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001602}
1603
1604// remquo
1605
Nikolas Klauser9806f452022-10-12 15:45:09 +02001606inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return ::remquof(__x, __y, __z);}
1607inline _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 +00001608
1609template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001610inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001611typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001612<
1613 std::is_arithmetic<_A1>::value &&
1614 std::is_arithmetic<_A2>::value,
1615 std::__promote<_A1, _A2>
1616>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001617remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001618{
1619 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001620 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1621 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001622 return ::remquo((__result_type)__x, (__result_type)__y, __z);
Richard Smith081bb592015-10-08 20:40:34 +00001623}
1624
1625// rint
1626
Nikolas Klauser9806f452022-10-12 15:45:09 +02001627inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001628{
1629#if __has_builtin(__builtin_rintf)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001630 return __builtin_rintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001631#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001632 return ::rintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001633#endif
1634}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001635inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001636{
1637#if __has_builtin(__builtin_rintl)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001638 return __builtin_rintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001639#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001640 return ::rintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001641#endif
1642}
Richard Smith081bb592015-10-08 20:40:34 +00001643
1644template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001645inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001646typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001647rint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001648{
1649#if __has_builtin(__builtin_rint)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001650 return __builtin_rint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001651#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001652 return ::rint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001653#endif
1654}
Richard Smith081bb592015-10-08 20:40:34 +00001655
1656// round
1657
Nikolas Klauser9806f452022-10-12 15:45:09 +02001658inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001659{
1660#if __has_builtin(__builtin_round)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001661 return __builtin_round(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001662#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001663 return ::round(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001664#endif
1665}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001666inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001667{
1668#if __has_builtin(__builtin_roundl)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001669 return __builtin_roundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001670#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001671 return ::roundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001672#endif
1673}
Richard Smith081bb592015-10-08 20:40:34 +00001674
1675template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001676inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001677typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001678round(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001679{
1680#if __has_builtin(__builtin_round)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001681 return __builtin_round((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001682#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001683 return ::round((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001684#endif
1685}
Richard Smith081bb592015-10-08 20:40:34 +00001686
1687// scalbln
1688
Nikolas Klauser9806f452022-10-12 15:45:09 +02001689inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return ::scalblnf(__x, __y);}
1690inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT {return ::scalblnl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001691
1692template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001693inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001694typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001695scalbln(_A1 __x, long __y) _NOEXCEPT {return ::scalbln((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001696
1697// scalbn
1698
Nikolas Klauser9806f452022-10-12 15:45:09 +02001699inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return ::scalbnf(__x, __y);}
1700inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT {return ::scalbnl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001701
1702template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001703inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001704typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001705scalbn(_A1 __x, int __y) _NOEXCEPT {return ::scalbn((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001706
1707// tgamma
1708
Nikolas Klauser9806f452022-10-12 15:45:09 +02001709inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return ::tgammaf(__x);}
1710inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT {return ::tgammal(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001711
1712template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001713inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001714typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001715tgamma(_A1 __x) _NOEXCEPT {return ::tgamma((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001716
1717// trunc
1718
Nikolas Klauser9806f452022-10-12 15:45:09 +02001719inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001720{
1721#if __has_builtin(__builtin_trunc)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001722 return __builtin_trunc(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001723#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001724 return ::trunc(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001725#endif
1726}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001727inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001728{
1729#if __has_builtin(__builtin_truncl)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001730 return __builtin_truncl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001731#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001732 return ::truncl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001733#endif
1734}
Richard Smith081bb592015-10-08 20:40:34 +00001735
1736template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001737inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001738typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001739trunc(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001740{
1741#if __has_builtin(__builtin_trunc)
Nikolas Klauser9806f452022-10-12 15:45:09 +02001742 return __builtin_trunc((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001743#else
Nikolas Klauser9806f452022-10-12 15:45:09 +02001744 return ::trunc((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001745#endif
1746}
Richard Smith081bb592015-10-08 20:40:34 +00001747
Richard Smith081bb592015-10-08 20:40:34 +00001748} // extern "C++"
1749
1750#endif // __cplusplus
1751
Mikhail Maltsev34b4f972018-02-22 09:34:08 +00001752#else // _LIBCPP_MATH_H
1753
1754// This include lives outside the header guard in order to support an MSVC
1755// extension which allows users to do:
1756//
1757// #define _USE_MATH_DEFINES
1758// #include <math.h>
1759//
1760// and receive the definitions of mathematical constants, even if <math.h>
1761// has previously been included.
1762#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
1763#include_next <math.h>
1764#endif
1765
Louis Dionne2b1ceaa2021-04-20 12:03:32 -04001766#endif // _LIBCPP_MATH_H