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 | |