1 /* Copyright (C) 1997-2017 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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 <http://www.gnu.org/licenses/>. */
19 * ISO C99 Standard: 7.22 Type-generic math <tgmath.h>
25 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
26 #include <bits/libc-header-start.h>
28 /* Include the needed headers. */
29 #include <bits/floatn.h>
34 /* Since `complex' is currently not really implemented in most C compilers
35 and if it is implemented, the implementations differ. This makes it
36 quite difficult to write a generic implementation of this header. We
37 do not try this for now and instead concentrate only on GNU CC. Once
38 we have more information support for other compilers might follow. */
40 #if __GNUC_PREREQ (2, 7)
42 # ifdef __NO_LONG_DOUBLE_MATH
43 # define __tgml(fct) fct
45 # define __tgml(fct) fct ## l
48 /* This is ugly but unless gcc gets appropriate builtins we have to do
49 something like this. Don't ask how it works. */
51 /* 1 if 'type' is a floating type, 0 if 'type' is an integer type.
52 Allows for _Bool. Expands to an integer constant expression. */
53 # if __GNUC_PREREQ (3, 1)
54 # define __floating_type(type) \
55 (__builtin_classify_type ((type) 0) == 8 \
56 || (__builtin_classify_type ((type) 0) == 9 \
57 && __builtin_classify_type (__real__ ((type) 0)) == 8))
59 # define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))
62 /* The tgmath real type for T, where E is 0 if T is an integer type and
63 1 for a floating type. */
64 # define __tgmath_real_type_sub(T, E) \
65 __typeof__ (*(0 ? (__typeof__ (0 ? (double *) 0 : (void *) (E))) 0 \
66 : (__typeof__ (0 ? (T *) 0 : (void *) (!(E)))) 0))
68 /* The tgmath real type of EXPR. */
69 # define __tgmath_real_type(expr) \
70 __tgmath_real_type_sub (__typeof__ ((__typeof__ (+(expr))) 0), \
71 __floating_type (__typeof__ (+(expr))))
73 /* Expand to text that checks if ARG_COMB has type _Float128, and if
74 so calls the appropriately suffixed FCT (which may include a cast),
75 or FCT and CFCT for complex functions, with arguments ARG_CALL. */
76 # if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
77 # define __TGMATH_F128(arg_comb, fct, arg_call) \
78 __builtin_types_compatible_p (__typeof (+(arg_comb)), _Float128) \
79 ? fct ## f128 arg_call :
80 # define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) \
81 __builtin_types_compatible_p (__typeof (+__real__ (arg_comb)), _Float128) \
82 ? (sizeof (+__real__ (arg_comb)) == sizeof (+(arg_comb)) \
83 ? fct ## f128 arg_call \
84 : cfct ## f128 arg_call) :
86 # define __TGMATH_F128(arg_comb, fct, arg_call) /* Nothing. */
87 # define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) /* Nothing. */
91 /* We have two kinds of generic macros: to support functions which are
92 only defined on real valued parameters and those which are defined
93 for complex functions as well. */
94 # define __TGMATH_UNARY_REAL_ONLY(Val, Fct) \
95 (__extension__ ((sizeof (+(Val)) == sizeof (double) \
96 || __builtin_classify_type (Val) != 8) \
97 ? (__tgmath_real_type (Val)) Fct (Val) \
98 : (sizeof (+(Val)) == sizeof (float)) \
99 ? (__tgmath_real_type (Val)) Fct##f (Val) \
100 : __TGMATH_F128 ((Val), (__tgmath_real_type (Val)) Fct, \
102 (__tgmath_real_type (Val)) __tgml(Fct) (Val)))
104 # define __TGMATH_UNARY_REAL_RET_ONLY(Val, Fct) \
105 (__extension__ ((sizeof (+(Val)) == sizeof (double) \
106 || __builtin_classify_type (Val) != 8) \
108 : (sizeof (+(Val)) == sizeof (float)) \
110 : __TGMATH_F128 ((Val), Fct, (Val)) \
113 # define __TGMATH_BINARY_FIRST_REAL_ONLY(Val1, Val2, Fct) \
114 (__extension__ ((sizeof (+(Val1)) == sizeof (double) \
115 || __builtin_classify_type (Val1) != 8) \
116 ? (__tgmath_real_type (Val1)) Fct (Val1, Val2) \
117 : (sizeof (+(Val1)) == sizeof (float)) \
118 ? (__tgmath_real_type (Val1)) Fct##f (Val1, Val2) \
119 : __TGMATH_F128 ((Val1), (__tgmath_real_type (Val1)) Fct, \
121 (__tgmath_real_type (Val1)) __tgml(Fct) (Val1, Val2)))
123 # define __TGMATH_BINARY_FIRST_REAL_STD_ONLY(Val1, Val2, Fct) \
124 (__extension__ ((sizeof (+(Val1)) == sizeof (double) \
125 || __builtin_classify_type (Val1) != 8) \
126 ? (__tgmath_real_type (Val1)) Fct (Val1, Val2) \
127 : (sizeof (+(Val1)) == sizeof (float)) \
128 ? (__tgmath_real_type (Val1)) Fct##f (Val1, Val2) \
129 : (__tgmath_real_type (Val1)) __tgml(Fct) (Val1, Val2)))
131 # define __TGMATH_BINARY_REAL_ONLY(Val1, Val2, Fct) \
132 (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \
133 && __builtin_classify_type ((Val1) + (Val2)) == 8) \
134 ? __TGMATH_F128 ((Val1) + (Val2), \
136 ((__tgmath_real_type (Val1)) 0 \
137 + (__tgmath_real_type (Val2)) 0)) Fct, \
139 (__typeof ((__tgmath_real_type (Val1)) 0 \
140 + (__tgmath_real_type (Val2)) 0)) \
141 __tgml(Fct) (Val1, Val2) \
142 : (sizeof (+(Val1)) == sizeof (double) \
143 || sizeof (+(Val2)) == sizeof (double) \
144 || __builtin_classify_type (Val1) != 8 \
145 || __builtin_classify_type (Val2) != 8) \
146 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
147 + (__tgmath_real_type (Val2)) 0)) \
149 : (__typeof ((__tgmath_real_type (Val1)) 0 \
150 + (__tgmath_real_type (Val2)) 0)) \
151 Fct##f (Val1, Val2)))
153 # define __TGMATH_BINARY_REAL_STD_ONLY(Val1, Val2, Fct) \
154 (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \
155 && __builtin_classify_type ((Val1) + (Val2)) == 8) \
156 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
157 + (__tgmath_real_type (Val2)) 0)) \
158 __tgml(Fct) (Val1, Val2) \
159 : (sizeof (+(Val1)) == sizeof (double) \
160 || sizeof (+(Val2)) == sizeof (double) \
161 || __builtin_classify_type (Val1) != 8 \
162 || __builtin_classify_type (Val2) != 8) \
163 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
164 + (__tgmath_real_type (Val2)) 0)) \
166 : (__typeof ((__tgmath_real_type (Val1)) 0 \
167 + (__tgmath_real_type (Val2)) 0)) \
168 Fct##f (Val1, Val2)))
170 # define __TGMATH_BINARY_REAL_RET_ONLY(Val1, Val2, Fct) \
171 (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \
172 && __builtin_classify_type ((Val1) + (Val2)) == 8) \
173 ? __TGMATH_F128 ((Val1) + (Val2), Fct, (Val1, Val2)) \
174 __tgml(Fct) (Val1, Val2) \
175 : (sizeof (+(Val1)) == sizeof (double) \
176 || sizeof (+(Val2)) == sizeof (double) \
177 || __builtin_classify_type (Val1) != 8 \
178 || __builtin_classify_type (Val2) != 8) \
180 : Fct##f (Val1, Val2)))
182 # define __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY(Val1, Val2, Val3, Fct) \
183 (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \
184 && __builtin_classify_type ((Val1) + (Val2)) == 8) \
185 ? __TGMATH_F128 ((Val1) + (Val2), \
187 ((__tgmath_real_type (Val1)) 0 \
188 + (__tgmath_real_type (Val2)) 0)) Fct, \
189 (Val1, Val2, Val3)) \
190 (__typeof ((__tgmath_real_type (Val1)) 0 \
191 + (__tgmath_real_type (Val2)) 0)) \
192 __tgml(Fct) (Val1, Val2, Val3) \
193 : (sizeof (+(Val1)) == sizeof (double) \
194 || sizeof (+(Val2)) == sizeof (double) \
195 || __builtin_classify_type (Val1) != 8 \
196 || __builtin_classify_type (Val2) != 8) \
197 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
198 + (__tgmath_real_type (Val2)) 0)) \
199 Fct (Val1, Val2, Val3) \
200 : (__typeof ((__tgmath_real_type (Val1)) 0 \
201 + (__tgmath_real_type (Val2)) 0)) \
202 Fct##f (Val1, Val2, Val3)))
204 # define __TGMATH_TERNARY_REAL_ONLY(Val1, Val2, Val3, Fct) \
205 (__extension__ ((sizeof ((Val1) + (Val2) + (Val3)) > sizeof (double) \
206 && __builtin_classify_type ((Val1) + (Val2) + (Val3)) \
208 ? __TGMATH_F128 ((Val1) + (Val2) + (Val3), \
210 ((__tgmath_real_type (Val1)) 0 \
211 + (__tgmath_real_type (Val2)) 0 \
212 + (__tgmath_real_type (Val3)) 0)) Fct, \
213 (Val1, Val2, Val3)) \
214 (__typeof ((__tgmath_real_type (Val1)) 0 \
215 + (__tgmath_real_type (Val2)) 0 \
216 + (__tgmath_real_type (Val3)) 0)) \
217 __tgml(Fct) (Val1, Val2, Val3) \
218 : (sizeof (+(Val1)) == sizeof (double) \
219 || sizeof (+(Val2)) == sizeof (double) \
220 || sizeof (+(Val3)) == sizeof (double) \
221 || __builtin_classify_type (Val1) != 8 \
222 || __builtin_classify_type (Val2) != 8 \
223 || __builtin_classify_type (Val3) != 8) \
224 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
225 + (__tgmath_real_type (Val2)) 0 \
226 + (__tgmath_real_type (Val3)) 0)) \
227 Fct (Val1, Val2, Val3) \
228 : (__typeof ((__tgmath_real_type (Val1)) 0 \
229 + (__tgmath_real_type (Val2)) 0 \
230 + (__tgmath_real_type (Val3)) 0)) \
231 Fct##f (Val1, Val2, Val3)))
233 # define __TGMATH_TERNARY_FIRST_REAL_RET_ONLY(Val1, Val2, Val3, Fct) \
234 (__extension__ ((sizeof (+(Val1)) == sizeof (double) \
235 || __builtin_classify_type (Val1) != 8) \
236 ? Fct (Val1, Val2, Val3) \
237 : (sizeof (+(Val1)) == sizeof (float)) \
238 ? Fct##f (Val1, Val2, Val3) \
239 : __TGMATH_F128 ((Val1), Fct, (Val1, Val2, Val3)) \
240 __tgml(Fct) (Val1, Val2, Val3)))
242 /* XXX This definition has to be changed as soon as the compiler understands
243 the imaginary keyword. */
244 # define __TGMATH_UNARY_REAL_IMAG(Val, Fct, Cfct) \
245 (__extension__ ((sizeof (+__real__ (Val)) == sizeof (double) \
246 || __builtin_classify_type (__real__ (Val)) != 8) \
247 ? ((sizeof (+__real__ (Val)) == sizeof (+(Val))) \
248 ? (__tgmath_real_type (Val)) Fct (Val) \
249 : (__tgmath_real_type (Val)) Cfct (Val)) \
250 : (sizeof (+__real__ (Val)) == sizeof (float)) \
251 ? ((sizeof (+__real__ (Val)) == sizeof (+(Val))) \
252 ? (__tgmath_real_type (Val)) Fct##f (Val) \
253 : (__tgmath_real_type (Val)) Cfct##f (Val)) \
254 : __TGMATH_CF128 ((Val), (__tgmath_real_type (Val)) Fct, \
255 (__tgmath_real_type (Val)) Cfct, \
257 ((sizeof (+__real__ (Val)) == sizeof (+(Val))) \
258 ? (__tgmath_real_type (Val)) __tgml(Fct) (Val) \
259 : (__tgmath_real_type (Val)) __tgml(Cfct) (Val))))
261 # define __TGMATH_UNARY_IMAG(Val, Cfct) \
262 (__extension__ ((sizeof (+__real__ (Val)) == sizeof (double) \
263 || __builtin_classify_type (__real__ (Val)) != 8) \
264 ? (__typeof__ ((__tgmath_real_type (Val)) 0 \
265 + _Complex_I)) Cfct (Val) \
266 : (sizeof (+__real__ (Val)) == sizeof (float)) \
267 ? (__typeof__ ((__tgmath_real_type (Val)) 0 \
268 + _Complex_I)) Cfct##f (Val) \
269 : __TGMATH_F128 (__real__ (Val), \
271 ((__tgmath_real_type (Val)) 0 \
272 + _Complex_I)) Cfct, (Val)) \
273 (__typeof__ ((__tgmath_real_type (Val)) 0 \
274 + _Complex_I)) __tgml(Cfct) (Val)))
276 /* XXX This definition has to be changed as soon as the compiler understands
277 the imaginary keyword. */
278 # define __TGMATH_UNARY_REAL_IMAG_RET_REAL(Val, Fct, Cfct) \
279 (__extension__ ((sizeof (+__real__ (Val)) == sizeof (double) \
280 || __builtin_classify_type (__real__ (Val)) != 8) \
281 ? ((sizeof (+__real__ (Val)) == sizeof (+(Val))) \
282 ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
284 : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
286 : (sizeof (+__real__ (Val)) == sizeof (float)) \
287 ? ((sizeof (+__real__ (Val)) == sizeof (+(Val))) \
288 ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
290 : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
292 : __TGMATH_CF128 ((Val), \
295 (__tgmath_real_type (Val)) 0)) Fct, \
298 (__tgmath_real_type (Val)) 0)) Cfct, \
300 ((sizeof (+__real__ (Val)) == sizeof (+(Val))) \
301 ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0)) \
303 : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0)) \
304 __tgml(Cfct) (Val))))
306 /* XXX This definition has to be changed as soon as the compiler understands
307 the imaginary keyword. */
308 # define __TGMATH_BINARY_REAL_IMAG(Val1, Val2, Fct, Cfct) \
309 (__extension__ ((sizeof (__real__ (Val1) \
310 + __real__ (Val2)) > sizeof (double) \
311 && __builtin_classify_type (__real__ (Val1) \
312 + __real__ (Val2)) == 8) \
313 ? __TGMATH_CF128 ((Val1) + (Val2), \
315 ((__tgmath_real_type (Val1)) 0 \
316 + (__tgmath_real_type (Val2)) 0)) \
319 ((__tgmath_real_type (Val1)) 0 \
320 + (__tgmath_real_type (Val2)) 0)) \
323 ((sizeof (+__real__ (Val1)) == sizeof (+(Val1)) \
324 && sizeof (+__real__ (Val2)) == sizeof (+(Val2))) \
325 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
326 + (__tgmath_real_type (Val2)) 0)) \
327 __tgml(Fct) (Val1, Val2) \
328 : (__typeof ((__tgmath_real_type (Val1)) 0 \
329 + (__tgmath_real_type (Val2)) 0)) \
330 __tgml(Cfct) (Val1, Val2)) \
331 : (sizeof (+__real__ (Val1)) == sizeof (double) \
332 || sizeof (+__real__ (Val2)) == sizeof (double) \
333 || __builtin_classify_type (__real__ (Val1)) != 8 \
334 || __builtin_classify_type (__real__ (Val2)) != 8) \
335 ? ((sizeof (+__real__ (Val1)) == sizeof (+(Val1)) \
336 && sizeof (+__real__ (Val2)) == sizeof (+(Val2))) \
337 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
338 + (__tgmath_real_type (Val2)) 0)) \
340 : (__typeof ((__tgmath_real_type (Val1)) 0 \
341 + (__tgmath_real_type (Val2)) 0)) \
343 : ((sizeof (+__real__ (Val1)) == sizeof (+(Val1)) \
344 && sizeof (+__real__ (Val2)) == sizeof (+(Val2))) \
345 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
346 + (__tgmath_real_type (Val2)) 0)) \
347 Fct##f (Val1, Val2) \
348 : (__typeof ((__tgmath_real_type (Val1)) 0 \
349 + (__tgmath_real_type (Val2)) 0)) \
350 Cfct##f (Val1, Val2))))
352 # error "Unsupported compiler; you cannot use <tgmath.h>"
356 /* Unary functions defined for real and complex values. */
359 /* Trigonometric functions. */
361 /* Arc cosine of X. */
362 #define acos(Val) __TGMATH_UNARY_REAL_IMAG (Val, acos, cacos)
364 #define asin(Val) __TGMATH_UNARY_REAL_IMAG (Val, asin, casin)
365 /* Arc tangent of X. */
366 #define atan(Val) __TGMATH_UNARY_REAL_IMAG (Val, atan, catan)
367 /* Arc tangent of Y/X. */
368 #define atan2(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, atan2)
371 #define cos(Val) __TGMATH_UNARY_REAL_IMAG (Val, cos, ccos)
373 #define sin(Val) __TGMATH_UNARY_REAL_IMAG (Val, sin, csin)
375 #define tan(Val) __TGMATH_UNARY_REAL_IMAG (Val, tan, ctan)
378 /* Hyperbolic functions. */
380 /* Hyperbolic arc cosine of X. */
381 #define acosh(Val) __TGMATH_UNARY_REAL_IMAG (Val, acosh, cacosh)
382 /* Hyperbolic arc sine of X. */
383 #define asinh(Val) __TGMATH_UNARY_REAL_IMAG (Val, asinh, casinh)
384 /* Hyperbolic arc tangent of X. */
385 #define atanh(Val) __TGMATH_UNARY_REAL_IMAG (Val, atanh, catanh)
387 /* Hyperbolic cosine of X. */
388 #define cosh(Val) __TGMATH_UNARY_REAL_IMAG (Val, cosh, ccosh)
389 /* Hyperbolic sine of X. */
390 #define sinh(Val) __TGMATH_UNARY_REAL_IMAG (Val, sinh, csinh)
391 /* Hyperbolic tangent of X. */
392 #define tanh(Val) __TGMATH_UNARY_REAL_IMAG (Val, tanh, ctanh)
395 /* Exponential and logarithmic functions. */
397 /* Exponential function of X. */
398 #define exp(Val) __TGMATH_UNARY_REAL_IMAG (Val, exp, cexp)
400 /* Break VALUE into a normalized fraction and an integral power of 2. */
401 #define frexp(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, frexp)
403 /* X times (two to the EXP power). */
404 #define ldexp(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, ldexp)
406 /* Natural logarithm of X. */
407 #define log(Val) __TGMATH_UNARY_REAL_IMAG (Val, log, clog)
409 /* Base-ten logarithm of X. */
411 # define log10(Val) __TGMATH_UNARY_REAL_IMAG (Val, log10, clog10)
413 # define log10(Val) __TGMATH_UNARY_REAL_ONLY (Val, log10)
416 /* Return exp(X) - 1. */
417 #define expm1(Val) __TGMATH_UNARY_REAL_ONLY (Val, expm1)
419 /* Return log(1 + X). */
420 #define log1p(Val) __TGMATH_UNARY_REAL_ONLY (Val, log1p)
422 /* Return the base 2 signed integral exponent of X. */
423 #define logb(Val) __TGMATH_UNARY_REAL_ONLY (Val, logb)
425 /* Compute base-2 exponential of X. */
426 #define exp2(Val) __TGMATH_UNARY_REAL_ONLY (Val, exp2)
428 /* Compute base-2 logarithm of X. */
429 #define log2(Val) __TGMATH_UNARY_REAL_ONLY (Val, log2)
432 /* Power functions. */
434 /* Return X to the Y power. */
435 #define pow(Val1, Val2) __TGMATH_BINARY_REAL_IMAG (Val1, Val2, pow, cpow)
437 /* Return the square root of X. */
438 #define sqrt(Val) __TGMATH_UNARY_REAL_IMAG (Val, sqrt, csqrt)
440 /* Return `sqrt(X*X + Y*Y)'. */
441 #define hypot(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, hypot)
443 /* Return the cube root of X. */
444 #define cbrt(Val) __TGMATH_UNARY_REAL_ONLY (Val, cbrt)
447 /* Nearest integer, absolute value, and remainder functions. */
449 /* Smallest integral value not less than X. */
450 #define ceil(Val) __TGMATH_UNARY_REAL_ONLY (Val, ceil)
452 /* Absolute value of X. */
453 #define fabs(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, fabs, cabs)
455 /* Largest integer not greater than X. */
456 #define floor(Val) __TGMATH_UNARY_REAL_ONLY (Val, floor)
458 /* Floating-point modulo remainder of X/Y. */
459 #define fmod(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmod)
461 /* Round X to integral valuein floating-point format using current
462 rounding direction, but do not raise inexact exception. */
463 #define nearbyint(Val) __TGMATH_UNARY_REAL_ONLY (Val, nearbyint)
465 /* Round X to nearest integral value, rounding halfway cases away from
467 #define round(Val) __TGMATH_UNARY_REAL_ONLY (Val, round)
469 /* Round X to the integral value in floating-point format nearest but
470 not larger in magnitude. */
471 #define trunc(Val) __TGMATH_UNARY_REAL_ONLY (Val, trunc)
473 /* Compute remainder of X and Y and put in *QUO a value with sign of x/y
474 and magnitude congruent `mod 2^n' to the magnitude of the integral
475 quotient x/y, with n >= 3. */
476 #define remquo(Val1, Val2, Val3) \
477 __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY (Val1, Val2, Val3, remquo)
479 /* Round X to nearest integral value according to current rounding
481 #define lrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, lrint)
482 #define llrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llrint)
484 /* Round X to nearest integral value, rounding halfway cases away from
486 #define lround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, lround)
487 #define llround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llround)
490 /* Return X with its signed changed to Y's. */
491 #define copysign(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, copysign)
493 /* Error and gamma functions. */
494 #define erf(Val) __TGMATH_UNARY_REAL_ONLY (Val, erf)
495 #define erfc(Val) __TGMATH_UNARY_REAL_ONLY (Val, erfc)
496 #define tgamma(Val) __TGMATH_UNARY_REAL_ONLY (Val, tgamma)
497 #define lgamma(Val) __TGMATH_UNARY_REAL_ONLY (Val, lgamma)
500 /* Return the integer nearest X in the direction of the
501 prevailing rounding mode. */
502 #define rint(Val) __TGMATH_UNARY_REAL_ONLY (Val, rint)
504 #if __GLIBC_USE (IEC_60559_BFP_EXT)
505 /* Return X - epsilon. */
506 # define nextdown(Val) __TGMATH_UNARY_REAL_ONLY (Val, nextdown)
507 /* Return X + epsilon. */
508 # define nextup(Val) __TGMATH_UNARY_REAL_ONLY (Val, nextup)
511 /* Return X + epsilon if X < Y, X - epsilon if X > Y. */
512 #define nextafter(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, nextafter)
513 #define nexttoward(Val1, Val2) \
514 __TGMATH_BINARY_FIRST_REAL_STD_ONLY (Val1, Val2, nexttoward)
516 /* Return the remainder of integer divison X / Y with infinite precision. */
517 #define remainder(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, remainder)
519 /* Return X times (2 to the Nth power). */
521 # define scalb(Val1, Val2) __TGMATH_BINARY_REAL_STD_ONLY (Val1, Val2, scalb)
524 /* Return X times (2 to the Nth power). */
525 #define scalbn(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbn)
527 /* Return X times (2 to the Nth power). */
528 #define scalbln(Val1, Val2) \
529 __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbln)
531 /* Return the binary exponent of X, which must be nonzero. */
532 #define ilogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, ilogb)
535 /* Return positive difference between X and Y. */
536 #define fdim(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fdim)
538 /* Return maximum numeric value from X and Y. */
539 #define fmax(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmax)
541 /* Return minimum numeric value from X and Y. */
542 #define fmin(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmin)
545 /* Multiply-add function computed as a ternary operation. */
546 #define fma(Val1, Val2, Val3) \
547 __TGMATH_TERNARY_REAL_ONLY (Val1, Val2, Val3, fma)
549 #if __GLIBC_USE (IEC_60559_BFP_EXT)
550 /* Round X to nearest integer value, rounding halfway cases to even. */
551 # define roundeven(Val) __TGMATH_UNARY_REAL_ONLY (Val, roundeven)
553 # define fromfp(Val1, Val2, Val3) \
554 __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, fromfp)
556 # define ufromfp(Val1, Val2, Val3) \
557 __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, ufromfp)
559 # define fromfpx(Val1, Val2, Val3) \
560 __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, fromfpx)
562 # define ufromfpx(Val1, Val2, Val3) \
563 __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, ufromfpx)
565 /* Like ilogb, but returning long int. */
566 # define llogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llogb)
568 /* Return value with maximum magnitude. */
569 # define fmaxmag(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmaxmag)
571 /* Return value with minimum magnitude. */
572 # define fminmag(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fminmag)
574 /* Total order operation. */
575 # define totalorder(Val1, Val2) \
576 __TGMATH_BINARY_REAL_RET_ONLY (Val1, Val2, totalorder)
578 /* Total order operation on absolute values. */
579 # define totalordermag(Val1, Val2) \
580 __TGMATH_BINARY_REAL_RET_ONLY (Val1, Val2, totalordermag)
584 /* Absolute value, conjugates, and projection. */
586 /* Argument value of Z. */
587 #define carg(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, carg, carg)
589 /* Complex conjugate of Z. */
590 #define conj(Val) __TGMATH_UNARY_IMAG (Val, conj)
592 /* Projection of Z onto the Riemann sphere. */
593 #define cproj(Val) __TGMATH_UNARY_IMAG (Val, cproj)
596 /* Decomposing complex values. */
598 /* Imaginary part of Z. */
599 #define cimag(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, cimag, cimag)
601 /* Real part of Z. */
602 #define creal(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, creal, creal)
604 #endif /* tgmath.h */