powerpc: Update ulps
[glibc.git] / math / bits / mathcalls.h
blobfbfc27a4522cd4e93f1368c9555ee2a0c3856213
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.
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.
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.
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/>. */
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.
23 This file provides prototype declarations for the math functions.
24 Most functions are declared using the macro:
26 __MATHCALL (NAME,[_r], (ARGS...));
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'.
34 Functions returning other types like `int' are declared using the macro:
36 __MATHDECL (TYPE, NAME,[_r], (ARGS...));
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.
42 Note that there must be no whitespace before the argument passed for
43 NAME, to make token pasting work with -traditional. */
45 #ifndef _MATH_H
46 # error "Never include <bits/mathcalls.h> directly; include <math.h> instead."
47 #endif
50 /* Trigonometric functions. */
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));
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));
68 /* Hyperbolic functions. */
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));
77 #ifdef __USE_GNU
78 /* Cosine and sine of X. */
79 __MATHDECL_VEC (void,sincos,,
80 (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx));
81 #endif
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
92 /* Exponential and logarithmic functions. */
94 /* Exponential function of X. */
95 __MATHCALL_VEC (exp,, (_Mdouble_ __x));
97 /* Break VALUE into a normalized fraction and an integral power of 2. */
98 __MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent));
100 /* X times (two to the EXP power). */
101 __MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent));
103 /* Natural logarithm of X. */
104 __MATHCALL_VEC (log,, (_Mdouble_ __x));
106 /* Base-ten logarithm of X. */
107 __MATHCALL_VEC (log10,, (_Mdouble_ __x));
109 /* Break VALUE into integral and fractional parts. */
110 __MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr)) __nonnull ((2));
112 #if __GLIBC_USE (IEC_60559_FUNCS_EXT_C23)
113 /* Compute exponent to base ten. */
114 __MATHCALL_VEC (exp10,, (_Mdouble_ __x));
116 /* Return log2(1 + X). */
117 __MATHCALL (log2p1,, (_Mdouble_ __x));
118 #endif
120 #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
121 /* Return exp(X) - 1. */
122 __MATHCALL_VEC (expm1,, (_Mdouble_ __x));
124 /* Return log(1 + X). */
125 __MATHCALL_VEC (log1p,, (_Mdouble_ __x));
127 /* Return the base 2 signed integral exponent of X. */
128 __MATHCALL (logb,, (_Mdouble_ __x));
129 #endif
131 #ifdef __USE_ISOC99
132 /* Compute base-2 exponential of X. */
133 __MATHCALL_VEC (exp2,, (_Mdouble_ __x));
135 /* Compute base-2 logarithm of X. */
136 __MATHCALL_VEC (log2,, (_Mdouble_ __x));
137 #endif
140 /* Power functions. */
142 /* Return X to the Y power. */
143 __MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
145 /* Return the square root of X. */
146 __MATHCALL (sqrt,, (_Mdouble_ __x));
148 #if defined __USE_XOPEN || defined __USE_ISOC99
149 /* Return `sqrt(X*X + Y*Y)'. */
150 __MATHCALL_VEC (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
151 #endif
153 #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
154 /* Return the cube root of X. */
155 __MATHCALL_VEC (cbrt,, (_Mdouble_ __x));
156 #endif
159 /* Nearest integer, absolute value, and remainder functions. */
161 /* Smallest integral value not less than X. */
162 __MATHCALLX (ceil,, (_Mdouble_ __x), (__const__));
164 /* Absolute value of X. */
165 __MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
167 /* Largest integer not greater than X. */
168 __MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
170 /* Floating-point modulo remainder of X/Y. */
171 __MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
173 #ifdef __USE_MISC
174 # if ((!defined __cplusplus \
175 || __cplusplus < 201103L /* isinf conflicts with C++11. */ \
176 || __MATH_DECLARING_DOUBLE == 0)) /* isinff or isinfl don't. */ \
177 && !__MATH_DECLARING_FLOATN
178 /* Return 0 if VALUE is finite or NaN, +1 if it
179 is +Infinity, -1 if it is -Infinity. */
180 __MATHDECL_ALIAS (int,isinf,, (_Mdouble_ __value), isinf)
181 __attribute__ ((__const__));
182 # endif
184 # if !__MATH_DECLARING_FLOATN
185 /* Return nonzero if VALUE is finite and not NaN. */
186 __MATHDECL_ALIAS (int,finite,, (_Mdouble_ __value), finite)
187 __attribute__ ((__const__));
189 /* Return the remainder of X/Y. */
190 __MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
193 /* Return the fractional part of X after dividing out `ilogb (X)'. */
194 __MATHCALL (significand,, (_Mdouble_ __x));
195 # endif
197 #endif /* Use misc. */
199 #ifdef __USE_ISOC99
200 /* Return X with its signed changed to Y's. */
201 __MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
202 #endif
204 #ifdef __USE_ISOC99
205 /* Return representation of qNaN for double type. */
206 __MATHCALL (nan,, (const char *__tagb));
207 #endif
210 #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
211 # if ((!defined __cplusplus \
212 || __cplusplus < 201103L /* isnan conflicts with C++11. */ \
213 || __MATH_DECLARING_DOUBLE == 0)) /* isnanf or isnanl don't. */ \
214 && !__MATH_DECLARING_FLOATN
215 /* Return nonzero if VALUE is not a number. */
216 __MATHDECL_ALIAS (int,isnan,, (_Mdouble_ __value), isnan)
217 __attribute__ ((__const__));
218 # endif
219 #endif
221 #if defined __USE_MISC || (defined __USE_XOPEN && __MATH_DECLARING_DOUBLE)
222 /* Bessel functions. */
223 __MATHCALL (j0,, (_Mdouble_));
224 __MATHCALL (j1,, (_Mdouble_));
225 __MATHCALL (jn,, (int, _Mdouble_));
226 __MATHCALL (y0,, (_Mdouble_));
227 __MATHCALL (y1,, (_Mdouble_));
228 __MATHCALL (yn,, (int, _Mdouble_));
229 #endif
232 #if defined __USE_XOPEN || defined __USE_ISOC99
233 /* Error and gamma functions. */
234 __MATHCALL_VEC (erf,, (_Mdouble_));
235 __MATHCALL_VEC (erfc,, (_Mdouble_));
236 __MATHCALL (lgamma,, (_Mdouble_));
237 #endif
239 #ifdef __USE_ISOC99
240 /* True gamma function. */
241 __MATHCALL (tgamma,, (_Mdouble_));
242 #endif
244 #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
245 # if !__MATH_DECLARING_FLOATN
246 /* Obsolete alias for `lgamma'. */
247 __MATHCALL (gamma,, (_Mdouble_));
248 # endif
249 #endif
251 #ifdef __USE_MISC
252 /* Reentrant version of lgamma. This function uses the global variable
253 `signgam'. The reentrant version instead takes a pointer and stores
254 the value through it. */
255 __MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp));
256 #endif
259 #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
260 /* Return the integer nearest X in the direction of the
261 prevailing rounding mode. */
262 __MATHCALL (rint,, (_Mdouble_ __x));
264 /* Return X + epsilon if X < Y, X - epsilon if X > Y. */
265 __MATHCALL (nextafter,, (_Mdouble_ __x, _Mdouble_ __y));
266 # if defined __USE_ISOC99 && !defined __LDBL_COMPAT && !__MATH_DECLARING_FLOATN
267 __MATHCALL (nexttoward,, (_Mdouble_ __x, long double __y));
268 # endif
270 # if __GLIBC_USE (IEC_60559_BFP_EXT_C23) || __MATH_DECLARING_FLOATN
271 /* Return X - epsilon. */
272 __MATHCALL (nextdown,, (_Mdouble_ __x));
273 /* Return X + epsilon. */
274 __MATHCALL (nextup,, (_Mdouble_ __x));
275 # endif
277 /* Return the remainder of integer division X / Y with infinite precision. */
278 __MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
280 # ifdef __USE_ISOC99
281 /* Return X times (2 to the Nth power). */
282 __MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
283 # endif
285 /* Return the binary exponent of X, which must be nonzero. */
286 __MATHDECL (int,ilogb,, (_Mdouble_ __x));
287 #endif
289 #if __GLIBC_USE (IEC_60559_BFP_EXT_C23) || __MATH_DECLARING_FLOATN
290 /* Like ilogb, but returning long int. */
291 __MATHDECL (long int, llogb,, (_Mdouble_ __x));
292 #endif
294 #ifdef __USE_ISOC99
295 /* Return X times (2 to the Nth power). */
296 __MATHCALL (scalbln,, (_Mdouble_ __x, long int __n));
298 /* Round X to integral value in floating-point format using current
299 rounding direction, but do not raise inexact exception. */
300 __MATHCALL (nearbyint,, (_Mdouble_ __x));
302 /* Round X to nearest integral value, rounding halfway cases away from
303 zero. */
304 __MATHCALLX (round,, (_Mdouble_ __x), (__const__));
306 /* Round X to the integral value in floating-point format nearest but
307 not larger in magnitude. */
308 __MATHCALLX (trunc,, (_Mdouble_ __x), (__const__));
310 /* Compute remainder of X and Y and put in *QUO a value with sign of x/y
311 and magnitude congruent `mod 2^n' to the magnitude of the integral
312 quotient x/y, with n >= 3. */
313 __MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));
316 /* Conversion functions. */
318 /* Round X to nearest integral value according to current rounding
319 direction. */
320 __MATHDECL (long int,lrint,, (_Mdouble_ __x));
321 __extension__
322 __MATHDECL (long long int,llrint,, (_Mdouble_ __x));
324 /* Round X to nearest integral value, rounding halfway cases away from
325 zero. */
326 __MATHDECL (long int,lround,, (_Mdouble_ __x));
327 __extension__
328 __MATHDECL (long long int,llround,, (_Mdouble_ __x));
331 /* Return positive difference between X and Y. */
332 __MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y));
334 # if !__MATH_DECLARING_FLOATN || defined __USE_GNU || !__GLIBC_USE (ISOC23)
335 /* Return maximum numeric value from X and Y. */
336 __MATHCALLX (fmax,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
338 /* Return minimum numeric value from X and Y. */
339 __MATHCALLX (fmin,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
340 # endif
342 /* Multiply-add function computed as a ternary operation. */
343 __MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));
344 #endif /* Use ISO C99. */
346 #if __GLIBC_USE (IEC_60559_BFP_EXT_C23) || __MATH_DECLARING_FLOATN
347 /* Round X to nearest integer value, rounding halfway cases to even. */
348 __MATHCALLX (roundeven,, (_Mdouble_ __x), (__const__));
350 /* Round X to nearest signed integer value, not raising inexact, with
351 control of rounding direction and width of result. */
352 __MATHDECL (__intmax_t, fromfp,, (_Mdouble_ __x, int __round,
353 unsigned int __width));
355 /* Round X to nearest unsigned integer value, not raising inexact,
356 with control of rounding direction and width of result. */
357 __MATHDECL (__uintmax_t, ufromfp,, (_Mdouble_ __x, int __round,
358 unsigned int __width));
360 /* Round X to nearest signed integer value, raising inexact for
361 non-integers, with control of rounding direction and width of
362 result. */
363 __MATHDECL (__intmax_t, fromfpx,, (_Mdouble_ __x, int __round,
364 unsigned int __width));
366 /* Round X to nearest unsigned integer value, raising inexact for
367 non-integers, with control of rounding direction and width of
368 result. */
369 __MATHDECL (__uintmax_t, ufromfpx,, (_Mdouble_ __x, int __round,
370 unsigned int __width));
372 /* Canonicalize floating-point representation. */
373 __MATHDECL_1 (int, canonicalize,, (_Mdouble_ *__cx, const _Mdouble_ *__x));
374 #endif
376 #if (__GLIBC_USE (IEC_60559_BFP_EXT) \
377 || (__MATH_DECLARING_FLOATN \
378 && (defined __USE_GNU || !__GLIBC_USE (ISOC23))))
379 /* Return value with maximum magnitude. */
380 __MATHCALLX (fmaxmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
382 /* Return value with minimum magnitude. */
383 __MATHCALLX (fminmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
384 #endif
386 #if __GLIBC_USE (ISOC23)
387 /* Return maximum value from X and Y. */
388 __MATHCALLX (fmaximum,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
390 /* Return minimum value from X and Y. */
391 __MATHCALLX (fminimum,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
393 /* Return maximum numeric value from X and Y. */
394 __MATHCALLX (fmaximum_num,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
396 /* Return minimum numeric value from X and Y. */
397 __MATHCALLX (fminimum_num,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
399 /* Return value with maximum magnitude. */
400 __MATHCALLX (fmaximum_mag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
402 /* Return value with minimum magnitude. */
403 __MATHCALLX (fminimum_mag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
405 /* Return numeric value with maximum magnitude. */
406 __MATHCALLX (fmaximum_mag_num,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
408 /* Return numeric value with minimum magnitude. */
409 __MATHCALLX (fminimum_mag_num,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
410 #endif
412 #if __GLIBC_USE (IEC_60559_EXT) || __MATH_DECLARING_FLOATN
413 /* Total order operation. */
414 __MATHDECL_1 (int, totalorder,, (const _Mdouble_ *__x,
415 const _Mdouble_ *__y))
416 __attribute_pure__;
418 /* Total order operation on absolute values. */
419 __MATHDECL_1 (int, totalordermag,, (const _Mdouble_ *__x,
420 const _Mdouble_ *__y))
421 __attribute_pure__;
423 /* Get NaN payload. */
424 __MATHCALL (getpayload,, (const _Mdouble_ *__x));
426 /* Set quiet NaN payload. */
427 __MATHDECL_1 (int, setpayload,, (_Mdouble_ *__x, _Mdouble_ __payload));
429 /* Set signaling NaN payload. */
430 __MATHDECL_1 (int, setpayloadsig,, (_Mdouble_ *__x, _Mdouble_ __payload));
431 #endif
433 #if (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \
434 && __MATH_DECLARING_DOUBLE \
435 && !defined __USE_XOPEN2K8)) \
436 && !__MATH_DECLARING_FLOATN
437 /* Return X times (2 to the Nth power). */
438 __MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
439 #endif