1/* Prototype declarations for math functions; helper file for <math.h>.
2 Copyright (C) 1996-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
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.
9
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
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
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
40 both a `NAME' and a `NAMEf' that takes `float' arguments.
41
42 Note that there must be no whitespace before the argument passed for
43 NAME, to make token pasting work with -traditional. */
44
45#ifndef _MATH_H
46# error "Never include <bits/mathcalls.h> directly; include <math.h> instead."
47#endif
48
49
50/* Trigonometric functions. */
51
52/* Arc cosine of X. */
53__MATHCALL_VEC (acos,, (_Mdouble_ __x));
54/* Arc sine of X. */
55__MATHCALL_VEC (asin,, (_Mdouble_ __x));
56/* Arc tangent of X. */
57__MATHCALL_VEC (atan,, (_Mdouble_ __x));
58/* Arc tangent of Y/X. */
59__MATHCALL_VEC (atan2,, (_Mdouble_ __y, _Mdouble_ __x));
60
61/* Cosine of X. */
62__MATHCALL_VEC (cos,, (_Mdouble_ __x));
63/* Sine of X. */
64__MATHCALL_VEC (sin,, (_Mdouble_ __x));
65/* Tangent of X. */
66__MATHCALL_VEC (tan,, (_Mdouble_ __x));
67
68/* Hyperbolic functions. */
69
70/* Hyperbolic cosine of X. */
71__MATHCALL_VEC (cosh,, (_Mdouble_ __x));
72/* Hyperbolic sine of X. */
73__MATHCALL_VEC (sinh,, (_Mdouble_ __x));
74/* Hyperbolic tangent of X. */
75__MATHCALL_VEC (tanh,, (_Mdouble_ __x));
76
77#ifdef __USE_GNU
78/* Cosine and sine of X. */
79__MATHDECL_VEC (void,sincos,,
80 (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx));
81#endif
82
83#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
84/* Hyperbolic arc cosine of X. */
85__MATHCALL_VEC (acosh,, (_Mdouble_ __x));
86/* Hyperbolic arc sine of X. */
87__MATHCALL_VEC (asinh,, (_Mdouble_ __x));
88/* Hyperbolic arc tangent of X. */
89__MATHCALL_VEC (atanh,, (_Mdouble_ __x));
90#endif
91
92/* Exponential and logarithmic functions. */
93
94/* Exponential function of X. */
95__MATHCALL_VEC (exp,, (_Mdouble_ __x));
96
97/* Break VALUE into a normalized fraction and an integral power of 2. */
98__MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent));
99
100/* X times (two to the EXP power). */
101__MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent));
102
103/* Natural logarithm of X. */
104__MATHCALL_VEC (log,, (_Mdouble_ __x));
105
106/* Base-ten logarithm of X. */
107__MATHCALL_VEC (log10,, (_Mdouble_ __x));
108
109/* Break VALUE into integral and fractional parts. */
110__MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr)) __nonnull ((2));
111
112#if __GLIBC_USE (IEC_60559_FUNCS_EXT_C23)
113/* Compute exponent to base ten. */
114__MATHCALL_VEC (exp10,, (_Mdouble_ __x));
115
116/* Return exp2(X) - 1. */
117__MATHCALL (exp2m1,, (_Mdouble_ __x));
118
119/* Return exp10(X) - 1. */
120__MATHCALL (exp10m1,, (_Mdouble_ __x));
121
122/* Return log2(1 + X). */
123__MATHCALL (log2p1,, (_Mdouble_ __x));
124
125/* Return log10(1 + X). */
126__MATHCALL (log10p1,, (_Mdouble_ __x));
127
128/* Return log(1 + X). */
129__MATHCALL (logp1,, (_Mdouble_ __x));
130#endif
131
132#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
133/* Return exp(X) - 1. */
134__MATHCALL_VEC (expm1,, (_Mdouble_ __x));
135
136/* Return log(1 + X). */
137__MATHCALL_VEC (log1p,, (_Mdouble_ __x));
138
139/* Return the base 2 signed integral exponent of X. */
140__MATHCALL (logb,, (_Mdouble_ __x));
141#endif
142
143#ifdef __USE_ISOC99
144/* Compute base-2 exponential of X. */
145__MATHCALL_VEC (exp2,, (_Mdouble_ __x));
146
147/* Compute base-2 logarithm of X. */
148__MATHCALL_VEC (log2,, (_Mdouble_ __x));
149#endif
150
151
152/* Power functions. */
153
154/* Return X to the Y power. */
155__MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
156
157/* Return the square root of X. */
158__MATHCALL (sqrt,, (_Mdouble_ __x));
159
160#if defined __USE_XOPEN || defined __USE_ISOC99
161/* Return `sqrt(X*X + Y*Y)'. */
162__MATHCALL_VEC (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
163#endif
164
165#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
166/* Return the cube root of X. */
167__MATHCALL_VEC (cbrt,, (_Mdouble_ __x));
168#endif
169
170
171/* Nearest integer, absolute value, and remainder functions. */
172
173/* Smallest integral value not less than X. */
174__MATHCALLX (ceil,, (_Mdouble_ __x), (__const__));
175
176/* Absolute value of X. */
177__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
178
179/* Largest integer not greater than X. */
180__MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
181
182/* Floating-point modulo remainder of X/Y. */
183__MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
184
185#ifdef __USE_MISC
186# if ((!defined __cplusplus \
187 || __cplusplus < 201103L /* isinf conflicts with C++11. */ \
188 || __MATH_DECLARING_DOUBLE == 0)) /* isinff or isinfl don't. */ \
189 && !__MATH_DECLARING_FLOATN
190/* Return 0 if VALUE is finite or NaN, +1 if it
191 is +Infinity, -1 if it is -Infinity. */
192__MATHDECL_ALIAS (int,isinf,, (_Mdouble_ __value), isinf)
193 __attribute__ ((__const__));
194# endif
195
196# if !__MATH_DECLARING_FLOATN
197/* Return nonzero if VALUE is finite and not NaN. */
198__MATHDECL_ALIAS (int,finite,, (_Mdouble_ __value), finite)
199 __attribute__ ((__const__));
200
201/* Return the remainder of X/Y. */
202__MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
203
204
205/* Return the fractional part of X after dividing out `ilogb (X)'. */
206__MATHCALL (significand,, (_Mdouble_ __x));
207# endif
208
209#endif /* Use misc. */
210
211#ifdef __USE_ISOC99
212/* Return X with its signed changed to Y's. */
213__MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
214#endif
215
216#ifdef __USE_ISOC99
217/* Return representation of qNaN for double type. */
218__MATHCALL (nan,, (const char *__tagb));
219#endif
220
221
222#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
223# if ((!defined __cplusplus \
224 || __cplusplus < 201103L /* isnan conflicts with C++11. */ \
225 || __MATH_DECLARING_DOUBLE == 0)) /* isnanf or isnanl don't. */ \
226 && !__MATH_DECLARING_FLOATN
227/* Return nonzero if VALUE is not a number. */
228__MATHDECL_ALIAS (int,isnan,, (_Mdouble_ __value), isnan)
229 __attribute__ ((__const__));
230# endif
231#endif
232
233#if defined __USE_MISC || (defined __USE_XOPEN && __MATH_DECLARING_DOUBLE)
234/* Bessel functions. */
235__MATHCALL (j0,, (_Mdouble_));
236__MATHCALL (j1,, (_Mdouble_));
237__MATHCALL (jn,, (int, _Mdouble_));
238__MATHCALL (y0,, (_Mdouble_));
239__MATHCALL (y1,, (_Mdouble_));
240__MATHCALL (yn,, (int, _Mdouble_));
241#endif
242
243
244#if defined __USE_XOPEN || defined __USE_ISOC99
245/* Error and gamma functions. */
246__MATHCALL_VEC (erf,, (_Mdouble_));
247__MATHCALL_VEC (erfc,, (_Mdouble_));
248__MATHCALL (lgamma,, (_Mdouble_));
249#endif
250
251#ifdef __USE_ISOC99
252/* True gamma function. */
253__MATHCALL (tgamma,, (_Mdouble_));
254#endif
255
256#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
257# if !__MATH_DECLARING_FLOATN
258/* Obsolete alias for `lgamma'. */
259__MATHCALL (gamma,, (_Mdouble_));
260# endif
261#endif
262
263#ifdef __USE_MISC
264/* Reentrant version of lgamma. This function uses the global variable
265 `signgam'. The reentrant version instead takes a pointer and stores
266 the value through it. */
267__MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp));
268#endif
269
270
271#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
272/* Return the integer nearest X in the direction of the
273 prevailing rounding mode. */
274__MATHCALL (rint,, (_Mdouble_ __x));
275
276/* Return X + epsilon if X < Y, X - epsilon if X > Y. */
277__MATHCALL (nextafter,, (_Mdouble_ __x, _Mdouble_ __y));
278# if defined __USE_ISOC99 && !defined __LDBL_COMPAT && !__MATH_DECLARING_FLOATN
279__MATHCALL (nexttoward,, (_Mdouble_ __x, long double __y));
280# endif
281
282# if __GLIBC_USE (IEC_60559_BFP_EXT_C23) || __MATH_DECLARING_FLOATN
283/* Return X - epsilon. */
284__MATHCALL (nextdown,, (_Mdouble_ __x));
285/* Return X + epsilon. */
286__MATHCALL (nextup,, (_Mdouble_ __x));
287# endif
288
289/* Return the remainder of integer division X / Y with infinite precision. */
290__MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
291
292# ifdef __USE_ISOC99
293/* Return X times (2 to the Nth power). */
294__MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
295# endif
296
297/* Return the binary exponent of X, which must be nonzero. */
298__MATHDECL (int,ilogb,, (_Mdouble_ __x));
299#endif
300
301#if __GLIBC_USE (IEC_60559_BFP_EXT_C23) || __MATH_DECLARING_FLOATN
302/* Like ilogb, but returning long int. */
303__MATHDECL (long int, llogb,, (_Mdouble_ __x));
304#endif
305
306#ifdef __USE_ISOC99
307/* Return X times (2 to the Nth power). */
308__MATHCALL (scalbln,, (_Mdouble_ __x, long int __n));
309
310/* Round X to integral value in floating-point format using current
311 rounding direction, but do not raise inexact exception. */
312__MATHCALL (nearbyint,, (_Mdouble_ __x));
313
314/* Round X to nearest integral value, rounding halfway cases away from
315 zero. */
316__MATHCALLX (round,, (_Mdouble_ __x), (__const__));
317
318/* Round X to the integral value in floating-point format nearest but
319 not larger in magnitude. */
320__MATHCALLX (trunc,, (_Mdouble_ __x), (__const__));
321
322/* Compute remainder of X and Y and put in *QUO a value with sign of x/y
323 and magnitude congruent `mod 2^n' to the magnitude of the integral
324 quotient x/y, with n >= 3. */
325__MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));
326
327
328/* Conversion functions. */
329
330/* Round X to nearest integral value according to current rounding
331 direction. */
332__MATHDECL (long int,lrint,, (_Mdouble_ __x));
333__extension__
334__MATHDECL (long long int,llrint,, (_Mdouble_ __x));
335
336/* Round X to nearest integral value, rounding halfway cases away from
337 zero. */
338__MATHDECL (long int,lround,, (_Mdouble_ __x));
339__extension__
340__MATHDECL (long long int,llround,, (_Mdouble_ __x));
341
342
343/* Return positive difference between X and Y. */
344__MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y));
345
346# if !__MATH_DECLARING_FLOATN || defined __USE_GNU || !__GLIBC_USE (ISOC23)
347/* Return maximum numeric value from X and Y. */
348__MATHCALLX (fmax,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
349
350/* Return minimum numeric value from X and Y. */
351__MATHCALLX (fmin,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
352# endif
353
354/* Multiply-add function computed as a ternary operation. */
355__MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));
356#endif /* Use ISO C99. */
357
358#if __GLIBC_USE (IEC_60559_BFP_EXT_C23) || __MATH_DECLARING_FLOATN
359/* Round X to nearest integer value, rounding halfway cases to even. */
360__MATHCALLX (roundeven,, (_Mdouble_ __x), (__const__));
361
362/* Round X to nearest signed integer value, not raising inexact, with
363 control of rounding direction and width of result. */
364__MATHDECL (__intmax_t, fromfp,, (_Mdouble_ __x, int __round,
365 unsigned int __width));
366
367/* Round X to nearest unsigned integer value, not raising inexact,
368 with control of rounding direction and width of result. */
369__MATHDECL (__uintmax_t, ufromfp,, (_Mdouble_ __x, int __round,
370 unsigned int __width));
371
372/* Round X to nearest signed integer value, raising inexact for
373 non-integers, with control of rounding direction and width of
374 result. */
375__MATHDECL (__intmax_t, fromfpx,, (_Mdouble_ __x, int __round,
376 unsigned int __width));
377
378/* Round X to nearest unsigned integer value, raising inexact for
379 non-integers, with control of rounding direction and width of
380 result. */
381__MATHDECL (__uintmax_t, ufromfpx,, (_Mdouble_ __x, int __round,
382 unsigned int __width));
383
384/* Canonicalize floating-point representation. */
385__MATHDECL_1 (int, canonicalize,, (_Mdouble_ *__cx, const _Mdouble_ *__x));
386#endif
387
388#if (__GLIBC_USE (IEC_60559_BFP_EXT) \
389 || (__MATH_DECLARING_FLOATN \
390 && (defined __USE_GNU || !__GLIBC_USE (ISOC23))))
391/* Return value with maximum magnitude. */
392__MATHCALLX (fmaxmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
393
394/* Return value with minimum magnitude. */
395__MATHCALLX (fminmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
396#endif
397
398#if __GLIBC_USE (ISOC23)
399/* Return maximum value from X and Y. */
400__MATHCALLX (fmaximum,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
401
402/* Return minimum value from X and Y. */
403__MATHCALLX (fminimum,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
404
405/* Return maximum numeric value from X and Y. */
406__MATHCALLX (fmaximum_num,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
407
408/* Return minimum numeric value from X and Y. */
409__MATHCALLX (fminimum_num,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
410
411/* Return value with maximum magnitude. */
412__MATHCALLX (fmaximum_mag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
413
414/* Return value with minimum magnitude. */
415__MATHCALLX (fminimum_mag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
416
417/* Return numeric value with maximum magnitude. */
418__MATHCALLX (fmaximum_mag_num,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
419
420/* Return numeric value with minimum magnitude. */
421__MATHCALLX (fminimum_mag_num,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
422#endif
423
424#if __GLIBC_USE (IEC_60559_EXT) || __MATH_DECLARING_FLOATN
425/* Total order operation. */
426__MATHDECL_1 (int, totalorder,, (const _Mdouble_ *__x,
427 const _Mdouble_ *__y))
428 __attribute_pure__;
429
430/* Total order operation on absolute values. */
431__MATHDECL_1 (int, totalordermag,, (const _Mdouble_ *__x,
432 const _Mdouble_ *__y))
433 __attribute_pure__;
434
435/* Get NaN payload. */
436__MATHCALL (getpayload,, (const _Mdouble_ *__x));
437
438/* Set quiet NaN payload. */
439__MATHDECL_1 (int, setpayload,, (_Mdouble_ *__x, _Mdouble_ __payload));
440
441/* Set signaling NaN payload. */
442__MATHDECL_1 (int, setpayloadsig,, (_Mdouble_ *__x, _Mdouble_ __payload));
443#endif
444
445#if (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \
446 && __MATH_DECLARING_DOUBLE \
447 && !defined __USE_XOPEN2K8)) \
448 && !__MATH_DECLARING_FLOATN
449/* Return X times (2 to the Nth power). */
450__MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
451#endif
452