5 tgmath.h is broken: return type is wrong
6 (always the highest conversion rank type: long double [complex])
7 (imaginary type is not supported)
13 #define __IS_FP(x) !!((1?1:(x))/2)
14 #define __IS_CX(x) (__IS_FP(x) && sizeof((x)) == sizeof((x)+I))
15 #define __IS_REAL(x) (__IS_FP(x) && 2*sizeof((x)) == sizeof((x)+I))
17 #define __FLT(x) (__IS_REAL((x)) && sizeof((x)) == sizeof(float))
18 #define __LDBL(x) (__IS_REAL((x)) && sizeof((x)) == sizeof(long double))
20 #define __FLTCX(x) (__IS_CX(x) && sizeof((x)) == sizeof(float complex))
21 #define __DBLCX(x) (__IS_CX(x) && sizeof((x)) == sizeof(double complex))
22 #define __LDBLCX(x) (__IS_CX(x) && sizeof((x)) == sizeof(long double complex))
24 #define __tg_real(__fun, x) ( \
25 __FLT(x) ? __fun ## f (x) : \
26 __LDBL(x) ? __fun ## l (x) : \
29 #define __tg_real_2_1(__fun, x, y) ( \
30 __FLT(x) ? __fun ## f (x, y) : \
31 __LDBL(x) ? __fun ## l (x, y) : \
34 #define __tg_real_2(__fun, x, y) ( \
35 __FLT(x) && __FLT(y) ? __fun ## f (x, y) : \
36 __LDBL(x) || __LDBL(y) ? __fun ## l (x, y) : \
39 #define __tg_complex(__fun, x) ( \
40 __FLTCX(x) || __FLT(x) ? __fun ## f (x) : \
41 __LDBLCX(x) || __LDBL(x) ? __fun ## l (x) : \
44 #define __tg_real_complex(__fun, x) ( \
45 __LDBLCX(x) ? c ## __fun ## l (x) : \
46 __DBLCX(x) ? c ## __fun (x) : \
47 __FLTCX(x) ? c ## __fun ## f (x) : \
48 __FLT(x) ? __fun ## f (x) : \
49 __LDBL(x) ? __fun ## l (x) : \
54 #define __tg_real_remquo(x, y, z) ( \
55 __FLT(x) && __FLT(y) ? remquof(x, y, z) : \
56 __LDBL(x) || __LDBL(y) ? remquol(x, y, z) : \
59 #define __tg_real_fma(x, y, z) ( \
60 __FLT(x) && __FLT(y) && __FLT(z) ? fmaf(x, y, z) : \
61 __LDBL(x) || __LDBL(y) || __LDBL(z) ? fmal(x, y, z) : \
64 #define __tg_real_complex_pow(x, y) ( \
65 __LDBLCX(x) || __LDBLCX(y) ? cpowl(x, y) : \
66 __DBLCX(x) || __DBLCX(y) ? cpow(x, y) : \
67 __FLTCX(x) || __FLTCX(y) ? cpowf(x, y) : \
68 __tg_real_2(pow, x, y) )
70 #define __tg_real_complex_fabs(__fun, x) ( \
71 __LDBLCX(x) ? cabsl(x) : \
72 __DBLCX(x) ? cabs(x) : \
73 __FLTCX(x) ? cabsf(x) : \
78 #define acos(x) __tg_real_complex(acos, (x))
79 #define acosh(x) __tg_real_complex(acosh, (x))
80 #define asin(x) __tg_real_complex(asin, (x))
81 #define asinh(x) __tg_real_complex(asinh, (x))
82 #define atan(x) __tg_real_complex(atan, (x))
83 #define atan2(x) __tg_real_2(atan2, (x), (y))
84 #define atanh(x) __tg_real_complex(atanh, (x))
85 #define carg(x) __tg_complex(carg, (x))
86 #define cbrt(x) __tg_real(cbrt, (x))
87 #define ceil(x) __tg_real(ceil, (x))
88 #define cimag(x) __tg_complex(cimag, (x))
89 #define conj(x) __tg_complex(conj, (x))
90 #define copysign(x,y) __tg_real_2(copysign, (x), (y))
91 #define cos(x) __tg_real_complex(cos, (x))
92 #define cosh(x) __tg_real_complex(cosh, (x))
93 #define cproj(x) __tg_complex(cproj, (x))
94 #define creal(x) __tg_complex(creal, (x))
95 #define erf(x) __tg_real(erf, (x))
96 #define erfc(x) __tg_real(erfc, (x))
97 #define exp(x) __tg_real_complex(exp, (x))
98 #define exp2(x) __tg_real(exp2, (x))
99 #define expm1(x) __tg_real(expm1, (x))
100 #define fabs(x) __tg_real_complex_fabs(x)
101 #define fdim(x) __tg_real(fdim, (x))
102 #define floor(x) __tg_real(floor, (x))
103 #define fma(x,y,z) __tg_real_fma((x), (y), (z))
104 #define fmax(x,y) __tg_real_2(fmax, (x), (y))
105 #define fmin(x,y) __tg_real_2(fmin, (x), (y))
106 #define fmod(x,y) __tg_real_2(fmod, (x), (y))
107 #define frexp(x,y) __tg_real_2_1(frexp, (x), (y))
108 #define hypot(x,y) __tg_real_2(hypot, (x), (y))
109 #define ilogb(x) __tg_real(ilogb, (x))
110 #define ldexp(x,y) __tg_real_2_1(ldexp, (x), (y))
111 #define lgamma(x) __tg_real(lgamma, (x))
112 #define llrint(x) __tg_real(llrint, (x))
113 #define llround(x) __tg_real(llround, (x))
114 #define log(x) __tg_real_complex(log, (x))
115 #define log10(x) __tg_real(log10, (x))
116 #define log1p(x) __tg_real(log1p, (x))
117 #define log2(x) __tg_real(log2, (x))
118 #define logb(x) __tg_real(logb, (x))
119 #define lrint(x) __tg_real(lrint, (x))
120 #define lround(x) __tg_real(lround, (x))
121 #define nearbyint(x) __tg_real(nearbyint, (x))
122 #define nextafter(x,y) __tg_real_2(nextafter, (x), (y)
123 #define nexttoward(x,y) __tg_real_2(nexttoward, (x), (y))
124 #define pow(x,y) __tg_real_complex_pow((x), (y))
125 #define remainder(x,y) __tg_real_2(remainder, (x), (y))
126 #define remquo(x,y,z) __tg_real_remquo((x), (y), (z))
127 #define rint(x) __tg_real(rint, (x))
128 #define round(x) __tg_real(round, (x))
129 #define scalbln(x,y) __tg_real_2_1(scalbln, (x), (y))
130 #define scalbn(x,y) __tg_real_2_1(scalbn, (x), (y))
131 #define sin(x) __tg_real_complex(sin, (x))
132 #define sinh(x) __tg_real_complex(sinh, (x))
133 #define sqrt(x) __tg_real_complex(sqrt, (x))
134 #define tan(x) __tg_real_complex(tan, (x))
135 #define tanh(x) __tg_real_complex(tanh, (x))
136 #define tgamma(x) __tg_real(tgamma, (x))
137 #define trunc(x) __tg_real(trunc, (x))