blob: 23a9f600d1667d1dd4a2e5e3759b8e46cc3a33bd [file] [log] [blame]
Richard Smith081bb592015-10-08 20:40:34 +00001// -*- C++ -*-
Louis Dionne9bd93882021-11-17 16:25:01 -05002//===----------------------------------------------------------------------===//
Richard Smith081bb592015-10-08 20:40:34 +00003//
Chandler Carruthd2012102019-01-19 10:56:40 +00004// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Richard Smith081bb592015-10-08 20:40:34 +00007//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_MATH_H
11#define _LIBCPP_MATH_H
12
13/*
14 math.h synopsis
15
16Macros:
17
18 HUGE_VAL
19 HUGE_VALF // C99
20 HUGE_VALL // C99
21 INFINITY // C99
22 NAN // C99
23 FP_INFINITE // C99
24 FP_NAN // C99
25 FP_NORMAL // C99
26 FP_SUBNORMAL // C99
27 FP_ZERO // C99
28 FP_FAST_FMA // C99
29 FP_FAST_FMAF // C99
30 FP_FAST_FMAL // C99
31 FP_ILOGB0 // C99
32 FP_ILOGBNAN // C99
33 MATH_ERRNO // C99
34 MATH_ERREXCEPT // C99
35 math_errhandling // C99
36
37Types:
38
39 float_t // C99
40 double_t // C99
41
42// C90
43
44floating_point abs(floating_point x);
45
46floating_point acos (arithmetic x);
47float acosf(float x);
48long double acosl(long double x);
49
50floating_point asin (arithmetic x);
51float asinf(float x);
52long double asinl(long double x);
53
54floating_point atan (arithmetic x);
55float atanf(float x);
56long double atanl(long double x);
57
58floating_point atan2 (arithmetic y, arithmetic x);
59float atan2f(float y, float x);
60long double atan2l(long double y, long double x);
61
62floating_point ceil (arithmetic x);
63float ceilf(float x);
64long double ceill(long double x);
65
66floating_point cos (arithmetic x);
67float cosf(float x);
68long double cosl(long double x);
69
70floating_point cosh (arithmetic x);
71float coshf(float x);
72long double coshl(long double x);
73
74floating_point exp (arithmetic x);
75float expf(float x);
76long double expl(long double x);
77
78floating_point fabs (arithmetic x);
79float fabsf(float x);
80long double fabsl(long double x);
81
82floating_point floor (arithmetic x);
83float floorf(float x);
84long double floorl(long double x);
85
86floating_point fmod (arithmetic x, arithmetic y);
87float fmodf(float x, float y);
88long double fmodl(long double x, long double y);
89
90floating_point frexp (arithmetic value, int* exp);
91float frexpf(float value, int* exp);
92long double frexpl(long double value, int* exp);
93
94floating_point ldexp (arithmetic value, int exp);
95float ldexpf(float value, int exp);
96long double ldexpl(long double value, int exp);
97
98floating_point log (arithmetic x);
99float logf(float x);
100long double logl(long double x);
101
102floating_point log10 (arithmetic x);
103float log10f(float x);
104long double log10l(long double x);
105
106floating_point modf (floating_point value, floating_point* iptr);
107float modff(float value, float* iptr);
108long double modfl(long double value, long double* iptr);
109
110floating_point pow (arithmetic x, arithmetic y);
111float powf(float x, float y);
112long double powl(long double x, long double y);
113
114floating_point sin (arithmetic x);
115float sinf(float x);
116long double sinl(long double x);
117
118floating_point sinh (arithmetic x);
119float sinhf(float x);
120long double sinhl(long double x);
121
122floating_point sqrt (arithmetic x);
123float sqrtf(float x);
124long double sqrtl(long double x);
125
126floating_point tan (arithmetic x);
127float tanf(float x);
128long double tanl(long double x);
129
130floating_point tanh (arithmetic x);
131float tanhf(float x);
132long double tanhl(long double x);
133
134// C99
135
136bool signbit(arithmetic x);
137
138int fpclassify(arithmetic x);
139
140bool isfinite(arithmetic x);
141bool isinf(arithmetic x);
142bool isnan(arithmetic x);
143bool isnormal(arithmetic x);
144
145bool isgreater(arithmetic x, arithmetic y);
146bool isgreaterequal(arithmetic x, arithmetic y);
147bool isless(arithmetic x, arithmetic y);
148bool islessequal(arithmetic x, arithmetic y);
149bool islessgreater(arithmetic x, arithmetic y);
150bool isunordered(arithmetic x, arithmetic y);
151
152floating_point acosh (arithmetic x);
153float acoshf(float x);
154long double acoshl(long double x);
155
156floating_point asinh (arithmetic x);
157float asinhf(float x);
158long double asinhl(long double x);
159
160floating_point atanh (arithmetic x);
161float atanhf(float x);
162long double atanhl(long double x);
163
164floating_point cbrt (arithmetic x);
165float cbrtf(float x);
166long double cbrtl(long double x);
167
168floating_point copysign (arithmetic x, arithmetic y);
169float copysignf(float x, float y);
170long double copysignl(long double x, long double y);
171
172floating_point erf (arithmetic x);
173float erff(float x);
174long double erfl(long double x);
175
176floating_point erfc (arithmetic x);
177float erfcf(float x);
178long double erfcl(long double x);
179
180floating_point exp2 (arithmetic x);
181float exp2f(float x);
182long double exp2l(long double x);
183
184floating_point expm1 (arithmetic x);
185float expm1f(float x);
186long double expm1l(long double x);
187
188floating_point fdim (arithmetic x, arithmetic y);
189float fdimf(float x, float y);
190long double fdiml(long double x, long double y);
191
192floating_point fma (arithmetic x, arithmetic y, arithmetic z);
193float fmaf(float x, float y, float z);
194long double fmal(long double x, long double y, long double z);
195
196floating_point fmax (arithmetic x, arithmetic y);
197float fmaxf(float x, float y);
198long double fmaxl(long double x, long double y);
199
200floating_point fmin (arithmetic x, arithmetic y);
201float fminf(float x, float y);
202long double fminl(long double x, long double y);
203
204floating_point hypot (arithmetic x, arithmetic y);
205float hypotf(float x, float y);
206long double hypotl(long double x, long double y);
207
208int ilogb (arithmetic x);
209int ilogbf(float x);
210int ilogbl(long double x);
211
212floating_point lgamma (arithmetic x);
213float lgammaf(float x);
214long double lgammal(long double x);
215
216long long llrint (arithmetic x);
217long long llrintf(float x);
218long long llrintl(long double x);
219
220long long llround (arithmetic x);
221long long llroundf(float x);
222long long llroundl(long double x);
223
224floating_point log1p (arithmetic x);
225float log1pf(float x);
226long double log1pl(long double x);
227
228floating_point log2 (arithmetic x);
229float log2f(float x);
230long double log2l(long double x);
231
232floating_point logb (arithmetic x);
233float logbf(float x);
234long double logbl(long double x);
235
236long lrint (arithmetic x);
237long lrintf(float x);
238long lrintl(long double x);
239
240long lround (arithmetic x);
241long lroundf(float x);
242long lroundl(long double x);
243
244double nan (const char* str);
245float nanf(const char* str);
246long double nanl(const char* str);
247
248floating_point nearbyint (arithmetic x);
249float nearbyintf(float x);
250long double nearbyintl(long double x);
251
252floating_point nextafter (arithmetic x, arithmetic y);
253float nextafterf(float x, float y);
254long double nextafterl(long double x, long double y);
255
256floating_point nexttoward (arithmetic x, long double y);
257float nexttowardf(float x, long double y);
258long double nexttowardl(long double x, long double y);
259
260floating_point remainder (arithmetic x, arithmetic y);
261float remainderf(float x, float y);
262long double remainderl(long double x, long double y);
263
264floating_point remquo (arithmetic x, arithmetic y, int* pquo);
265float remquof(float x, float y, int* pquo);
266long double remquol(long double x, long double y, int* pquo);
267
268floating_point rint (arithmetic x);
269float rintf(float x);
270long double rintl(long double x);
271
272floating_point round (arithmetic x);
273float roundf(float x);
274long double roundl(long double x);
275
276floating_point scalbln (arithmetic x, long ex);
277float scalblnf(float x, long ex);
278long double scalblnl(long double x, long ex);
279
280floating_point scalbn (arithmetic x, int ex);
281float scalbnf(float x, int ex);
282long double scalbnl(long double x, int ex);
283
284floating_point tgamma (arithmetic x);
285float tgammaf(float x);
286long double tgammal(long double x);
287
288floating_point trunc (arithmetic x);
289float truncf(float x);
290long double truncl(long double x);
291
292*/
293
294#include <__config>
Richard Smith081bb592015-10-08 20:40:34 +0000295
296#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Arthur O'Dwyer6eeaa002022-02-01 20:16:40 -0500297# pragma GCC system_header
Richard Smith081bb592015-10-08 20:40:34 +0000298#endif
299
Louis Dionnebe1aa9e2022-11-15 17:08:01 -0500300# if __has_include_next(<math.h>)
301# include_next <math.h>
302# endif
Mikhail Maltsev34b4f972018-02-22 09:34:08 +0000303
Richard Smith081bb592015-10-08 20:40:34 +0000304#ifdef __cplusplus
305
306// We support including .h headers inside 'extern "C"' contexts, so switch
307// back to C++ linkage before including these C++ headers.
308extern "C++" {
309
Nikolas Klauser6c8f7122022-07-24 16:03:12 +0200310#include <__type_traits/promote.h>
Arthur O'Dwyer65077c02022-01-07 09:45:05 -0500311#include <limits>
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500312#include <stdlib.h>
Richard Smith081bb592015-10-08 20:40:34 +0000313#include <type_traits>
314
Richard Smith081bb592015-10-08 20:40:34 +0000315// signbit
316
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100317# ifdef signbit
Richard Smith081bb592015-10-08 20:40:34 +0000318
319template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100320_LIBCPP_HIDE_FROM_ABI bool __libcpp_signbit(_A1 __x) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100321 return __builtin_signbit(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000322}
323
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100324# undef signbit
Richard Smith081bb592015-10-08 20:40:34 +0000325
326template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100327inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
328signbit(_A1 __x) _NOEXCEPT {
329 return __libcpp_signbit(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000330}
331
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000332template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200333inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100334 typename std::enable_if< std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
335 signbit(_A1 __x) _NOEXCEPT {
336 return __x < 0;
337}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000338
339template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200340inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100341 typename std::enable_if< std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
342 signbit(_A1) _NOEXCEPT {
343 return false;
344}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000345
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100346# elif defined(_LIBCPP_MSVCRT)
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000347
348template <typename _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100349inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
350signbit(_A1 __x) _NOEXCEPT {
Nikolas Klauser37a5b4f2022-10-27 20:01:13 +0200351 return ::signbit(__x);
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000352}
353
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000354template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200355inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100356 typename std::enable_if< std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
357 signbit(_A1 __x) _NOEXCEPT {
358 return __x < 0;
359}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000360
361template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200362inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100363 typename std::enable_if< std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
364 signbit(_A1) _NOEXCEPT {
365 return false;
366}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000367
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100368# endif // signbit
Richard Smith081bb592015-10-08 20:40:34 +0000369
370// fpclassify
371
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100372# ifdef fpclassify
Richard Smith081bb592015-10-08 20:40:34 +0000373
374template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100375_LIBCPP_HIDE_FROM_ABI int __libcpp_fpclassify(_A1 __x) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100376 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
Richard Smith081bb592015-10-08 20:40:34 +0000377}
378
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100379# undef fpclassify
Richard Smith081bb592015-10-08 20:40:34 +0000380
381template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100382inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, int>::type
383fpclassify(_A1 __x) _NOEXCEPT {
384 return __libcpp_fpclassify(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000385}
386
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000387template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100388inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, int>::type
389fpclassify(_A1 __x) _NOEXCEPT {
390 return __x == 0 ? FP_ZERO : FP_NORMAL;
391}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000392
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100393# elif defined(_LIBCPP_MSVCRT)
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000394
395template <typename _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100396inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
397fpclassify(_A1 __x) _NOEXCEPT {
Nikolas Klauser37a5b4f2022-10-27 20:01:13 +0200398 return ::fpclassify(__x);
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000399}
400
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000401template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100402inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, int>::type
403fpclassify(_A1 __x) _NOEXCEPT {
404 return __x == 0 ? FP_ZERO : FP_NORMAL;
405}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000406
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100407# endif // fpclassify
Richard Smith081bb592015-10-08 20:40:34 +0000408
409// isfinite
410
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100411# ifdef isfinite
Richard Smith081bb592015-10-08 20:40:34 +0000412
413template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100414_LIBCPP_HIDE_FROM_ABI bool __libcpp_isfinite(_A1 __x) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100415 return __builtin_isfinite(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000416}
417
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100418# undef isfinite
Richard Smith081bb592015-10-08 20:40:34 +0000419
420template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200421inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100422 typename std::enable_if< std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, bool>::type
423 isfinite(_A1 __x) _NOEXCEPT {
424 return __libcpp_isfinite((typename std::__promote<_A1>::type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000425}
426
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000427template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200428inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100429 typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type
430 isfinite(_A1) _NOEXCEPT {
431 return true;
432}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000433
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100434# endif // isfinite
Richard Smith081bb592015-10-08 20:40:34 +0000435
436// isinf
437
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100438# ifdef isinf
Richard Smith081bb592015-10-08 20:40:34 +0000439
440template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100441_LIBCPP_HIDE_FROM_ABI bool __libcpp_isinf(_A1 __x) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100442 return __builtin_isinf(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000443}
444
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100445# undef isinf
Richard Smith081bb592015-10-08 20:40:34 +0000446
447template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200448inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100449 typename std::enable_if< std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, bool>::type
450 isinf(_A1 __x) _NOEXCEPT {
451 return __libcpp_isinf((typename std::__promote<_A1>::type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000452}
453
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000454template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200455inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100456 typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type
457 isinf(_A1) _NOEXCEPT {
458 return false;
459}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000460
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100461# ifdef _LIBCPP_PREFERRED_OVERLOAD
462inline _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { return __libcpp_isinf(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000463
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100464inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT { return __libcpp_isinf(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000465
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100466inline _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { return __libcpp_isinf(__x); }
467# endif
Richard Smithafccfd32018-05-01 03:05:40 +0000468
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100469# endif // isinf
Richard Smith081bb592015-10-08 20:40:34 +0000470
471// isnan
472
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100473# ifdef isnan
Richard Smith081bb592015-10-08 20:40:34 +0000474
475template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100476_LIBCPP_HIDE_FROM_ABI bool __libcpp_isnan(_A1 __x) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100477 return __builtin_isnan(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000478}
479
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100480# undef isnan
Richard Smith081bb592015-10-08 20:40:34 +0000481
482template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100483inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
484isnan(_A1 __x) _NOEXCEPT {
485 return __libcpp_isnan(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000486}
487
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000488template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100489inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, bool>::type isnan(_A1) _NOEXCEPT {
490 return false;
491}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000492
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100493# ifdef _LIBCPP_PREFERRED_OVERLOAD
494inline _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { return __libcpp_isnan(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000495
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100496inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT { return __libcpp_isnan(__x); }
Richard Smithafccfd32018-05-01 03:05:40 +0000497
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100498inline _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { return __libcpp_isnan(__x); }
499# endif
Richard Smithafccfd32018-05-01 03:05:40 +0000500
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100501# endif // isnan
Richard Smith081bb592015-10-08 20:40:34 +0000502
503// isnormal
504
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100505# ifdef isnormal
Richard Smith081bb592015-10-08 20:40:34 +0000506
507template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100508_LIBCPP_HIDE_FROM_ABI bool __libcpp_isnormal(_A1 __x) _NOEXCEPT {
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100509 return __builtin_isnormal(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000510}
511
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100512# undef isnormal
Richard Smith081bb592015-10-08 20:40:34 +0000513
514template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100515inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
516isnormal(_A1 __x) _NOEXCEPT {
517 return __libcpp_isnormal(__x);
Richard Smith081bb592015-10-08 20:40:34 +0000518}
519
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000520template <class _A1>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100521inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, bool>::type
522isnormal(_A1 __x) _NOEXCEPT {
523 return __x != 0;
524}
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000525
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100526# endif // isnormal
Richard Smith081bb592015-10-08 20:40:34 +0000527
528// isgreater
529
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100530# ifdef isgreater
Richard Smith081bb592015-10-08 20:40:34 +0000531
532template <class _A1, class _A2>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100533_LIBCPP_HIDE_FROM_ABI bool __libcpp_isgreater(_A1 __x, _A2 __y) _NOEXCEPT {
534 return isgreater(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000535}
536
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100537# undef isgreater
Richard Smith081bb592015-10-08 20:40:34 +0000538
539template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200540inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100541 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
542 isgreater(_A1 __x, _A2 __y) _NOEXCEPT {
543 typedef typename std::__promote<_A1, _A2>::type type;
544 return __libcpp_isgreater((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000545}
546
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100547# endif // isgreater
Richard Smith081bb592015-10-08 20:40:34 +0000548
549// isgreaterequal
550
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100551# ifdef isgreaterequal
Richard Smith081bb592015-10-08 20:40:34 +0000552
553template <class _A1, class _A2>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100554_LIBCPP_HIDE_FROM_ABI bool __libcpp_isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {
555 return isgreaterequal(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000556}
557
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100558# undef isgreaterequal
Richard Smith081bb592015-10-08 20:40:34 +0000559
560template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200561inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100562 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
563 isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {
564 typedef typename std::__promote<_A1, _A2>::type type;
565 return __libcpp_isgreaterequal((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000566}
567
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100568# endif // isgreaterequal
Richard Smith081bb592015-10-08 20:40:34 +0000569
570// isless
571
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100572# ifdef isless
Richard Smith081bb592015-10-08 20:40:34 +0000573
574template <class _A1, class _A2>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100575_LIBCPP_HIDE_FROM_ABI bool __libcpp_isless(_A1 __x, _A2 __y) _NOEXCEPT {
576 return isless(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000577}
578
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100579# undef isless
Richard Smith081bb592015-10-08 20:40:34 +0000580
581template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200582inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100583 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
584 isless(_A1 __x, _A2 __y) _NOEXCEPT {
585 typedef typename std::__promote<_A1, _A2>::type type;
586 return __libcpp_isless((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000587}
588
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100589# endif // isless
Richard Smith081bb592015-10-08 20:40:34 +0000590
591// islessequal
592
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100593# ifdef islessequal
Richard Smith081bb592015-10-08 20:40:34 +0000594
595template <class _A1, class _A2>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100596_LIBCPP_HIDE_FROM_ABI bool __libcpp_islessequal(_A1 __x, _A2 __y) _NOEXCEPT {
597 return islessequal(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000598}
599
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100600# undef islessequal
Richard Smith081bb592015-10-08 20:40:34 +0000601
602template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200603inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100604 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
605 islessequal(_A1 __x, _A2 __y) _NOEXCEPT {
606 typedef typename std::__promote<_A1, _A2>::type type;
607 return __libcpp_islessequal((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000608}
609
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100610# endif // islessequal
Richard Smith081bb592015-10-08 20:40:34 +0000611
612// islessgreater
613
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100614# ifdef islessgreater
Richard Smith081bb592015-10-08 20:40:34 +0000615
616template <class _A1, class _A2>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100617_LIBCPP_HIDE_FROM_ABI bool __libcpp_islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {
618 return islessgreater(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000619}
620
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100621# undef islessgreater
Richard Smith081bb592015-10-08 20:40:34 +0000622
623template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200624inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100625 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
626 islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {
627 typedef typename std::__promote<_A1, _A2>::type type;
628 return __libcpp_islessgreater((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000629}
630
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100631# endif // islessgreater
Richard Smith081bb592015-10-08 20:40:34 +0000632
633// isunordered
634
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100635# ifdef isunordered
Richard Smith081bb592015-10-08 20:40:34 +0000636
637template <class _A1, class _A2>
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100638_LIBCPP_HIDE_FROM_ABI bool __libcpp_isunordered(_A1 __x, _A2 __y) _NOEXCEPT {
639 return isunordered(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000640}
641
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100642# undef isunordered
Richard Smith081bb592015-10-08 20:40:34 +0000643
644template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200645inline _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100646 typename std::enable_if< std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, bool >::type
647 isunordered(_A1 __x, _A2 __y) _NOEXCEPT {
648 typedef typename std::__promote<_A1, _A2>::type type;
649 return __libcpp_isunordered((type)__x, (type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000650}
651
Nikolas Klauser9a97dd72022-11-04 16:36:34 +0100652# endif // isunordered
Richard Smith081bb592015-10-08 20:40:34 +0000653
Richard Smith081bb592015-10-08 20:40:34 +0000654// abs
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500655//
656// handled in stdlib.h
Richard Smith081bb592015-10-08 20:40:34 +0000657
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000658// div
Eric Fiselier6c9e1a72020-02-15 18:55:07 -0500659//
660// handled in stdlib.h
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000661
Richard Smith081bb592015-10-08 20:40:34 +0000662// acos
663
David Tenty7249ac92022-02-07 18:22:35 -0500664# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200665inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return ::acosf(__x);}
666inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT {return ::acosl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500667# endif
Richard Smith081bb592015-10-08 20:40:34 +0000668
669template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200670inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000671typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200672acos(_A1 __x) _NOEXCEPT {return ::acos((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000673
674// asin
675
David Tenty7249ac92022-02-07 18:22:35 -0500676# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200677inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return ::asinf(__x);}
678inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT {return ::asinl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500679# endif
Richard Smith081bb592015-10-08 20:40:34 +0000680
681template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200682inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000683typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200684asin(_A1 __x) _NOEXCEPT {return ::asin((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000685
686// atan
687
David Tenty7249ac92022-02-07 18:22:35 -0500688# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200689inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return ::atanf(__x);}
690inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT {return ::atanl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500691# endif
Richard Smith081bb592015-10-08 20:40:34 +0000692
693template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200694inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000695typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200696atan(_A1 __x) _NOEXCEPT {return ::atan((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000697
698// atan2
699
David Tenty7249ac92022-02-07 18:22:35 -0500700# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200701inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return ::atan2f(__y, __x);}
702inline _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 -0500703# endif
Richard Smith081bb592015-10-08 20:40:34 +0000704
705template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200706inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400707typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000708<
709 std::is_arithmetic<_A1>::value &&
710 std::is_arithmetic<_A2>::value,
711 std::__promote<_A1, _A2>
712>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200713atan2(_A1 __y, _A2 __x) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000714{
715 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000716 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
717 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200718 return ::atan2((__result_type)__y, (__result_type)__x);
Richard Smith081bb592015-10-08 20:40:34 +0000719}
720
721// ceil
722
David Tenty7249ac92022-02-07 18:22:35 -0500723# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200724inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return ::ceilf(__x);}
725inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return ::ceill(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500726# endif
Richard Smith081bb592015-10-08 20:40:34 +0000727
728template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200729inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000730typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200731ceil(_A1 __x) _NOEXCEPT {return ::ceil((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000732
733// cos
734
David Tenty7249ac92022-02-07 18:22:35 -0500735# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200736inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return ::cosf(__x);}
737inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT {return ::cosl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500738# endif
Richard Smith081bb592015-10-08 20:40:34 +0000739
740template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200741inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000742typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200743cos(_A1 __x) _NOEXCEPT {return ::cos((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000744
745// cosh
746
David Tenty7249ac92022-02-07 18:22:35 -0500747# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200748inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return ::coshf(__x);}
749inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT {return ::coshl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500750# endif
Richard Smith081bb592015-10-08 20:40:34 +0000751
752template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200753inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000754typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200755cosh(_A1 __x) _NOEXCEPT {return ::cosh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000756
757// exp
758
David Tenty7249ac92022-02-07 18:22:35 -0500759# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200760inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return ::expf(__x);}
761inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT {return ::expl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500762# endif
Richard Smith081bb592015-10-08 20:40:34 +0000763
764template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200765inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000766typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200767exp(_A1 __x) _NOEXCEPT {return ::exp((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000768
769// fabs
770
David Tenty7249ac92022-02-07 18:22:35 -0500771# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200772inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return ::fabsf(__x);}
773inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return ::fabsl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500774# endif
Richard Smith081bb592015-10-08 20:40:34 +0000775
776template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200777inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000778typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200779fabs(_A1 __x) _NOEXCEPT {return ::fabs((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000780
781// floor
782
David Tenty7249ac92022-02-07 18:22:35 -0500783# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200784inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return ::floorf(__x);}
785inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return ::floorl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500786# endif
Richard Smith081bb592015-10-08 20:40:34 +0000787
788template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200789inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000790typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200791floor(_A1 __x) _NOEXCEPT {return ::floor((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000792
793// fmod
794
David Tenty7249ac92022-02-07 18:22:35 -0500795# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200796inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return ::fmodf(__x, __y);}
797inline _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 -0500798# endif
Richard Smith081bb592015-10-08 20:40:34 +0000799
800template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200801inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400802typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000803<
804 std::is_arithmetic<_A1>::value &&
805 std::is_arithmetic<_A2>::value,
806 std::__promote<_A1, _A2>
807>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200808fmod(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000809{
810 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000811 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
812 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200813 return ::fmod((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000814}
815
816// frexp
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 frexp(float __x, int* __e) _NOEXCEPT {return ::frexpf(__x, __e);}
820inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {return ::frexpl(__x, __e);}
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 +0200826frexp(_A1 __x, int* __e) _NOEXCEPT {return ::frexp((double)__x, __e);}
Richard Smith081bb592015-10-08 20:40:34 +0000827
828// ldexp
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 ldexp(float __x, int __e) _NOEXCEPT {return ::ldexpf(__x, __e);}
832inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {return ::ldexpl(__x, __e);}
David Tenty7249ac92022-02-07 18:22:35 -0500833# endif
Richard Smith081bb592015-10-08 20:40:34 +0000834
835template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200836inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000837typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200838ldexp(_A1 __x, int __e) _NOEXCEPT {return ::ldexp((double)__x, __e);}
Richard Smith081bb592015-10-08 20:40:34 +0000839
840// log
841
David Tenty7249ac92022-02-07 18:22:35 -0500842# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200843inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return ::logf(__x);}
844inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT {return ::logl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500845# endif
Richard Smith081bb592015-10-08 20:40:34 +0000846
847template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200848inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000849typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200850log(_A1 __x) _NOEXCEPT {return ::log((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000851
852// log10
853
David Tenty7249ac92022-02-07 18:22:35 -0500854# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200855inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return ::log10f(__x);}
856inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT {return ::log10l(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500857# endif
Richard Smith081bb592015-10-08 20:40:34 +0000858
859template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200860inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000861typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200862log10(_A1 __x) _NOEXCEPT {return ::log10((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000863
864// modf
865
David Tenty7249ac92022-02-07 18:22:35 -0500866# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200867inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return ::modff(__x, __y);}
868inline _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 -0500869# endif
Richard Smith081bb592015-10-08 20:40:34 +0000870
871// pow
872
David Tenty7249ac92022-02-07 18:22:35 -0500873# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200874inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return ::powf(__x, __y);}
875inline _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 -0500876# endif
Richard Smith081bb592015-10-08 20:40:34 +0000877
878template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200879inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -0400880typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +0000881<
882 std::is_arithmetic<_A1>::value &&
883 std::is_arithmetic<_A2>::value,
884 std::__promote<_A1, _A2>
885>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200886pow(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +0000887{
888 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000889 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
890 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +0200891 return ::pow((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +0000892}
893
894// sin
895
David Tenty7249ac92022-02-07 18:22:35 -0500896# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200897inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return ::sinf(__x);}
898inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT {return ::sinl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000899#endif
900
901template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200902inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000903typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200904sin(_A1 __x) _NOEXCEPT {return ::sin((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000905
906// sinh
907
David Tenty7249ac92022-02-07 18:22:35 -0500908# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200909inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return ::sinhf(__x);}
910inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT {return ::sinhl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500911# endif
Richard Smith081bb592015-10-08 20:40:34 +0000912
913template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200914inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000915typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200916sinh(_A1 __x) _NOEXCEPT {return ::sinh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000917
918// sqrt
919
David Tenty7249ac92022-02-07 18:22:35 -0500920# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200921inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return ::sqrtf(__x);}
922inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT {return ::sqrtl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500923# endif
Richard Smith081bb592015-10-08 20:40:34 +0000924
Richard Smith081bb592015-10-08 20:40:34 +0000925template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200926inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000927typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200928sqrt(_A1 __x) _NOEXCEPT {return ::sqrt((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000929
930// tan
931
David Tenty7249ac92022-02-07 18:22:35 -0500932# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200933inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return ::tanf(__x);}
934inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT {return ::tanl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500935# endif
Richard Smith081bb592015-10-08 20:40:34 +0000936
937template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200938inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000939typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200940tan(_A1 __x) _NOEXCEPT {return ::tan((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000941
942// tanh
943
David Tenty7249ac92022-02-07 18:22:35 -0500944# if !defined(__sun__)
Nikolas Klauser9806f452022-10-12 15:45:09 +0200945inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return ::tanhf(__x);}
946inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT {return ::tanhl(__x);}
David Tenty7249ac92022-02-07 18:22:35 -0500947# endif
Richard Smith081bb592015-10-08 20:40:34 +0000948
949template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200950inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000951typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200952tanh(_A1 __x) _NOEXCEPT {return ::tanh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000953
954// acosh
955
Nikolas Klauser9806f452022-10-12 15:45:09 +0200956inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return ::acoshf(__x);}
957inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT {return ::acoshl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000958
959template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200960inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000961typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200962acosh(_A1 __x) _NOEXCEPT {return ::acosh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000963
964// asinh
965
Nikolas Klauser9806f452022-10-12 15:45:09 +0200966inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return ::asinhf(__x);}
967inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT {return ::asinhl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000968
969template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200970inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000971typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200972asinh(_A1 __x) _NOEXCEPT {return ::asinh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000973
974// atanh
975
Nikolas Klauser9806f452022-10-12 15:45:09 +0200976inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return ::atanhf(__x);}
977inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT {return ::atanhl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000978
979template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +0200980inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +0000981typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +0200982atanh(_A1 __x) _NOEXCEPT {return ::atanh((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000983
984// cbrt
985
Nikolas Klauser9806f452022-10-12 15:45:09 +0200986inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return ::cbrtf(__x);}
987inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {return ::cbrtl(__x);}
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 +0200992cbrt(_A1 __x) _NOEXCEPT {return ::cbrt((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +0000993
994// copysign
995
Marek Kurdeja933f0d2021-07-21 15:58:17 +0200996_LIBCPP_CONSTEXPR
Nikolas Klauser9806f452022-10-12 15:45:09 +0200997inline _LIBCPP_HIDE_FROM_ABI float __libcpp_copysign(float __x, float __y) _NOEXCEPT {
Nikolas Klauser9806f452022-10-12 15:45:09 +0200998 return __builtin_copysignf(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +0000999}
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001000
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001001_LIBCPP_CONSTEXPR
Nikolas Klauser9806f452022-10-12 15:45:09 +02001002inline _LIBCPP_HIDE_FROM_ABI double __libcpp_copysign(double __x, double __y) _NOEXCEPT {
Nikolas Klauser9806f452022-10-12 15:45:09 +02001003 return __builtin_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001004}
1005
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001006_LIBCPP_CONSTEXPR
Nikolas Klauser9806f452022-10-12 15:45:09 +02001007inline _LIBCPP_HIDE_FROM_ABI long double __libcpp_copysign(long double __x, long double __y) _NOEXCEPT {
Nikolas Klauser9806f452022-10-12 15:45:09 +02001008 return __builtin_copysignl(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +00001009}
Richard Smith081bb592015-10-08 20:40:34 +00001010
1011template <class _A1, class _A2>
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001012_LIBCPP_CONSTEXPR
Nikolas Klauser4956e722022-10-12 15:41:22 +02001013inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001014typename std::__enable_if_t
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001015<
1016 std::is_arithmetic<_A1>::value &&
1017 std::is_arithmetic<_A2>::value,
1018 std::__promote<_A1, _A2>
1019>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001020__libcpp_copysign(_A1 __x, _A2 __y) _NOEXCEPT {
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001021 typedef typename std::__promote<_A1, _A2>::type __result_type;
1022 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1023 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001024 return __builtin_copysign((__result_type)__x, (__result_type)__y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001025}
1026
Nikolas Klauser9806f452022-10-12 15:45:09 +02001027inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT {
1028 return ::__libcpp_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001029}
1030
Nikolas Klauser9806f452022-10-12 15:45:09 +02001031inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT {
1032 return ::__libcpp_copysign(__x, __y);
Marek Kurdeja933f0d2021-07-21 15:58:17 +02001033}
1034
1035template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001036inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001037typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001038<
1039 std::is_arithmetic<_A1>::value &&
1040 std::is_arithmetic<_A2>::value,
1041 std::__promote<_A1, _A2>
1042>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001043 copysign(_A1 __x, _A2 __y) _NOEXCEPT {
1044 return ::__libcpp_copysign(__x, __y);
Richard Smith081bb592015-10-08 20:40:34 +00001045}
1046
Richard Smith081bb592015-10-08 20:40:34 +00001047// erf
1048
Nikolas Klauser9806f452022-10-12 15:45:09 +02001049inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return ::erff(__x);}
1050inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT {return ::erfl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001051
1052template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001053inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001054typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001055erf(_A1 __x) _NOEXCEPT {return ::erf((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001056
1057// erfc
1058
Nikolas Klauser9806f452022-10-12 15:45:09 +02001059inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return ::erfcf(__x);}
1060inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT {return ::erfcl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001061
1062template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001063inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001064typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001065erfc(_A1 __x) _NOEXCEPT {return ::erfc((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001066
1067// exp2
1068
Nikolas Klauser9806f452022-10-12 15:45:09 +02001069inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return ::exp2f(__x);}
1070inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT {return ::exp2l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001071
1072template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001073inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001074typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001075exp2(_A1 __x) _NOEXCEPT {return ::exp2((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001076
1077// expm1
1078
Nikolas Klauser9806f452022-10-12 15:45:09 +02001079inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return ::expm1f(__x);}
1080inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT {return ::expm1l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001081
1082template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001083inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001084typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001085expm1(_A1 __x) _NOEXCEPT {return ::expm1((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001086
1087// fdim
1088
Nikolas Klauser9806f452022-10-12 15:45:09 +02001089inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return ::fdimf(__x, __y);}
1090inline _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 +00001091
1092template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001093inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001094typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001095<
1096 std::is_arithmetic<_A1>::value &&
1097 std::is_arithmetic<_A2>::value,
1098 std::__promote<_A1, _A2>
1099>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001100fdim(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001101{
1102 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001103 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1104 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001105 return ::fdim((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001106}
1107
1108// fma
1109
Nikolas Klauser9806f452022-10-12 15:45:09 +02001110inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001111{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001112 return __builtin_fmaf(__x, __y, __z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001113}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001114inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001115{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001116 return __builtin_fmal(__x, __y, __z);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001117}
Richard Smith081bb592015-10-08 20:40:34 +00001118
1119template <class _A1, class _A2, class _A3>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001120inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001121typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001122<
1123 std::is_arithmetic<_A1>::value &&
1124 std::is_arithmetic<_A2>::value &&
1125 std::is_arithmetic<_A3>::value,
1126 std::__promote<_A1, _A2, _A3>
1127>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001128fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001129{
1130 typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001131 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1132 std::_IsSame<_A2, __result_type>::value &&
1133 std::_IsSame<_A3, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001134 return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
Richard Smith081bb592015-10-08 20:40:34 +00001135}
1136
1137// fmax
1138
Nikolas Klauser9806f452022-10-12 15:45:09 +02001139inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return ::fmaxf(__x, __y);}
1140inline _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 +00001141
1142template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001143inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001144typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001145<
1146 std::is_arithmetic<_A1>::value &&
1147 std::is_arithmetic<_A2>::value,
1148 std::__promote<_A1, _A2>
1149>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001150fmax(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001151{
1152 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001153 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1154 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001155 return ::fmax((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001156}
1157
1158// fmin
1159
Nikolas Klauser9806f452022-10-12 15:45:09 +02001160inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return ::fminf(__x, __y);}
1161inline _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 +00001162
1163template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001164inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001165typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001166<
1167 std::is_arithmetic<_A1>::value &&
1168 std::is_arithmetic<_A2>::value,
1169 std::__promote<_A1, _A2>
1170>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001171fmin(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001172{
1173 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001174 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1175 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001176 return ::fmin((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001177}
1178
1179// hypot
1180
Nikolas Klauser9806f452022-10-12 15:45:09 +02001181inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return ::hypotf(__x, __y);}
1182inline _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 +00001183
1184template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001185inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001186typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001187<
1188 std::is_arithmetic<_A1>::value &&
1189 std::is_arithmetic<_A2>::value,
1190 std::__promote<_A1, _A2>
1191>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001192hypot(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001193{
1194 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001195 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1196 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001197 return ::hypot((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001198}
1199
1200// ilogb
1201
Nikolas Klauser9806f452022-10-12 15:45:09 +02001202inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return ::ilogbf(__x);}
1203inline _LIBCPP_HIDE_FROM_ABI int ilogb(long double __x) _NOEXCEPT {return ::ilogbl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001204
1205template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001206inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001207typename std::enable_if<std::is_integral<_A1>::value, int>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001208ilogb(_A1 __x) _NOEXCEPT {return ::ilogb((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001209
1210// lgamma
1211
Nikolas Klauser9806f452022-10-12 15:45:09 +02001212inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return ::lgammaf(__x);}
1213inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT {return ::lgammal(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001214
1215template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001216inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001217typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001218lgamma(_A1 __x) _NOEXCEPT {return ::lgamma((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001219
1220// llrint
1221
Nikolas Klauser9806f452022-10-12 15:45:09 +02001222inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001223{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001224 return __builtin_llrintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001225}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001226inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001227{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001228 return __builtin_llrintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001229}
Richard Smith081bb592015-10-08 20:40:34 +00001230
1231template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001232inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001233typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001234llrint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001235{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001236 return __builtin_llrint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001237}
Richard Smith081bb592015-10-08 20:40:34 +00001238
1239// llround
1240
Nikolas Klauser9806f452022-10-12 15:45:09 +02001241inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001242{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001243 return __builtin_llroundf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001244}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001245inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001246{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001247 return __builtin_llroundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001248}
Richard Smith081bb592015-10-08 20:40:34 +00001249
1250template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001251inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001252typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001253llround(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001254{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001255 return __builtin_llround((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001256}
Richard Smith081bb592015-10-08 20:40:34 +00001257
1258// log1p
1259
Nikolas Klauser9806f452022-10-12 15:45:09 +02001260inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return ::log1pf(__x);}
1261inline _LIBCPP_HIDE_FROM_ABI long double log1p(long double __x) _NOEXCEPT {return ::log1pl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001262
1263template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001264inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001265typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001266log1p(_A1 __x) _NOEXCEPT {return ::log1p((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001267
1268// log2
1269
Nikolas Klauser9806f452022-10-12 15:45:09 +02001270inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return ::log2f(__x);}
1271inline _LIBCPP_HIDE_FROM_ABI long double log2(long double __x) _NOEXCEPT {return ::log2l(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001272
1273template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001274inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001275typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001276log2(_A1 __x) _NOEXCEPT {return ::log2((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001277
1278// logb
1279
Nikolas Klauser9806f452022-10-12 15:45:09 +02001280inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return ::logbf(__x);}
1281inline _LIBCPP_HIDE_FROM_ABI long double logb(long double __x) _NOEXCEPT {return ::logbl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001282
1283template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001284inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001285typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001286logb(_A1 __x) _NOEXCEPT {return ::logb((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001287
1288// lrint
1289
Nikolas Klauser9806f452022-10-12 15:45:09 +02001290inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001291{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001292 return __builtin_lrintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001293}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001294inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001295{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001296 return __builtin_lrintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001297}
Richard Smith081bb592015-10-08 20:40:34 +00001298
1299template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001300inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001301typename std::enable_if<std::is_integral<_A1>::value, long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001302lrint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001303{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001304 return __builtin_lrint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001305}
Richard Smith081bb592015-10-08 20:40:34 +00001306
1307// lround
1308
Nikolas Klauser9806f452022-10-12 15:45:09 +02001309inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001310{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001311 return __builtin_lroundf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001312}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001313inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001314{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001315 return __builtin_lroundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001316}
Richard Smith081bb592015-10-08 20:40:34 +00001317
1318template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001319inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001320typename std::enable_if<std::is_integral<_A1>::value, long>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001321lround(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001322{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001323 return __builtin_lround((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001324}
Richard Smith081bb592015-10-08 20:40:34 +00001325
1326// nan
1327
1328// nearbyint
1329
Nikolas Klauser9806f452022-10-12 15:45:09 +02001330inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return ::nearbyintf(__x);}
1331inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {return ::nearbyintl(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001332
1333template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001334inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001335typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001336nearbyint(_A1 __x) _NOEXCEPT {return ::nearbyint((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001337
1338// nextafter
1339
Nikolas Klauser9806f452022-10-12 15:45:09 +02001340inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return ::nextafterf(__x, __y);}
1341inline _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 +00001342
1343template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001344inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001345typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001346<
1347 std::is_arithmetic<_A1>::value &&
1348 std::is_arithmetic<_A2>::value,
1349 std::__promote<_A1, _A2>
1350>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001351nextafter(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001352{
1353 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001354 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1355 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001356 return ::nextafter((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001357}
1358
1359// nexttoward
1360
Nikolas Klauser9806f452022-10-12 15:45:09 +02001361inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return ::nexttowardf(__x, __y);}
1362inline _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 +00001363
1364template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001365inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001366typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001367nexttoward(_A1 __x, long double __y) _NOEXCEPT {return ::nexttoward((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001368
1369// remainder
1370
Nikolas Klauser9806f452022-10-12 15:45:09 +02001371inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return ::remainderf(__x, __y);}
1372inline _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 +00001373
1374template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001375inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001376typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001377<
1378 std::is_arithmetic<_A1>::value &&
1379 std::is_arithmetic<_A2>::value,
1380 std::__promote<_A1, _A2>
1381>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001382remainder(_A1 __x, _A2 __y) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001383{
1384 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001385 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1386 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001387 return ::remainder((__result_type)__x, (__result_type)__y);
Richard Smith081bb592015-10-08 20:40:34 +00001388}
1389
1390// remquo
1391
Nikolas Klauser9806f452022-10-12 15:45:09 +02001392inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return ::remquof(__x, __y, __z);}
1393inline _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 +00001394
1395template <class _A1, class _A2>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001396inline _LIBCPP_HIDE_FROM_ABI
Louis Dionne9ce598d2021-09-08 09:14:43 -04001397typename std::__enable_if_t
Richard Smith081bb592015-10-08 20:40:34 +00001398<
1399 std::is_arithmetic<_A1>::value &&
1400 std::is_arithmetic<_A2>::value,
1401 std::__promote<_A1, _A2>
1402>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001403remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT
Richard Smith081bb592015-10-08 20:40:34 +00001404{
1405 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001406 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1407 std::_IsSame<_A2, __result_type>::value)), "");
Nikolas Klauser9806f452022-10-12 15:45:09 +02001408 return ::remquo((__result_type)__x, (__result_type)__y, __z);
Richard Smith081bb592015-10-08 20:40:34 +00001409}
1410
1411// rint
1412
Nikolas Klauser9806f452022-10-12 15:45:09 +02001413inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001414{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001415 return __builtin_rintf(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001416}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001417inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001418{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001419 return __builtin_rintl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001420}
Richard Smith081bb592015-10-08 20:40:34 +00001421
1422template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001423inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001424typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001425rint(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001426{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001427 return __builtin_rint((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001428}
Richard Smith081bb592015-10-08 20:40:34 +00001429
1430// round
1431
Nikolas Klauser9806f452022-10-12 15:45:09 +02001432inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001433{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001434 return __builtin_round(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001435}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001436inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001437{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001438 return __builtin_roundl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001439}
Richard Smith081bb592015-10-08 20:40:34 +00001440
1441template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001442inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001443typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001444round(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001445{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001446 return __builtin_round((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001447}
Richard Smith081bb592015-10-08 20:40:34 +00001448
1449// scalbln
1450
Nikolas Klauser9806f452022-10-12 15:45:09 +02001451inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return ::scalblnf(__x, __y);}
1452inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT {return ::scalblnl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001453
1454template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001455inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001456typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001457scalbln(_A1 __x, long __y) _NOEXCEPT {return ::scalbln((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001458
1459// scalbn
1460
Nikolas Klauser9806f452022-10-12 15:45:09 +02001461inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return ::scalbnf(__x, __y);}
1462inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT {return ::scalbnl(__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001463
1464template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001465inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001466typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001467scalbn(_A1 __x, int __y) _NOEXCEPT {return ::scalbn((double)__x, __y);}
Richard Smith081bb592015-10-08 20:40:34 +00001468
1469// tgamma
1470
Nikolas Klauser9806f452022-10-12 15:45:09 +02001471inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return ::tgammaf(__x);}
1472inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT {return ::tgammal(__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001473
1474template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001475inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001476typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001477tgamma(_A1 __x) _NOEXCEPT {return ::tgamma((double)__x);}
Richard Smith081bb592015-10-08 20:40:34 +00001478
1479// trunc
1480
Nikolas Klauser9806f452022-10-12 15:45:09 +02001481inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001482{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001483 return __builtin_trunc(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001484}
Nikolas Klauser9806f452022-10-12 15:45:09 +02001485inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001486{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001487 return __builtin_truncl(__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001488}
Richard Smith081bb592015-10-08 20:40:34 +00001489
1490template <class _A1>
Nikolas Klauser4956e722022-10-12 15:41:22 +02001491inline _LIBCPP_HIDE_FROM_ABI
Richard Smith081bb592015-10-08 20:40:34 +00001492typename std::enable_if<std::is_integral<_A1>::value, double>::type
Nikolas Klauser9806f452022-10-12 15:45:09 +02001493trunc(_A1 __x) _NOEXCEPT
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001494{
Nikolas Klauser9806f452022-10-12 15:45:09 +02001495 return __builtin_trunc((double)__x);
Ilya Tokarc3abffb2021-02-10 13:05:19 -05001496}
Richard Smith081bb592015-10-08 20:40:34 +00001497
Richard Smith081bb592015-10-08 20:40:34 +00001498} // extern "C++"
1499
1500#endif // __cplusplus
1501
Mikhail Maltsev34b4f972018-02-22 09:34:08 +00001502#else // _LIBCPP_MATH_H
1503
1504// This include lives outside the header guard in order to support an MSVC
1505// extension which allows users to do:
1506//
1507// #define _USE_MATH_DEFINES
1508// #include <math.h>
1509//
1510// and receive the definitions of mathematical constants, even if <math.h>
1511// has previously been included.
1512#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
1513#include_next <math.h>
1514#endif
1515
Louis Dionne2b1ceaa2021-04-20 12:03:32 -04001516#endif // _LIBCPP_MATH_H