1 /*===---- tgmath.h - Standard header for type generic math ----------------===*\
2  *
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
6  *
7 \*===----------------------------------------------------------------------===*/
8 
9 #ifndef __CLANG_TGMATH_H
10 #define __CLANG_TGMATH_H
11 
12 /* C99 7.22 Type-generic math <tgmath.h>. */
13 #include <math.h>
14 
15 /*
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.
19  */
20 #if defined(__APPLE__) && __STDC_HOSTED__ && __has_include_next(<tgmath.h>)
21 #  include_next <tgmath.h>
22 #else
23 
24 /* C++ handles type genericity with overloading in math.h. */
25 #ifndef __cplusplus
26 #include <complex.h>
27 
28 #define _TG_ATTRSp __attribute__((__overloadable__))
29 #define _TG_ATTRS __attribute__((__overloadable__, __always_inline__))
30 
31 // promotion
32 
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);
48 
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)))
55 
56 // acos
57 
58 static float
59     _TG_ATTRS
60     __tg_acos(float __x) {return acosf(__x);}
61 
62 static double
63     _TG_ATTRS
64     __tg_acos(double __x) {return acos(__x);}
65 
66 static long double
67     _TG_ATTRS
68     __tg_acos(long double __x) {return acosl(__x);}
69 
70 static float _Complex
71     _TG_ATTRS
72     __tg_acos(float _Complex __x) {return cacosf(__x);}
73 
74 static double _Complex
75     _TG_ATTRS
76     __tg_acos(double _Complex __x) {return cacos(__x);}
77 
78 static long double _Complex
79     _TG_ATTRS
80     __tg_acos(long double _Complex __x) {return cacosl(__x);}
81 
82 #undef acos
83 #define acos(__x) __tg_acos(__tg_promote1((__x))(__x))
84 
85 // asin
86 
87 static float
88     _TG_ATTRS
89     __tg_asin(float __x) {return asinf(__x);}
90 
91 static double
92     _TG_ATTRS
93     __tg_asin(double __x) {return asin(__x);}
94 
95 static long double
96     _TG_ATTRS
97     __tg_asin(long double __x) {return asinl(__x);}
98 
99 static float _Complex
100     _TG_ATTRS
101     __tg_asin(float _Complex __x) {return casinf(__x);}
102 
103 static double _Complex
104     _TG_ATTRS
105     __tg_asin(double _Complex __x) {return casin(__x);}
106 
107 static long double _Complex
108     _TG_ATTRS
109     __tg_asin(long double _Complex __x) {return casinl(__x);}
110 
111 #undef asin
112 #define asin(__x) __tg_asin(__tg_promote1((__x))(__x))
113 
114 // atan
115 
116 static float
117     _TG_ATTRS
118     __tg_atan(float __x) {return atanf(__x);}
119 
120 static double
121     _TG_ATTRS
122     __tg_atan(double __x) {return atan(__x);}
123 
124 static long double
125     _TG_ATTRS
126     __tg_atan(long double __x) {return atanl(__x);}
127 
128 static float _Complex
129     _TG_ATTRS
130     __tg_atan(float _Complex __x) {return catanf(__x);}
131 
132 static double _Complex
133     _TG_ATTRS
134     __tg_atan(double _Complex __x) {return catan(__x);}
135 
136 static long double _Complex
137     _TG_ATTRS
138     __tg_atan(long double _Complex __x) {return catanl(__x);}
139 
140 #undef atan
141 #define atan(__x) __tg_atan(__tg_promote1((__x))(__x))
142 
143 // acosh
144 
145 static float
146     _TG_ATTRS
147     __tg_acosh(float __x) {return acoshf(__x);}
148 
149 static double
150     _TG_ATTRS
151     __tg_acosh(double __x) {return acosh(__x);}
152 
153 static long double
154     _TG_ATTRS
155     __tg_acosh(long double __x) {return acoshl(__x);}
156 
157 static float _Complex
158     _TG_ATTRS
159     __tg_acosh(float _Complex __x) {return cacoshf(__x);}
160 
161 static double _Complex
162     _TG_ATTRS
163     __tg_acosh(double _Complex __x) {return cacosh(__x);}
164 
165 static long double _Complex
166     _TG_ATTRS
167     __tg_acosh(long double _Complex __x) {return cacoshl(__x);}
168 
169 #undef acosh
170 #define acosh(__x) __tg_acosh(__tg_promote1((__x))(__x))
171 
172 // asinh
173 
174 static float
175     _TG_ATTRS
176     __tg_asinh(float __x) {return asinhf(__x);}
177 
178 static double
179     _TG_ATTRS
180     __tg_asinh(double __x) {return asinh(__x);}
181 
182 static long double
183     _TG_ATTRS
184     __tg_asinh(long double __x) {return asinhl(__x);}
185 
186 static float _Complex
187     _TG_ATTRS
188     __tg_asinh(float _Complex __x) {return casinhf(__x);}
189 
190 static double _Complex
191     _TG_ATTRS
192     __tg_asinh(double _Complex __x) {return casinh(__x);}
193 
194 static long double _Complex
195     _TG_ATTRS
196     __tg_asinh(long double _Complex __x) {return casinhl(__x);}
197 
198 #undef asinh
199 #define asinh(__x) __tg_asinh(__tg_promote1((__x))(__x))
200 
201 // atanh
202 
203 static float
204     _TG_ATTRS
205     __tg_atanh(float __x) {return atanhf(__x);}
206 
207 static double
208     _TG_ATTRS
209     __tg_atanh(double __x) {return atanh(__x);}
210 
211 static long double
212     _TG_ATTRS
213     __tg_atanh(long double __x) {return atanhl(__x);}
214 
215 static float _Complex
216     _TG_ATTRS
217     __tg_atanh(float _Complex __x) {return catanhf(__x);}
218 
219 static double _Complex
220     _TG_ATTRS
221     __tg_atanh(double _Complex __x) {return catanh(__x);}
222 
223 static long double _Complex
224     _TG_ATTRS
225     __tg_atanh(long double _Complex __x) {return catanhl(__x);}
226 
227 #undef atanh
228 #define atanh(__x) __tg_atanh(__tg_promote1((__x))(__x))
229 
230 // cos
231 
232 static float
233     _TG_ATTRS
234     __tg_cos(float __x) {return cosf(__x);}
235 
236 static double
237     _TG_ATTRS
238     __tg_cos(double __x) {return cos(__x);}
239 
240 static long double
241     _TG_ATTRS
242     __tg_cos(long double __x) {return cosl(__x);}
243 
244 static float _Complex
245     _TG_ATTRS
246     __tg_cos(float _Complex __x) {return ccosf(__x);}
247 
248 static double _Complex
249     _TG_ATTRS
250     __tg_cos(double _Complex __x) {return ccos(__x);}
251 
252 static long double _Complex
253     _TG_ATTRS
254     __tg_cos(long double _Complex __x) {return ccosl(__x);}
255 
256 #undef cos
257 #define cos(__x) __tg_cos(__tg_promote1((__x))(__x))
258 
259 // sin
260 
261 static float
262     _TG_ATTRS
263     __tg_sin(float __x) {return sinf(__x);}
264 
265 static double
266     _TG_ATTRS
267     __tg_sin(double __x) {return sin(__x);}
268 
269 static long double
270     _TG_ATTRS
271     __tg_sin(long double __x) {return sinl(__x);}
272 
273 static float _Complex
274     _TG_ATTRS
275     __tg_sin(float _Complex __x) {return csinf(__x);}
276 
277 static double _Complex
278     _TG_ATTRS
279     __tg_sin(double _Complex __x) {return csin(__x);}
280 
281 static long double _Complex
282     _TG_ATTRS
283     __tg_sin(long double _Complex __x) {return csinl(__x);}
284 
285 #undef sin
286 #define sin(__x) __tg_sin(__tg_promote1((__x))(__x))
287 
288 // tan
289 
290 static float
291     _TG_ATTRS
292     __tg_tan(float __x) {return tanf(__x);}
293 
294 static double
295     _TG_ATTRS
296     __tg_tan(double __x) {return tan(__x);}
297 
298 static long double
299     _TG_ATTRS
300     __tg_tan(long double __x) {return tanl(__x);}
301 
302 static float _Complex
303     _TG_ATTRS
304     __tg_tan(float _Complex __x) {return ctanf(__x);}
305 
306 static double _Complex
307     _TG_ATTRS
308     __tg_tan(double _Complex __x) {return ctan(__x);}
309 
310 static long double _Complex
311     _TG_ATTRS
312     __tg_tan(long double _Complex __x) {return ctanl(__x);}
313 
314 #undef tan
315 #define tan(__x) __tg_tan(__tg_promote1((__x))(__x))
316 
317 // cosh
318 
319 static float
320     _TG_ATTRS
321     __tg_cosh(float __x) {return coshf(__x);}
322 
323 static double
324     _TG_ATTRS
325     __tg_cosh(double __x) {return cosh(__x);}
326 
327 static long double
328     _TG_ATTRS
329     __tg_cosh(long double __x) {return coshl(__x);}
330 
331 static float _Complex
332     _TG_ATTRS
333     __tg_cosh(float _Complex __x) {return ccoshf(__x);}
334 
335 static double _Complex
336     _TG_ATTRS
337     __tg_cosh(double _Complex __x) {return ccosh(__x);}
338 
339 static long double _Complex
340     _TG_ATTRS
341     __tg_cosh(long double _Complex __x) {return ccoshl(__x);}
342 
343 #undef cosh
344 #define cosh(__x) __tg_cosh(__tg_promote1((__x))(__x))
345 
346 // sinh
347 
348 static float
349     _TG_ATTRS
350     __tg_sinh(float __x) {return sinhf(__x);}
351 
352 static double
353     _TG_ATTRS
354     __tg_sinh(double __x) {return sinh(__x);}
355 
356 static long double
357     _TG_ATTRS
358     __tg_sinh(long double __x) {return sinhl(__x);}
359 
360 static float _Complex
361     _TG_ATTRS
362     __tg_sinh(float _Complex __x) {return csinhf(__x);}
363 
364 static double _Complex
365     _TG_ATTRS
366     __tg_sinh(double _Complex __x) {return csinh(__x);}
367 
368 static long double _Complex
369     _TG_ATTRS
370     __tg_sinh(long double _Complex __x) {return csinhl(__x);}
371 
372 #undef sinh
373 #define sinh(__x) __tg_sinh(__tg_promote1((__x))(__x))
374 
375 // tanh
376 
377 static float
378     _TG_ATTRS
379     __tg_tanh(float __x) {return tanhf(__x);}
380 
381 static double
382     _TG_ATTRS
383     __tg_tanh(double __x) {return tanh(__x);}
384 
385 static long double
386     _TG_ATTRS
387     __tg_tanh(long double __x) {return tanhl(__x);}
388 
389 static float _Complex
390     _TG_ATTRS
391     __tg_tanh(float _Complex __x) {return ctanhf(__x);}
392 
393 static double _Complex
394     _TG_ATTRS
395     __tg_tanh(double _Complex __x) {return ctanh(__x);}
396 
397 static long double _Complex
398     _TG_ATTRS
399     __tg_tanh(long double _Complex __x) {return ctanhl(__x);}
400 
401 #undef tanh
402 #define tanh(__x) __tg_tanh(__tg_promote1((__x))(__x))
403 
404 // exp
405 
406 static float
407     _TG_ATTRS
408     __tg_exp(float __x) {return expf(__x);}
409 
410 static double
411     _TG_ATTRS
412     __tg_exp(double __x) {return exp(__x);}
413 
414 static long double
415     _TG_ATTRS
416     __tg_exp(long double __x) {return expl(__x);}
417 
418 static float _Complex
419     _TG_ATTRS
420     __tg_exp(float _Complex __x) {return cexpf(__x);}
421 
422 static double _Complex
423     _TG_ATTRS
424     __tg_exp(double _Complex __x) {return cexp(__x);}
425 
426 static long double _Complex
427     _TG_ATTRS
428     __tg_exp(long double _Complex __x) {return cexpl(__x);}
429 
430 #undef exp
431 #define exp(__x) __tg_exp(__tg_promote1((__x))(__x))
432 
433 // log
434 
435 static float
436     _TG_ATTRS
437     __tg_log(float __x) {return logf(__x);}
438 
439 static double
440     _TG_ATTRS
441     __tg_log(double __x) {return log(__x);}
442 
443 static long double
444     _TG_ATTRS
445     __tg_log(long double __x) {return logl(__x);}
446 
447 static float _Complex
448     _TG_ATTRS
449     __tg_log(float _Complex __x) {return clogf(__x);}
450 
451 static double _Complex
452     _TG_ATTRS
453     __tg_log(double _Complex __x) {return clog(__x);}
454 
455 static long double _Complex
456     _TG_ATTRS
457     __tg_log(long double _Complex __x) {return clogl(__x);}
458 
459 #undef log
460 #define log(__x) __tg_log(__tg_promote1((__x))(__x))
461 
462 // pow
463 
464 static float
465     _TG_ATTRS
466     __tg_pow(float __x, float __y) {return powf(__x, __y);}
467 
468 static double
469     _TG_ATTRS
470     __tg_pow(double __x, double __y) {return pow(__x, __y);}
471 
472 static long double
473     _TG_ATTRS
474     __tg_pow(long double __x, long double __y) {return powl(__x, __y);}
475 
476 static float _Complex
477     _TG_ATTRS
478     __tg_pow(float _Complex __x, float _Complex __y) {return cpowf(__x, __y);}
479 
480 static double _Complex
481     _TG_ATTRS
482     __tg_pow(double _Complex __x, double _Complex __y) {return cpow(__x, __y);}
483 
484 static long double _Complex
485     _TG_ATTRS
486     __tg_pow(long double _Complex __x, long double _Complex __y)
487     {return cpowl(__x, __y);}
488 
489 #undef pow
490 #define pow(__x, __y) __tg_pow(__tg_promote2((__x), (__y))(__x), \
491                                __tg_promote2((__x), (__y))(__y))
492 
493 // sqrt
494 
495 static float
496     _TG_ATTRS
497     __tg_sqrt(float __x) {return sqrtf(__x);}
498 
499 static double
500     _TG_ATTRS
501     __tg_sqrt(double __x) {return sqrt(__x);}
502 
503 static long double
504     _TG_ATTRS
505     __tg_sqrt(long double __x) {return sqrtl(__x);}
506 
507 static float _Complex
508     _TG_ATTRS
509     __tg_sqrt(float _Complex __x) {return csqrtf(__x);}
510 
511 static double _Complex
512     _TG_ATTRS
513     __tg_sqrt(double _Complex __x) {return csqrt(__x);}
514 
515 static long double _Complex
516     _TG_ATTRS
517     __tg_sqrt(long double _Complex __x) {return csqrtl(__x);}
518 
519 #undef sqrt
520 #define sqrt(__x) __tg_sqrt(__tg_promote1((__x))(__x))
521 
522 // fabs
523 
524 static float
525     _TG_ATTRS
526     __tg_fabs(float __x) {return fabsf(__x);}
527 
528 static double
529     _TG_ATTRS
530     __tg_fabs(double __x) {return fabs(__x);}
531 
532 static long double
533     _TG_ATTRS
534     __tg_fabs(long double __x) {return fabsl(__x);}
535 
536 static float
537     _TG_ATTRS
538     __tg_fabs(float _Complex __x) {return cabsf(__x);}
539 
540 static double
541     _TG_ATTRS
542     __tg_fabs(double _Complex __x) {return cabs(__x);}
543 
544 static long double
545     _TG_ATTRS
546     __tg_fabs(long double _Complex __x) {return cabsl(__x);}
547 
548 #undef fabs
549 #define fabs(__x) __tg_fabs(__tg_promote1((__x))(__x))
550 
551 // atan2
552 
553 static float
554     _TG_ATTRS
555     __tg_atan2(float __x, float __y) {return atan2f(__x, __y);}
556 
557 static double
558     _TG_ATTRS
559     __tg_atan2(double __x, double __y) {return atan2(__x, __y);}
560 
561 static long double
562     _TG_ATTRS
563     __tg_atan2(long double __x, long double __y) {return atan2l(__x, __y);}
564 
565 #undef atan2
566 #define atan2(__x, __y) __tg_atan2(__tg_promote2((__x), (__y))(__x), \
567                                    __tg_promote2((__x), (__y))(__y))
568 
569 // cbrt
570 
571 static float
572     _TG_ATTRS
573     __tg_cbrt(float __x) {return cbrtf(__x);}
574 
575 static double
576     _TG_ATTRS
577     __tg_cbrt(double __x) {return cbrt(__x);}
578 
579 static long double
580     _TG_ATTRS
581     __tg_cbrt(long double __x) {return cbrtl(__x);}
582 
583 #undef cbrt
584 #define cbrt(__x) __tg_cbrt(__tg_promote1((__x))(__x))
585 
586 // ceil
587 
588 static float
589     _TG_ATTRS
590     __tg_ceil(float __x) {return ceilf(__x);}
591 
592 static double
593     _TG_ATTRS
594     __tg_ceil(double __x) {return ceil(__x);}
595 
596 static long double
597     _TG_ATTRS
598     __tg_ceil(long double __x) {return ceill(__x);}
599 
600 #undef ceil
601 #define ceil(__x) __tg_ceil(__tg_promote1((__x))(__x))
602 
603 // copysign
604 
605 static float
606     _TG_ATTRS
607     __tg_copysign(float __x, float __y) {return copysignf(__x, __y);}
608 
609 static double
610     _TG_ATTRS
611     __tg_copysign(double __x, double __y) {return copysign(__x, __y);}
612 
613 static long double
614     _TG_ATTRS
615     __tg_copysign(long double __x, long double __y) {return copysignl(__x, __y);}
616 
617 #undef copysign
618 #define copysign(__x, __y) __tg_copysign(__tg_promote2((__x), (__y))(__x), \
619                                          __tg_promote2((__x), (__y))(__y))
620 
621 // erf
622 
623 static float
624     _TG_ATTRS
625     __tg_erf(float __x) {return erff(__x);}
626 
627 static double
628     _TG_ATTRS
629     __tg_erf(double __x) {return erf(__x);}
630 
631 static long double
632     _TG_ATTRS
633     __tg_erf(long double __x) {return erfl(__x);}
634 
635 #undef erf
636 #define erf(__x) __tg_erf(__tg_promote1((__x))(__x))
637 
638 // erfc
639 
640 static float
641     _TG_ATTRS
642     __tg_erfc(float __x) {return erfcf(__x);}
643 
644 static double
645     _TG_ATTRS
646     __tg_erfc(double __x) {return erfc(__x);}
647 
648 static long double
649     _TG_ATTRS
650     __tg_erfc(long double __x) {return erfcl(__x);}
651 
652 #undef erfc
653 #define erfc(__x) __tg_erfc(__tg_promote1((__x))(__x))
654 
655 // exp2
656 
657 static float
658     _TG_ATTRS
659     __tg_exp2(float __x) {return exp2f(__x);}
660 
661 static double
662     _TG_ATTRS
663     __tg_exp2(double __x) {return exp2(__x);}
664 
665 static long double
666     _TG_ATTRS
667     __tg_exp2(long double __x) {return exp2l(__x);}
668 
669 #undef exp2
670 #define exp2(__x) __tg_exp2(__tg_promote1((__x))(__x))
671 
672 // expm1
673 
674 static float
675     _TG_ATTRS
676     __tg_expm1(float __x) {return expm1f(__x);}
677 
678 static double
679     _TG_ATTRS
680     __tg_expm1(double __x) {return expm1(__x);}
681 
682 static long double
683     _TG_ATTRS
684     __tg_expm1(long double __x) {return expm1l(__x);}
685 
686 #undef expm1
687 #define expm1(__x) __tg_expm1(__tg_promote1((__x))(__x))
688 
689 // fdim
690 
691 static float
692     _TG_ATTRS
693     __tg_fdim(float __x, float __y) {return fdimf(__x, __y);}
694 
695 static double
696     _TG_ATTRS
697     __tg_fdim(double __x, double __y) {return fdim(__x, __y);}
698 
699 static long double
700     _TG_ATTRS
701     __tg_fdim(long double __x, long double __y) {return fdiml(__x, __y);}
702 
703 #undef fdim
704 #define fdim(__x, __y) __tg_fdim(__tg_promote2((__x), (__y))(__x), \
705                                  __tg_promote2((__x), (__y))(__y))
706 
707 // floor
708 
709 static float
710     _TG_ATTRS
711     __tg_floor(float __x) {return floorf(__x);}
712 
713 static double
714     _TG_ATTRS
715     __tg_floor(double __x) {return floor(__x);}
716 
717 static long double
718     _TG_ATTRS
719     __tg_floor(long double __x) {return floorl(__x);}
720 
721 #undef floor
722 #define floor(__x) __tg_floor(__tg_promote1((__x))(__x))
723 
724 // fma
725 
726 static float
727     _TG_ATTRS
728     __tg_fma(float __x, float __y, float __z)
729     {return fmaf(__x, __y, __z);}
730 
731 static double
732     _TG_ATTRS
733     __tg_fma(double __x, double __y, double __z)
734     {return fma(__x, __y, __z);}
735 
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);}
740 
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))
746 
747 // fmax
748 
749 static float
750     _TG_ATTRS
751     __tg_fmax(float __x, float __y) {return fmaxf(__x, __y);}
752 
753 static double
754     _TG_ATTRS
755     __tg_fmax(double __x, double __y) {return fmax(__x, __y);}
756 
757 static long double
758     _TG_ATTRS
759     __tg_fmax(long double __x, long double __y) {return fmaxl(__x, __y);}
760 
761 #undef fmax
762 #define fmax(__x, __y) __tg_fmax(__tg_promote2((__x), (__y))(__x), \
763                                  __tg_promote2((__x), (__y))(__y))
764 
765 // fmin
766 
767 static float
768     _TG_ATTRS
769     __tg_fmin(float __x, float __y) {return fminf(__x, __y);}
770 
771 static double
772     _TG_ATTRS
773     __tg_fmin(double __x, double __y) {return fmin(__x, __y);}
774 
775 static long double
776     _TG_ATTRS
777     __tg_fmin(long double __x, long double __y) {return fminl(__x, __y);}
778 
779 #undef fmin
780 #define fmin(__x, __y) __tg_fmin(__tg_promote2((__x), (__y))(__x), \
781                                  __tg_promote2((__x), (__y))(__y))
782 
783 // fmod
784 
785 static float
786     _TG_ATTRS
787     __tg_fmod(float __x, float __y) {return fmodf(__x, __y);}
788 
789 static double
790     _TG_ATTRS
791     __tg_fmod(double __x, double __y) {return fmod(__x, __y);}
792 
793 static long double
794     _TG_ATTRS
795     __tg_fmod(long double __x, long double __y) {return fmodl(__x, __y);}
796 
797 #undef fmod
798 #define fmod(__x, __y) __tg_fmod(__tg_promote2((__x), (__y))(__x), \
799                                  __tg_promote2((__x), (__y))(__y))
800 
801 // frexp
802 
803 static float
804     _TG_ATTRS
805     __tg_frexp(float __x, int* __y) {return frexpf(__x, __y);}
806 
807 static double
808     _TG_ATTRS
809     __tg_frexp(double __x, int* __y) {return frexp(__x, __y);}
810 
811 static long double
812     _TG_ATTRS
813     __tg_frexp(long double __x, int* __y) {return frexpl(__x, __y);}
814 
815 #undef frexp
816 #define frexp(__x, __y) __tg_frexp(__tg_promote1((__x))(__x), __y)
817 
818 // hypot
819 
820 static float
821     _TG_ATTRS
822     __tg_hypot(float __x, float __y) {return hypotf(__x, __y);}
823 
824 static double
825     _TG_ATTRS
826     __tg_hypot(double __x, double __y) {return hypot(__x, __y);}
827 
828 static long double
829     _TG_ATTRS
830     __tg_hypot(long double __x, long double __y) {return hypotl(__x, __y);}
831 
832 #undef hypot
833 #define hypot(__x, __y) __tg_hypot(__tg_promote2((__x), (__y))(__x), \
834                                    __tg_promote2((__x), (__y))(__y))
835 
836 // ilogb
837 
838 static int
839     _TG_ATTRS
840     __tg_ilogb(float __x) {return ilogbf(__x);}
841 
842 static int
843     _TG_ATTRS
844     __tg_ilogb(double __x) {return ilogb(__x);}
845 
846 static int
847     _TG_ATTRS
848     __tg_ilogb(long double __x) {return ilogbl(__x);}
849 
850 #undef ilogb
851 #define ilogb(__x) __tg_ilogb(__tg_promote1((__x))(__x))
852 
853 // ldexp
854 
855 static float
856     _TG_ATTRS
857     __tg_ldexp(float __x, int __y) {return ldexpf(__x, __y);}
858 
859 static double
860     _TG_ATTRS
861     __tg_ldexp(double __x, int __y) {return ldexp(__x, __y);}
862 
863 static long double
864     _TG_ATTRS
865     __tg_ldexp(long double __x, int __y) {return ldexpl(__x, __y);}
866 
867 #undef ldexp
868 #define ldexp(__x, __y) __tg_ldexp(__tg_promote1((__x))(__x), __y)
869 
870 // lgamma
871 
872 static float
873     _TG_ATTRS
874     __tg_lgamma(float __x) {return lgammaf(__x);}
875 
876 static double
877     _TG_ATTRS
878     __tg_lgamma(double __x) {return lgamma(__x);}
879 
880 static long double
881     _TG_ATTRS
882     __tg_lgamma(long double __x) {return lgammal(__x);}
883 
884 #undef lgamma
885 #define lgamma(__x) __tg_lgamma(__tg_promote1((__x))(__x))
886 
887 // llrint
888 
889 static long long
890     _TG_ATTRS
891     __tg_llrint(float __x) {return llrintf(__x);}
892 
893 static long long
894     _TG_ATTRS
895     __tg_llrint(double __x) {return llrint(__x);}
896 
897 static long long
898     _TG_ATTRS
899     __tg_llrint(long double __x) {return llrintl(__x);}
900 
901 #undef llrint
902 #define llrint(__x) __tg_llrint(__tg_promote1((__x))(__x))
903 
904 // llround
905 
906 static long long
907     _TG_ATTRS
908     __tg_llround(float __x) {return llroundf(__x);}
909 
910 static long long
911     _TG_ATTRS
912     __tg_llround(double __x) {return llround(__x);}
913 
914 static long long
915     _TG_ATTRS
916     __tg_llround(long double __x) {return llroundl(__x);}
917 
918 #undef llround
919 #define llround(__x) __tg_llround(__tg_promote1((__x))(__x))
920 
921 // log10
922 
923 static float
924     _TG_ATTRS
925     __tg_log10(float __x) {return log10f(__x);}
926 
927 static double
928     _TG_ATTRS
929     __tg_log10(double __x) {return log10(__x);}
930 
931 static long double
932     _TG_ATTRS
933     __tg_log10(long double __x) {return log10l(__x);}
934 
935 #undef log10
936 #define log10(__x) __tg_log10(__tg_promote1((__x))(__x))
937 
938 // log1p
939 
940 static float
941     _TG_ATTRS
942     __tg_log1p(float __x) {return log1pf(__x);}
943 
944 static double
945     _TG_ATTRS
946     __tg_log1p(double __x) {return log1p(__x);}
947 
948 static long double
949     _TG_ATTRS
950     __tg_log1p(long double __x) {return log1pl(__x);}
951 
952 #undef log1p
953 #define log1p(__x) __tg_log1p(__tg_promote1((__x))(__x))
954 
955 // log2
956 
957 static float
958     _TG_ATTRS
959     __tg_log2(float __x) {return log2f(__x);}
960 
961 static double
962     _TG_ATTRS
963     __tg_log2(double __x) {return log2(__x);}
964 
965 static long double
966     _TG_ATTRS
967     __tg_log2(long double __x) {return log2l(__x);}
968 
969 #undef log2
970 #define log2(__x) __tg_log2(__tg_promote1((__x))(__x))
971 
972 // logb
973 
974 static float
975     _TG_ATTRS
976     __tg_logb(float __x) {return logbf(__x);}
977 
978 static double
979     _TG_ATTRS
980     __tg_logb(double __x) {return logb(__x);}
981 
982 static long double
983     _TG_ATTRS
984     __tg_logb(long double __x) {return logbl(__x);}
985 
986 #undef logb
987 #define logb(__x) __tg_logb(__tg_promote1((__x))(__x))
988 
989 // lrint
990 
991 static long
992     _TG_ATTRS
993     __tg_lrint(float __x) {return lrintf(__x);}
994 
995 static long
996     _TG_ATTRS
997     __tg_lrint(double __x) {return lrint(__x);}
998 
999 static long
1000     _TG_ATTRS
1001     __tg_lrint(long double __x) {return lrintl(__x);}
1002 
1003 #undef lrint
1004 #define lrint(__x) __tg_lrint(__tg_promote1((__x))(__x))
1005 
1006 // lround
1007 
1008 static long
1009     _TG_ATTRS
1010     __tg_lround(float __x) {return lroundf(__x);}
1011 
1012 static long
1013     _TG_ATTRS
1014     __tg_lround(double __x) {return lround(__x);}
1015 
1016 static long
1017     _TG_ATTRS
1018     __tg_lround(long double __x) {return lroundl(__x);}
1019 
1020 #undef lround
1021 #define lround(__x) __tg_lround(__tg_promote1((__x))(__x))
1022 
1023 // nearbyint
1024 
1025 static float
1026     _TG_ATTRS
1027     __tg_nearbyint(float __x) {return nearbyintf(__x);}
1028 
1029 static double
1030     _TG_ATTRS
1031     __tg_nearbyint(double __x) {return nearbyint(__x);}
1032 
1033 static long double
1034     _TG_ATTRS
1035     __tg_nearbyint(long double __x) {return nearbyintl(__x);}
1036 
1037 #undef nearbyint
1038 #define nearbyint(__x) __tg_nearbyint(__tg_promote1((__x))(__x))
1039 
1040 // nextafter
1041 
1042 static float
1043     _TG_ATTRS
1044     __tg_nextafter(float __x, float __y) {return nextafterf(__x, __y);}
1045 
1046 static double
1047     _TG_ATTRS
1048     __tg_nextafter(double __x, double __y) {return nextafter(__x, __y);}
1049 
1050 static long double
1051     _TG_ATTRS
1052     __tg_nextafter(long double __x, long double __y) {return nextafterl(__x, __y);}
1053 
1054 #undef nextafter
1055 #define nextafter(__x, __y) __tg_nextafter(__tg_promote2((__x), (__y))(__x), \
1056                                            __tg_promote2((__x), (__y))(__y))
1057 
1058 // nexttoward
1059 
1060 static float
1061     _TG_ATTRS
1062     __tg_nexttoward(float __x, long double __y) {return nexttowardf(__x, __y);}
1063 
1064 static double
1065     _TG_ATTRS
1066     __tg_nexttoward(double __x, long double __y) {return nexttoward(__x, __y);}
1067 
1068 static long double
1069     _TG_ATTRS
1070     __tg_nexttoward(long double __x, long double __y) {return nexttowardl(__x, __y);}
1071 
1072 #undef nexttoward
1073 #define nexttoward(__x, __y) __tg_nexttoward(__tg_promote1((__x))(__x), (__y))
1074 
1075 // remainder
1076 
1077 static float
1078     _TG_ATTRS
1079     __tg_remainder(float __x, float __y) {return remainderf(__x, __y);}
1080 
1081 static double
1082     _TG_ATTRS
1083     __tg_remainder(double __x, double __y) {return remainder(__x, __y);}
1084 
1085 static long double
1086     _TG_ATTRS
1087     __tg_remainder(long double __x, long double __y) {return remainderl(__x, __y);}
1088 
1089 #undef remainder
1090 #define remainder(__x, __y) __tg_remainder(__tg_promote2((__x), (__y))(__x), \
1091                                            __tg_promote2((__x), (__y))(__y))
1092 
1093 // remquo
1094 
1095 static float
1096     _TG_ATTRS
1097     __tg_remquo(float __x, float __y, int* __z)
1098     {return remquof(__x, __y, __z);}
1099 
1100 static double
1101     _TG_ATTRS
1102     __tg_remquo(double __x, double __y, int* __z)
1103     {return remquo(__x, __y, __z);}
1104 
1105 static long double
1106     _TG_ATTRS
1107     __tg_remquo(long double __x,long double __y, int* __z)
1108     {return remquol(__x, __y, __z);}
1109 
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))
1115 
1116 // rint
1117 
1118 static float
1119     _TG_ATTRS
1120     __tg_rint(float __x) {return rintf(__x);}
1121 
1122 static double
1123     _TG_ATTRS
1124     __tg_rint(double __x) {return rint(__x);}
1125 
1126 static long double
1127     _TG_ATTRS
1128     __tg_rint(long double __x) {return rintl(__x);}
1129 
1130 #undef rint
1131 #define rint(__x) __tg_rint(__tg_promote1((__x))(__x))
1132 
1133 // round
1134 
1135 static float
1136     _TG_ATTRS
1137     __tg_round(float __x) {return roundf(__x);}
1138 
1139 static double
1140     _TG_ATTRS
1141     __tg_round(double __x) {return round(__x);}
1142 
1143 static long double
1144     _TG_ATTRS
1145     __tg_round(long double __x) {return roundl(__x);}
1146 
1147 #undef round
1148 #define round(__x) __tg_round(__tg_promote1((__x))(__x))
1149 
1150 // scalbn
1151 
1152 static float
1153     _TG_ATTRS
1154     __tg_scalbn(float __x, int __y) {return scalbnf(__x, __y);}
1155 
1156 static double
1157     _TG_ATTRS
1158     __tg_scalbn(double __x, int __y) {return scalbn(__x, __y);}
1159 
1160 static long double
1161     _TG_ATTRS
1162     __tg_scalbn(long double __x, int __y) {return scalbnl(__x, __y);}
1163 
1164 #undef scalbn
1165 #define scalbn(__x, __y) __tg_scalbn(__tg_promote1((__x))(__x), __y)
1166 
1167 // scalbln
1168 
1169 static float
1170     _TG_ATTRS
1171     __tg_scalbln(float __x, long __y) {return scalblnf(__x, __y);}
1172 
1173 static double
1174     _TG_ATTRS
1175     __tg_scalbln(double __x, long __y) {return scalbln(__x, __y);}
1176 
1177 static long double
1178     _TG_ATTRS
1179     __tg_scalbln(long double __x, long __y) {return scalblnl(__x, __y);}
1180 
1181 #undef scalbln
1182 #define scalbln(__x, __y) __tg_scalbln(__tg_promote1((__x))(__x), __y)
1183 
1184 // tgamma
1185 
1186 static float
1187     _TG_ATTRS
1188     __tg_tgamma(float __x) {return tgammaf(__x);}
1189 
1190 static double
1191     _TG_ATTRS
1192     __tg_tgamma(double __x) {return tgamma(__x);}
1193 
1194 static long double
1195     _TG_ATTRS
1196     __tg_tgamma(long double __x) {return tgammal(__x);}
1197 
1198 #undef tgamma
1199 #define tgamma(__x) __tg_tgamma(__tg_promote1((__x))(__x))
1200 
1201 // trunc
1202 
1203 static float
1204     _TG_ATTRS
1205     __tg_trunc(float __x) {return truncf(__x);}
1206 
1207 static double
1208     _TG_ATTRS
1209     __tg_trunc(double __x) {return trunc(__x);}
1210 
1211 static long double
1212     _TG_ATTRS
1213     __tg_trunc(long double __x) {return truncl(__x);}
1214 
1215 #undef trunc
1216 #define trunc(__x) __tg_trunc(__tg_promote1((__x))(__x))
1217 
1218 // carg
1219 
1220 static float
1221     _TG_ATTRS
1222     __tg_carg(float __x) {return atan2f(0.F, __x);}
1223 
1224 static double
1225     _TG_ATTRS
1226     __tg_carg(double __x) {return atan2(0., __x);}
1227 
1228 static long double
1229     _TG_ATTRS
1230     __tg_carg(long double __x) {return atan2l(0.L, __x);}
1231 
1232 static float
1233     _TG_ATTRS
1234     __tg_carg(float _Complex __x) {return cargf(__x);}
1235 
1236 static double
1237     _TG_ATTRS
1238     __tg_carg(double _Complex __x) {return carg(__x);}
1239 
1240 static long double
1241     _TG_ATTRS
1242     __tg_carg(long double _Complex __x) {return cargl(__x);}
1243 
1244 #undef carg
1245 #define carg(__x) __tg_carg(__tg_promote1((__x))(__x))
1246 
1247 // cimag
1248 
1249 static float
1250     _TG_ATTRS
1251     __tg_cimag(float __x) {return 0;}
1252 
1253 static double
1254     _TG_ATTRS
1255     __tg_cimag(double __x) {return 0;}
1256 
1257 static long double
1258     _TG_ATTRS
1259     __tg_cimag(long double __x) {return 0;}
1260 
1261 static float
1262     _TG_ATTRS
1263     __tg_cimag(float _Complex __x) {return cimagf(__x);}
1264 
1265 static double
1266     _TG_ATTRS
1267     __tg_cimag(double _Complex __x) {return cimag(__x);}
1268 
1269 static long double
1270     _TG_ATTRS
1271     __tg_cimag(long double _Complex __x) {return cimagl(__x);}
1272 
1273 #undef cimag
1274 #define cimag(__x) __tg_cimag(__tg_promote1((__x))(__x))
1275 
1276 // conj
1277 
1278 static float _Complex
1279     _TG_ATTRS
1280     __tg_conj(float __x) {return __x;}
1281 
1282 static double _Complex
1283     _TG_ATTRS
1284     __tg_conj(double __x) {return __x;}
1285 
1286 static long double _Complex
1287     _TG_ATTRS
1288     __tg_conj(long double __x) {return __x;}
1289 
1290 static float _Complex
1291     _TG_ATTRS
1292     __tg_conj(float _Complex __x) {return conjf(__x);}
1293 
1294 static double _Complex
1295     _TG_ATTRS
1296     __tg_conj(double _Complex __x) {return conj(__x);}
1297 
1298 static long double _Complex
1299     _TG_ATTRS
1300     __tg_conj(long double _Complex __x) {return conjl(__x);}
1301 
1302 #undef conj
1303 #define conj(__x) __tg_conj(__tg_promote1((__x))(__x))
1304 
1305 // cproj
1306 
1307 static float _Complex
1308     _TG_ATTRS
1309     __tg_cproj(float __x) {return cprojf(__x);}
1310 
1311 static double _Complex
1312     _TG_ATTRS
1313     __tg_cproj(double __x) {return cproj(__x);}
1314 
1315 static long double _Complex
1316     _TG_ATTRS
1317     __tg_cproj(long double __x) {return cprojl(__x);}
1318 
1319 static float _Complex
1320     _TG_ATTRS
1321     __tg_cproj(float _Complex __x) {return cprojf(__x);}
1322 
1323 static double _Complex
1324     _TG_ATTRS
1325     __tg_cproj(double _Complex __x) {return cproj(__x);}
1326 
1327 static long double _Complex
1328     _TG_ATTRS
1329     __tg_cproj(long double _Complex __x) {return cprojl(__x);}
1330 
1331 #undef cproj
1332 #define cproj(__x) __tg_cproj(__tg_promote1((__x))(__x))
1333 
1334 // creal
1335 
1336 static float
1337     _TG_ATTRS
1338     __tg_creal(float __x) {return __x;}
1339 
1340 static double
1341     _TG_ATTRS
1342     __tg_creal(double __x) {return __x;}
1343 
1344 static long double
1345     _TG_ATTRS
1346     __tg_creal(long double __x) {return __x;}
1347 
1348 static float
1349     _TG_ATTRS
1350     __tg_creal(float _Complex __x) {return crealf(__x);}
1351 
1352 static double
1353     _TG_ATTRS
1354     __tg_creal(double _Complex __x) {return creal(__x);}
1355 
1356 static long double
1357     _TG_ATTRS
1358     __tg_creal(long double _Complex __x) {return creall(__x);}
1359 
1360 #undef creal
1361 #define creal(__x) __tg_creal(__tg_promote1((__x))(__x))
1362 
1363 #undef _TG_ATTRSp
1364 #undef _TG_ATTRS
1365 
1366 #endif /* __cplusplus */
1367 #endif /* __has_include_next */
1368 #endif /* __CLANG_TGMATH_H */
1369