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