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