]> git.ipfire.org Git - thirdparty/glibc.git/blame - math/tgmath.h
resolv: Turn historic name lookup functions into compat symbols
[thirdparty/glibc.git] / math / tgmath.h
CommitLineData
f7a9f785 1/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
dfd2257a
UD
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
41bdb6e2
AJ
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.
dfd2257a
UD
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
41bdb6e2 12 Lesser General Public License for more details.
dfd2257a 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
dfd2257a
UD
17
18/*
63ae7b63 19 * ISO C99 Standard: 7.22 Type-generic math <tgmath.h>
dfd2257a
UD
20 */
21
22#ifndef _TGMATH_H
23#define _TGMATH_H 1
24
25/* Include the needed headers. */
26#include <math.h>
27#include <complex.h>
28
29
30/* Since `complex' is currently not really implemented in most C compilers
31 and if it is implemented, the implementations differ. This makes it
32 quite difficult to write a generic implementation of this header. We
33 do not try this for now and instead concentrate only on GNU CC. Once
34 we have more information support for other compilers might follow. */
35
4360eafd 36#if __GNUC_PREREQ (2, 7)
dfd2257a 37
0d3fee40
UD
38# ifdef __NO_LONG_DOUBLE_MATH
39# define __tgml(fct) fct
40# else
41# define __tgml(fct) fct ## l
42# endif
43
925e31d9
UD
44/* This is ugly but unless gcc gets appropriate builtins we have to do
45 something like this. Don't ask how it works. */
46
47/* 1 if 'type' is a floating type, 0 if 'type' is an integer type.
48 Allows for _Bool. Expands to an integer constant expression. */
acd44dbc
UD
49# if __GNUC_PREREQ (3, 1)
50# define __floating_type(type) \
51 (__builtin_classify_type ((type) 0) == 8 \
52 || (__builtin_classify_type ((type) 0) == 9 \
53 && __builtin_classify_type (__real__ ((type) 0)) == 8))
54# else
55# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))
56# endif
925e31d9
UD
57
58/* The tgmath real type for T, where E is 0 if T is an integer type and
59 1 for a floating type. */
deea1b29 60# define __tgmath_real_type_sub(T, E) \
1c298d08
UD
61 __typeof__ (*(0 ? (__typeof__ (0 ? (double *) 0 : (void *) (E))) 0 \
62 : (__typeof__ (0 ? (T *) 0 : (void *) (!(E)))) 0))
925e31d9
UD
63
64/* The tgmath real type of EXPR. */
deea1b29 65# define __tgmath_real_type(expr) \
1c298d08
UD
66 __tgmath_real_type_sub (__typeof__ ((__typeof__ (expr)) 0), \
67 __floating_type (__typeof__ (expr)))
925e31d9
UD
68
69
dfd2257a
UD
70/* We have two kinds of generic macros: to support functions which are
71 only defined on real valued parameters and those which are defined
72 for complex functions as well. */
73# define __TGMATH_UNARY_REAL_ONLY(Val, Fct) \
1c298d08
UD
74 (__extension__ ((sizeof (Val) == sizeof (double) \
75 || __builtin_classify_type (Val) != 8) \
76 ? (__tgmath_real_type (Val)) Fct (Val) \
77 : (sizeof (Val) == sizeof (float)) \
78 ? (__tgmath_real_type (Val)) Fct##f (Val) \
79 : (__tgmath_real_type (Val)) __tgml(Fct) (Val)))
71502ebe
UD
80
81# define __TGMATH_UNARY_REAL_RET_ONLY(Val, RetType, Fct) \
1c298d08
UD
82 (__extension__ ((sizeof (Val) == sizeof (double) \
83 || __builtin_classify_type (Val) != 8) \
84 ? (RetType) Fct (Val) \
85 : (sizeof (Val) == sizeof (float)) \
86 ? (RetType) Fct##f (Val) \
87 : (RetType) __tgml(Fct) (Val)))
dfd2257a
UD
88
89# define __TGMATH_BINARY_FIRST_REAL_ONLY(Val1, Val2, Fct) \
1c298d08
UD
90 (__extension__ ((sizeof (Val1) == sizeof (double) \
91 || __builtin_classify_type (Val1) != 8) \
92 ? (__tgmath_real_type (Val1)) Fct (Val1, Val2) \
93 : (sizeof (Val1) == sizeof (float)) \
94 ? (__tgmath_real_type (Val1)) Fct##f (Val1, Val2) \
95 : (__tgmath_real_type (Val1)) __tgml(Fct) (Val1, Val2)))
dfd2257a
UD
96
97# define __TGMATH_BINARY_REAL_ONLY(Val1, Val2, Fct) \
1c298d08
UD
98 (__extension__ (((sizeof (Val1) > sizeof (double) \
99 || sizeof (Val2) > sizeof (double)) \
100 && __builtin_classify_type ((Val1) + (Val2)) == 8) \
101 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
102 + (__tgmath_real_type (Val2)) 0)) \
103 __tgml(Fct) (Val1, Val2) \
104 : (sizeof (Val1) == sizeof (double) \
105 || sizeof (Val2) == sizeof (double) \
106 || __builtin_classify_type (Val1) != 8 \
107 || __builtin_classify_type (Val2) != 8) \
108 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
109 + (__tgmath_real_type (Val2)) 0)) \
110 Fct (Val1, Val2) \
111 : (__typeof ((__tgmath_real_type (Val1)) 0 \
112 + (__tgmath_real_type (Val2)) 0)) \
113 Fct##f (Val1, Val2)))
dfd2257a
UD
114
115# define __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY(Val1, Val2, Val3, Fct) \
1c298d08
UD
116 (__extension__ (((sizeof (Val1) > sizeof (double) \
117 || sizeof (Val2) > sizeof (double)) \
118 && __builtin_classify_type ((Val1) + (Val2)) == 8) \
119 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
120 + (__tgmath_real_type (Val2)) 0)) \
121 __tgml(Fct) (Val1, Val2, Val3) \
122 : (sizeof (Val1) == sizeof (double) \
123 || sizeof (Val2) == sizeof (double) \
124 || __builtin_classify_type (Val1) != 8 \
125 || __builtin_classify_type (Val2) != 8) \
126 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
127 + (__tgmath_real_type (Val2)) 0)) \
128 Fct (Val1, Val2, Val3) \
129 : (__typeof ((__tgmath_real_type (Val1)) 0 \
130 + (__tgmath_real_type (Val2)) 0)) \
131 Fct##f (Val1, Val2, Val3)))
bfce746a
UD
132
133# define __TGMATH_TERNARY_REAL_ONLY(Val1, Val2, Val3, Fct) \
1c298d08
UD
134 (__extension__ (((sizeof (Val1) > sizeof (double) \
135 || sizeof (Val2) > sizeof (double) \
136 || sizeof (Val3) > sizeof (double)) \
137 && __builtin_classify_type ((Val1) + (Val2) + (Val3)) \
138 == 8) \
139 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
140 + (__tgmath_real_type (Val2)) 0 \
141 + (__tgmath_real_type (Val3)) 0)) \
142 __tgml(Fct) (Val1, Val2, Val3) \
143 : (sizeof (Val1) == sizeof (double) \
144 || sizeof (Val2) == sizeof (double) \
145 || sizeof (Val3) == sizeof (double) \
146 || __builtin_classify_type (Val1) != 8 \
147 || __builtin_classify_type (Val2) != 8 \
148 || __builtin_classify_type (Val3) != 8) \
149 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
150 + (__tgmath_real_type (Val2)) 0 \
151 + (__tgmath_real_type (Val3)) 0)) \
152 Fct (Val1, Val2, Val3) \
153 : (__typeof ((__tgmath_real_type (Val1)) 0 \
154 + (__tgmath_real_type (Val2)) 0 \
155 + (__tgmath_real_type (Val3)) 0)) \
156 Fct##f (Val1, Val2, Val3)))
dfd2257a 157
48244d09
UD
158/* XXX This definition has to be changed as soon as the compiler understands
159 the imaginary keyword. */
dfd2257a 160# define __TGMATH_UNARY_REAL_IMAG(Val, Fct, Cfct) \
1c298d08
UD
161 (__extension__ ((sizeof (__real__ (Val)) == sizeof (double) \
162 || __builtin_classify_type (__real__ (Val)) != 8) \
163 ? ((sizeof (__real__ (Val)) == sizeof (Val)) \
164 ? (__tgmath_real_type (Val)) Fct (Val) \
165 : (__tgmath_real_type (Val)) Cfct (Val)) \
166 : (sizeof (__real__ (Val)) == sizeof (float)) \
167 ? ((sizeof (__real__ (Val)) == sizeof (Val)) \
168 ? (__tgmath_real_type (Val)) Fct##f (Val) \
169 : (__tgmath_real_type (Val)) Cfct##f (Val)) \
170 : ((sizeof (__real__ (Val)) == sizeof (Val)) \
171 ? (__tgmath_real_type (Val)) __tgml(Fct) (Val) \
172 : (__tgmath_real_type (Val)) __tgml(Cfct) (Val))))
173
174# define __TGMATH_UNARY_IMAG(Val, Cfct) \
175 (__extension__ ((sizeof (__real__ (Val)) == sizeof (double) \
176 || __builtin_classify_type (__real__ (Val)) != 8) \
177 ? (__typeof__ ((__tgmath_real_type (Val)) 0 \
178 + _Complex_I)) Cfct (Val) \
179 : (sizeof (__real__ (Val)) == sizeof (float)) \
180 ? (__typeof__ ((__tgmath_real_type (Val)) 0 \
181 + _Complex_I)) Cfct##f (Val) \
182 : (__typeof__ ((__tgmath_real_type (Val)) 0 \
183 + _Complex_I)) __tgml(Cfct) (Val)))
dfd2257a 184
58d87ee1
UD
185/* XXX This definition has to be changed as soon as the compiler understands
186 the imaginary keyword. */
187# define __TGMATH_UNARY_REAL_IMAG_RET_REAL(Val, Fct, Cfct) \
1c298d08
UD
188 (__extension__ ((sizeof (__real__ (Val)) == sizeof (double) \
189 || __builtin_classify_type (__real__ (Val)) != 8) \
190 ? ((sizeof (__real__ (Val)) == sizeof (Val)) \
191 ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
192 Fct (Val) \
193 : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
194 Cfct (Val)) \
195 : (sizeof (__real__ (Val)) == sizeof (float)) \
196 ? ((sizeof (__real__ (Val)) == sizeof (Val)) \
197 ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
198 Fct##f (Val) \
199 : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
200 Cfct##f (Val)) \
201 : ((sizeof (__real__ (Val)) == sizeof (Val)) \
202 ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
203 __tgml(Fct) (Val) \
204 : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
205 __tgml(Cfct) (Val))))
58d87ee1 206
48244d09
UD
207/* XXX This definition has to be changed as soon as the compiler understands
208 the imaginary keyword. */
dfd2257a 209# define __TGMATH_BINARY_REAL_IMAG(Val1, Val2, Fct, Cfct) \
1c298d08
UD
210 (__extension__ (((sizeof (__real__ (Val1)) > sizeof (double) \
211 || sizeof (__real__ (Val2)) > sizeof (double)) \
212 && __builtin_classify_type (__real__ (Val1) \
213 + __real__ (Val2)) == 8) \
214 ? ((sizeof (__real__ (Val1)) == sizeof (Val1) \
215 && sizeof (__real__ (Val2)) == sizeof (Val2)) \
216 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
217 + (__tgmath_real_type (Val2)) 0)) \
218 __tgml(Fct) (Val1, Val2) \
219 : (__typeof ((__tgmath_real_type (Val1)) 0 \
220 + (__tgmath_real_type (Val2)) 0)) \
221 __tgml(Cfct) (Val1, Val2)) \
222 : (sizeof (__real__ (Val1)) == sizeof (double) \
223 || sizeof (__real__ (Val2)) == sizeof (double) \
224 || __builtin_classify_type (__real__ (Val1)) != 8 \
225 || __builtin_classify_type (__real__ (Val2)) != 8) \
226 ? ((sizeof (__real__ (Val1)) == sizeof (Val1) \
227 && sizeof (__real__ (Val2)) == sizeof (Val2)) \
228 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
229 + (__tgmath_real_type (Val2)) 0)) \
230 Fct (Val1, Val2) \
231 : (__typeof ((__tgmath_real_type (Val1)) 0 \
232 + (__tgmath_real_type (Val2)) 0)) \
233 Cfct (Val1, Val2)) \
234 : ((sizeof (__real__ (Val1)) == sizeof (Val1) \
235 && sizeof (__real__ (Val2)) == sizeof (Val2)) \
236 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
237 + (__tgmath_real_type (Val2)) 0)) \
238 Fct##f (Val1, Val2) \
239 : (__typeof ((__tgmath_real_type (Val1)) 0 \
240 + (__tgmath_real_type (Val2)) 0)) \
241 Cfct##f (Val1, Val2))))
dfd2257a
UD
242#else
243# error "Unsupported compiler; you cannot use <tgmath.h>"
244#endif
245
246
247/* Unary functions defined for real and complex values. */
248
249
250/* Trigonometric functions. */
251
252/* Arc cosine of X. */
253#define acos(Val) __TGMATH_UNARY_REAL_IMAG (Val, acos, cacos)
254/* Arc sine of X. */
255#define asin(Val) __TGMATH_UNARY_REAL_IMAG (Val, asin, casin)
256/* Arc tangent of X. */
257#define atan(Val) __TGMATH_UNARY_REAL_IMAG (Val, atan, catan)
258/* Arc tangent of Y/X. */
cfb32a6c 259#define atan2(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, atan2)
dfd2257a
UD
260
261/* Cosine of X. */
262#define cos(Val) __TGMATH_UNARY_REAL_IMAG (Val, cos, ccos)
263/* Sine of X. */
264#define sin(Val) __TGMATH_UNARY_REAL_IMAG (Val, sin, csin)
265/* Tangent of X. */
266#define tan(Val) __TGMATH_UNARY_REAL_IMAG (Val, tan, ctan)
267
268
269/* Hyperbolic functions. */
270
271/* Hyperbolic arc cosine of X. */
272#define acosh(Val) __TGMATH_UNARY_REAL_IMAG (Val, acosh, cacosh)
273/* Hyperbolic arc sine of X. */
274#define asinh(Val) __TGMATH_UNARY_REAL_IMAG (Val, asinh, casinh)
275/* Hyperbolic arc tangent of X. */
276#define atanh(Val) __TGMATH_UNARY_REAL_IMAG (Val, atanh, catanh)
277
278/* Hyperbolic cosine of X. */
279#define cosh(Val) __TGMATH_UNARY_REAL_IMAG (Val, cosh, ccosh)
280/* Hyperbolic sine of X. */
281#define sinh(Val) __TGMATH_UNARY_REAL_IMAG (Val, sinh, csinh)
282/* Hyperbolic tangent of X. */
283#define tanh(Val) __TGMATH_UNARY_REAL_IMAG (Val, tanh, ctanh)
284
285
286/* Exponential and logarithmic functions. */
287
288/* Exponential function of X. */
289#define exp(Val) __TGMATH_UNARY_REAL_IMAG (Val, exp, cexp)
290
291/* Break VALUE into a normalized fraction and an integral power of 2. */
292#define frexp(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, frexp)
293
294/* X times (two to the EXP power). */
295#define ldexp(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, ldexp)
296
297/* Natural logarithm of X. */
298#define log(Val) __TGMATH_UNARY_REAL_IMAG (Val, log, clog)
299
300/* Base-ten logarithm of X. */
cc3fa755
UD
301#ifdef __USE_GNU
302# define log10(Val) __TGMATH_UNARY_REAL_IMAG (Val, log10, __clog10)
303#else
304# define log10(Val) __TGMATH_UNARY_REAL_ONLY (Val, log10)
305#endif
dfd2257a
UD
306
307/* Return exp(X) - 1. */
308#define expm1(Val) __TGMATH_UNARY_REAL_ONLY (Val, expm1)
309
310/* Return log(1 + X). */
311#define log1p(Val) __TGMATH_UNARY_REAL_ONLY (Val, log1p)
312
313/* Return the base 2 signed integral exponent of X. */
314#define logb(Val) __TGMATH_UNARY_REAL_ONLY (Val, logb)
315
316/* Compute base-2 exponential of X. */
317#define exp2(Val) __TGMATH_UNARY_REAL_ONLY (Val, exp2)
318
319/* Compute base-2 logarithm of X. */
320#define log2(Val) __TGMATH_UNARY_REAL_ONLY (Val, log2)
321
322
323/* Power functions. */
324
325/* Return X to the Y power. */
326#define pow(Val1, Val2) __TGMATH_BINARY_REAL_IMAG (Val1, Val2, pow, cpow)
327
328/* Return the square root of X. */
329#define sqrt(Val) __TGMATH_UNARY_REAL_IMAG (Val, sqrt, csqrt)
330
331/* Return `sqrt(X*X + Y*Y)'. */
332#define hypot(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, hypot)
333
334/* Return the cube root of X. */
335#define cbrt(Val) __TGMATH_UNARY_REAL_ONLY (Val, cbrt)
336
337
338/* Nearest integer, absolute value, and remainder functions. */
339
340/* Smallest integral value not less than X. */
341#define ceil(Val) __TGMATH_UNARY_REAL_ONLY (Val, ceil)
342
343/* Absolute value of X. */
f1debaf6 344#define fabs(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, fabs, cabs)
dfd2257a
UD
345
346/* Largest integer not greater than X. */
347#define floor(Val) __TGMATH_UNARY_REAL_ONLY (Val, floor)
348
349/* Floating-point modulo remainder of X/Y. */
350#define fmod(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmod)
351
352/* Round X to integral valuein floating-point format using current
353 rounding direction, but do not raise inexact exception. */
354#define nearbyint(Val) __TGMATH_UNARY_REAL_ONLY (Val, nearbyint)
355
356/* Round X to nearest integral value, rounding halfway cases away from
357 zero. */
358#define round(Val) __TGMATH_UNARY_REAL_ONLY (Val, round)
359
360/* Round X to the integral value in floating-point format nearest but
361 not larger in magnitude. */
362#define trunc(Val) __TGMATH_UNARY_REAL_ONLY (Val, trunc)
363
364/* Compute remainder of X and Y and put in *QUO a value with sign of x/y
365 and magnitude congruent `mod 2^n' to the magnitude of the integral
366 quotient x/y, with n >= 3. */
367#define remquo(Val1, Val2, Val3) \
368 __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY (Val1, Val2, Val3, remquo)
369
370/* Round X to nearest integral value according to current rounding
371 direction. */
71502ebe
UD
372#define lrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long int, lrint)
373#define llrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long long int, llrint)
dfd2257a
UD
374
375/* Round X to nearest integral value, rounding halfway cases away from
376 zero. */
71502ebe
UD
377#define lround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long int, lround)
378#define llround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long long int, llround)
dfd2257a
UD
379
380
381/* Return X with its signed changed to Y's. */
382#define copysign(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, copysign)
383
384/* Error and gamma functions. */
385#define erf(Val) __TGMATH_UNARY_REAL_ONLY (Val, erf)
386#define erfc(Val) __TGMATH_UNARY_REAL_ONLY (Val, erfc)
00d8bc81 387#define tgamma(Val) __TGMATH_UNARY_REAL_ONLY (Val, tgamma)
dfd2257a
UD
388#define lgamma(Val) __TGMATH_UNARY_REAL_ONLY (Val, lgamma)
389
390
391/* Return the integer nearest X in the direction of the
392 prevailing rounding mode. */
393#define rint(Val) __TGMATH_UNARY_REAL_ONLY (Val, rint)
394
146f208d 395#if __GLIBC_USE (IEC_60559_BFP_EXT)
41a359e2
RS
396/* Return X - epsilon. */
397# define nextdown(Val) __TGMATH_UNARY_REAL_ONLY (Val, nextdown)
398/* Return X + epsilon. */
399# define nextup(Val) __TGMATH_UNARY_REAL_ONLY (Val, nextup)
400#endif
401
dfd2257a
UD
402/* Return X + epsilon if X < Y, X - epsilon if X > Y. */
403#define nextafter(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, nextafter)
42bd0a85
UD
404#define nexttoward(Val1, Val2) \
405 __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, nexttoward)
dfd2257a
UD
406
407/* Return the remainder of integer divison X / Y with infinite precision. */
408#define remainder(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, remainder)
409
410/* Return X times (2 to the Nth power). */
de20571d 411#ifdef __USE_MISC
204e299e 412# define scalb(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, scalb)
26644e87 413#endif
dfd2257a
UD
414
415/* Return X times (2 to the Nth power). */
416#define scalbn(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbn)
417
418/* Return X times (2 to the Nth power). */
419#define scalbln(Val1, Val2) \
420 __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbln)
421
422/* Return the binary exponent of X, which must be nonzero. */
301a6724 423#define ilogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, int, ilogb)
dfd2257a
UD
424
425
426/* Return positive difference between X and Y. */
427#define fdim(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fdim)
428
429/* Return maximum numeric value from X and Y. */
430#define fmax(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmax)
431
432/* Return minimum numeric value from X and Y. */
433#define fmin(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmin)
434
435
bfce746a 436/* Multiply-add function computed as a ternary operation. */
e7c3d12b 437#define fma(Val1, Val2, Val3) \
bfce746a
UD
438 __TGMATH_TERNARY_REAL_ONLY (Val1, Val2, Val3, fma)
439
5e9d98a3 440#if __GLIBC_USE (IEC_60559_BFP_EXT)
41c67149
JM
441/* Round X to nearest integer value, rounding halfway cases to even. */
442# define roundeven(Val) __TGMATH_UNARY_REAL_ONLY (Val, roundeven)
443
55a38f82 444/* Like ilogb, but returning long int. */
60c07b05 445# define llogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long int, llogb)
55a38f82 446
525f8039
JM
447/* Return value with maximum magnitude. */
448# define fmaxmag(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmaxmag)
449
450/* Return value with minimum magnitude. */
451# define fminmag(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fminmag)
452
5e9d98a3
JM
453/* Total order operation. */
454# define totalorder(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, \
455 totalorder)
cc6a8d74
JM
456
457/* Total order operation on absolute values. */
458# define totalordermag(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, \
459 totalordermag)
5e9d98a3
JM
460#endif
461
bfce746a 462
dfd2257a
UD
463/* Absolute value, conjugates, and projection. */
464
465/* Argument value of Z. */
f1debaf6 466#define carg(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, carg, carg)
dfd2257a
UD
467
468/* Complex conjugate of Z. */
1c298d08 469#define conj(Val) __TGMATH_UNARY_IMAG (Val, conj)
dfd2257a
UD
470
471/* Projection of Z onto the Riemann sphere. */
1c298d08 472#define cproj(Val) __TGMATH_UNARY_IMAG (Val, cproj)
dfd2257a
UD
473
474
475/* Decomposing complex values. */
476
477/* Imaginary part of Z. */
58d87ee1 478#define cimag(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, cimag, cimag)
dfd2257a
UD
479
480/* Real part of Z. */
58d87ee1 481#define creal(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, creal, creal)
dfd2257a
UD
482
483#endif /* tgmath.h */