comparison gcc/ginclude/tgmath.h @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* Copyright (C) 2004-2017 Free Software Foundation, Inc. 1 /* Copyright (C) 2004-2018 Free Software Foundation, Inc.
2 Contributed by Apple, Inc. 2 Contributed by Apple, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify 6 GCC is free software; you can redistribute it and/or modify
36 36
37 /* Naming convention: generic macros are defining using 37 /* Naming convention: generic macros are defining using
38 __TGMATH_CPLX*, __TGMATH_REAL*, and __TGMATH_CPLX_ONLY. _CPLX 38 __TGMATH_CPLX*, __TGMATH_REAL*, and __TGMATH_CPLX_ONLY. _CPLX
39 means the generic argument(s) may be real or complex, _REAL means 39 means the generic argument(s) may be real or complex, _REAL means
40 real only, _CPLX means complex only. If there is no suffix, we are 40 real only, _CPLX means complex only. If there is no suffix, we are
41 defining a function of one generic argument. If the suffix is _n 41 defining a function of one argument. If the suffix is _n
42 it is a function of n generic arguments. If the suffix is _m_n it 42 it is a function of n arguments. We only define these macros for
43 is a function of n arguments, the first m of which are generic. We 43 values of n that are needed. */
44 only define these macros for values of n and/or m that are needed. */
45 44
46 /* The general rules for generic macros are given in 7.22 paragraphs 1 and 2. 45 #define __TGMATH_CPLX(z,R,C) \
47 If any generic parameter is complex, we use a complex version. Otherwise 46 __builtin_tgmath (R##f, R, R##l, C##f, C, C##l, (z))
48 we use a real version. If the real part of any generic parameter is long
49 double, we use the long double version. Otherwise if the real part of any
50 generic parameter is double or of integer type, we use the double version.
51 Otherwise we use the float version. */
52 47
53 #define __tg_cplx(expr) \ 48 #define __TGMATH_CPLX_2(z1,z2,R,C) \
54 __builtin_classify_type(expr) == 9 49 __builtin_tgmath (R##f, R, R##l, C##f, C, C##l, (z1), (z2))
55
56 #define __tg_ldbl(expr) \
57 __builtin_types_compatible_p(__typeof__(expr), long double)
58
59 #define __tg_dbl(expr) \
60 (__builtin_types_compatible_p(__typeof__(expr), double) \
61 || __builtin_classify_type(expr) == 1)
62
63 #define __tg_choose(x,f,d,l) \
64 __builtin_choose_expr(__tg_ldbl(x), l, \
65 __builtin_choose_expr(__tg_dbl(x), d, \
66 f))
67
68 #define __tg_choose_2(x,y,f,d,l) \
69 __builtin_choose_expr(__tg_ldbl(x) || __tg_ldbl(y), l, \
70 __builtin_choose_expr(__tg_dbl(x) || __tg_dbl(y), d, \
71 f))
72
73 #define __tg_choose_3(x,y,z,f,d,l) \
74 __builtin_choose_expr(__tg_ldbl(x) || __tg_ldbl(y) || __tg_ldbl(z), l, \
75 __builtin_choose_expr(__tg_dbl(x) || __tg_dbl(y) \
76 || __tg_dbl(z), d, \
77 f))
78
79 #define __TGMATH_CPLX(z,R,C) \
80 __builtin_choose_expr (__tg_cplx(z), \
81 __tg_choose (__real__(z), C##f(z), (C)(z), C##l(z)), \
82 __tg_choose (z, R##f(z), (R)(z), R##l(z)))
83
84 #define __TGMATH_CPLX_2(z1,z2,R,C) \
85 __builtin_choose_expr (__tg_cplx(z1) || __tg_cplx(z2), \
86 __tg_choose_2 (__real__(z1), __real__(z2), \
87 C##f(z1,z2), (C)(z1,z2), C##l(z1,z2)), \
88 __tg_choose_2 (z1, z2, \
89 R##f(z1,z2), (R)(z1,z2), R##l(z1,z2)))
90 50
91 #define __TGMATH_REAL(x,R) \ 51 #define __TGMATH_REAL(x,R) \
92 __tg_choose (x, R##f(x), (R)(x), R##l(x)) 52 __builtin_tgmath (R##f, R, R##l, (x))
93 #define __TGMATH_REAL_2(x,y,R) \ 53 #define __TGMATH_REAL_2(x,y,R) \
94 __tg_choose_2 (x, y, R##f(x,y), (R)(x,y), R##l(x,y)) 54 __builtin_tgmath (R##f, R, R##l, (x), (y))
95 #define __TGMATH_REAL_3(x,y,z,R) \ 55 #define __TGMATH_REAL_3(x,y,z,R) \
96 __tg_choose_3 (x, y, z, R##f(x,y,z), (R)(x,y,z), R##l(x,y,z)) 56 __builtin_tgmath (R##f, R, R##l, (x), (y), (z))
97 #define __TGMATH_REAL_1_2(x,y,R) \
98 __tg_choose (x, R##f(x,y), (R)(x,y), R##l(x,y))
99 #define __TGMATH_REAL_2_3(x,y,z,R) \
100 __tg_choose_2 (x, y, R##f(x,y,z), (R)(x,y,z), R##l(x,y,z))
101 #define __TGMATH_CPLX_ONLY(z,C) \ 57 #define __TGMATH_CPLX_ONLY(z,C) \
102 __tg_choose (__real__(z), C##f(z), (C)(z), C##l(z)) 58 __builtin_tgmath (C##f, C, C##l, (z))
103 59
104 /* Functions defined in both <math.h> and <complex.h> (7.22p4) */ 60 /* Functions defined in both <math.h> and <complex.h> (7.22p4) */
105 #define acos(z) __TGMATH_CPLX(z, acos, cacos) 61 #define acos(z) __TGMATH_CPLX(z, acos, cacos)
106 #define asin(z) __TGMATH_CPLX(z, asin, casin) 62 #define asin(z) __TGMATH_CPLX(z, asin, casin)
107 #define atan(z) __TGMATH_CPLX(z, atan, catan) 63 #define atan(z) __TGMATH_CPLX(z, atan, catan)
133 #define floor(x) __TGMATH_REAL(x, floor) 89 #define floor(x) __TGMATH_REAL(x, floor)
134 #define fma(x,y,z) __TGMATH_REAL_3(x, y, z, fma) 90 #define fma(x,y,z) __TGMATH_REAL_3(x, y, z, fma)
135 #define fmax(x,y) __TGMATH_REAL_2(x, y, fmax) 91 #define fmax(x,y) __TGMATH_REAL_2(x, y, fmax)
136 #define fmin(x,y) __TGMATH_REAL_2(x, y, fmin) 92 #define fmin(x,y) __TGMATH_REAL_2(x, y, fmin)
137 #define fmod(x,y) __TGMATH_REAL_2(x, y, fmod) 93 #define fmod(x,y) __TGMATH_REAL_2(x, y, fmod)
138 #define frexp(x,y) __TGMATH_REAL_1_2(x, y, frexp) 94 #define frexp(x,y) __TGMATH_REAL_2(x, y, frexp)
139 #define hypot(x,y) __TGMATH_REAL_2(x, y, hypot) 95 #define hypot(x,y) __TGMATH_REAL_2(x, y, hypot)
140 #define ilogb(x) __TGMATH_REAL(x, ilogb) 96 #define ilogb(x) __TGMATH_REAL(x, ilogb)
141 #define ldexp(x,y) __TGMATH_REAL_1_2(x, y, ldexp) 97 #define ldexp(x,y) __TGMATH_REAL_2(x, y, ldexp)
142 #define lgamma(x) __TGMATH_REAL(x, lgamma) 98 #define lgamma(x) __TGMATH_REAL(x, lgamma)
143 #define llrint(x) __TGMATH_REAL(x, llrint) 99 #define llrint(x) __TGMATH_REAL(x, llrint)
144 #define llround(x) __TGMATH_REAL(x, llround) 100 #define llround(x) __TGMATH_REAL(x, llround)
145 #define log10(x) __TGMATH_REAL(x, log10) 101 #define log10(x) __TGMATH_REAL(x, log10)
146 #define log1p(x) __TGMATH_REAL(x, log1p) 102 #define log1p(x) __TGMATH_REAL(x, log1p)
148 #define logb(x) __TGMATH_REAL(x, logb) 104 #define logb(x) __TGMATH_REAL(x, logb)
149 #define lrint(x) __TGMATH_REAL(x, lrint) 105 #define lrint(x) __TGMATH_REAL(x, lrint)
150 #define lround(x) __TGMATH_REAL(x, lround) 106 #define lround(x) __TGMATH_REAL(x, lround)
151 #define nearbyint(x) __TGMATH_REAL(x, nearbyint) 107 #define nearbyint(x) __TGMATH_REAL(x, nearbyint)
152 #define nextafter(x,y) __TGMATH_REAL_2(x, y, nextafter) 108 #define nextafter(x,y) __TGMATH_REAL_2(x, y, nextafter)
153 #define nexttoward(x,y) __TGMATH_REAL_1_2(x, y, nexttoward) 109 #define nexttoward(x,y) __TGMATH_REAL_2(x, y, nexttoward)
154 #define remainder(x,y) __TGMATH_REAL_2(x, y, remainder) 110 #define remainder(x,y) __TGMATH_REAL_2(x, y, remainder)
155 #define remquo(x,y,z) __TGMATH_REAL_2_3(x, y, z, remquo) 111 #define remquo(x,y,z) __TGMATH_REAL_3(x, y, z, remquo)
156 #define rint(x) __TGMATH_REAL(x, rint) 112 #define rint(x) __TGMATH_REAL(x, rint)
157 #define round(x) __TGMATH_REAL(x, round) 113 #define round(x) __TGMATH_REAL(x, round)
158 #define scalbn(x,y) __TGMATH_REAL_1_2(x, y, scalbn) 114 #define scalbn(x,y) __TGMATH_REAL_2(x, y, scalbn)
159 #define scalbln(x,y) __TGMATH_REAL_1_2(x, y, scalbln) 115 #define scalbln(x,y) __TGMATH_REAL_2(x, y, scalbln)
160 #define tgamma(x) __TGMATH_REAL(x, tgamma) 116 #define tgamma(x) __TGMATH_REAL(x, tgamma)
161 #define trunc(x) __TGMATH_REAL(x, trunc) 117 #define trunc(x) __TGMATH_REAL(x, trunc)
162 118
163 /* Functions defined in <complex.h> only (7.22p6) */ 119 /* Functions defined in <complex.h> only (7.22p6) */
164 #define carg(z) __TGMATH_CPLX_ONLY(z, carg) 120 #define carg(z) __TGMATH_CPLX_ONLY(z, carg)