[docs] Fix build-docs.sh
[llvm-project.git] / clang / lib / Headers / tgmath.h
blob7acf18b9dd3578e1d315eda874bd3dfe189eeb6d
1 /*===---- tgmath.h - Standard header for type generic math ----------------===*\
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 \*===----------------------------------------------------------------------===*/
9 #ifndef __CLANG_TGMATH_H
10 #define __CLANG_TGMATH_H
12 /* C99 7.22 Type-generic math <tgmath.h>. */
13 #include <math.h>
16 * Allow additional definitions and implementation-defined values on Apple
17 * platforms. This is done after #include <math.h> to avoid depcycle conflicts
18 * between libcxx and darwin in C++ modules builds.
20 #if defined(__APPLE__) && __STDC_HOSTED__ && __has_include_next(<tgmath.h>)
21 # include_next <tgmath.h>
22 #else
24 /* C++ handles type genericity with overloading in math.h. */
25 #ifndef __cplusplus
26 #include <complex.h>
28 #define _TG_ATTRSp __attribute__((__overloadable__))
29 #define _TG_ATTRS __attribute__((__overloadable__, __always_inline__))
31 // promotion
33 typedef void _Argument_type_is_not_arithmetic;
34 static _Argument_type_is_not_arithmetic __tg_promote(...)
35 __attribute__((__unavailable__,__overloadable__));
36 static double _TG_ATTRSp __tg_promote(int);
37 static double _TG_ATTRSp __tg_promote(unsigned int);
38 static double _TG_ATTRSp __tg_promote(long);
39 static double _TG_ATTRSp __tg_promote(unsigned long);
40 static double _TG_ATTRSp __tg_promote(long long);
41 static double _TG_ATTRSp __tg_promote(unsigned long long);
42 static float _TG_ATTRSp __tg_promote(float);
43 static double _TG_ATTRSp __tg_promote(double);
44 static long double _TG_ATTRSp __tg_promote(long double);
45 static float _Complex _TG_ATTRSp __tg_promote(float _Complex);
46 static double _Complex _TG_ATTRSp __tg_promote(double _Complex);
47 static long double _Complex _TG_ATTRSp __tg_promote(long double _Complex);
49 #define __tg_promote1(__x) (__typeof__(__tg_promote(__x)))
50 #define __tg_promote2(__x, __y) (__typeof__(__tg_promote(__x) + \
51 __tg_promote(__y)))
52 #define __tg_promote3(__x, __y, __z) (__typeof__(__tg_promote(__x) + \
53 __tg_promote(__y) + \
54 __tg_promote(__z)))
56 // acos
58 static float
59 _TG_ATTRS
60 __tg_acos(float __x) {return acosf(__x);}
62 static double
63 _TG_ATTRS
64 __tg_acos(double __x) {return acos(__x);}
66 static long double
67 _TG_ATTRS
68 __tg_acos(long double __x) {return acosl(__x);}
70 static float _Complex
71 _TG_ATTRS
72 __tg_acos(float _Complex __x) {return cacosf(__x);}
74 static double _Complex
75 _TG_ATTRS
76 __tg_acos(double _Complex __x) {return cacos(__x);}
78 static long double _Complex
79 _TG_ATTRS
80 __tg_acos(long double _Complex __x) {return cacosl(__x);}
82 #undef acos
83 #define acos(__x) __tg_acos(__tg_promote1((__x))(__x))
85 // asin
87 static float
88 _TG_ATTRS
89 __tg_asin(float __x) {return asinf(__x);}
91 static double
92 _TG_ATTRS
93 __tg_asin(double __x) {return asin(__x);}
95 static long double
96 _TG_ATTRS
97 __tg_asin(long double __x) {return asinl(__x);}
99 static float _Complex
100 _TG_ATTRS
101 __tg_asin(float _Complex __x) {return casinf(__x);}
103 static double _Complex
104 _TG_ATTRS
105 __tg_asin(double _Complex __x) {return casin(__x);}
107 static long double _Complex
108 _TG_ATTRS
109 __tg_asin(long double _Complex __x) {return casinl(__x);}
111 #undef asin
112 #define asin(__x) __tg_asin(__tg_promote1((__x))(__x))
114 // atan
116 static float
117 _TG_ATTRS
118 __tg_atan(float __x) {return atanf(__x);}
120 static double
121 _TG_ATTRS
122 __tg_atan(double __x) {return atan(__x);}
124 static long double
125 _TG_ATTRS
126 __tg_atan(long double __x) {return atanl(__x);}
128 static float _Complex
129 _TG_ATTRS
130 __tg_atan(float _Complex __x) {return catanf(__x);}
132 static double _Complex
133 _TG_ATTRS
134 __tg_atan(double _Complex __x) {return catan(__x);}
136 static long double _Complex
137 _TG_ATTRS
138 __tg_atan(long double _Complex __x) {return catanl(__x);}
140 #undef atan
141 #define atan(__x) __tg_atan(__tg_promote1((__x))(__x))
143 // acosh
145 static float
146 _TG_ATTRS
147 __tg_acosh(float __x) {return acoshf(__x);}
149 static double
150 _TG_ATTRS
151 __tg_acosh(double __x) {return acosh(__x);}
153 static long double
154 _TG_ATTRS
155 __tg_acosh(long double __x) {return acoshl(__x);}
157 static float _Complex
158 _TG_ATTRS
159 __tg_acosh(float _Complex __x) {return cacoshf(__x);}
161 static double _Complex
162 _TG_ATTRS
163 __tg_acosh(double _Complex __x) {return cacosh(__x);}
165 static long double _Complex
166 _TG_ATTRS
167 __tg_acosh(long double _Complex __x) {return cacoshl(__x);}
169 #undef acosh
170 #define acosh(__x) __tg_acosh(__tg_promote1((__x))(__x))
172 // asinh
174 static float
175 _TG_ATTRS
176 __tg_asinh(float __x) {return asinhf(__x);}
178 static double
179 _TG_ATTRS
180 __tg_asinh(double __x) {return asinh(__x);}
182 static long double
183 _TG_ATTRS
184 __tg_asinh(long double __x) {return asinhl(__x);}
186 static float _Complex
187 _TG_ATTRS
188 __tg_asinh(float _Complex __x) {return casinhf(__x);}
190 static double _Complex
191 _TG_ATTRS
192 __tg_asinh(double _Complex __x) {return casinh(__x);}
194 static long double _Complex
195 _TG_ATTRS
196 __tg_asinh(long double _Complex __x) {return casinhl(__x);}
198 #undef asinh
199 #define asinh(__x) __tg_asinh(__tg_promote1((__x))(__x))
201 // atanh
203 static float
204 _TG_ATTRS
205 __tg_atanh(float __x) {return atanhf(__x);}
207 static double
208 _TG_ATTRS
209 __tg_atanh(double __x) {return atanh(__x);}
211 static long double
212 _TG_ATTRS
213 __tg_atanh(long double __x) {return atanhl(__x);}
215 static float _Complex
216 _TG_ATTRS
217 __tg_atanh(float _Complex __x) {return catanhf(__x);}
219 static double _Complex
220 _TG_ATTRS
221 __tg_atanh(double _Complex __x) {return catanh(__x);}
223 static long double _Complex
224 _TG_ATTRS
225 __tg_atanh(long double _Complex __x) {return catanhl(__x);}
227 #undef atanh
228 #define atanh(__x) __tg_atanh(__tg_promote1((__x))(__x))
230 // cos
232 static float
233 _TG_ATTRS
234 __tg_cos(float __x) {return cosf(__x);}
236 static double
237 _TG_ATTRS
238 __tg_cos(double __x) {return cos(__x);}
240 static long double
241 _TG_ATTRS
242 __tg_cos(long double __x) {return cosl(__x);}
244 static float _Complex
245 _TG_ATTRS
246 __tg_cos(float _Complex __x) {return ccosf(__x);}
248 static double _Complex
249 _TG_ATTRS
250 __tg_cos(double _Complex __x) {return ccos(__x);}
252 static long double _Complex
253 _TG_ATTRS
254 __tg_cos(long double _Complex __x) {return ccosl(__x);}
256 #undef cos
257 #define cos(__x) __tg_cos(__tg_promote1((__x))(__x))
259 // sin
261 static float
262 _TG_ATTRS
263 __tg_sin(float __x) {return sinf(__x);}
265 static double
266 _TG_ATTRS
267 __tg_sin(double __x) {return sin(__x);}
269 static long double
270 _TG_ATTRS
271 __tg_sin(long double __x) {return sinl(__x);}
273 static float _Complex
274 _TG_ATTRS
275 __tg_sin(float _Complex __x) {return csinf(__x);}
277 static double _Complex
278 _TG_ATTRS
279 __tg_sin(double _Complex __x) {return csin(__x);}
281 static long double _Complex
282 _TG_ATTRS
283 __tg_sin(long double _Complex __x) {return csinl(__x);}
285 #undef sin
286 #define sin(__x) __tg_sin(__tg_promote1((__x))(__x))
288 // tan
290 static float
291 _TG_ATTRS
292 __tg_tan(float __x) {return tanf(__x);}
294 static double
295 _TG_ATTRS
296 __tg_tan(double __x) {return tan(__x);}
298 static long double
299 _TG_ATTRS
300 __tg_tan(long double __x) {return tanl(__x);}
302 static float _Complex
303 _TG_ATTRS
304 __tg_tan(float _Complex __x) {return ctanf(__x);}
306 static double _Complex
307 _TG_ATTRS
308 __tg_tan(double _Complex __x) {return ctan(__x);}
310 static long double _Complex
311 _TG_ATTRS
312 __tg_tan(long double _Complex __x) {return ctanl(__x);}
314 #undef tan
315 #define tan(__x) __tg_tan(__tg_promote1((__x))(__x))
317 // cosh
319 static float
320 _TG_ATTRS
321 __tg_cosh(float __x) {return coshf(__x);}
323 static double
324 _TG_ATTRS
325 __tg_cosh(double __x) {return cosh(__x);}
327 static long double
328 _TG_ATTRS
329 __tg_cosh(long double __x) {return coshl(__x);}
331 static float _Complex
332 _TG_ATTRS
333 __tg_cosh(float _Complex __x) {return ccoshf(__x);}
335 static double _Complex
336 _TG_ATTRS
337 __tg_cosh(double _Complex __x) {return ccosh(__x);}
339 static long double _Complex
340 _TG_ATTRS
341 __tg_cosh(long double _Complex __x) {return ccoshl(__x);}
343 #undef cosh
344 #define cosh(__x) __tg_cosh(__tg_promote1((__x))(__x))
346 // sinh
348 static float
349 _TG_ATTRS
350 __tg_sinh(float __x) {return sinhf(__x);}
352 static double
353 _TG_ATTRS
354 __tg_sinh(double __x) {return sinh(__x);}
356 static long double
357 _TG_ATTRS
358 __tg_sinh(long double __x) {return sinhl(__x);}
360 static float _Complex
361 _TG_ATTRS
362 __tg_sinh(float _Complex __x) {return csinhf(__x);}
364 static double _Complex
365 _TG_ATTRS
366 __tg_sinh(double _Complex __x) {return csinh(__x);}
368 static long double _Complex
369 _TG_ATTRS
370 __tg_sinh(long double _Complex __x) {return csinhl(__x);}
372 #undef sinh
373 #define sinh(__x) __tg_sinh(__tg_promote1((__x))(__x))
375 // tanh
377 static float
378 _TG_ATTRS
379 __tg_tanh(float __x) {return tanhf(__x);}
381 static double
382 _TG_ATTRS
383 __tg_tanh(double __x) {return tanh(__x);}
385 static long double
386 _TG_ATTRS
387 __tg_tanh(long double __x) {return tanhl(__x);}
389 static float _Complex
390 _TG_ATTRS
391 __tg_tanh(float _Complex __x) {return ctanhf(__x);}
393 static double _Complex
394 _TG_ATTRS
395 __tg_tanh(double _Complex __x) {return ctanh(__x);}
397 static long double _Complex
398 _TG_ATTRS
399 __tg_tanh(long double _Complex __x) {return ctanhl(__x);}
401 #undef tanh
402 #define tanh(__x) __tg_tanh(__tg_promote1((__x))(__x))
404 // exp
406 static float
407 _TG_ATTRS
408 __tg_exp(float __x) {return expf(__x);}
410 static double
411 _TG_ATTRS
412 __tg_exp(double __x) {return exp(__x);}
414 static long double
415 _TG_ATTRS
416 __tg_exp(long double __x) {return expl(__x);}
418 static float _Complex
419 _TG_ATTRS
420 __tg_exp(float _Complex __x) {return cexpf(__x);}
422 static double _Complex
423 _TG_ATTRS
424 __tg_exp(double _Complex __x) {return cexp(__x);}
426 static long double _Complex
427 _TG_ATTRS
428 __tg_exp(long double _Complex __x) {return cexpl(__x);}
430 #undef exp
431 #define exp(__x) __tg_exp(__tg_promote1((__x))(__x))
433 // log
435 static float
436 _TG_ATTRS
437 __tg_log(float __x) {return logf(__x);}
439 static double
440 _TG_ATTRS
441 __tg_log(double __x) {return log(__x);}
443 static long double
444 _TG_ATTRS
445 __tg_log(long double __x) {return logl(__x);}
447 static float _Complex
448 _TG_ATTRS
449 __tg_log(float _Complex __x) {return clogf(__x);}
451 static double _Complex
452 _TG_ATTRS
453 __tg_log(double _Complex __x) {return clog(__x);}
455 static long double _Complex
456 _TG_ATTRS
457 __tg_log(long double _Complex __x) {return clogl(__x);}
459 #undef log
460 #define log(__x) __tg_log(__tg_promote1((__x))(__x))
462 // pow
464 static float
465 _TG_ATTRS
466 __tg_pow(float __x, float __y) {return powf(__x, __y);}
468 static double
469 _TG_ATTRS
470 __tg_pow(double __x, double __y) {return pow(__x, __y);}
472 static long double
473 _TG_ATTRS
474 __tg_pow(long double __x, long double __y) {return powl(__x, __y);}
476 static float _Complex
477 _TG_ATTRS
478 __tg_pow(float _Complex __x, float _Complex __y) {return cpowf(__x, __y);}
480 static double _Complex
481 _TG_ATTRS
482 __tg_pow(double _Complex __x, double _Complex __y) {return cpow(__x, __y);}
484 static long double _Complex
485 _TG_ATTRS
486 __tg_pow(long double _Complex __x, long double _Complex __y)
487 {return cpowl(__x, __y);}
489 #undef pow
490 #define pow(__x, __y) __tg_pow(__tg_promote2((__x), (__y))(__x), \
491 __tg_promote2((__x), (__y))(__y))
493 // sqrt
495 static float
496 _TG_ATTRS
497 __tg_sqrt(float __x) {return sqrtf(__x);}
499 static double
500 _TG_ATTRS
501 __tg_sqrt(double __x) {return sqrt(__x);}
503 static long double
504 _TG_ATTRS
505 __tg_sqrt(long double __x) {return sqrtl(__x);}
507 static float _Complex
508 _TG_ATTRS
509 __tg_sqrt(float _Complex __x) {return csqrtf(__x);}
511 static double _Complex
512 _TG_ATTRS
513 __tg_sqrt(double _Complex __x) {return csqrt(__x);}
515 static long double _Complex
516 _TG_ATTRS
517 __tg_sqrt(long double _Complex __x) {return csqrtl(__x);}
519 #undef sqrt
520 #define sqrt(__x) __tg_sqrt(__tg_promote1((__x))(__x))
522 // fabs
524 static float
525 _TG_ATTRS
526 __tg_fabs(float __x) {return fabsf(__x);}
528 static double
529 _TG_ATTRS
530 __tg_fabs(double __x) {return fabs(__x);}
532 static long double
533 _TG_ATTRS
534 __tg_fabs(long double __x) {return fabsl(__x);}
536 static float
537 _TG_ATTRS
538 __tg_fabs(float _Complex __x) {return cabsf(__x);}
540 static double
541 _TG_ATTRS
542 __tg_fabs(double _Complex __x) {return cabs(__x);}
544 static long double
545 _TG_ATTRS
546 __tg_fabs(long double _Complex __x) {return cabsl(__x);}
548 #undef fabs
549 #define fabs(__x) __tg_fabs(__tg_promote1((__x))(__x))
551 // atan2
553 static float
554 _TG_ATTRS
555 __tg_atan2(float __x, float __y) {return atan2f(__x, __y);}
557 static double
558 _TG_ATTRS
559 __tg_atan2(double __x, double __y) {return atan2(__x, __y);}
561 static long double
562 _TG_ATTRS
563 __tg_atan2(long double __x, long double __y) {return atan2l(__x, __y);}
565 #undef atan2
566 #define atan2(__x, __y) __tg_atan2(__tg_promote2((__x), (__y))(__x), \
567 __tg_promote2((__x), (__y))(__y))
569 // cbrt
571 static float
572 _TG_ATTRS
573 __tg_cbrt(float __x) {return cbrtf(__x);}
575 static double
576 _TG_ATTRS
577 __tg_cbrt(double __x) {return cbrt(__x);}
579 static long double
580 _TG_ATTRS
581 __tg_cbrt(long double __x) {return cbrtl(__x);}
583 #undef cbrt
584 #define cbrt(__x) __tg_cbrt(__tg_promote1((__x))(__x))
586 // ceil
588 static float
589 _TG_ATTRS
590 __tg_ceil(float __x) {return ceilf(__x);}
592 static double
593 _TG_ATTRS
594 __tg_ceil(double __x) {return ceil(__x);}
596 static long double
597 _TG_ATTRS
598 __tg_ceil(long double __x) {return ceill(__x);}
600 #undef ceil
601 #define ceil(__x) __tg_ceil(__tg_promote1((__x))(__x))
603 // copysign
605 static float
606 _TG_ATTRS
607 __tg_copysign(float __x, float __y) {return copysignf(__x, __y);}
609 static double
610 _TG_ATTRS
611 __tg_copysign(double __x, double __y) {return copysign(__x, __y);}
613 static long double
614 _TG_ATTRS
615 __tg_copysign(long double __x, long double __y) {return copysignl(__x, __y);}
617 #undef copysign
618 #define copysign(__x, __y) __tg_copysign(__tg_promote2((__x), (__y))(__x), \
619 __tg_promote2((__x), (__y))(__y))
621 // erf
623 static float
624 _TG_ATTRS
625 __tg_erf(float __x) {return erff(__x);}
627 static double
628 _TG_ATTRS
629 __tg_erf(double __x) {return erf(__x);}
631 static long double
632 _TG_ATTRS
633 __tg_erf(long double __x) {return erfl(__x);}
635 #undef erf
636 #define erf(__x) __tg_erf(__tg_promote1((__x))(__x))
638 // erfc
640 static float
641 _TG_ATTRS
642 __tg_erfc(float __x) {return erfcf(__x);}
644 static double
645 _TG_ATTRS
646 __tg_erfc(double __x) {return erfc(__x);}
648 static long double
649 _TG_ATTRS
650 __tg_erfc(long double __x) {return erfcl(__x);}
652 #undef erfc
653 #define erfc(__x) __tg_erfc(__tg_promote1((__x))(__x))
655 // exp2
657 static float
658 _TG_ATTRS
659 __tg_exp2(float __x) {return exp2f(__x);}
661 static double
662 _TG_ATTRS
663 __tg_exp2(double __x) {return exp2(__x);}
665 static long double
666 _TG_ATTRS
667 __tg_exp2(long double __x) {return exp2l(__x);}
669 #undef exp2
670 #define exp2(__x) __tg_exp2(__tg_promote1((__x))(__x))
672 // expm1
674 static float
675 _TG_ATTRS
676 __tg_expm1(float __x) {return expm1f(__x);}
678 static double
679 _TG_ATTRS
680 __tg_expm1(double __x) {return expm1(__x);}
682 static long double
683 _TG_ATTRS
684 __tg_expm1(long double __x) {return expm1l(__x);}
686 #undef expm1
687 #define expm1(__x) __tg_expm1(__tg_promote1((__x))(__x))
689 // fdim
691 static float
692 _TG_ATTRS
693 __tg_fdim(float __x, float __y) {return fdimf(__x, __y);}
695 static double
696 _TG_ATTRS
697 __tg_fdim(double __x, double __y) {return fdim(__x, __y);}
699 static long double
700 _TG_ATTRS
701 __tg_fdim(long double __x, long double __y) {return fdiml(__x, __y);}
703 #undef fdim
704 #define fdim(__x, __y) __tg_fdim(__tg_promote2((__x), (__y))(__x), \
705 __tg_promote2((__x), (__y))(__y))
707 // floor
709 static float
710 _TG_ATTRS
711 __tg_floor(float __x) {return floorf(__x);}
713 static double
714 _TG_ATTRS
715 __tg_floor(double __x) {return floor(__x);}
717 static long double
718 _TG_ATTRS
719 __tg_floor(long double __x) {return floorl(__x);}
721 #undef floor
722 #define floor(__x) __tg_floor(__tg_promote1((__x))(__x))
724 // fma
726 static float
727 _TG_ATTRS
728 __tg_fma(float __x, float __y, float __z)
729 {return fmaf(__x, __y, __z);}
731 static double
732 _TG_ATTRS
733 __tg_fma(double __x, double __y, double __z)
734 {return fma(__x, __y, __z);}
736 static long double
737 _TG_ATTRS
738 __tg_fma(long double __x,long double __y, long double __z)
739 {return fmal(__x, __y, __z);}
741 #undef fma
742 #define fma(__x, __y, __z) \
743 __tg_fma(__tg_promote3((__x), (__y), (__z))(__x), \
744 __tg_promote3((__x), (__y), (__z))(__y), \
745 __tg_promote3((__x), (__y), (__z))(__z))
747 // fmax
749 static float
750 _TG_ATTRS
751 __tg_fmax(float __x, float __y) {return fmaxf(__x, __y);}
753 static double
754 _TG_ATTRS
755 __tg_fmax(double __x, double __y) {return fmax(__x, __y);}
757 static long double
758 _TG_ATTRS
759 __tg_fmax(long double __x, long double __y) {return fmaxl(__x, __y);}
761 #undef fmax
762 #define fmax(__x, __y) __tg_fmax(__tg_promote2((__x), (__y))(__x), \
763 __tg_promote2((__x), (__y))(__y))
765 // fmin
767 static float
768 _TG_ATTRS
769 __tg_fmin(float __x, float __y) {return fminf(__x, __y);}
771 static double
772 _TG_ATTRS
773 __tg_fmin(double __x, double __y) {return fmin(__x, __y);}
775 static long double
776 _TG_ATTRS
777 __tg_fmin(long double __x, long double __y) {return fminl(__x, __y);}
779 #undef fmin
780 #define fmin(__x, __y) __tg_fmin(__tg_promote2((__x), (__y))(__x), \
781 __tg_promote2((__x), (__y))(__y))
783 // fmod
785 static float
786 _TG_ATTRS
787 __tg_fmod(float __x, float __y) {return fmodf(__x, __y);}
789 static double
790 _TG_ATTRS
791 __tg_fmod(double __x, double __y) {return fmod(__x, __y);}
793 static long double
794 _TG_ATTRS
795 __tg_fmod(long double __x, long double __y) {return fmodl(__x, __y);}
797 #undef fmod
798 #define fmod(__x, __y) __tg_fmod(__tg_promote2((__x), (__y))(__x), \
799 __tg_promote2((__x), (__y))(__y))
801 // frexp
803 static float
804 _TG_ATTRS
805 __tg_frexp(float __x, int* __y) {return frexpf(__x, __y);}
807 static double
808 _TG_ATTRS
809 __tg_frexp(double __x, int* __y) {return frexp(__x, __y);}
811 static long double
812 _TG_ATTRS
813 __tg_frexp(long double __x, int* __y) {return frexpl(__x, __y);}
815 #undef frexp
816 #define frexp(__x, __y) __tg_frexp(__tg_promote1((__x))(__x), __y)
818 // hypot
820 static float
821 _TG_ATTRS
822 __tg_hypot(float __x, float __y) {return hypotf(__x, __y);}
824 static double
825 _TG_ATTRS
826 __tg_hypot(double __x, double __y) {return hypot(__x, __y);}
828 static long double
829 _TG_ATTRS
830 __tg_hypot(long double __x, long double __y) {return hypotl(__x, __y);}
832 #undef hypot
833 #define hypot(__x, __y) __tg_hypot(__tg_promote2((__x), (__y))(__x), \
834 __tg_promote2((__x), (__y))(__y))
836 // ilogb
838 static int
839 _TG_ATTRS
840 __tg_ilogb(float __x) {return ilogbf(__x);}
842 static int
843 _TG_ATTRS
844 __tg_ilogb(double __x) {return ilogb(__x);}
846 static int
847 _TG_ATTRS
848 __tg_ilogb(long double __x) {return ilogbl(__x);}
850 #undef ilogb
851 #define ilogb(__x) __tg_ilogb(__tg_promote1((__x))(__x))
853 // ldexp
855 static float
856 _TG_ATTRS
857 __tg_ldexp(float __x, int __y) {return ldexpf(__x, __y);}
859 static double
860 _TG_ATTRS
861 __tg_ldexp(double __x, int __y) {return ldexp(__x, __y);}
863 static long double
864 _TG_ATTRS
865 __tg_ldexp(long double __x, int __y) {return ldexpl(__x, __y);}
867 #undef ldexp
868 #define ldexp(__x, __y) __tg_ldexp(__tg_promote1((__x))(__x), __y)
870 // lgamma
872 static float
873 _TG_ATTRS
874 __tg_lgamma(float __x) {return lgammaf(__x);}
876 static double
877 _TG_ATTRS
878 __tg_lgamma(double __x) {return lgamma(__x);}
880 static long double
881 _TG_ATTRS
882 __tg_lgamma(long double __x) {return lgammal(__x);}
884 #undef lgamma
885 #define lgamma(__x) __tg_lgamma(__tg_promote1((__x))(__x))
887 // llrint
889 static long long
890 _TG_ATTRS
891 __tg_llrint(float __x) {return llrintf(__x);}
893 static long long
894 _TG_ATTRS
895 __tg_llrint(double __x) {return llrint(__x);}
897 static long long
898 _TG_ATTRS
899 __tg_llrint(long double __x) {return llrintl(__x);}
901 #undef llrint
902 #define llrint(__x) __tg_llrint(__tg_promote1((__x))(__x))
904 // llround
906 static long long
907 _TG_ATTRS
908 __tg_llround(float __x) {return llroundf(__x);}
910 static long long
911 _TG_ATTRS
912 __tg_llround(double __x) {return llround(__x);}
914 static long long
915 _TG_ATTRS
916 __tg_llround(long double __x) {return llroundl(__x);}
918 #undef llround
919 #define llround(__x) __tg_llround(__tg_promote1((__x))(__x))
921 // log10
923 static float
924 _TG_ATTRS
925 __tg_log10(float __x) {return log10f(__x);}
927 static double
928 _TG_ATTRS
929 __tg_log10(double __x) {return log10(__x);}
931 static long double
932 _TG_ATTRS
933 __tg_log10(long double __x) {return log10l(__x);}
935 #undef log10
936 #define log10(__x) __tg_log10(__tg_promote1((__x))(__x))
938 // log1p
940 static float
941 _TG_ATTRS
942 __tg_log1p(float __x) {return log1pf(__x);}
944 static double
945 _TG_ATTRS
946 __tg_log1p(double __x) {return log1p(__x);}
948 static long double
949 _TG_ATTRS
950 __tg_log1p(long double __x) {return log1pl(__x);}
952 #undef log1p
953 #define log1p(__x) __tg_log1p(__tg_promote1((__x))(__x))
955 // log2
957 static float
958 _TG_ATTRS
959 __tg_log2(float __x) {return log2f(__x);}
961 static double
962 _TG_ATTRS
963 __tg_log2(double __x) {return log2(__x);}
965 static long double
966 _TG_ATTRS
967 __tg_log2(long double __x) {return log2l(__x);}
969 #undef log2
970 #define log2(__x) __tg_log2(__tg_promote1((__x))(__x))
972 // logb
974 static float
975 _TG_ATTRS
976 __tg_logb(float __x) {return logbf(__x);}
978 static double
979 _TG_ATTRS
980 __tg_logb(double __x) {return logb(__x);}
982 static long double
983 _TG_ATTRS
984 __tg_logb(long double __x) {return logbl(__x);}
986 #undef logb
987 #define logb(__x) __tg_logb(__tg_promote1((__x))(__x))
989 // lrint
991 static long
992 _TG_ATTRS
993 __tg_lrint(float __x) {return lrintf(__x);}
995 static long
996 _TG_ATTRS
997 __tg_lrint(double __x) {return lrint(__x);}
999 static long
1000 _TG_ATTRS
1001 __tg_lrint(long double __x) {return lrintl(__x);}
1003 #undef lrint
1004 #define lrint(__x) __tg_lrint(__tg_promote1((__x))(__x))
1006 // lround
1008 static long
1009 _TG_ATTRS
1010 __tg_lround(float __x) {return lroundf(__x);}
1012 static long
1013 _TG_ATTRS
1014 __tg_lround(double __x) {return lround(__x);}
1016 static long
1017 _TG_ATTRS
1018 __tg_lround(long double __x) {return lroundl(__x);}
1020 #undef lround
1021 #define lround(__x) __tg_lround(__tg_promote1((__x))(__x))
1023 // nearbyint
1025 static float
1026 _TG_ATTRS
1027 __tg_nearbyint(float __x) {return nearbyintf(__x);}
1029 static double
1030 _TG_ATTRS
1031 __tg_nearbyint(double __x) {return nearbyint(__x);}
1033 static long double
1034 _TG_ATTRS
1035 __tg_nearbyint(long double __x) {return nearbyintl(__x);}
1037 #undef nearbyint
1038 #define nearbyint(__x) __tg_nearbyint(__tg_promote1((__x))(__x))
1040 // nextafter
1042 static float
1043 _TG_ATTRS
1044 __tg_nextafter(float __x, float __y) {return nextafterf(__x, __y);}
1046 static double
1047 _TG_ATTRS
1048 __tg_nextafter(double __x, double __y) {return nextafter(__x, __y);}
1050 static long double
1051 _TG_ATTRS
1052 __tg_nextafter(long double __x, long double __y) {return nextafterl(__x, __y);}
1054 #undef nextafter
1055 #define nextafter(__x, __y) __tg_nextafter(__tg_promote2((__x), (__y))(__x), \
1056 __tg_promote2((__x), (__y))(__y))
1058 // nexttoward
1060 static float
1061 _TG_ATTRS
1062 __tg_nexttoward(float __x, long double __y) {return nexttowardf(__x, __y);}
1064 static double
1065 _TG_ATTRS
1066 __tg_nexttoward(double __x, long double __y) {return nexttoward(__x, __y);}
1068 static long double
1069 _TG_ATTRS
1070 __tg_nexttoward(long double __x, long double __y) {return nexttowardl(__x, __y);}
1072 #undef nexttoward
1073 #define nexttoward(__x, __y) __tg_nexttoward(__tg_promote1((__x))(__x), (__y))
1075 // remainder
1077 static float
1078 _TG_ATTRS
1079 __tg_remainder(float __x, float __y) {return remainderf(__x, __y);}
1081 static double
1082 _TG_ATTRS
1083 __tg_remainder(double __x, double __y) {return remainder(__x, __y);}
1085 static long double
1086 _TG_ATTRS
1087 __tg_remainder(long double __x, long double __y) {return remainderl(__x, __y);}
1089 #undef remainder
1090 #define remainder(__x, __y) __tg_remainder(__tg_promote2((__x), (__y))(__x), \
1091 __tg_promote2((__x), (__y))(__y))
1093 // remquo
1095 static float
1096 _TG_ATTRS
1097 __tg_remquo(float __x, float __y, int* __z)
1098 {return remquof(__x, __y, __z);}
1100 static double
1101 _TG_ATTRS
1102 __tg_remquo(double __x, double __y, int* __z)
1103 {return remquo(__x, __y, __z);}
1105 static long double
1106 _TG_ATTRS
1107 __tg_remquo(long double __x,long double __y, int* __z)
1108 {return remquol(__x, __y, __z);}
1110 #undef remquo
1111 #define remquo(__x, __y, __z) \
1112 __tg_remquo(__tg_promote2((__x), (__y))(__x), \
1113 __tg_promote2((__x), (__y))(__y), \
1114 (__z))
1116 // rint
1118 static float
1119 _TG_ATTRS
1120 __tg_rint(float __x) {return rintf(__x);}
1122 static double
1123 _TG_ATTRS
1124 __tg_rint(double __x) {return rint(__x);}
1126 static long double
1127 _TG_ATTRS
1128 __tg_rint(long double __x) {return rintl(__x);}
1130 #undef rint
1131 #define rint(__x) __tg_rint(__tg_promote1((__x))(__x))
1133 // round
1135 static float
1136 _TG_ATTRS
1137 __tg_round(float __x) {return roundf(__x);}
1139 static double
1140 _TG_ATTRS
1141 __tg_round(double __x) {return round(__x);}
1143 static long double
1144 _TG_ATTRS
1145 __tg_round(long double __x) {return roundl(__x);}
1147 #undef round
1148 #define round(__x) __tg_round(__tg_promote1((__x))(__x))
1150 // scalbn
1152 static float
1153 _TG_ATTRS
1154 __tg_scalbn(float __x, int __y) {return scalbnf(__x, __y);}
1156 static double
1157 _TG_ATTRS
1158 __tg_scalbn(double __x, int __y) {return scalbn(__x, __y);}
1160 static long double
1161 _TG_ATTRS
1162 __tg_scalbn(long double __x, int __y) {return scalbnl(__x, __y);}
1164 #undef scalbn
1165 #define scalbn(__x, __y) __tg_scalbn(__tg_promote1((__x))(__x), __y)
1167 // scalbln
1169 static float
1170 _TG_ATTRS
1171 __tg_scalbln(float __x, long __y) {return scalblnf(__x, __y);}
1173 static double
1174 _TG_ATTRS
1175 __tg_scalbln(double __x, long __y) {return scalbln(__x, __y);}
1177 static long double
1178 _TG_ATTRS
1179 __tg_scalbln(long double __x, long __y) {return scalblnl(__x, __y);}
1181 #undef scalbln
1182 #define scalbln(__x, __y) __tg_scalbln(__tg_promote1((__x))(__x), __y)
1184 // tgamma
1186 static float
1187 _TG_ATTRS
1188 __tg_tgamma(float __x) {return tgammaf(__x);}
1190 static double
1191 _TG_ATTRS
1192 __tg_tgamma(double __x) {return tgamma(__x);}
1194 static long double
1195 _TG_ATTRS
1196 __tg_tgamma(long double __x) {return tgammal(__x);}
1198 #undef tgamma
1199 #define tgamma(__x) __tg_tgamma(__tg_promote1((__x))(__x))
1201 // trunc
1203 static float
1204 _TG_ATTRS
1205 __tg_trunc(float __x) {return truncf(__x);}
1207 static double
1208 _TG_ATTRS
1209 __tg_trunc(double __x) {return trunc(__x);}
1211 static long double
1212 _TG_ATTRS
1213 __tg_trunc(long double __x) {return truncl(__x);}
1215 #undef trunc
1216 #define trunc(__x) __tg_trunc(__tg_promote1((__x))(__x))
1218 // carg
1220 static float
1221 _TG_ATTRS
1222 __tg_carg(float __x) {return atan2f(0.F, __x);}
1224 static double
1225 _TG_ATTRS
1226 __tg_carg(double __x) {return atan2(0., __x);}
1228 static long double
1229 _TG_ATTRS
1230 __tg_carg(long double __x) {return atan2l(0.L, __x);}
1232 static float
1233 _TG_ATTRS
1234 __tg_carg(float _Complex __x) {return cargf(__x);}
1236 static double
1237 _TG_ATTRS
1238 __tg_carg(double _Complex __x) {return carg(__x);}
1240 static long double
1241 _TG_ATTRS
1242 __tg_carg(long double _Complex __x) {return cargl(__x);}
1244 #undef carg
1245 #define carg(__x) __tg_carg(__tg_promote1((__x))(__x))
1247 // cimag
1249 static float
1250 _TG_ATTRS
1251 __tg_cimag(float __x) {return 0;}
1253 static double
1254 _TG_ATTRS
1255 __tg_cimag(double __x) {return 0;}
1257 static long double
1258 _TG_ATTRS
1259 __tg_cimag(long double __x) {return 0;}
1261 static float
1262 _TG_ATTRS
1263 __tg_cimag(float _Complex __x) {return cimagf(__x);}
1265 static double
1266 _TG_ATTRS
1267 __tg_cimag(double _Complex __x) {return cimag(__x);}
1269 static long double
1270 _TG_ATTRS
1271 __tg_cimag(long double _Complex __x) {return cimagl(__x);}
1273 #undef cimag
1274 #define cimag(__x) __tg_cimag(__tg_promote1((__x))(__x))
1276 // conj
1278 static float _Complex
1279 _TG_ATTRS
1280 __tg_conj(float __x) {return __x;}
1282 static double _Complex
1283 _TG_ATTRS
1284 __tg_conj(double __x) {return __x;}
1286 static long double _Complex
1287 _TG_ATTRS
1288 __tg_conj(long double __x) {return __x;}
1290 static float _Complex
1291 _TG_ATTRS
1292 __tg_conj(float _Complex __x) {return conjf(__x);}
1294 static double _Complex
1295 _TG_ATTRS
1296 __tg_conj(double _Complex __x) {return conj(__x);}
1298 static long double _Complex
1299 _TG_ATTRS
1300 __tg_conj(long double _Complex __x) {return conjl(__x);}
1302 #undef conj
1303 #define conj(__x) __tg_conj(__tg_promote1((__x))(__x))
1305 // cproj
1307 static float _Complex
1308 _TG_ATTRS
1309 __tg_cproj(float __x) {return cprojf(__x);}
1311 static double _Complex
1312 _TG_ATTRS
1313 __tg_cproj(double __x) {return cproj(__x);}
1315 static long double _Complex
1316 _TG_ATTRS
1317 __tg_cproj(long double __x) {return cprojl(__x);}
1319 static float _Complex
1320 _TG_ATTRS
1321 __tg_cproj(float _Complex __x) {return cprojf(__x);}
1323 static double _Complex
1324 _TG_ATTRS
1325 __tg_cproj(double _Complex __x) {return cproj(__x);}
1327 static long double _Complex
1328 _TG_ATTRS
1329 __tg_cproj(long double _Complex __x) {return cprojl(__x);}
1331 #undef cproj
1332 #define cproj(__x) __tg_cproj(__tg_promote1((__x))(__x))
1334 // creal
1336 static float
1337 _TG_ATTRS
1338 __tg_creal(float __x) {return __x;}
1340 static double
1341 _TG_ATTRS
1342 __tg_creal(double __x) {return __x;}
1344 static long double
1345 _TG_ATTRS
1346 __tg_creal(long double __x) {return __x;}
1348 static float
1349 _TG_ATTRS
1350 __tg_creal(float _Complex __x) {return crealf(__x);}
1352 static double
1353 _TG_ATTRS
1354 __tg_creal(double _Complex __x) {return creal(__x);}
1356 static long double
1357 _TG_ATTRS
1358 __tg_creal(long double _Complex __x) {return creall(__x);}
1360 #undef creal
1361 #define creal(__x) __tg_creal(__tg_promote1((__x))(__x))
1363 #undef _TG_ATTRSp
1364 #undef _TG_ATTRS
1366 #endif /* __cplusplus */
1367 #endif /* __has_include_next */
1368 #endif /* __CLANG_TGMATH_H */