]> git.ipfire.org Git - thirdparty/glibc.git/blame - math/tgmath.h
Remove non cancellable sigsuspend definition
[thirdparty/glibc.git] / math / tgmath.h
CommitLineData
bfff8b1b 1/* Copyright (C) 1997-2017 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
614d15f9
JM
25#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
26#include <bits/libc-header-start.h>
27
dfd2257a 28/* Include the needed headers. */
614d15f9 29#include <bits/floatn.h>
dfd2257a
UD
30#include <math.h>
31#include <complex.h>
32
33
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. */
39
4360eafd 40#if __GNUC_PREREQ (2, 7)
dfd2257a 41
0d3fee40
UD
42# ifdef __NO_LONG_DOUBLE_MATH
43# define __tgml(fct) fct
44# else
45# define __tgml(fct) fct ## l
46# endif
47
925e31d9
UD
48/* This is ugly but unless gcc gets appropriate builtins we have to do
49 something like this. Don't ask how it works. */
50
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. */
acd44dbc
UD
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))
58# else
59# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))
60# endif
925e31d9
UD
61
62/* The tgmath real type for T, where E is 0 if T is an integer type and
63 1 for a floating type. */
deea1b29 64# define __tgmath_real_type_sub(T, E) \
1c298d08
UD
65 __typeof__ (*(0 ? (__typeof__ (0 ? (double *) 0 : (void *) (E))) 0 \
66 : (__typeof__ (0 ? (T *) 0 : (void *) (!(E)))) 0))
925e31d9
UD
67
68/* The tgmath real type of EXPR. */
deea1b29 69# define __tgmath_real_type(expr) \
2fee621d
JM
70 __tgmath_real_type_sub (__typeof__ ((__typeof__ (+(expr))) 0), \
71 __floating_type (__typeof__ (+(expr))))
925e31d9 72
614d15f9
JM
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) \
2fee621d 78 __builtin_types_compatible_p (__typeof (+(arg_comb)), _Float128) \
614d15f9
JM
79 ? fct ## f128 arg_call :
80# define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) \
2fee621d
JM
81 __builtin_types_compatible_p (__typeof (+__real__ (arg_comb)), _Float128) \
82 ? (sizeof (+__real__ (arg_comb)) == sizeof (+(arg_comb)) \
614d15f9
JM
83 ? fct ## f128 arg_call \
84 : cfct ## f128 arg_call) :
85# else
86# define __TGMATH_F128(arg_comb, fct, arg_call) /* Nothing. */
87# define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) /* Nothing. */
88# endif
89
925e31d9 90
dfd2257a
UD
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) \
2fee621d 95 (__extension__ ((sizeof (+(Val)) == sizeof (double) \
1c298d08
UD
96 || __builtin_classify_type (Val) != 8) \
97 ? (__tgmath_real_type (Val)) Fct (Val) \
2fee621d 98 : (sizeof (+(Val)) == sizeof (float)) \
1c298d08 99 ? (__tgmath_real_type (Val)) Fct##f (Val) \
614d15f9
JM
100 : __TGMATH_F128 ((Val), (__tgmath_real_type (Val)) Fct, \
101 (Val)) \
102 (__tgmath_real_type (Val)) __tgml(Fct) (Val)))
71502ebe 103
cfa44345 104# define __TGMATH_UNARY_REAL_RET_ONLY(Val, Fct) \
2fee621d 105 (__extension__ ((sizeof (+(Val)) == sizeof (double) \
1c298d08 106 || __builtin_classify_type (Val) != 8) \
cfa44345 107 ? Fct (Val) \
2fee621d 108 : (sizeof (+(Val)) == sizeof (float)) \
cfa44345 109 ? Fct##f (Val) \
614d15f9
JM
110 : __TGMATH_F128 ((Val), Fct, (Val)) \
111 __tgml(Fct) (Val)))
dfd2257a
UD
112
113# define __TGMATH_BINARY_FIRST_REAL_ONLY(Val1, Val2, Fct) \
2fee621d 114 (__extension__ ((sizeof (+(Val1)) == sizeof (double) \
614d15f9
JM
115 || __builtin_classify_type (Val1) != 8) \
116 ? (__tgmath_real_type (Val1)) Fct (Val1, Val2) \
2fee621d 117 : (sizeof (+(Val1)) == sizeof (float)) \
614d15f9
JM
118 ? (__tgmath_real_type (Val1)) Fct##f (Val1, Val2) \
119 : __TGMATH_F128 ((Val1), (__tgmath_real_type (Val1)) Fct, \
120 (Val1, Val2)) \
121 (__tgmath_real_type (Val1)) __tgml(Fct) (Val1, Val2)))
122
123# define __TGMATH_BINARY_FIRST_REAL_STD_ONLY(Val1, Val2, Fct) \
2fee621d 124 (__extension__ ((sizeof (+(Val1)) == sizeof (double) \
1c298d08
UD
125 || __builtin_classify_type (Val1) != 8) \
126 ? (__tgmath_real_type (Val1)) Fct (Val1, Val2) \
2fee621d 127 : (sizeof (+(Val1)) == sizeof (float)) \
1c298d08
UD
128 ? (__tgmath_real_type (Val1)) Fct##f (Val1, Val2) \
129 : (__tgmath_real_type (Val1)) __tgml(Fct) (Val1, Val2)))
dfd2257a
UD
130
131# define __TGMATH_BINARY_REAL_ONLY(Val1, Val2, Fct) \
42df8d59 132 (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \
1c298d08 133 && __builtin_classify_type ((Val1) + (Val2)) == 8) \
614d15f9
JM
134 ? __TGMATH_F128 ((Val1) + (Val2), \
135 (__typeof \
136 ((__tgmath_real_type (Val1)) 0 \
137 + (__tgmath_real_type (Val2)) 0)) Fct, \
138 (Val1, Val2)) \
139 (__typeof ((__tgmath_real_type (Val1)) 0 \
140 + (__tgmath_real_type (Val2)) 0)) \
141 __tgml(Fct) (Val1, Val2) \
2fee621d
JM
142 : (sizeof (+(Val1)) == sizeof (double) \
143 || sizeof (+(Val2)) == sizeof (double) \
614d15f9
JM
144 || __builtin_classify_type (Val1) != 8 \
145 || __builtin_classify_type (Val2) != 8) \
1c298d08
UD
146 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
147 + (__tgmath_real_type (Val2)) 0)) \
614d15f9
JM
148 Fct (Val1, Val2) \
149 : (__typeof ((__tgmath_real_type (Val1)) 0 \
150 + (__tgmath_real_type (Val2)) 0)) \
151 Fct##f (Val1, Val2)))
152
153# define __TGMATH_BINARY_REAL_STD_ONLY(Val1, Val2, Fct) \
42df8d59 154 (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \
614d15f9
JM
155 && __builtin_classify_type ((Val1) + (Val2)) == 8) \
156 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
157 + (__tgmath_real_type (Val2)) 0)) \
1c298d08 158 __tgml(Fct) (Val1, Val2) \
2fee621d
JM
159 : (sizeof (+(Val1)) == sizeof (double) \
160 || sizeof (+(Val2)) == sizeof (double) \
1c298d08
UD
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)) \
165 Fct (Val1, Val2) \
166 : (__typeof ((__tgmath_real_type (Val1)) 0 \
167 + (__tgmath_real_type (Val2)) 0)) \
168 Fct##f (Val1, Val2)))
dfd2257a 169
d12a22c5 170# define __TGMATH_BINARY_REAL_RET_ONLY(Val1, Val2, Fct) \
42df8d59 171 (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \
d12a22c5 172 && __builtin_classify_type ((Val1) + (Val2)) == 8) \
614d15f9
JM
173 ? __TGMATH_F128 ((Val1) + (Val2), Fct, (Val1, Val2)) \
174 __tgml(Fct) (Val1, Val2) \
2fee621d
JM
175 : (sizeof (+(Val1)) == sizeof (double) \
176 || sizeof (+(Val2)) == sizeof (double) \
d12a22c5
JM
177 || __builtin_classify_type (Val1) != 8 \
178 || __builtin_classify_type (Val2) != 8) \
179 ? Fct (Val1, Val2) \
180 : Fct##f (Val1, Val2)))
181
dfd2257a 182# define __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY(Val1, Val2, Val3, Fct) \
42df8d59 183 (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \
1c298d08 184 && __builtin_classify_type ((Val1) + (Val2)) == 8) \
614d15f9
JM
185 ? __TGMATH_F128 ((Val1) + (Val2), \
186 (__typeof \
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) \
2fee621d
JM
193 : (sizeof (+(Val1)) == sizeof (double) \
194 || sizeof (+(Val2)) == sizeof (double) \
1c298d08
UD
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)))
bfce746a
UD
203
204# define __TGMATH_TERNARY_REAL_ONLY(Val1, Val2, Val3, Fct) \
42df8d59 205 (__extension__ ((sizeof ((Val1) + (Val2) + (Val3)) > sizeof (double) \
1c298d08
UD
206 && __builtin_classify_type ((Val1) + (Val2) + (Val3)) \
207 == 8) \
614d15f9
JM
208 ? __TGMATH_F128 ((Val1) + (Val2) + (Val3), \
209 (__typeof \
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)) \
1c298d08 217 __tgml(Fct) (Val1, Val2, Val3) \
2fee621d
JM
218 : (sizeof (+(Val1)) == sizeof (double) \
219 || sizeof (+(Val2)) == sizeof (double) \
220 || sizeof (+(Val3)) == sizeof (double) \
1c298d08
UD
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)))
dfd2257a 232
cfa44345 233# define __TGMATH_TERNARY_FIRST_REAL_RET_ONLY(Val1, Val2, Val3, Fct) \
2fee621d 234 (__extension__ ((sizeof (+(Val1)) == sizeof (double) \
423c2b9d 235 || __builtin_classify_type (Val1) != 8) \
cfa44345 236 ? Fct (Val1, Val2, Val3) \
2fee621d 237 : (sizeof (+(Val1)) == sizeof (float)) \
cfa44345 238 ? Fct##f (Val1, Val2, Val3) \
614d15f9
JM
239 : __TGMATH_F128 ((Val1), Fct, (Val1, Val2, Val3)) \
240 __tgml(Fct) (Val1, Val2, Val3)))
423c2b9d 241
48244d09
UD
242/* XXX This definition has to be changed as soon as the compiler understands
243 the imaginary keyword. */
dfd2257a 244# define __TGMATH_UNARY_REAL_IMAG(Val, Fct, Cfct) \
2fee621d 245 (__extension__ ((sizeof (+__real__ (Val)) == sizeof (double) \
1c298d08 246 || __builtin_classify_type (__real__ (Val)) != 8) \
2fee621d 247 ? ((sizeof (+__real__ (Val)) == sizeof (+(Val))) \
1c298d08
UD
248 ? (__tgmath_real_type (Val)) Fct (Val) \
249 : (__tgmath_real_type (Val)) Cfct (Val)) \
2fee621d
JM
250 : (sizeof (+__real__ (Val)) == sizeof (float)) \
251 ? ((sizeof (+__real__ (Val)) == sizeof (+(Val))) \
1c298d08
UD
252 ? (__tgmath_real_type (Val)) Fct##f (Val) \
253 : (__tgmath_real_type (Val)) Cfct##f (Val)) \
614d15f9
JM
254 : __TGMATH_CF128 ((Val), (__tgmath_real_type (Val)) Fct, \
255 (__tgmath_real_type (Val)) Cfct, \
256 (Val)) \
2fee621d 257 ((sizeof (+__real__ (Val)) == sizeof (+(Val))) \
614d15f9
JM
258 ? (__tgmath_real_type (Val)) __tgml(Fct) (Val) \
259 : (__tgmath_real_type (Val)) __tgml(Cfct) (Val))))
1c298d08
UD
260
261# define __TGMATH_UNARY_IMAG(Val, Cfct) \
2fee621d 262 (__extension__ ((sizeof (+__real__ (Val)) == sizeof (double) \
1c298d08
UD
263 || __builtin_classify_type (__real__ (Val)) != 8) \
264 ? (__typeof__ ((__tgmath_real_type (Val)) 0 \
265 + _Complex_I)) Cfct (Val) \
2fee621d 266 : (sizeof (+__real__ (Val)) == sizeof (float)) \
1c298d08
UD
267 ? (__typeof__ ((__tgmath_real_type (Val)) 0 \
268 + _Complex_I)) Cfct##f (Val) \
614d15f9
JM
269 : __TGMATH_F128 (__real__ (Val), \
270 (__typeof__ \
271 ((__tgmath_real_type (Val)) 0 \
272 + _Complex_I)) Cfct, (Val)) \
273 (__typeof__ ((__tgmath_real_type (Val)) 0 \
274 + _Complex_I)) __tgml(Cfct) (Val)))
dfd2257a 275
58d87ee1
UD
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) \
2fee621d 279 (__extension__ ((sizeof (+__real__ (Val)) == sizeof (double) \
1c298d08 280 || __builtin_classify_type (__real__ (Val)) != 8) \
2fee621d 281 ? ((sizeof (+__real__ (Val)) == sizeof (+(Val))) \
1c298d08
UD
282 ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
283 Fct (Val) \
284 : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
285 Cfct (Val)) \
2fee621d
JM
286 : (sizeof (+__real__ (Val)) == sizeof (float)) \
287 ? ((sizeof (+__real__ (Val)) == sizeof (+(Val))) \
1c298d08
UD
288 ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
289 Fct##f (Val) \
290 : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
291 Cfct##f (Val)) \
614d15f9
JM
292 : __TGMATH_CF128 ((Val), \
293 (__typeof__ \
294 (__real__ \
295 (__tgmath_real_type (Val)) 0)) Fct, \
296 (__typeof__ \
297 (__real__ \
298 (__tgmath_real_type (Val)) 0)) Cfct, \
299 (Val)) \
2fee621d 300 ((sizeof (+__real__ (Val)) == sizeof (+(Val))) \
614d15f9
JM
301 ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0)) \
302 __tgml(Fct) (Val) \
303 : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0)) \
304 __tgml(Cfct) (Val))))
58d87ee1 305
48244d09
UD
306/* XXX This definition has to be changed as soon as the compiler understands
307 the imaginary keyword. */
dfd2257a 308# define __TGMATH_BINARY_REAL_IMAG(Val1, Val2, Fct, Cfct) \
42df8d59
JM
309 (__extension__ ((sizeof (__real__ (Val1) \
310 + __real__ (Val2)) > sizeof (double) \
1c298d08
UD
311 && __builtin_classify_type (__real__ (Val1) \
312 + __real__ (Val2)) == 8) \
614d15f9
JM
313 ? __TGMATH_CF128 ((Val1) + (Val2), \
314 (__typeof \
315 ((__tgmath_real_type (Val1)) 0 \
316 + (__tgmath_real_type (Val2)) 0)) \
317 Fct, \
318 (__typeof \
319 ((__tgmath_real_type (Val1)) 0 \
320 + (__tgmath_real_type (Val2)) 0)) \
321 Cfct, \
322 (Val1, Val2)) \
2fee621d
JM
323 ((sizeof (+__real__ (Val1)) == sizeof (+(Val1)) \
324 && sizeof (+__real__ (Val2)) == sizeof (+(Val2))) \
614d15f9 325 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
1c298d08 326 + (__tgmath_real_type (Val2)) 0)) \
614d15f9
JM
327 __tgml(Fct) (Val1, Val2) \
328 : (__typeof ((__tgmath_real_type (Val1)) 0 \
1c298d08 329 + (__tgmath_real_type (Val2)) 0)) \
614d15f9 330 __tgml(Cfct) (Val1, Val2)) \
2fee621d
JM
331 : (sizeof (+__real__ (Val1)) == sizeof (double) \
332 || sizeof (+__real__ (Val2)) == sizeof (double) \
1c298d08
UD
333 || __builtin_classify_type (__real__ (Val1)) != 8 \
334 || __builtin_classify_type (__real__ (Val2)) != 8) \
2fee621d
JM
335 ? ((sizeof (+__real__ (Val1)) == sizeof (+(Val1)) \
336 && sizeof (+__real__ (Val2)) == sizeof (+(Val2))) \
1c298d08
UD
337 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
338 + (__tgmath_real_type (Val2)) 0)) \
339 Fct (Val1, Val2) \
340 : (__typeof ((__tgmath_real_type (Val1)) 0 \
341 + (__tgmath_real_type (Val2)) 0)) \
342 Cfct (Val1, Val2)) \
2fee621d
JM
343 : ((sizeof (+__real__ (Val1)) == sizeof (+(Val1)) \
344 && sizeof (+__real__ (Val2)) == sizeof (+(Val2))) \
1c298d08
UD
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))))
dfd2257a
UD
351#else
352# error "Unsupported compiler; you cannot use <tgmath.h>"
353#endif
354
355
356/* Unary functions defined for real and complex values. */
357
358
359/* Trigonometric functions. */
360
361/* Arc cosine of X. */
362#define acos(Val) __TGMATH_UNARY_REAL_IMAG (Val, acos, cacos)
363/* Arc sine of X. */
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. */
cfb32a6c 368#define atan2(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, atan2)
dfd2257a
UD
369
370/* Cosine of X. */
371#define cos(Val) __TGMATH_UNARY_REAL_IMAG (Val, cos, ccos)
372/* Sine of X. */
373#define sin(Val) __TGMATH_UNARY_REAL_IMAG (Val, sin, csin)
374/* Tangent of X. */
375#define tan(Val) __TGMATH_UNARY_REAL_IMAG (Val, tan, ctan)
376
377
378/* Hyperbolic functions. */
379
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)
386
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)
393
394
395/* Exponential and logarithmic functions. */
396
397/* Exponential function of X. */
398#define exp(Val) __TGMATH_UNARY_REAL_IMAG (Val, exp, cexp)
399
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)
402
403/* X times (two to the EXP power). */
404#define ldexp(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, ldexp)
405
406/* Natural logarithm of X. */
407#define log(Val) __TGMATH_UNARY_REAL_IMAG (Val, log, clog)
408
409/* Base-ten logarithm of X. */
cc3fa755 410#ifdef __USE_GNU
0908a38a 411# define log10(Val) __TGMATH_UNARY_REAL_IMAG (Val, log10, clog10)
cc3fa755
UD
412#else
413# define log10(Val) __TGMATH_UNARY_REAL_ONLY (Val, log10)
414#endif
dfd2257a
UD
415
416/* Return exp(X) - 1. */
417#define expm1(Val) __TGMATH_UNARY_REAL_ONLY (Val, expm1)
418
419/* Return log(1 + X). */
420#define log1p(Val) __TGMATH_UNARY_REAL_ONLY (Val, log1p)
421
422/* Return the base 2 signed integral exponent of X. */
423#define logb(Val) __TGMATH_UNARY_REAL_ONLY (Val, logb)
424
425/* Compute base-2 exponential of X. */
426#define exp2(Val) __TGMATH_UNARY_REAL_ONLY (Val, exp2)
427
428/* Compute base-2 logarithm of X. */
429#define log2(Val) __TGMATH_UNARY_REAL_ONLY (Val, log2)
430
431
432/* Power functions. */
433
434/* Return X to the Y power. */
435#define pow(Val1, Val2) __TGMATH_BINARY_REAL_IMAG (Val1, Val2, pow, cpow)
436
437/* Return the square root of X. */
438#define sqrt(Val) __TGMATH_UNARY_REAL_IMAG (Val, sqrt, csqrt)
439
440/* Return `sqrt(X*X + Y*Y)'. */
441#define hypot(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, hypot)
442
443/* Return the cube root of X. */
444#define cbrt(Val) __TGMATH_UNARY_REAL_ONLY (Val, cbrt)
445
446
447/* Nearest integer, absolute value, and remainder functions. */
448
449/* Smallest integral value not less than X. */
450#define ceil(Val) __TGMATH_UNARY_REAL_ONLY (Val, ceil)
451
452/* Absolute value of X. */
f1debaf6 453#define fabs(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, fabs, cabs)
dfd2257a
UD
454
455/* Largest integer not greater than X. */
456#define floor(Val) __TGMATH_UNARY_REAL_ONLY (Val, floor)
457
458/* Floating-point modulo remainder of X/Y. */
459#define fmod(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmod)
460
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)
464
465/* Round X to nearest integral value, rounding halfway cases away from
466 zero. */
467#define round(Val) __TGMATH_UNARY_REAL_ONLY (Val, round)
468
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)
472
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)
478
479/* Round X to nearest integral value according to current rounding
480 direction. */
cfa44345
JM
481#define lrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, lrint)
482#define llrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llrint)
dfd2257a
UD
483
484/* Round X to nearest integral value, rounding halfway cases away from
485 zero. */
cfa44345
JM
486#define lround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, lround)
487#define llround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llround)
dfd2257a
UD
488
489
490/* Return X with its signed changed to Y's. */
491#define copysign(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, copysign)
492
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)
00d8bc81 496#define tgamma(Val) __TGMATH_UNARY_REAL_ONLY (Val, tgamma)
dfd2257a
UD
497#define lgamma(Val) __TGMATH_UNARY_REAL_ONLY (Val, lgamma)
498
499
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)
503
146f208d 504#if __GLIBC_USE (IEC_60559_BFP_EXT)
41a359e2
RS
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)
509#endif
510
dfd2257a
UD
511/* Return X + epsilon if X < Y, X - epsilon if X > Y. */
512#define nextafter(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, nextafter)
42bd0a85 513#define nexttoward(Val1, Val2) \
614d15f9 514 __TGMATH_BINARY_FIRST_REAL_STD_ONLY (Val1, Val2, nexttoward)
dfd2257a
UD
515
516/* Return the remainder of integer divison X / Y with infinite precision. */
517#define remainder(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, remainder)
518
519/* Return X times (2 to the Nth power). */
de20571d 520#ifdef __USE_MISC
614d15f9 521# define scalb(Val1, Val2) __TGMATH_BINARY_REAL_STD_ONLY (Val1, Val2, scalb)
26644e87 522#endif
dfd2257a
UD
523
524/* Return X times (2 to the Nth power). */
525#define scalbn(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbn)
526
527/* Return X times (2 to the Nth power). */
528#define scalbln(Val1, Val2) \
529 __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbln)
530
531/* Return the binary exponent of X, which must be nonzero. */
cfa44345 532#define ilogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, ilogb)
dfd2257a
UD
533
534
535/* Return positive difference between X and Y. */
536#define fdim(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fdim)
537
538/* Return maximum numeric value from X and Y. */
539#define fmax(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmax)
540
541/* Return minimum numeric value from X and Y. */
542#define fmin(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmin)
543
544
bfce746a 545/* Multiply-add function computed as a ternary operation. */
e7c3d12b 546#define fma(Val1, Val2, Val3) \
bfce746a
UD
547 __TGMATH_TERNARY_REAL_ONLY (Val1, Val2, Val3, fma)
548
5e9d98a3 549#if __GLIBC_USE (IEC_60559_BFP_EXT)
41c67149
JM
550/* Round X to nearest integer value, rounding halfway cases to even. */
551# define roundeven(Val) __TGMATH_UNARY_REAL_ONLY (Val, roundeven)
552
423c2b9d 553# define fromfp(Val1, Val2, Val3) \
cfa44345 554 __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, fromfp)
423c2b9d
JM
555
556# define ufromfp(Val1, Val2, Val3) \
cfa44345 557 __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, ufromfp)
423c2b9d
JM
558
559# define fromfpx(Val1, Val2, Val3) \
cfa44345 560 __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, fromfpx)
423c2b9d
JM
561
562# define ufromfpx(Val1, Val2, Val3) \
cfa44345 563 __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, ufromfpx)
423c2b9d 564
55a38f82 565/* Like ilogb, but returning long int. */
cfa44345 566# define llogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llogb)
55a38f82 567
525f8039
JM
568/* Return value with maximum magnitude. */
569# define fmaxmag(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmaxmag)
570
571/* Return value with minimum magnitude. */
572# define fminmag(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fminmag)
573
5e9d98a3 574/* Total order operation. */
d12a22c5
JM
575# define totalorder(Val1, Val2) \
576 __TGMATH_BINARY_REAL_RET_ONLY (Val1, Val2, totalorder)
cc6a8d74
JM
577
578/* Total order operation on absolute values. */
d12a22c5
JM
579# define totalordermag(Val1, Val2) \
580 __TGMATH_BINARY_REAL_RET_ONLY (Val1, Val2, totalordermag)
5e9d98a3
JM
581#endif
582
bfce746a 583
dfd2257a
UD
584/* Absolute value, conjugates, and projection. */
585
586/* Argument value of Z. */
f1debaf6 587#define carg(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, carg, carg)
dfd2257a
UD
588
589/* Complex conjugate of Z. */
1c298d08 590#define conj(Val) __TGMATH_UNARY_IMAG (Val, conj)
dfd2257a
UD
591
592/* Projection of Z onto the Riemann sphere. */
1c298d08 593#define cproj(Val) __TGMATH_UNARY_IMAG (Val, cproj)
dfd2257a
UD
594
595
596/* Decomposing complex values. */
597
598/* Imaginary part of Z. */
58d87ee1 599#define cimag(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, cimag, cimag)
dfd2257a
UD
600
601/* Real part of Z. */
58d87ee1 602#define creal(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, creal, creal)
dfd2257a
UD
603
604#endif /* tgmath.h */