]> git.ipfire.org Git - thirdparty/glibc.git/blame - math/bits/mathcalls.h
Split helper classification macros from mathcalls.h
[thirdparty/glibc.git] / math / bits / mathcalls.h
CommitLineData
f7eac6eb 1/* Prototype declarations for math functions; helper file for <math.h>.
bfff8b1b 2 Copyright (C) 1996-2017 Free Software Foundation, Inc.
2c6fe0bd 3 This file is part of the GNU C Library.
f7eac6eb 4
2c6fe0bd 5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
f7eac6eb 9
2c6fe0bd
UD
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 13 Lesser General Public License for more details.
f7eac6eb 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
f7eac6eb
RM
18
19/* NOTE: Because of the special way this file is used by <math.h>, this
20 file must NOT be protected from multiple inclusion as header files
21 usually are.
22
23 This file provides prototype declarations for the math functions.
24 Most functions are declared using the macro:
25
26 __MATHCALL (NAME,[_r], (ARGS...));
27
28 This means there is a function `NAME' returning `double' and a function
29 `NAMEf' returning `float'. Each place `_Mdouble_' appears in the
30 prototype, that is actually `double' in the prototype for `NAME' and
31 `float' in the prototype for `NAMEf'. Reentrant variant functions are
32 called `NAME_r' and `NAMEf_r'.
33
34 Functions returning other types like `int' are declared using the macro:
35
36 __MATHDECL (TYPE, NAME,[_r], (ARGS...));
37
38 This is just like __MATHCALL but for a function returning `TYPE'
39 instead of `_Mdouble_'. In all of these cases, there is still
af6f3906 40 both a `NAME' and a `NAMEf' that takes `float' arguments.
4bbac92a 41
af6f3906
UD
42 Note that there must be no whitespace before the argument passed for
43 NAME, to make token pasting work with -traditional. */
f7eac6eb
RM
44
45#ifndef _MATH_H
7a5affeb 46# error "Never include <bits/mathcalls.h> directly; include <math.h> instead."
f7eac6eb
RM
47#endif
48
49
50/* Trigonometric functions. */
51
7a5affeb 52_Mdouble_BEGIN_NAMESPACE
f7eac6eb
RM
53/* Arc cosine of X. */
54__MATHCALL (acos,, (_Mdouble_ __x));
55/* Arc sine of X. */
56__MATHCALL (asin,, (_Mdouble_ __x));
57/* Arc tangent of X. */
58__MATHCALL (atan,, (_Mdouble_ __x));
59/* Arc tangent of Y/X. */
60__MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x));
61
62/* Cosine of X. */
21933112 63__MATHCALL_VEC (cos,, (_Mdouble_ __x));
f7eac6eb 64/* Sine of X. */
4b9c2b70 65__MATHCALL_VEC (sin,, (_Mdouble_ __x));
f7eac6eb
RM
66/* Tangent of X. */
67__MATHCALL (tan,, (_Mdouble_ __x));
68
f7eac6eb
RM
69/* Hyperbolic functions. */
70
71/* Hyperbolic cosine of X. */
72__MATHCALL (cosh,, (_Mdouble_ __x));
73/* Hyperbolic sine of X. */
74__MATHCALL (sinh,, (_Mdouble_ __x));
75/* Hyperbolic tangent of X. */
76__MATHCALL (tanh,, (_Mdouble_ __x));
7a5affeb
UD
77_Mdouble_END_NAMESPACE
78
79#ifdef __USE_GNU
80/* Cosine and sine of X. */
c9a8c526
AS
81__MATHDECL_VEC (void,sincos,,
82 (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx));
7a5affeb 83#endif
f7eac6eb 84
acd7f096 85#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
7a5affeb 86__BEGIN_NAMESPACE_C99
f7eac6eb
RM
87/* Hyperbolic arc cosine of X. */
88__MATHCALL (acosh,, (_Mdouble_ __x));
89/* Hyperbolic arc sine of X. */
90__MATHCALL (asinh,, (_Mdouble_ __x));
91/* Hyperbolic arc tangent of X. */
92__MATHCALL (atanh,, (_Mdouble_ __x));
7a5affeb 93__END_NAMESPACE_C99
f7eac6eb
RM
94#endif
95
96/* Exponential and logarithmic functions. */
97
7a5affeb 98_Mdouble_BEGIN_NAMESPACE
6d52618b 99/* Exponential function of X. */
9c02f663 100__MATHCALL_VEC (exp,, (_Mdouble_ __x));
f7eac6eb
RM
101
102/* Break VALUE into a normalized fraction and an integral power of 2. */
afd4eb37 103__MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent));
f7eac6eb
RM
104
105/* X times (two to the EXP power). */
afd4eb37 106__MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent));
f7eac6eb
RM
107
108/* Natural logarithm of X. */
6af25acc 109__MATHCALL_VEC (log,, (_Mdouble_ __x));
f7eac6eb
RM
110
111/* Base-ten logarithm of X. */
112__MATHCALL (log10,, (_Mdouble_ __x));
113
377a515b 114/* Break VALUE into integral and fractional parts. */
9c89fca6 115__MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr)) __nonnull ((2));
7a5affeb
UD
116_Mdouble_END_NAMESPACE
117
412cb261
JM
118#if __GLIBC_USE (IEC_60559_FUNCS_EXT)
119/* Compute exponent to base ten. */
7a5affeb 120__MATHCALL (exp10,, (_Mdouble_ __x));
412cb261
JM
121#endif
122#ifdef __USE_GNU
7a5affeb
UD
123/* Another name occasionally used. */
124__MATHCALL (pow10,, (_Mdouble_ __x));
125#endif
377a515b 126
acd7f096 127#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
7a5affeb 128__BEGIN_NAMESPACE_C99
f7eac6eb
RM
129/* Return exp(X) - 1. */
130__MATHCALL (expm1,, (_Mdouble_ __x));
131
132/* Return log(1 + X). */
133__MATHCALL (log1p,, (_Mdouble_ __x));
2c6fe0bd
UD
134
135/* Return the base 2 signed integral exponent of X. */
136__MATHCALL (logb,, (_Mdouble_ __x));
7a5affeb 137__END_NAMESPACE_C99
f7eac6eb
RM
138#endif
139
ec751a23 140#ifdef __USE_ISOC99
7a5affeb 141__BEGIN_NAMESPACE_C99
377a515b
UD
142/* Compute base-2 exponential of X. */
143__MATHCALL (exp2,, (_Mdouble_ __x));
144
145/* Compute base-2 logarithm of X. */
146__MATHCALL (log2,, (_Mdouble_ __x));
7a5affeb 147__END_NAMESPACE_C99
377a515b 148#endif
f7eac6eb
RM
149
150
151/* Power functions. */
152
7a5affeb 153_Mdouble_BEGIN_NAMESPACE
f7eac6eb 154/* Return X to the Y power. */
c10b9b13 155__MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
f7eac6eb
RM
156
157/* Return the square root of X. */
158__MATHCALL (sqrt,, (_Mdouble_ __x));
7a5affeb 159_Mdouble_END_NAMESPACE
f7eac6eb 160
acd7f096 161#if defined __USE_XOPEN || defined __USE_ISOC99
7a5affeb 162__BEGIN_NAMESPACE_C99
377a515b
UD
163/* Return `sqrt(X*X + Y*Y)'. */
164__MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
7a5affeb 165__END_NAMESPACE_C99
e918a7fe 166#endif
377a515b 167
acd7f096 168#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
7a5affeb 169__BEGIN_NAMESPACE_C99
f7eac6eb
RM
170/* Return the cube root of X. */
171__MATHCALL (cbrt,, (_Mdouble_ __x));
7a5affeb 172__END_NAMESPACE_C99
f7eac6eb
RM
173#endif
174
175
176/* Nearest integer, absolute value, and remainder functions. */
177
7a5affeb 178_Mdouble_BEGIN_NAMESPACE
f7eac6eb 179/* Smallest integral value not less than X. */
f4efd068 180__MATHCALLX (ceil,, (_Mdouble_ __x), (__const__));
f7eac6eb
RM
181
182/* Absolute value of X. */
3e5f5557 183__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
f7eac6eb
RM
184
185/* Largest integer not greater than X. */
f4efd068 186__MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
f7eac6eb
RM
187
188/* Floating-point modulo remainder of X/Y. */
189__MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
7a5affeb 190_Mdouble_END_NAMESPACE
a1648746 191
f7eac6eb 192#ifdef __USE_MISC
3c47c83a
CD
193# if (!defined __cplusplus \
194 || __cplusplus < 201103L /* isinf conflicts with C++11. */ \
195 || __MATH_DECLARING_DOUBLE == 0) /* isinff or isinfl don't. */
f7eac6eb
RM
196/* Return 0 if VALUE is finite or NaN, +1 if it
197 is +Infinity, -1 if it is -Infinity. */
bfce746a 198__MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
d9b965fa 199# endif
f7eac6eb 200
f7eac6eb 201/* Return nonzero if VALUE is finite and not NaN. */
a1648746 202__MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
f7eac6eb 203
f7eac6eb
RM
204/* Return the remainder of X/Y. */
205__MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
206
f7eac6eb 207
2c6fe0bd
UD
208/* Return the fractional part of X after dividing out `ilogb (X)'. */
209__MATHCALL (significand,, (_Mdouble_ __x));
210#endif /* Use misc. */
f7eac6eb 211
acd7f096 212#ifdef __USE_ISOC99
7a5affeb 213__BEGIN_NAMESPACE_C99
377a515b 214/* Return X with its signed changed to Y's. */
3e5f5557 215__MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
7a5affeb 216__END_NAMESPACE_C99
377a515b
UD
217#endif
218
ec751a23 219#ifdef __USE_ISOC99
7a5affeb 220__BEGIN_NAMESPACE_C99
67e971f1 221/* Return representation of qNaN for double type. */
a784e502 222__MATHCALLX (nan,, (const char *__tagb), (__const__));
7a5affeb 223__END_NAMESPACE_C99
377a515b 224#endif
2c6fe0bd 225
2c6fe0bd 226
de20571d 227#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
3c47c83a
CD
228# if (!defined __cplusplus \
229 || __cplusplus < 201103L /* isnan conflicts with C++11. */ \
230 || __MATH_DECLARING_DOUBLE == 0) /* isnanf or isnanl don't. */
2c6fe0bd 231/* Return nonzero if VALUE is not a number. */
a1648746 232__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
d9b965fa 233# endif
de20571d 234#endif
f7eac6eb 235
1f11365a 236#if defined __USE_MISC || (defined __USE_XOPEN && __MATH_DECLARING_DOUBLE)
377a515b
UD
237/* Bessel functions. */
238__MATHCALL (j0,, (_Mdouble_));
239__MATHCALL (j1,, (_Mdouble_));
240__MATHCALL (jn,, (int, _Mdouble_));
241__MATHCALL (y0,, (_Mdouble_));
242__MATHCALL (y1,, (_Mdouble_));
243__MATHCALL (yn,, (int, _Mdouble_));
244#endif
f7eac6eb
RM
245
246
acd7f096 247#if defined __USE_XOPEN || defined __USE_ISOC99
7a5affeb 248__BEGIN_NAMESPACE_C99
7d6a8338 249/* Error and gamma functions. */
f7eac6eb
RM
250__MATHCALL (erf,, (_Mdouble_));
251__MATHCALL (erfc,, (_Mdouble_));
f7eac6eb 252__MATHCALL (lgamma,, (_Mdouble_));
7a5affeb 253__END_NAMESPACE_C99
0ed99ce4
UD
254#endif
255
256#ifdef __USE_ISOC99
7a5affeb
UD
257__BEGIN_NAMESPACE_C99
258/* True gamma function. */
e852e889 259__MATHCALL (tgamma,, (_Mdouble_));
7a5affeb 260__END_NAMESPACE_C99
e852e889
UD
261#endif
262
de20571d 263#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
7d6a8338 264/* Obsolete alias for `lgamma'. */
e852e889 265__MATHCALL (gamma,, (_Mdouble_));
d705269e 266#endif
f7eac6eb 267
19361cb7 268#ifdef __USE_MISC
7d6a8338
UD
269/* Reentrant version of lgamma. This function uses the global variable
270 `signgam'. The reentrant version instead takes a pointer and stores
271 the value through it. */
272__MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp));
f7eac6eb
RM
273#endif
274
2c6fe0bd 275
acd7f096 276#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
7a5affeb 277__BEGIN_NAMESPACE_C99
2c6fe0bd
UD
278/* Return the integer nearest X in the direction of the
279 prevailing rounding mode. */
280__MATHCALL (rint,, (_Mdouble_ __x));
281
2c6fe0bd 282/* Return X + epsilon if X < Y, X - epsilon if X > Y. */
3e5f5557 283__MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
c6251f03 284# if defined __USE_ISOC99 && !defined __LDBL_COMPAT
36fe9ac9 285__MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__));
bfce746a 286# endif
2c6fe0bd 287
bf91be88 288#if __GLIBC_USE (IEC_60559_BFP_EXT)
41a359e2
RS
289/* Return X - epsilon. */
290__MATHCALL (nextdown,, (_Mdouble_ __x));
291/* Return X + epsilon. */
292__MATHCALL (nextup,, (_Mdouble_ __x));
293# endif
294
2c6fe0bd
UD
295/* Return the remainder of integer divison X / Y with infinite precision. */
296__MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
2c6fe0bd 297
acd7f096 298# ifdef __USE_ISOC99
d705269e 299/* Return X times (2 to the Nth power). */
dfd2257a 300__MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
0ed99ce4 301# endif
d705269e
UD
302
303/* Return the binary exponent of X, which must be nonzero. */
304__MATHDECL (int,ilogb,, (_Mdouble_ __x));
377a515b
UD
305#endif
306
55a38f82
JM
307#if __GLIBC_USE (IEC_60559_BFP_EXT)
308/* Like ilogb, but returning long int. */
309__MATHDECL (long int, llogb,, (_Mdouble_ __x));
310#endif
311
ec751a23 312#ifdef __USE_ISOC99
dfd2257a
UD
313/* Return X times (2 to the Nth power). */
314__MATHCALL (scalbln,, (_Mdouble_ __x, long int __n));
315
4caef86c 316/* Round X to integral value in floating-point format using current
377a515b
UD
317 rounding direction, but do not raise inexact exception. */
318__MATHCALL (nearbyint,, (_Mdouble_ __x));
319
320/* Round X to nearest integral value, rounding halfway cases away from
321 zero. */
27caaf41 322__MATHCALLX (round,, (_Mdouble_ __x), (__const__));
377a515b
UD
323
324/* Round X to the integral value in floating-point format nearest but
325 not larger in magnitude. */
3e5f5557 326__MATHCALLX (trunc,, (_Mdouble_ __x), (__const__));
377a515b
UD
327
328/* Compute remainder of X and Y and put in *QUO a value with sign of x/y
329 and magnitude congruent `mod 2^n' to the magnitude of the integral
330 quotient x/y, with n >= 3. */
331__MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));
332
333
dfd2257a
UD
334/* Conversion functions. */
335
336/* Round X to nearest integral value according to current rounding
337 direction. */
af6f3906 338__MATHDECL (long int,lrint,, (_Mdouble_ __x));
828beb13 339__extension__
af6f3906 340__MATHDECL (long long int,llrint,, (_Mdouble_ __x));
dfd2257a
UD
341
342/* Round X to nearest integral value, rounding halfway cases away from
343 zero. */
af6f3906 344__MATHDECL (long int,lround,, (_Mdouble_ __x));
828beb13 345__extension__
af6f3906 346__MATHDECL (long long int,llround,, (_Mdouble_ __x));
dfd2257a
UD
347
348
377a515b
UD
349/* Return positive difference between X and Y. */
350__MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y));
351
4cca6b86 352/* Return maximum numeric value from X and Y. */
e58ef0f2 353__MATHCALLX (fmax,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
377a515b 354
4cca6b86 355/* Return minimum numeric value from X and Y. */
e58ef0f2 356__MATHCALLX (fmin,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
377a515b 357
dfd2257a
UD
358/* Multiply-add function computed as a ternary operation. */
359__MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));
d36421fa
RM
360#endif /* Use ISO C99. */
361
acd7f096 362#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
7a5affeb 363__END_NAMESPACE_C99
d36421fa 364#endif
7a5affeb 365
bf91be88 366#if __GLIBC_USE (IEC_60559_BFP_EXT)
41c67149
JM
367/* Round X to nearest integer value, rounding halfway cases to even. */
368__MATHCALLX (roundeven,, (_Mdouble_ __x), (__const__));
369
423c2b9d
JM
370/* Round X to nearest signed integer value, not raising inexact, with
371 control of rounding direction and width of result. */
372__MATHDECL (__intmax_t, fromfp,, (_Mdouble_ __x, int __round,
373 unsigned int __width));
374
375/* Round X to nearest unsigned integer value, not raising inexact,
376 with control of rounding direction and width of result. */
377__MATHDECL (__uintmax_t, ufromfp,, (_Mdouble_ __x, int __round,
378 unsigned int __width));
379
380/* Round X to nearest signed integer value, raising inexact for
381 non-integers, with control of rounding direction and width of
382 result. */
383__MATHDECL (__intmax_t, fromfpx,, (_Mdouble_ __x, int __round,
384 unsigned int __width));
385
386/* Round X to nearest unsigned integer value, raising inexact for
387 non-integers, with control of rounding direction and width of
388 result. */
389__MATHDECL (__uintmax_t, ufromfpx,, (_Mdouble_ __x, int __round,
390 unsigned int __width));
391
525f8039
JM
392/* Return value with maximum magnitude. */
393__MATHCALLX (fmaxmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
394
395/* Return value with minimum magnitude. */
396__MATHCALLX (fminmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
397
5e9d98a3
JM
398/* Total order operation. */
399__MATHDECL_1 (int, totalorder,, (_Mdouble_ __x, _Mdouble_ __y))
400 __attribute__ ((__const__));
cc6a8d74
JM
401
402/* Total order operation on absolute values. */
403__MATHDECL_1 (int, totalordermag,, (_Mdouble_ __x, _Mdouble_ __y))
404 __attribute__ ((__const__));
f8e8b8ed 405
eaf5ad0b
JM
406/* Canonicalize floating-point representation. */
407__MATHDECL_1 (int, canonicalize,, (_Mdouble_ *__cx, const _Mdouble_ *__x));
408
f8e8b8ed
JM
409/* Get NaN payload. */
410__MATHCALL (getpayload,, (const _Mdouble_ *__x));
eb3c12c7
JM
411
412/* Set quiet NaN payload. */
413__MATHDECL_1 (int, setpayload,, (_Mdouble_ *__x, _Mdouble_ __payload));
457663a7
JM
414
415/* Set signaling NaN payload. */
416__MATHDECL_1 (int, setpayloadsig,, (_Mdouble_ *__x, _Mdouble_ __payload));
57267616
TS
417#endif
418
de20571d
JM
419#if defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \
420 && __MATH_DECLARING_DOUBLE \
421 && !defined __USE_XOPEN2K8)
7a5affeb
UD
422/* Return X times (2 to the Nth power). */
423__MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
d36421fa 424#endif