| 1 | /* Copyright (C) 1997-2024 Free Software Foundation, Inc. |
| 2 | This file is part of the GNU C Library. |
| 3 | |
| 4 | The GNU C Library is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU Lesser General Public |
| 6 | License as published by the Free Software Foundation; either |
| 7 | version 2.1 of the License, or (at your option) any later version. |
| 8 | |
| 9 | The GNU C Library is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public |
| 15 | License along with the GNU C Library; if not, see |
| 16 | <https://www.gnu.org/licenses/>. */ |
| 17 | |
| 18 | /* |
| 19 | * ISO C99 Standard: 7.22 Type-generic math <tgmath.h> |
| 20 | */ |
| 21 | |
| 22 | #ifndef _TGMATH_H |
| 23 | #define _TGMATH_H 1 |
| 24 | |
| 25 | #define |
| 26 | #include <bits/libc-header-start.h> |
| 27 | |
| 28 | /* Include the needed headers. */ |
| 29 | #include <bits/floatn.h> |
| 30 | #include <math.h> |
| 31 | #include <complex.h> |
| 32 | |
| 33 | |
| 34 | /* There are two variant implementations of type-generic macros in |
| 35 | this file: one for GCC 8 and later, using __builtin_tgmath and |
| 36 | where each macro expands each of its arguments only once, and one |
| 37 | for older GCC, using other compiler extensions but with macros |
| 38 | expanding their arguments many times (so resulting in exponential |
| 39 | blowup of the size of expansions when calls to such macros are |
| 40 | nested inside arguments to such macros). Because of a long series |
| 41 | of defect fixes made after the initial release of TS 18661-1, GCC |
| 42 | versions before GCC 13 have __builtin_tgmath semantics that, when |
| 43 | integer arguments are passed to narrowing macros returning |
| 44 | _Float32x, or non-narrowing macros with at least two generic |
| 45 | arguments, do not always correspond to the C2X semantics, so more |
| 46 | complicated macro definitions are also used in some cases for |
| 47 | versions from GCC 8 to GCC 12. */ |
| 48 | |
| 49 | #define __HAVE_BUILTIN_TGMATH __GNUC_PREREQ (8, 0) |
| 50 | #define __HAVE_BUILTIN_TGMATH_C2X __GNUC_PREREQ (13, 0) |
| 51 | |
| 52 | #if __GNUC_PREREQ (2, 7) |
| 53 | |
| 54 | /* Certain cases of narrowing macros only need to call a single |
| 55 | function so cannot use __builtin_tgmath and do not need any |
| 56 | complicated logic. */ |
| 57 | # if __HAVE_FLOAT128X |
| 58 | # error "Unsupported _Float128x type for <tgmath.h>." |
| 59 | # endif |
| 60 | # if ((__HAVE_FLOAT64X && !__HAVE_FLOAT128) \ |
| 61 | || (__HAVE_FLOAT128 && !__HAVE_FLOAT64X)) |
| 62 | # error "Unsupported combination of types for <tgmath.h>." |
| 63 | # endif |
| 64 | # define __TGMATH_1_NARROW_D(F, X) \ |
| 65 | (F ## l (X)) |
| 66 | # define __TGMATH_2_NARROW_D(F, X, Y) \ |
| 67 | (F ## l (X, Y)) |
| 68 | # define __TGMATH_3_NARROW_D(F, X, Y, Z) \ |
| 69 | (F ## l (X, Y, Z)) |
| 70 | # define __TGMATH_1_NARROW_F64X(F, X) \ |
| 71 | (F ## f128 (X)) |
| 72 | # define __TGMATH_2_NARROW_F64X(F, X, Y) \ |
| 73 | (F ## f128 (X, Y)) |
| 74 | # define __TGMATH_3_NARROW_F64X(F, X, Y, Z) \ |
| 75 | (F ## f128 (X, Y, Z)) |
| 76 | # if !__HAVE_FLOAT128 |
| 77 | # define __TGMATH_1_NARROW_F32X(F, X) \ |
| 78 | (F ## f64 (X)) |
| 79 | # define __TGMATH_2_NARROW_F32X(F, X, Y) \ |
| 80 | (F ## f64 (X, Y)) |
| 81 | # define __TGMATH_3_NARROW_F32X(F, X, Y, Z) \ |
| 82 | (F ## f64 (X, Y, Z)) |
| 83 | # endif |
| 84 | |
| 85 | # if __HAVE_BUILTIN_TGMATH |
| 86 | |
| 87 | # if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT) |
| 88 | # define __TG_F16_ARG(X) X ## f16, |
| 89 | # else |
| 90 | # define __TG_F16_ARG(X) |
| 91 | # endif |
| 92 | # if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT) |
| 93 | # define __TG_F32_ARG(X) X ## f32, |
| 94 | # else |
| 95 | # define __TG_F32_ARG(X) |
| 96 | # endif |
| 97 | # if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT) |
| 98 | # define __TG_F64_ARG(X) X ## f64, |
| 99 | # else |
| 100 | # define __TG_F64_ARG(X) |
| 101 | # endif |
| 102 | # if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) |
| 103 | # define __TG_F128_ARG(X) X ## f128, |
| 104 | # else |
| 105 | # define __TG_F128_ARG(X) |
| 106 | # endif |
| 107 | # if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT) |
| 108 | # define __TG_F32X_ARG(X) X ## f32x, |
| 109 | # else |
| 110 | # define __TG_F32X_ARG(X) |
| 111 | # endif |
| 112 | # if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT) |
| 113 | # define __TG_F64X_ARG(X) X ## f64x, |
| 114 | # else |
| 115 | # define __TG_F64X_ARG(X) |
| 116 | # endif |
| 117 | # if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT) |
| 118 | # define __TG_F128X_ARG(X) X ## f128x, |
| 119 | # else |
| 120 | # define __TG_F128X_ARG(X) |
| 121 | # endif |
| 122 | |
| 123 | # define __TGMATH_FUNCS(X) X ## f, X, X ## l, \ |
| 124 | __TG_F16_ARG (X) __TG_F32_ARG (X) __TG_F64_ARG (X) __TG_F128_ARG (X) \ |
| 125 | __TG_F32X_ARG (X) __TG_F64X_ARG (X) __TG_F128X_ARG (X) |
| 126 | # define __TGMATH_RCFUNCS(F, C) __TGMATH_FUNCS (F) __TGMATH_FUNCS (C) |
| 127 | # define __TGMATH_1(F, X) __builtin_tgmath (__TGMATH_FUNCS (F) (X)) |
| 128 | # define __TGMATH_2(F, X, Y) __builtin_tgmath (__TGMATH_FUNCS (F) (X), (Y)) |
| 129 | # define __TGMATH_2STD(F, X, Y) __builtin_tgmath (F ## f, F, F ## l, (X), (Y)) |
| 130 | # define __TGMATH_3(F, X, Y, Z) __builtin_tgmath (__TGMATH_FUNCS (F) \ |
| 131 | (X), (Y), (Z)) |
| 132 | # define __TGMATH_1C(F, C, X) __builtin_tgmath (__TGMATH_RCFUNCS (F, C) (X)) |
| 133 | # define __TGMATH_2C(F, C, X, Y) __builtin_tgmath (__TGMATH_RCFUNCS (F, C) \ |
| 134 | (X), (Y)) |
| 135 | |
| 136 | # define __TGMATH_NARROW_FUNCS_F(X) X, X ## l, |
| 137 | # define __TGMATH_NARROW_FUNCS_F16(X) \ |
| 138 | __TG_F32_ARG (X) __TG_F64_ARG (X) __TG_F128_ARG (X) \ |
| 139 | __TG_F32X_ARG (X) __TG_F64X_ARG (X) __TG_F128X_ARG (X) |
| 140 | # define __TGMATH_NARROW_FUNCS_F32(X) \ |
| 141 | __TG_F64_ARG (X) __TG_F128_ARG (X) \ |
| 142 | __TG_F32X_ARG (X) __TG_F64X_ARG (X) __TG_F128X_ARG (X) |
| 143 | # define __TGMATH_NARROW_FUNCS_F64(X) \ |
| 144 | __TG_F128_ARG (X) \ |
| 145 | __TG_F64X_ARG (X) __TG_F128X_ARG (X) |
| 146 | # define __TGMATH_NARROW_FUNCS_F32X(X) \ |
| 147 | __TG_F64X_ARG (X) __TG_F128X_ARG (X) \ |
| 148 | __TG_F64_ARG (X) __TG_F128_ARG (X) |
| 149 | |
| 150 | # define __TGMATH_1_NARROW_F(F, X) \ |
| 151 | __builtin_tgmath (__TGMATH_NARROW_FUNCS_F (F) (X)) |
| 152 | # define __TGMATH_2_NARROW_F(F, X, Y) \ |
| 153 | __builtin_tgmath (__TGMATH_NARROW_FUNCS_F (F) (X), (Y)) |
| 154 | # define __TGMATH_3_NARROW_F(F, X, Y, Z) \ |
| 155 | __builtin_tgmath (__TGMATH_NARROW_FUNCS_F (F) (X), (Y), (Z)) |
| 156 | # define __TGMATH_1_NARROW_F16(F, X) \ |
| 157 | __builtin_tgmath (__TGMATH_NARROW_FUNCS_F16 (F) (X)) |
| 158 | # define __TGMATH_2_NARROW_F16(F, X, Y) \ |
| 159 | __builtin_tgmath (__TGMATH_NARROW_FUNCS_F16 (F) (X), (Y)) |
| 160 | # define __TGMATH_3_NARROW_F16(F, X, Y, Z) \ |
| 161 | __builtin_tgmath (__TGMATH_NARROW_FUNCS_F16 (F) (X), (Y), (Z)) |
| 162 | # define __TGMATH_1_NARROW_F32(F, X) \ |
| 163 | __builtin_tgmath (__TGMATH_NARROW_FUNCS_F32 (F) (X)) |
| 164 | # define __TGMATH_2_NARROW_F32(F, X, Y) \ |
| 165 | __builtin_tgmath (__TGMATH_NARROW_FUNCS_F32 (F) (X), (Y)) |
| 166 | # define __TGMATH_3_NARROW_F32(F, X, Y, Z) \ |
| 167 | __builtin_tgmath (__TGMATH_NARROW_FUNCS_F32 (F) (X), (Y), (Z)) |
| 168 | # define __TGMATH_1_NARROW_F64(F, X) \ |
| 169 | __builtin_tgmath (__TGMATH_NARROW_FUNCS_F64 (F) (X)) |
| 170 | # define __TGMATH_2_NARROW_F64(F, X, Y) \ |
| 171 | __builtin_tgmath (__TGMATH_NARROW_FUNCS_F64 (F) (X), (Y)) |
| 172 | # define __TGMATH_3_NARROW_F64(F, X, Y, Z) \ |
| 173 | __builtin_tgmath (__TGMATH_NARROW_FUNCS_F64 (F) (X), (Y), (Z)) |
| 174 | # if __HAVE_FLOAT128 && __HAVE_BUILTIN_TGMATH_C2X |
| 175 | # define __TGMATH_1_NARROW_F32X(F, X) \ |
| 176 | __builtin_tgmath (__TGMATH_NARROW_FUNCS_F32X (F) (X)) |
| 177 | # define __TGMATH_2_NARROW_F32X(F, X, Y) \ |
| 178 | __builtin_tgmath (__TGMATH_NARROW_FUNCS_F32X (F) (X), (Y)) |
| 179 | # define __TGMATH_3_NARROW_F32X(F, X, Y, Z) \ |
| 180 | __builtin_tgmath (__TGMATH_NARROW_FUNCS_F32X (F) (X), (Y), (Z)) |
| 181 | # endif |
| 182 | |
| 183 | # endif |
| 184 | |
| 185 | # if !__HAVE_BUILTIN_TGMATH_C2X |
| 186 | # ifdef __NO_LONG_DOUBLE_MATH |
| 187 | # define __tgml(fct) fct |
| 188 | # else |
| 189 | # define __tgml(fct) fct ## l |
| 190 | # endif |
| 191 | |
| 192 | /* __floating_type expands to 1 if TYPE is a floating type (including |
| 193 | complex floating types), 0 if TYPE is an integer type (including |
| 194 | complex integer types). __real_integer_type expands to 1 if TYPE |
| 195 | is a real integer type. __complex_integer_type expands to 1 if |
| 196 | TYPE is a complex integer type. All these macros expand to integer |
| 197 | constant expressions. All these macros can assume their argument |
| 198 | has an arithmetic type (not vector, decimal floating-point or |
| 199 | fixed-point), valid to pass to tgmath.h macros. */ |
| 200 | # if __GNUC_PREREQ (3, 1) |
| 201 | /* __builtin_classify_type expands to an integer constant expression |
| 202 | in GCC 3.1 and later. Default conversions applied to the argument |
| 203 | of __builtin_classify_type mean it always returns 1 for real |
| 204 | integer types rather than ever returning different values for |
| 205 | character, boolean or enumerated types. */ |
| 206 | # define __floating_type(type) \ |
| 207 | (__builtin_classify_type (__real__ ((type) 0)) == 8) |
| 208 | # define __real_integer_type(type) \ |
| 209 | (__builtin_classify_type ((type) 0) == 1) |
| 210 | # define __complex_integer_type(type) \ |
| 211 | (__builtin_classify_type ((type) 0) == 9 \ |
| 212 | && __builtin_classify_type (__real__ ((type) 0)) == 1) |
| 213 | # else |
| 214 | /* GCC versions predating __builtin_classify_type are also looser on |
| 215 | what counts as an integer constant expression. */ |
| 216 | # define __floating_type(type) (((type) 1.25) != 1) |
| 217 | # define __real_integer_type(type) (((type) (1.25 + _Complex_I)) == 1) |
| 218 | # define __complex_integer_type(type) \ |
| 219 | (((type) (1.25 + _Complex_I)) == (1 + _Complex_I)) |
| 220 | # endif |
| 221 | |
| 222 | /* Whether an expression (of arithmetic type) has a real type. */ |
| 223 | # define __expr_is_real(E) (__builtin_classify_type (E) != 9) |
| 224 | |
| 225 | /* Type T1 if E is 1, type T2 is E is 0. */ |
| 226 | # define __tgmath_type_if(T1, T2, E) \ |
| 227 | __typeof__ (*(0 ? (__typeof__ (0 ? (T2 *) 0 : (void *) (E))) 0 \ |
| 228 | : (__typeof__ (0 ? (T1 *) 0 : (void *) (!(E)))) 0)) |
| 229 | |
| 230 | /* The tgmath real type for T, where E is 0 if T is an integer type |
| 231 | and 1 for a floating type. If T has a complex type, it is |
| 232 | unspecified whether the return type is real or complex (but it has |
| 233 | the correct corresponding real type). */ |
| 234 | # define __tgmath_real_type_sub(T, E) \ |
| 235 | __tgmath_type_if (T, double, E) |
| 236 | |
| 237 | /* The tgmath real type of EXPR. */ |
| 238 | # define __tgmath_real_type(expr) \ |
| 239 | __tgmath_real_type_sub (__typeof__ ((__typeof__ (+(expr))) 0), \ |
| 240 | __floating_type (__typeof__ (+(expr)))) |
| 241 | |
| 242 | /* The tgmath complex type for T, where E1 is 1 if T has a floating |
| 243 | type and 0 otherwise, E2 is 1 if T has a real integer type and 0 |
| 244 | otherwise, and E3 is 1 if T has a complex type and 0 otherwise. */ |
| 245 | # define __tgmath_complex_type_sub(T, E1, E2, E3) \ |
| 246 | __typeof__ (*(0 \ |
| 247 | ? (__typeof__ (0 ? (T *) 0 : (void *) (!(E1)))) 0 \ |
| 248 | : (__typeof__ (0 \ |
| 249 | ? (__typeof__ (0 \ |
| 250 | ? (double *) 0 \ |
| 251 | : (void *) (!(E2)))) 0 \ |
| 252 | : (__typeof__ (0 \ |
| 253 | ? (_Complex double *) 0 \ |
| 254 | : (void *) (!(E3)))) 0)) 0)) |
| 255 | |
| 256 | /* The tgmath complex type of EXPR. */ |
| 257 | # define __tgmath_complex_type(expr) \ |
| 258 | __tgmath_complex_type_sub (__typeof__ ((__typeof__ (+(expr))) 0), \ |
| 259 | __floating_type (__typeof__ (+(expr))), \ |
| 260 | __real_integer_type (__typeof__ (+(expr))), \ |
| 261 | __complex_integer_type (__typeof__ (+(expr)))) |
| 262 | |
| 263 | /* The tgmath real type of EXPR1 combined with EXPR2, without handling |
| 264 | the C2X rule of interpreting integer arguments as _Float32x if any |
| 265 | argument is _FloatNx. */ |
| 266 | # define __tgmath_real_type2_base(expr1, expr2) \ |
| 267 | __typeof ((__tgmath_real_type (expr1)) 0 + (__tgmath_real_type (expr2)) 0) |
| 268 | |
| 269 | /* The tgmath complex type of EXPR1 combined with EXPR2, without |
| 270 | handling the C2X rule of interpreting integer arguments as |
| 271 | _Float32x if any argument is _FloatNx. */ |
| 272 | # define __tgmath_complex_type2_base(expr1, expr2) \ |
| 273 | __typeof ((__tgmath_complex_type (expr1)) 0 \ |
| 274 | + (__tgmath_complex_type (expr2)) 0) |
| 275 | |
| 276 | /* The tgmath real type of EXPR1 combined with EXPR2 and EXPR3, |
| 277 | without handling the C2X rule of interpreting integer arguments as |
| 278 | _Float32x if any argument is _FloatNx. */ |
| 279 | # define __tgmath_real_type3_base(expr1, expr2, expr3) \ |
| 280 | __typeof ((__tgmath_real_type (expr1)) 0 \ |
| 281 | + (__tgmath_real_type (expr2)) 0 \ |
| 282 | + (__tgmath_real_type (expr3)) 0) |
| 283 | |
| 284 | /* The tgmath real or complex type of EXPR1 combined with EXPR2 (and |
| 285 | EXPR3 if applicable). */ |
| 286 | # if __HAVE_FLOATN_NOT_TYPEDEF |
| 287 | # define __tgmath_real_type2(expr1, expr2) \ |
| 288 | __tgmath_type_if (_Float32x, __tgmath_real_type2_base (expr1, expr2), \ |
| 289 | _Generic ((expr1) + (expr2), _Float32x: 1, default: 0)) |
| 290 | # define __tgmath_complex_type2(expr1, expr2) \ |
| 291 | __tgmath_type_if (_Float32x, \ |
| 292 | __tgmath_type_if (_Complex _Float32x, \ |
| 293 | __tgmath_complex_type2_base (expr1, \ |
| 294 | expr2), \ |
| 295 | _Generic ((expr1) + (expr2), \ |
| 296 | _Complex _Float32x: 1, \ |
| 297 | default: 0)), \ |
| 298 | _Generic ((expr1) + (expr2), _Float32x: 1, default: 0)) |
| 299 | # define __tgmath_real_type3(expr1, expr2, expr3) \ |
| 300 | __tgmath_type_if (_Float32x, \ |
| 301 | __tgmath_real_type3_base (expr1, expr2, expr3), \ |
| 302 | _Generic ((expr1) + (expr2) + (expr3), \ |
| 303 | _Float32x: 1, default: 0)) |
| 304 | # else |
| 305 | # define __tgmath_real_type2(expr1, expr2) \ |
| 306 | __tgmath_real_type2_base (expr1, expr2) |
| 307 | # define __tgmath_complex_type2(expr1, expr2) \ |
| 308 | __tgmath_complex_type2_base (expr1, expr2) |
| 309 | # define __tgmath_real_type3(expr1, expr2, expr3) \ |
| 310 | __tgmath_real_type3_base (expr1, expr2, expr3) |
| 311 | # endif |
| 312 | |
| 313 | # if (__HAVE_DISTINCT_FLOAT16 \ |
| 314 | || __HAVE_DISTINCT_FLOAT32 \ |
| 315 | || __HAVE_DISTINCT_FLOAT64 \ |
| 316 | || __HAVE_DISTINCT_FLOAT32X \ |
| 317 | || __HAVE_DISTINCT_FLOAT64X \ |
| 318 | || __HAVE_DISTINCT_FLOAT128X) |
| 319 | # error "Unsupported _FloatN or _FloatNx types for <tgmath.h>." |
| 320 | # endif |
| 321 | |
| 322 | /* Expand to text that checks if ARG_COMB has type _Float128, and if |
| 323 | so calls the appropriately suffixed FCT (which may include a cast), |
| 324 | or FCT and CFCT for complex functions, with arguments ARG_CALL. |
| 325 | __TGMATH_F128LD (only used in the __HAVE_FLOAT64X_LONG_DOUBLE case, |
| 326 | for narrowing macros) handles long double the same as |
| 327 | _Float128. */ |
| 328 | # if __HAVE_DISTINCT_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) |
| 329 | # if (!__HAVE_FLOAT64X \ |
| 330 | || __HAVE_FLOAT64X_LONG_DOUBLE \ |
| 331 | || !__HAVE_FLOATN_NOT_TYPEDEF) |
| 332 | # define __TGMATH_F128(arg_comb, fct, arg_call) \ |
| 333 | __builtin_types_compatible_p (__typeof (+(arg_comb)), _Float128) \ |
| 334 | ? fct ## f128 arg_call : |
| 335 | # define __TGMATH_F128LD(arg_comb, fct, arg_call) \ |
| 336 | (__builtin_types_compatible_p (__typeof (+(arg_comb)), _Float128) \ |
| 337 | || __builtin_types_compatible_p (__typeof (+(arg_comb)), long double)) \ |
| 338 | ? fct ## f128 arg_call : |
| 339 | # define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) \ |
| 340 | __builtin_types_compatible_p (__typeof (+__real__ (arg_comb)), _Float128) \ |
| 341 | ? (__expr_is_real (arg_comb) \ |
| 342 | ? fct ## f128 arg_call \ |
| 343 | : cfct ## f128 arg_call) : |
| 344 | # else |
| 345 | /* _Float64x is a distinct type at the C language level, which must be |
| 346 | handled like _Float128. */ |
| 347 | # define __TGMATH_F128(arg_comb, fct, arg_call) \ |
| 348 | (__builtin_types_compatible_p (__typeof (+(arg_comb)), _Float128) \ |
| 349 | || __builtin_types_compatible_p (__typeof (+(arg_comb)), _Float64x)) \ |
| 350 | ? fct ## f128 arg_call : |
| 351 | # define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) \ |
| 352 | (__builtin_types_compatible_p (__typeof (+__real__ (arg_comb)), _Float128) \ |
| 353 | || __builtin_types_compatible_p (__typeof (+__real__ (arg_comb)), \ |
| 354 | _Float64x)) \ |
| 355 | ? (__expr_is_real (arg_comb) \ |
| 356 | ? fct ## f128 arg_call \ |
| 357 | : cfct ## f128 arg_call) : |
| 358 | # endif |
| 359 | # else |
| 360 | # define __TGMATH_F128(arg_comb, fct, arg_call) /* Nothing. */ |
| 361 | # define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) /* Nothing. */ |
| 362 | # endif |
| 363 | |
| 364 | # endif /* !__HAVE_BUILTIN_TGMATH_C2X. */ |
| 365 | |
| 366 | /* We have two kinds of generic macros: to support functions which are |
| 367 | only defined on real valued parameters and those which are defined |
| 368 | for complex functions as well. */ |
| 369 | # if __HAVE_BUILTIN_TGMATH |
| 370 | |
| 371 | # define __TGMATH_UNARY_REAL_ONLY(Val, Fct) __TGMATH_1 (Fct, (Val)) |
| 372 | # define __TGMATH_UNARY_REAL_RET_ONLY(Val, Fct) __TGMATH_1 (Fct, (Val)) |
| 373 | # define __TGMATH_BINARY_FIRST_REAL_ONLY(Val1, Val2, Fct) \ |
| 374 | __TGMATH_2 (Fct, (Val1), (Val2)) |
| 375 | # define __TGMATH_BINARY_FIRST_REAL_STD_ONLY(Val1, Val2, Fct) \ |
| 376 | __TGMATH_2STD (Fct, (Val1), (Val2)) |
| 377 | # if __HAVE_BUILTIN_TGMATH_C2X |
| 378 | # define __TGMATH_BINARY_REAL_ONLY(Val1, Val2, Fct) \ |
| 379 | __TGMATH_2 (Fct, (Val1), (Val2)) |
| 380 | # endif |
| 381 | # define __TGMATH_BINARY_REAL_STD_ONLY(Val1, Val2, Fct) \ |
| 382 | __TGMATH_2STD (Fct, (Val1), (Val2)) |
| 383 | # if __HAVE_BUILTIN_TGMATH_C2X |
| 384 | # define __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY(Val1, Val2, Val3, Fct) \ |
| 385 | __TGMATH_3 (Fct, (Val1), (Val2), (Val3)) |
| 386 | # define __TGMATH_TERNARY_REAL_ONLY(Val1, Val2, Val3, Fct) \ |
| 387 | __TGMATH_3 (Fct, (Val1), (Val2), (Val3)) |
| 388 | # endif |
| 389 | # define __TGMATH_TERNARY_FIRST_REAL_RET_ONLY(Val1, Val2, Val3, Fct) \ |
| 390 | __TGMATH_3 (Fct, (Val1), (Val2), (Val3)) |
| 391 | # define __TGMATH_UNARY_REAL_IMAG(Val, Fct, Cfct) \ |
| 392 | __TGMATH_1C (Fct, Cfct, (Val)) |
| 393 | # define __TGMATH_UNARY_IMAG(Val, Cfct) __TGMATH_1 (Cfct, (Val)) |
| 394 | # define __TGMATH_UNARY_REAL_IMAG_RET_REAL(Val, Fct, Cfct) \ |
| 395 | __TGMATH_1C (Fct, Cfct, (Val)) |
| 396 | # define __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME(Val, Cfct) \ |
| 397 | __TGMATH_1 (Cfct, (Val)) |
| 398 | # if __HAVE_BUILTIN_TGMATH_C2X |
| 399 | # define __TGMATH_BINARY_REAL_IMAG(Val1, Val2, Fct, Cfct) \ |
| 400 | __TGMATH_2C (Fct, Cfct, (Val1), (Val2)) |
| 401 | # endif |
| 402 | |
| 403 | # endif |
| 404 | |
| 405 | # if !__HAVE_BUILTIN_TGMATH |
| 406 | # define __TGMATH_UNARY_REAL_ONLY(Val, Fct) \ |
| 407 | (__extension__ ((sizeof (+(Val)) == sizeof (double) \ |
| 408 | || __builtin_classify_type (Val) != 8) \ |
| 409 | ? (__tgmath_real_type (Val)) Fct (Val) \ |
| 410 | : (sizeof (+(Val)) == sizeof (float)) \ |
| 411 | ? (__tgmath_real_type (Val)) Fct##f (Val) \ |
| 412 | : __TGMATH_F128 ((Val), (__tgmath_real_type (Val)) Fct, \ |
| 413 | (Val)) \ |
| 414 | (__tgmath_real_type (Val)) __tgml(Fct) (Val))) |
| 415 | |
| 416 | # define __TGMATH_UNARY_REAL_RET_ONLY(Val, Fct) \ |
| 417 | (__extension__ ((sizeof (+(Val)) == sizeof (double) \ |
| 418 | || __builtin_classify_type (Val) != 8) \ |
| 419 | ? Fct (Val) \ |
| 420 | : (sizeof (+(Val)) == sizeof (float)) \ |
| 421 | ? Fct##f (Val) \ |
| 422 | : __TGMATH_F128 ((Val), Fct, (Val)) \ |
| 423 | __tgml(Fct) (Val))) |
| 424 | |
| 425 | # define __TGMATH_BINARY_FIRST_REAL_ONLY(Val1, Val2, Fct) \ |
| 426 | (__extension__ ((sizeof (+(Val1)) == sizeof (double) \ |
| 427 | || __builtin_classify_type (Val1) != 8) \ |
| 428 | ? (__tgmath_real_type (Val1)) Fct (Val1, Val2) \ |
| 429 | : (sizeof (+(Val1)) == sizeof (float)) \ |
| 430 | ? (__tgmath_real_type (Val1)) Fct##f (Val1, Val2) \ |
| 431 | : __TGMATH_F128 ((Val1), (__tgmath_real_type (Val1)) Fct, \ |
| 432 | (Val1, Val2)) \ |
| 433 | (__tgmath_real_type (Val1)) __tgml(Fct) (Val1, Val2))) |
| 434 | |
| 435 | # define __TGMATH_BINARY_FIRST_REAL_STD_ONLY(Val1, Val2, Fct) \ |
| 436 | (__extension__ ((sizeof (+(Val1)) == sizeof (double) \ |
| 437 | || __builtin_classify_type (Val1) != 8) \ |
| 438 | ? (__tgmath_real_type (Val1)) Fct (Val1, Val2) \ |
| 439 | : (sizeof (+(Val1)) == sizeof (float)) \ |
| 440 | ? (__tgmath_real_type (Val1)) Fct##f (Val1, Val2) \ |
| 441 | : (__tgmath_real_type (Val1)) __tgml(Fct) (Val1, Val2))) |
| 442 | # endif |
| 443 | |
| 444 | # if !__HAVE_BUILTIN_TGMATH_C2X |
| 445 | # define __TGMATH_BINARY_REAL_ONLY(Val1, Val2, Fct) \ |
| 446 | (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \ |
| 447 | && __builtin_classify_type ((Val1) + (Val2)) == 8) \ |
| 448 | ? __TGMATH_F128 ((Val1) + (Val2), \ |
| 449 | (__tgmath_real_type2 (Val1, Val2)) Fct, \ |
| 450 | (Val1, Val2)) \ |
| 451 | (__tgmath_real_type2 (Val1, Val2)) \ |
| 452 | __tgml(Fct) (Val1, Val2) \ |
| 453 | : (sizeof (+(Val1)) == sizeof (double) \ |
| 454 | || sizeof (+(Val2)) == sizeof (double) \ |
| 455 | || __builtin_classify_type (Val1) != 8 \ |
| 456 | || __builtin_classify_type (Val2) != 8) \ |
| 457 | ? (__tgmath_real_type2 (Val1, Val2)) \ |
| 458 | Fct (Val1, Val2) \ |
| 459 | : (__tgmath_real_type2 (Val1, Val2)) \ |
| 460 | Fct##f (Val1, Val2))) |
| 461 | # endif |
| 462 | |
| 463 | # if !__HAVE_BUILTIN_TGMATH |
| 464 | # define __TGMATH_BINARY_REAL_STD_ONLY(Val1, Val2, Fct) \ |
| 465 | (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \ |
| 466 | && __builtin_classify_type ((Val1) + (Val2)) == 8) \ |
| 467 | ? (__typeof ((__tgmath_real_type (Val1)) 0 \ |
| 468 | + (__tgmath_real_type (Val2)) 0)) \ |
| 469 | __tgml(Fct) (Val1, Val2) \ |
| 470 | : (sizeof (+(Val1)) == sizeof (double) \ |
| 471 | || sizeof (+(Val2)) == sizeof (double) \ |
| 472 | || __builtin_classify_type (Val1) != 8 \ |
| 473 | || __builtin_classify_type (Val2) != 8) \ |
| 474 | ? (__typeof ((__tgmath_real_type (Val1)) 0 \ |
| 475 | + (__tgmath_real_type (Val2)) 0)) \ |
| 476 | Fct (Val1, Val2) \ |
| 477 | : (__typeof ((__tgmath_real_type (Val1)) 0 \ |
| 478 | + (__tgmath_real_type (Val2)) 0)) \ |
| 479 | Fct##f (Val1, Val2))) |
| 480 | # endif |
| 481 | |
| 482 | # if !__HAVE_BUILTIN_TGMATH_C2X |
| 483 | # define __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY(Val1, Val2, Val3, Fct) \ |
| 484 | (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \ |
| 485 | && __builtin_classify_type ((Val1) + (Val2)) == 8) \ |
| 486 | ? __TGMATH_F128 ((Val1) + (Val2), \ |
| 487 | (__tgmath_real_type2 (Val1, Val2)) Fct, \ |
| 488 | (Val1, Val2, Val3)) \ |
| 489 | (__tgmath_real_type2 (Val1, Val2)) \ |
| 490 | __tgml(Fct) (Val1, Val2, Val3) \ |
| 491 | : (sizeof (+(Val1)) == sizeof (double) \ |
| 492 | || sizeof (+(Val2)) == sizeof (double) \ |
| 493 | || __builtin_classify_type (Val1) != 8 \ |
| 494 | || __builtin_classify_type (Val2) != 8) \ |
| 495 | ? (__tgmath_real_type2 (Val1, Val2)) \ |
| 496 | Fct (Val1, Val2, Val3) \ |
| 497 | : (__tgmath_real_type2 (Val1, Val2)) \ |
| 498 | Fct##f (Val1, Val2, Val3))) |
| 499 | |
| 500 | # define __TGMATH_TERNARY_REAL_ONLY(Val1, Val2, Val3, Fct) \ |
| 501 | (__extension__ ((sizeof ((Val1) + (Val2) + (Val3)) > sizeof (double) \ |
| 502 | && __builtin_classify_type ((Val1) + (Val2) + (Val3)) \ |
| 503 | == 8) \ |
| 504 | ? __TGMATH_F128 ((Val1) + (Val2) + (Val3), \ |
| 505 | (__tgmath_real_type3 (Val1, Val2, \ |
| 506 | Val3)) Fct, \ |
| 507 | (Val1, Val2, Val3)) \ |
| 508 | (__tgmath_real_type3 (Val1, Val2, Val3)) \ |
| 509 | __tgml(Fct) (Val1, Val2, Val3) \ |
| 510 | : (sizeof (+(Val1)) == sizeof (double) \ |
| 511 | || sizeof (+(Val2)) == sizeof (double) \ |
| 512 | || sizeof (+(Val3)) == sizeof (double) \ |
| 513 | || __builtin_classify_type (Val1) != 8 \ |
| 514 | || __builtin_classify_type (Val2) != 8 \ |
| 515 | || __builtin_classify_type (Val3) != 8) \ |
| 516 | ? (__tgmath_real_type3 (Val1, Val2, Val3)) \ |
| 517 | Fct (Val1, Val2, Val3) \ |
| 518 | : (__tgmath_real_type3 (Val1, Val2, Val3)) \ |
| 519 | Fct##f (Val1, Val2, Val3))) |
| 520 | # endif |
| 521 | |
| 522 | # if !__HAVE_BUILTIN_TGMATH |
| 523 | # define __TGMATH_TERNARY_FIRST_REAL_RET_ONLY(Val1, Val2, Val3, Fct) \ |
| 524 | (__extension__ ((sizeof (+(Val1)) == sizeof (double) \ |
| 525 | || __builtin_classify_type (Val1) != 8) \ |
| 526 | ? Fct (Val1, Val2, Val3) \ |
| 527 | : (sizeof (+(Val1)) == sizeof (float)) \ |
| 528 | ? Fct##f (Val1, Val2, Val3) \ |
| 529 | : __TGMATH_F128 ((Val1), Fct, (Val1, Val2, Val3)) \ |
| 530 | __tgml(Fct) (Val1, Val2, Val3))) |
| 531 | |
| 532 | /* XXX This definition has to be changed as soon as the compiler understands |
| 533 | the imaginary keyword. */ |
| 534 | # define __TGMATH_UNARY_REAL_IMAG(Val, Fct, Cfct) \ |
| 535 | (__extension__ ((sizeof (+__real__ (Val)) == sizeof (double) \ |
| 536 | || __builtin_classify_type (__real__ (Val)) != 8) \ |
| 537 | ? (__expr_is_real (Val) \ |
| 538 | ? (__tgmath_complex_type (Val)) Fct (Val) \ |
| 539 | : (__tgmath_complex_type (Val)) Cfct (Val)) \ |
| 540 | : (sizeof (+__real__ (Val)) == sizeof (float)) \ |
| 541 | ? (__expr_is_real (Val) \ |
| 542 | ? (__tgmath_complex_type (Val)) Fct##f (Val) \ |
| 543 | : (__tgmath_complex_type (Val)) Cfct##f (Val)) \ |
| 544 | : __TGMATH_CF128 ((Val), \ |
| 545 | (__tgmath_complex_type (Val)) Fct, \ |
| 546 | (__tgmath_complex_type (Val)) Cfct, \ |
| 547 | (Val)) \ |
| 548 | (__expr_is_real (Val) \ |
| 549 | ? (__tgmath_complex_type (Val)) __tgml(Fct) (Val) \ |
| 550 | : (__tgmath_complex_type (Val)) __tgml(Cfct) (Val)))) |
| 551 | |
| 552 | # define __TGMATH_UNARY_IMAG(Val, Cfct) \ |
| 553 | (__extension__ ((sizeof (+__real__ (Val)) == sizeof (double) \ |
| 554 | || __builtin_classify_type (__real__ (Val)) != 8) \ |
| 555 | ? (__typeof__ ((__tgmath_real_type (Val)) 0 \ |
| 556 | + _Complex_I)) Cfct (Val) \ |
| 557 | : (sizeof (+__real__ (Val)) == sizeof (float)) \ |
| 558 | ? (__typeof__ ((__tgmath_real_type (Val)) 0 \ |
| 559 | + _Complex_I)) Cfct##f (Val) \ |
| 560 | : __TGMATH_F128 (__real__ (Val), \ |
| 561 | (__typeof__ \ |
| 562 | ((__tgmath_real_type (Val)) 0 \ |
| 563 | + _Complex_I)) Cfct, (Val)) \ |
| 564 | (__typeof__ ((__tgmath_real_type (Val)) 0 \ |
| 565 | + _Complex_I)) __tgml(Cfct) (Val))) |
| 566 | |
| 567 | /* XXX This definition has to be changed as soon as the compiler understands |
| 568 | the imaginary keyword. */ |
| 569 | # define __TGMATH_UNARY_REAL_IMAG_RET_REAL(Val, Fct, Cfct) \ |
| 570 | (__extension__ ((sizeof (+__real__ (Val)) == sizeof (double) \ |
| 571 | || __builtin_classify_type (__real__ (Val)) != 8) \ |
| 572 | ? (__expr_is_real (Val) \ |
| 573 | ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\ |
| 574 | Fct (Val) \ |
| 575 | : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\ |
| 576 | Cfct (Val)) \ |
| 577 | : (sizeof (+__real__ (Val)) == sizeof (float)) \ |
| 578 | ? (__expr_is_real (Val) \ |
| 579 | ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\ |
| 580 | Fct##f (Val) \ |
| 581 | : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\ |
| 582 | Cfct##f (Val)) \ |
| 583 | : __TGMATH_CF128 ((Val), \ |
| 584 | (__typeof__ \ |
| 585 | (__real__ \ |
| 586 | (__tgmath_real_type (Val)) 0)) Fct, \ |
| 587 | (__typeof__ \ |
| 588 | (__real__ \ |
| 589 | (__tgmath_real_type (Val)) 0)) Cfct, \ |
| 590 | (Val)) \ |
| 591 | (__expr_is_real (Val) \ |
| 592 | ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0)) \ |
| 593 | __tgml(Fct) (Val) \ |
| 594 | : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0)) \ |
| 595 | __tgml(Cfct) (Val)))) |
| 596 | # define __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME(Val, Cfct) \ |
| 597 | __TGMATH_UNARY_REAL_IMAG_RET_REAL ((Val), Cfct, Cfct) |
| 598 | # endif |
| 599 | |
| 600 | # if !__HAVE_BUILTIN_TGMATH_C2X |
| 601 | /* XXX This definition has to be changed as soon as the compiler understands |
| 602 | the imaginary keyword. */ |
| 603 | # define __TGMATH_BINARY_REAL_IMAG(Val1, Val2, Fct, Cfct) \ |
| 604 | (__extension__ ((sizeof (__real__ (Val1) \ |
| 605 | + __real__ (Val2)) > sizeof (double) \ |
| 606 | && __builtin_classify_type (__real__ (Val1) \ |
| 607 | + __real__ (Val2)) == 8) \ |
| 608 | ? __TGMATH_CF128 ((Val1) + (Val2), \ |
| 609 | (__tgmath_complex_type2 (Val1, Val2)) \ |
| 610 | Fct, \ |
| 611 | (__tgmath_complex_type2 (Val1, Val2)) \ |
| 612 | Cfct, \ |
| 613 | (Val1, Val2)) \ |
| 614 | (__expr_is_real ((Val1) + (Val2)) \ |
| 615 | ? (__tgmath_complex_type2 (Val1, Val2)) \ |
| 616 | __tgml(Fct) (Val1, Val2) \ |
| 617 | : (__tgmath_complex_type2 (Val1, Val2)) \ |
| 618 | __tgml(Cfct) (Val1, Val2)) \ |
| 619 | : (sizeof (+__real__ (Val1)) == sizeof (double) \ |
| 620 | || sizeof (+__real__ (Val2)) == sizeof (double) \ |
| 621 | || __builtin_classify_type (__real__ (Val1)) != 8 \ |
| 622 | || __builtin_classify_type (__real__ (Val2)) != 8) \ |
| 623 | ? (__expr_is_real ((Val1) + (Val2)) \ |
| 624 | ? (__tgmath_complex_type2 (Val1, Val2)) \ |
| 625 | Fct (Val1, Val2) \ |
| 626 | : (__tgmath_complex_type2 (Val1, Val2)) \ |
| 627 | Cfct (Val1, Val2)) \ |
| 628 | : (__expr_is_real ((Val1) + (Val2)) \ |
| 629 | ? (__tgmath_complex_type2 (Val1, Val2)) \ |
| 630 | Fct##f (Val1, Val2) \ |
| 631 | : (__tgmath_complex_type2 (Val1, Val2)) \ |
| 632 | Cfct##f (Val1, Val2)))) |
| 633 | # endif |
| 634 | |
| 635 | # if !__HAVE_BUILTIN_TGMATH |
| 636 | # define __TGMATH_1_NARROW_F(F, X) \ |
| 637 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0) > sizeof (double) \ |
| 638 | ? F ## l (X) \ |
| 639 | : F (X))) |
| 640 | # define __TGMATH_2_NARROW_F(F, X, Y) \ |
| 641 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ |
| 642 | + (__tgmath_real_type (Y)) 0) > sizeof (double) \ |
| 643 | ? F ## l (X, Y) \ |
| 644 | : F (X, Y))) |
| 645 | # define __TGMATH_3_NARROW_F(F, X, Y, Z) \ |
| 646 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ |
| 647 | + (__tgmath_real_type (Y)) 0 \ |
| 648 | + (__tgmath_real_type (Z)) 0) > sizeof (double) \ |
| 649 | ? F ## l (X, Y, Z) \ |
| 650 | : F (X, Y, Z))) |
| 651 | # endif |
| 652 | /* In most cases, these narrowing macro definitions based on sizeof |
| 653 | ensure that the function called has the right argument format, as |
| 654 | for other <tgmath.h> macros for compilers before GCC 8, but may not |
| 655 | have exactly the argument type (among the types with that format) |
| 656 | specified in the standard logic. |
| 657 | |
| 658 | In the case of macros for _Float32x return type, when _Float64x |
| 659 | exists, _Float64 arguments should result in the *f64 function being |
| 660 | called while _Float32x, float and double arguments should result in |
| 661 | the *f64x function being called (and integer arguments are |
| 662 | considered to have type _Float32x if any argument has type |
| 663 | _FloatNx, or double otherwise). These cases cannot be |
| 664 | distinguished using sizeof (or at all if the types are typedefs |
| 665 | rather than different types, in which case we err on the side of |
| 666 | using the wider type if unsure). */ |
| 667 | # if !__HAVE_BUILTIN_TGMATH_C2X |
| 668 | # if __HAVE_FLOATN_NOT_TYPEDEF |
| 669 | # define __TGMATH_NARROW_F32X_USE_F64X(X) \ |
| 670 | !__builtin_types_compatible_p (__typeof (+(X)), _Float64) |
| 671 | # else |
| 672 | # define __TGMATH_NARROW_F32X_USE_F64X(X) \ |
| 673 | (__builtin_types_compatible_p (__typeof (+(X)), double) \ |
| 674 | || __builtin_types_compatible_p (__typeof (+(X)), float) \ |
| 675 | || !__floating_type (__typeof (+(X)))) |
| 676 | # endif |
| 677 | # endif |
| 678 | # if __HAVE_FLOAT64X_LONG_DOUBLE && __HAVE_DISTINCT_FLOAT128 |
| 679 | # if !__HAVE_BUILTIN_TGMATH |
| 680 | # define __TGMATH_1_NARROW_F32(F, X) \ |
| 681 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0) > sizeof (_Float64) \ |
| 682 | ? __TGMATH_F128LD ((X), F, (X)) \ |
| 683 | F ## f64x (X) \ |
| 684 | : F ## f64 (X))) |
| 685 | # define __TGMATH_2_NARROW_F32(F, X, Y) \ |
| 686 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ |
| 687 | + (__tgmath_real_type (Y)) 0) > sizeof (_Float64) \ |
| 688 | ? __TGMATH_F128LD ((X) + (Y), F, (X, Y)) \ |
| 689 | F ## f64x (X, Y) \ |
| 690 | : F ## f64 (X, Y))) |
| 691 | # define __TGMATH_3_NARROW_F32(F, X, Y, Z) \ |
| 692 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ |
| 693 | + (__tgmath_real_type (Y)) 0 \ |
| 694 | + (__tgmath_real_type (Z)) 0) > sizeof (_Float64) \ |
| 695 | ? __TGMATH_F128LD ((X) + (Y) + (Z), F, (X, Y, Z)) \ |
| 696 | F ## f64x (X, Y, Z) \ |
| 697 | : F ## f64 (X, Y, Z))) |
| 698 | # define __TGMATH_1_NARROW_F64(F, X) \ |
| 699 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0) > sizeof (_Float64) \ |
| 700 | ? __TGMATH_F128LD ((X), F, (X)) \ |
| 701 | F ## f64x (X) \ |
| 702 | : F ## f128 (X))) |
| 703 | # define __TGMATH_2_NARROW_F64(F, X, Y) \ |
| 704 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ |
| 705 | + (__tgmath_real_type (Y)) 0) > sizeof (_Float64) \ |
| 706 | ? __TGMATH_F128LD ((X) + (Y), F, (X, Y)) \ |
| 707 | F ## f64x (X, Y) \ |
| 708 | : F ## f128 (X, Y))) |
| 709 | # define __TGMATH_3_NARROW_F64(F, X, Y, Z) \ |
| 710 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ |
| 711 | + (__tgmath_real_type (Y)) 0 \ |
| 712 | + (__tgmath_real_type (Z)) 0) > sizeof (_Float64) \ |
| 713 | ? __TGMATH_F128LD ((X) + (Y) + (Z), F, (X, Y, Z)) \ |
| 714 | F ## f64x (X, Y, Z) \ |
| 715 | : F ## f128 (X, Y, Z))) |
| 716 | # endif |
| 717 | # if !__HAVE_BUILTIN_TGMATH_C2X |
| 718 | # define __TGMATH_1_NARROW_F32X(F, X) \ |
| 719 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0) > sizeof (_Float64) \ |
| 720 | || __TGMATH_NARROW_F32X_USE_F64X (X) \ |
| 721 | ? __TGMATH_F128 ((X), F, (X)) \ |
| 722 | F ## f64x (X) \ |
| 723 | : F ## f64 (X))) |
| 724 | # define __TGMATH_2_NARROW_F32X(F, X, Y) \ |
| 725 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ |
| 726 | + (__tgmath_real_type (Y)) 0) > sizeof (_Float64) \ |
| 727 | || __TGMATH_NARROW_F32X_USE_F64X ((X) + (Y)) \ |
| 728 | ? __TGMATH_F128 ((X) + (Y), F, (X, Y)) \ |
| 729 | F ## f64x (X, Y) \ |
| 730 | : F ## f64 (X, Y))) |
| 731 | # define __TGMATH_3_NARROW_F32X(F, X, Y, Z) \ |
| 732 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ |
| 733 | + (__tgmath_real_type (Y)) 0 \ |
| 734 | + (__tgmath_real_type (Z)) 0) > sizeof (_Float64) \ |
| 735 | || __TGMATH_NARROW_F32X_USE_F64X ((X) + (Y) + (Z)) \ |
| 736 | ? __TGMATH_F128 ((X) + (Y) + (Z), F, (X, Y, Z)) \ |
| 737 | F ## f64x (X, Y, Z) \ |
| 738 | : F ## f64 (X, Y, Z))) |
| 739 | # endif |
| 740 | # elif __HAVE_FLOAT128 |
| 741 | # if !__HAVE_BUILTIN_TGMATH |
| 742 | # define __TGMATH_1_NARROW_F32(F, X) \ |
| 743 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0) > sizeof (_Float64) \ |
| 744 | ? F ## f128 (X) \ |
| 745 | : F ## f64 (X))) |
| 746 | # define __TGMATH_2_NARROW_F32(F, X, Y) \ |
| 747 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ |
| 748 | + (__tgmath_real_type (Y)) 0) > sizeof (_Float64) \ |
| 749 | ? F ## f128 (X, Y) \ |
| 750 | : F ## f64 (X, Y))) |
| 751 | # define __TGMATH_3_NARROW_F32(F, X, Y, Z) \ |
| 752 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ |
| 753 | + (__tgmath_real_type (Y)) 0 \ |
| 754 | + (__tgmath_real_type (Z)) 0) > sizeof (_Float64) \ |
| 755 | ? F ## f128 (X, Y, Z) \ |
| 756 | : F ## f64 (X, Y, Z))) |
| 757 | # define __TGMATH_1_NARROW_F64(F, X) \ |
| 758 | (F ## f128 (X)) |
| 759 | # define __TGMATH_2_NARROW_F64(F, X, Y) \ |
| 760 | (F ## f128 (X, Y)) |
| 761 | # define __TGMATH_3_NARROW_F64(F, X, Y, Z) \ |
| 762 | (F ## f128 (X, Y, Z)) |
| 763 | # endif |
| 764 | # if !__HAVE_BUILTIN_TGMATH_C2X |
| 765 | # define __TGMATH_1_NARROW_F32X(F, X) \ |
| 766 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0) > sizeof (_Float32x) \ |
| 767 | || __TGMATH_NARROW_F32X_USE_F64X (X) \ |
| 768 | ? F ## f64x (X) \ |
| 769 | : F ## f64 (X))) |
| 770 | # define __TGMATH_2_NARROW_F32X(F, X, Y) \ |
| 771 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ |
| 772 | + (__tgmath_real_type (Y)) 0) > sizeof (_Float32x) \ |
| 773 | || __TGMATH_NARROW_F32X_USE_F64X ((X) + (Y)) \ |
| 774 | ? F ## f64x (X, Y) \ |
| 775 | : F ## f64 (X, Y))) |
| 776 | # define __TGMATH_3_NARROW_F32X(F, X, Y, Z) \ |
| 777 | (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ |
| 778 | + (__tgmath_real_type (Y)) 0 \ |
| 779 | + (__tgmath_real_type (Z)) 0) > sizeof (_Float32x) \ |
| 780 | || __TGMATH_NARROW_F32X_USE_F64X ((X) + (Y) + (Z)) \ |
| 781 | ? F ## f64x (X, Y, Z) \ |
| 782 | : F ## f64 (X, Y, Z))) |
| 783 | # endif |
| 784 | # else |
| 785 | # if !__HAVE_BUILTIN_TGMATH |
| 786 | # define __TGMATH_1_NARROW_F32(F, X) \ |
| 787 | (F ## f64 (X)) |
| 788 | # define __TGMATH_2_NARROW_F32(F, X, Y) \ |
| 789 | (F ## f64 (X, Y)) |
| 790 | # define __TGMATH_3_NARROW_F32(F, X, Y, Z) \ |
| 791 | (F ## f64 (X, Y, Z)) |
| 792 | # endif |
| 793 | # endif |
| 794 | #else |
| 795 | # error "Unsupported compiler; you cannot use <tgmath.h>" |
| 796 | #endif |
| 797 | |
| 798 | |
| 799 | /* Unary functions defined for real and complex values. */ |
| 800 | |
| 801 | |
| 802 | /* Trigonometric functions. */ |
| 803 | |
| 804 | /* Arc cosine of X. */ |
| 805 | #define acos(Val) __TGMATH_UNARY_REAL_IMAG (Val, acos, cacos) |
| 806 | /* Arc sine of X. */ |
| 807 | #define asin(Val) __TGMATH_UNARY_REAL_IMAG (Val, asin, casin) |
| 808 | /* Arc tangent of X. */ |
| 809 | #define atan(Val) __TGMATH_UNARY_REAL_IMAG (Val, atan, catan) |
| 810 | /* Arc tangent of Y/X. */ |
| 811 | #define atan2(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, atan2) |
| 812 | |
| 813 | /* Cosine of X. */ |
| 814 | #define cos(Val) __TGMATH_UNARY_REAL_IMAG (Val, cos, ccos) |
| 815 | /* Sine of X. */ |
| 816 | #define sin(Val) __TGMATH_UNARY_REAL_IMAG (Val, sin, csin) |
| 817 | /* Tangent of X. */ |
| 818 | #define tan(Val) __TGMATH_UNARY_REAL_IMAG (Val, tan, ctan) |
| 819 | |
| 820 | |
| 821 | /* Hyperbolic functions. */ |
| 822 | |
| 823 | /* Hyperbolic arc cosine of X. */ |
| 824 | #define acosh(Val) __TGMATH_UNARY_REAL_IMAG (Val, acosh, cacosh) |
| 825 | /* Hyperbolic arc sine of X. */ |
| 826 | #define asinh(Val) __TGMATH_UNARY_REAL_IMAG (Val, asinh, casinh) |
| 827 | /* Hyperbolic arc tangent of X. */ |
| 828 | #define atanh(Val) __TGMATH_UNARY_REAL_IMAG (Val, atanh, catanh) |
| 829 | |
| 830 | /* Hyperbolic cosine of X. */ |
| 831 | #define cosh(Val) __TGMATH_UNARY_REAL_IMAG (Val, cosh, ccosh) |
| 832 | /* Hyperbolic sine of X. */ |
| 833 | #define sinh(Val) __TGMATH_UNARY_REAL_IMAG (Val, sinh, csinh) |
| 834 | /* Hyperbolic tangent of X. */ |
| 835 | #define tanh(Val) __TGMATH_UNARY_REAL_IMAG (Val, tanh, ctanh) |
| 836 | |
| 837 | |
| 838 | /* Exponential and logarithmic functions. */ |
| 839 | |
| 840 | /* Exponential function of X. */ |
| 841 | #define exp(Val) __TGMATH_UNARY_REAL_IMAG (Val, exp, cexp) |
| 842 | |
| 843 | /* Break VALUE into a normalized fraction and an integral power of 2. */ |
| 844 | #define frexp(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, frexp) |
| 845 | |
| 846 | /* X times (two to the EXP power). */ |
| 847 | #define ldexp(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, ldexp) |
| 848 | |
| 849 | /* Natural logarithm of X. */ |
| 850 | #define log(Val) __TGMATH_UNARY_REAL_IMAG (Val, log, clog) |
| 851 | |
| 852 | /* Base-ten logarithm of X. */ |
| 853 | #ifdef __USE_GNU |
| 854 | # define log10(Val) __TGMATH_UNARY_REAL_IMAG (Val, log10, clog10) |
| 855 | #else |
| 856 | # define log10(Val) __TGMATH_UNARY_REAL_ONLY (Val, log10) |
| 857 | #endif |
| 858 | |
| 859 | /* Return exp(X) - 1. */ |
| 860 | #define expm1(Val) __TGMATH_UNARY_REAL_ONLY (Val, expm1) |
| 861 | |
| 862 | /* Return log(1 + X). */ |
| 863 | #define log1p(Val) __TGMATH_UNARY_REAL_ONLY (Val, log1p) |
| 864 | |
| 865 | /* Return the base 2 signed integral exponent of X. */ |
| 866 | #define logb(Val) __TGMATH_UNARY_REAL_ONLY (Val, logb) |
| 867 | |
| 868 | /* Compute base-2 exponential of X. */ |
| 869 | #define exp2(Val) __TGMATH_UNARY_REAL_ONLY (Val, exp2) |
| 870 | |
| 871 | /* Compute base-2 logarithm of X. */ |
| 872 | #define log2(Val) __TGMATH_UNARY_REAL_ONLY (Val, log2) |
| 873 | |
| 874 | #if __GLIBC_USE (IEC_60559_FUNCS_EXT_C2X) |
| 875 | /* Compute exponent to base ten. */ |
| 876 | #define exp10(Val) __TGMATH_UNARY_REAL_ONLY (Val, exp10) |
| 877 | #endif |
| 878 | |
| 879 | |
| 880 | /* Power functions. */ |
| 881 | |
| 882 | /* Return X to the Y power. */ |
| 883 | #define pow(Val1, Val2) __TGMATH_BINARY_REAL_IMAG (Val1, Val2, pow, cpow) |
| 884 | |
| 885 | /* Return the square root of X. */ |
| 886 | #define sqrt(Val) __TGMATH_UNARY_REAL_IMAG (Val, sqrt, csqrt) |
| 887 | |
| 888 | /* Return `sqrt(X*X + Y*Y)'. */ |
| 889 | #define hypot(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, hypot) |
| 890 | |
| 891 | /* Return the cube root of X. */ |
| 892 | #define cbrt(Val) __TGMATH_UNARY_REAL_ONLY (Val, cbrt) |
| 893 | |
| 894 | |
| 895 | /* Nearest integer, absolute value, and remainder functions. */ |
| 896 | |
| 897 | /* Smallest integral value not less than X. */ |
| 898 | #define ceil(Val) __TGMATH_UNARY_REAL_ONLY (Val, ceil) |
| 899 | |
| 900 | /* Absolute value of X. */ |
| 901 | #define fabs(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, fabs, cabs) |
| 902 | |
| 903 | /* Largest integer not greater than X. */ |
| 904 | #define floor(Val) __TGMATH_UNARY_REAL_ONLY (Val, floor) |
| 905 | |
| 906 | /* Floating-point modulo remainder of X/Y. */ |
| 907 | #define fmod(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmod) |
| 908 | |
| 909 | /* Round X to integral valuein floating-point format using current |
| 910 | rounding direction, but do not raise inexact exception. */ |
| 911 | #define nearbyint(Val) __TGMATH_UNARY_REAL_ONLY (Val, nearbyint) |
| 912 | |
| 913 | /* Round X to nearest integral value, rounding halfway cases away from |
| 914 | zero. */ |
| 915 | #define round(Val) __TGMATH_UNARY_REAL_ONLY (Val, round) |
| 916 | |
| 917 | /* Round X to the integral value in floating-point format nearest but |
| 918 | not larger in magnitude. */ |
| 919 | #define trunc(Val) __TGMATH_UNARY_REAL_ONLY (Val, trunc) |
| 920 | |
| 921 | /* Compute remainder of X and Y and put in *QUO a value with sign of x/y |
| 922 | and magnitude congruent `mod 2^n' to the magnitude of the integral |
| 923 | quotient x/y, with n >= 3. */ |
| 924 | #define remquo(Val1, Val2, Val3) \ |
| 925 | __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY (Val1, Val2, Val3, remquo) |
| 926 | |
| 927 | /* Round X to nearest integral value according to current rounding |
| 928 | direction. */ |
| 929 | #define lrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, lrint) |
| 930 | #define llrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llrint) |
| 931 | |
| 932 | /* Round X to nearest integral value, rounding halfway cases away from |
| 933 | zero. */ |
| 934 | #define lround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, lround) |
| 935 | #define llround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llround) |
| 936 | |
| 937 | |
| 938 | /* Return X with its signed changed to Y's. */ |
| 939 | #define copysign(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, copysign) |
| 940 | |
| 941 | /* Error and gamma functions. */ |
| 942 | #define erf(Val) __TGMATH_UNARY_REAL_ONLY (Val, erf) |
| 943 | #define erfc(Val) __TGMATH_UNARY_REAL_ONLY (Val, erfc) |
| 944 | #define tgamma(Val) __TGMATH_UNARY_REAL_ONLY (Val, tgamma) |
| 945 | #define lgamma(Val) __TGMATH_UNARY_REAL_ONLY (Val, lgamma) |
| 946 | |
| 947 | |
| 948 | /* Return the integer nearest X in the direction of the |
| 949 | prevailing rounding mode. */ |
| 950 | #define rint(Val) __TGMATH_UNARY_REAL_ONLY (Val, rint) |
| 951 | |
| 952 | #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) |
| 953 | /* Return X - epsilon. */ |
| 954 | # define nextdown(Val) __TGMATH_UNARY_REAL_ONLY (Val, nextdown) |
| 955 | /* Return X + epsilon. */ |
| 956 | # define nextup(Val) __TGMATH_UNARY_REAL_ONLY (Val, nextup) |
| 957 | #endif |
| 958 | |
| 959 | /* Return X + epsilon if X < Y, X - epsilon if X > Y. */ |
| 960 | #define nextafter(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, nextafter) |
| 961 | #define nexttoward(Val1, Val2) \ |
| 962 | __TGMATH_BINARY_FIRST_REAL_STD_ONLY (Val1, Val2, nexttoward) |
| 963 | |
| 964 | /* Return the remainder of integer division X / Y with infinite precision. */ |
| 965 | #define remainder(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, remainder) |
| 966 | |
| 967 | /* Return X times (2 to the Nth power). */ |
| 968 | #ifdef __USE_MISC |
| 969 | # define scalb(Val1, Val2) __TGMATH_BINARY_REAL_STD_ONLY (Val1, Val2, scalb) |
| 970 | #endif |
| 971 | |
| 972 | /* Return X times (2 to the Nth power). */ |
| 973 | #define scalbn(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbn) |
| 974 | |
| 975 | /* Return X times (2 to the Nth power). */ |
| 976 | #define scalbln(Val1, Val2) \ |
| 977 | __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbln) |
| 978 | |
| 979 | /* Return the binary exponent of X, which must be nonzero. */ |
| 980 | #define ilogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, ilogb) |
| 981 | |
| 982 | |
| 983 | /* Return positive difference between X and Y. */ |
| 984 | #define fdim(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fdim) |
| 985 | |
| 986 | #if __GLIBC_USE (ISOC2X) && !defined __USE_GNU |
| 987 | /* Return maximum numeric value from X and Y. */ |
| 988 | # define fmax(Val1, Val2) __TGMATH_BINARY_REAL_STD_ONLY (Val1, Val2, fmax) |
| 989 | |
| 990 | /* Return minimum numeric value from X and Y. */ |
| 991 | # define fmin(Val1, Val2) __TGMATH_BINARY_REAL_STD_ONLY (Val1, Val2, fmin) |
| 992 | #else |
| 993 | /* Return maximum numeric value from X and Y. */ |
| 994 | # define fmax(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmax) |
| 995 | |
| 996 | /* Return minimum numeric value from X and Y. */ |
| 997 | # define fmin(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmin) |
| 998 | #endif |
| 999 | |
| 1000 | |
| 1001 | /* Multiply-add function computed as a ternary operation. */ |
| 1002 | #define fma(Val1, Val2, Val3) \ |
| 1003 | __TGMATH_TERNARY_REAL_ONLY (Val1, Val2, Val3, fma) |
| 1004 | |
| 1005 | #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) |
| 1006 | /* Round X to nearest integer value, rounding halfway cases to even. */ |
| 1007 | # define roundeven(Val) __TGMATH_UNARY_REAL_ONLY (Val, roundeven) |
| 1008 | |
| 1009 | # define fromfp(Val1, Val2, Val3) \ |
| 1010 | __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, fromfp) |
| 1011 | |
| 1012 | # define ufromfp(Val1, Val2, Val3) \ |
| 1013 | __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, ufromfp) |
| 1014 | |
| 1015 | # define fromfpx(Val1, Val2, Val3) \ |
| 1016 | __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, fromfpx) |
| 1017 | |
| 1018 | # define ufromfpx(Val1, Val2, Val3) \ |
| 1019 | __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, ufromfpx) |
| 1020 | |
| 1021 | /* Like ilogb, but returning long int. */ |
| 1022 | # define llogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llogb) |
| 1023 | #endif |
| 1024 | |
| 1025 | #if __GLIBC_USE (IEC_60559_BFP_EXT) |
| 1026 | /* Return value with maximum magnitude. */ |
| 1027 | # define fmaxmag(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmaxmag) |
| 1028 | |
| 1029 | /* Return value with minimum magnitude. */ |
| 1030 | # define fminmag(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fminmag) |
| 1031 | #endif |
| 1032 | |
| 1033 | #if __GLIBC_USE (ISOC2X) |
| 1034 | /* Return maximum value from X and Y. */ |
| 1035 | # define fmaximum(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmaximum) |
| 1036 | |
| 1037 | /* Return minimum value from X and Y. */ |
| 1038 | # define fminimum(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fminimum) |
| 1039 | |
| 1040 | /* Return maximum numeric value from X and Y. */ |
| 1041 | # define fmaximum_num(Val1, Val2) \ |
| 1042 | __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmaximum_num) |
| 1043 | |
| 1044 | /* Return minimum numeric value from X and Y. */ |
| 1045 | # define fminimum_num(Val1, Val2) \ |
| 1046 | __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fminimum_num) |
| 1047 | |
| 1048 | /* Return value with maximum magnitude. */ |
| 1049 | # define fmaximum_mag(Val1, Val2) \ |
| 1050 | __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmaximum_mag) |
| 1051 | |
| 1052 | /* Return value with minimum magnitude. */ |
| 1053 | # define fminimum_mag(Val1, Val2) \ |
| 1054 | __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fminimum_mag) |
| 1055 | |
| 1056 | /* Return numeric value with maximum magnitude. */ |
| 1057 | # define fmaximum_mag_num(Val1, Val2) \ |
| 1058 | __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmaximum_mag_num) |
| 1059 | |
| 1060 | /* Return numeric value with minimum magnitude. */ |
| 1061 | # define fminimum_mag_num(Val1, Val2) \ |
| 1062 | __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fminimum_mag_num) |
| 1063 | #endif |
| 1064 | |
| 1065 | |
| 1066 | /* Absolute value, conjugates, and projection. */ |
| 1067 | |
| 1068 | /* Argument value of Z. */ |
| 1069 | #define carg(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME (Val, carg) |
| 1070 | |
| 1071 | /* Complex conjugate of Z. */ |
| 1072 | #define conj(Val) __TGMATH_UNARY_IMAG (Val, conj) |
| 1073 | |
| 1074 | /* Projection of Z onto the Riemann sphere. */ |
| 1075 | #define cproj(Val) __TGMATH_UNARY_IMAG (Val, cproj) |
| 1076 | |
| 1077 | |
| 1078 | /* Decomposing complex values. */ |
| 1079 | |
| 1080 | /* Imaginary part of Z. */ |
| 1081 | #define cimag(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME (Val, cimag) |
| 1082 | |
| 1083 | /* Real part of Z. */ |
| 1084 | #define creal(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME (Val, creal) |
| 1085 | |
| 1086 | |
| 1087 | /* Narrowing functions. */ |
| 1088 | |
| 1089 | #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) |
| 1090 | |
| 1091 | /* Add. */ |
| 1092 | # define fadd(Val1, Val2) __TGMATH_2_NARROW_F (fadd, Val1, Val2) |
| 1093 | # define dadd(Val1, Val2) __TGMATH_2_NARROW_D (dadd, Val1, Val2) |
| 1094 | |
| 1095 | /* Divide. */ |
| 1096 | # define fdiv(Val1, Val2) __TGMATH_2_NARROW_F (fdiv, Val1, Val2) |
| 1097 | # define ddiv(Val1, Val2) __TGMATH_2_NARROW_D (ddiv, Val1, Val2) |
| 1098 | |
| 1099 | /* Multiply. */ |
| 1100 | # define fmul(Val1, Val2) __TGMATH_2_NARROW_F (fmul, Val1, Val2) |
| 1101 | # define dmul(Val1, Val2) __TGMATH_2_NARROW_D (dmul, Val1, Val2) |
| 1102 | |
| 1103 | /* Subtract. */ |
| 1104 | # define fsub(Val1, Val2) __TGMATH_2_NARROW_F (fsub, Val1, Val2) |
| 1105 | # define dsub(Val1, Val2) __TGMATH_2_NARROW_D (dsub, Val1, Val2) |
| 1106 | |
| 1107 | /* Square root. */ |
| 1108 | # define fsqrt(Val) __TGMATH_1_NARROW_F (fsqrt, Val) |
| 1109 | # define dsqrt(Val) __TGMATH_1_NARROW_D (dsqrt, Val) |
| 1110 | |
| 1111 | /* Fused multiply-add. */ |
| 1112 | # define ffma(Val1, Val2, Val3) __TGMATH_3_NARROW_F (ffma, Val1, Val2, Val3) |
| 1113 | # define dfma(Val1, Val2, Val3) __TGMATH_3_NARROW_D (dfma, Val1, Val2, Val3) |
| 1114 | |
| 1115 | #endif |
| 1116 | |
| 1117 | #if __GLIBC_USE (IEC_60559_TYPES_EXT) |
| 1118 | |
| 1119 | # if __HAVE_FLOAT16 |
| 1120 | # define f16add(Val1, Val2) __TGMATH_2_NARROW_F16 (f16add, Val1, Val2) |
| 1121 | # define f16div(Val1, Val2) __TGMATH_2_NARROW_F16 (f16div, Val1, Val2) |
| 1122 | # define f16mul(Val1, Val2) __TGMATH_2_NARROW_F16 (f16mul, Val1, Val2) |
| 1123 | # define f16sub(Val1, Val2) __TGMATH_2_NARROW_F16 (f16sub, Val1, Val2) |
| 1124 | # define f16sqrt(Val) __TGMATH_1_NARROW_F16 (f16sqrt, Val) |
| 1125 | # define f16fma(Val1, Val2, Val3) \ |
| 1126 | __TGMATH_3_NARROW_F16 (f16fma, Val1, Val2, Val3) |
| 1127 | # endif |
| 1128 | |
| 1129 | # if __HAVE_FLOAT32 |
| 1130 | # define f32add(Val1, Val2) __TGMATH_2_NARROW_F32 (f32add, Val1, Val2) |
| 1131 | # define f32div(Val1, Val2) __TGMATH_2_NARROW_F32 (f32div, Val1, Val2) |
| 1132 | # define f32mul(Val1, Val2) __TGMATH_2_NARROW_F32 (f32mul, Val1, Val2) |
| 1133 | # define f32sub(Val1, Val2) __TGMATH_2_NARROW_F32 (f32sub, Val1, Val2) |
| 1134 | # define f32sqrt(Val) __TGMATH_1_NARROW_F32 (f32sqrt, Val) |
| 1135 | # define f32fma(Val1, Val2, Val3) \ |
| 1136 | __TGMATH_3_NARROW_F32 (f32fma, Val1, Val2, Val3) |
| 1137 | # endif |
| 1138 | |
| 1139 | # if __HAVE_FLOAT64 && (__HAVE_FLOAT64X || __HAVE_FLOAT128) |
| 1140 | # define f64add(Val1, Val2) __TGMATH_2_NARROW_F64 (f64add, Val1, Val2) |
| 1141 | # define f64div(Val1, Val2) __TGMATH_2_NARROW_F64 (f64div, Val1, Val2) |
| 1142 | # define f64mul(Val1, Val2) __TGMATH_2_NARROW_F64 (f64mul, Val1, Val2) |
| 1143 | # define f64sub(Val1, Val2) __TGMATH_2_NARROW_F64 (f64sub, Val1, Val2) |
| 1144 | # define f64sqrt(Val) __TGMATH_1_NARROW_F64 (f64sqrt, Val) |
| 1145 | # define f64fma(Val1, Val2, Val3) \ |
| 1146 | __TGMATH_3_NARROW_F64 (f64fma, Val1, Val2, Val3) |
| 1147 | # endif |
| 1148 | |
| 1149 | # if __HAVE_FLOAT32X |
| 1150 | # define f32xadd(Val1, Val2) __TGMATH_2_NARROW_F32X (f32xadd, Val1, Val2) |
| 1151 | # define f32xdiv(Val1, Val2) __TGMATH_2_NARROW_F32X (f32xdiv, Val1, Val2) |
| 1152 | # define f32xmul(Val1, Val2) __TGMATH_2_NARROW_F32X (f32xmul, Val1, Val2) |
| 1153 | # define f32xsub(Val1, Val2) __TGMATH_2_NARROW_F32X (f32xsub, Val1, Val2) |
| 1154 | # define f32xsqrt(Val) __TGMATH_1_NARROW_F32X (f32xsqrt, Val) |
| 1155 | # define f32xfma(Val1, Val2, Val3) \ |
| 1156 | __TGMATH_3_NARROW_F32X (f32xfma, Val1, Val2, Val3) |
| 1157 | # endif |
| 1158 | |
| 1159 | # if __HAVE_FLOAT64X && (__HAVE_FLOAT128X || __HAVE_FLOAT128) |
| 1160 | # define f64xadd(Val1, Val2) __TGMATH_2_NARROW_F64X (f64xadd, Val1, Val2) |
| 1161 | # define f64xdiv(Val1, Val2) __TGMATH_2_NARROW_F64X (f64xdiv, Val1, Val2) |
| 1162 | # define f64xmul(Val1, Val2) __TGMATH_2_NARROW_F64X (f64xmul, Val1, Val2) |
| 1163 | # define f64xsub(Val1, Val2) __TGMATH_2_NARROW_F64X (f64xsub, Val1, Val2) |
| 1164 | # define f64xsqrt(Val) __TGMATH_1_NARROW_F64X (f64xsqrt, Val) |
| 1165 | # define f64xfma(Val1, Val2, Val3) \ |
| 1166 | __TGMATH_3_NARROW_F64X (f64xfma, Val1, Val2, Val3) |
| 1167 | # endif |
| 1168 | |
| 1169 | #endif |
| 1170 | |
| 1171 | #endif /* tgmath.h */ |
| 1172 | |