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