1 /* Prototype declarations for math functions; helper file for <math.h>.
2 Copyright (C) 1996-2002, 2003, 2006 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 <http://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
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. */
46 # error "Never include <bits/mathcalls.h> directly; include <math.h> instead."
50 /* __MATHCALLX(type,function,[suffix],args,attrib) and
51 * __MATHCALLI(type,function,[suffix],args) include libm_hidden_proto
52 * (for "double" versions only, xxxf and xxxl do not get this treatment).
54 * __MATHDECL(type,function,[suffix],args) does not.
55 * __MATHCALL(function,[suffix],args) also does not
56 * (it is just a shortcut to __MATHDECL(_Mdouble_,function,[suffix],args)).
58 * __MATHDECL_PRIV(type,function,[suffix],args,attrib)
59 * includes libm_hidden_proto (always) and declares __foo, not foo.
63 /* Trigonometric functions. */
65 _Mdouble_BEGIN_NAMESPACE
66 /* Arc cosine of X. */
67 __MATHCALLI (acos,, (_Mdouble_ __x))
69 __MATHCALLI (asin,, (_Mdouble_ __x))
70 /* Arc tangent of X. */
71 __MATHCALLI (atan,, (_Mdouble_ __x))
72 /* Arc tangent of Y/X. */
73 __MATHCALLI (atan2,, (_Mdouble_ __y, _Mdouble_ __x))
76 __MATHCALLI (cos,, (_Mdouble_ __x))
78 __MATHCALLI (sin,, (_Mdouble_ __x))
80 __MATHCALLI (tan,, (_Mdouble_ __x))
82 /* Hyperbolic functions. */
84 /* Hyperbolic cosine of X. */
85 __MATHCALLI (cosh,, (_Mdouble_ __x))
86 /* Hyperbolic sine of X. */
87 __MATHCALLI (sinh,, (_Mdouble_ __x))
88 /* Hyperbolic tangent of X. */
89 __MATHCALLI (tanh,, (_Mdouble_ __x))
90 _Mdouble_END_NAMESPACE
93 /* Cosine and sine of X. */
94 __MATHDECL (void,sincos,,
95 (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx))
98 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
100 /* Hyperbolic arc cosine of X. */
101 __MATHCALLI (acosh,, (_Mdouble_ __x))
102 /* Hyperbolic arc sine of X. */
103 __MATHCALLI (asinh,, (_Mdouble_ __x))
104 /* Hyperbolic arc tangent of X. */
105 __MATHCALLI (atanh,, (_Mdouble_ __x))
109 /* Exponential and logarithmic functions. */
111 _Mdouble_BEGIN_NAMESPACE
112 /* Exponential function of X. */
113 __MATHCALLI (exp,, (_Mdouble_ __x))
115 /* Break VALUE into a normalized fraction and an integral power of 2. */
116 __MATHCALLI (frexp,, (_Mdouble_ __x, int *__exponent))
118 /* X times (two to the EXP power). */
119 __MATHCALLI (ldexp,, (_Mdouble_ __x, int __exponent))
121 /* Natural logarithm of X. */
122 __MATHCALLI (log,, (_Mdouble_ __x))
124 /* Base-ten logarithm of X. */
125 __MATHCALLI (log10,, (_Mdouble_ __x))
127 /* Break VALUE into integral and fractional parts. */
128 __MATHCALLI (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr))
129 _Mdouble_END_NAMESPACE
131 #if 0 /*def __USE_GNU*/
132 /* A function missing in all standards: compute exponent to base ten. */
133 __MATHCALL (exp10,, (_Mdouble_ __x))
134 /* Another name occasionally used. */
135 __MATHCALL (pow10,, (_Mdouble_ __x))
138 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
139 __BEGIN_NAMESPACE_C99
140 /* Return exp(X) - 1. */
141 __MATHCALLI (expm1,, (_Mdouble_ __x))
143 /* Return log(1 + X). */
144 __MATHCALLI (log1p,, (_Mdouble_ __x))
146 /* Return the base 2 signed integral exponent of X. */
147 __MATHCALLI (logb,, (_Mdouble_ __x))
152 __BEGIN_NAMESPACE_C99
153 /* Compute base-2 exponential of X. */
154 __MATHCALLI (exp2,, (_Mdouble_ __x))
156 /* Compute base-2 logarithm of X. */
157 __MATHCALLI (log2,, (_Mdouble_ __x))
162 /* Power functions. */
164 _Mdouble_BEGIN_NAMESPACE
165 /* Return X to the Y power. */
166 __MATHCALLI (pow,, (_Mdouble_ __x, _Mdouble_ __y))
168 /* Return the square root of X. */
169 __MATHCALLI (sqrt,, (_Mdouble_ __x))
170 _Mdouble_END_NAMESPACE
172 #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
173 __BEGIN_NAMESPACE_C99
174 /* Return `sqrt(X*X + Y*Y)'. */
175 __MATHCALLI (hypot,, (_Mdouble_ __x, _Mdouble_ __y))
179 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
180 __BEGIN_NAMESPACE_C99
181 /* Return the cube root of X. */
182 __MATHCALLI (cbrt,, (_Mdouble_ __x))
187 /* Nearest integer, absolute value, and remainder functions. */
189 _Mdouble_BEGIN_NAMESPACE
190 /* Smallest integral value not less than X. */
191 __MATHCALLX (ceil,, (_Mdouble_ __x), (__const__))
193 /* Absolute value of X. */
194 __MATHCALLX (fabs,, (_Mdouble_ __x), (__const__))
196 /* Largest integer not greater than X. */
197 __MATHCALLX (floor,, (_Mdouble_ __x), (__const__))
199 /* Floating-point modulo remainder of X/Y. */
200 __MATHCALLI (fmod,, (_Mdouble_ __x, _Mdouble_ __y))
203 /* Return 0 if VALUE is finite or NaN, +1 if it
204 is +Infinity, -1 if it is -Infinity. */
205 __MATHDECL_PRIV (int,isinf,, (_Mdouble_ __value), (__const__))
207 /* Return nonzero if VALUE is finite and not NaN. */
208 __MATHDECL_PRIV (int,finite,, (_Mdouble_ __value), (__const__))
209 _Mdouble_END_NAMESPACE
213 /* Return 0 if VALUE is finite or NaN, +1 if it
214 is +Infinity, -1 if it is -Infinity. */
215 __MATHDECL_PRIV (int,isinf,, (_Mdouble_ __value), (__const__))
217 /* Return nonzero if VALUE is finite and not NaN. */
218 __MATHDECL_PRIV (int,finite,, (_Mdouble_ __value), (__const__))
220 /* Return the remainder of X/Y. */
221 __MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y))
224 /* Return the fractional part of X after dividing out `ilogb (X)'. */
225 __MATHCALLI (significand,, (_Mdouble_ __x))
226 #endif /* Use misc. */
228 #if defined __USE_MISC || defined __USE_ISOC99
229 __BEGIN_NAMESPACE_C99
230 /* Return X with its signed changed to Y's. */
231 __MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__))
236 __BEGIN_NAMESPACE_C99
237 /* Return representation of NaN for double type. */
238 __MATHCALLX (nan,, (__const char *__tagb), (__const__))
242 #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
243 /* Return nonzero if VALUE is not a number. */
244 __BEGIN_NAMESPACE_C99
245 __MATHDECL_PRIV (int,isnan,, (_Mdouble_ __value), (__const__))
249 #if defined __USE_MISC || defined __USE_XOPEN
250 # ifdef __DO_XSI_MATH__
251 /* Bessel functions. */
252 __MATHCALL (j0,, (_Mdouble_))
253 __MATHCALL (j1,, (_Mdouble_))
254 __MATHCALL (jn,, (int, _Mdouble_))
255 __MATHCALL (y0,, (_Mdouble_))
256 __MATHCALL (y1,, (_Mdouble_))
257 __MATHCALL (yn,, (int, _Mdouble_))
262 #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
263 __BEGIN_NAMESPACE_C99
264 /* Error and gamma functions. */
265 __MATHCALLI (erf,, (_Mdouble_))
266 __MATHCALLI (erfc,, (_Mdouble_))
267 __MATHCALLI (lgamma,, (_Mdouble_))
272 __BEGIN_NAMESPACE_C99
273 /* True gamma function. */
274 __MATHCALLI (tgamma,, (_Mdouble_))
278 #if defined __USE_MISC || defined __USE_XOPEN
279 /* Obsolete alias for `lgamma'. */
280 __MATHCALLI (gamma,, (_Mdouble_))
284 /* Reentrant version of lgamma. This function uses the global variable
285 `signgam'. The reentrant version instead takes a pointer and stores
286 the value through it. */
287 __MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp))
288 /* __MATHCALLI does not work here, probably due to ,_r, */
289 libm_hidden_proto(lgamma_r)
293 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
294 __BEGIN_NAMESPACE_C99
295 /* Return the integer nearest X in the direction of the
296 prevailing rounding mode. */
297 __MATHCALLI (rint,, (_Mdouble_ __x))
299 /* Return X + epsilon if X < Y, X - epsilon if X > Y. */
300 __MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__))
301 # if defined __USE_ISOC99 && !defined __LDBL_COMPAT
302 __MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__))
305 /* Return the remainder of integer divison X / Y with infinite precision. */
306 __MATHCALLI (remainder,, (_Mdouble_ __x, _Mdouble_ __y))
308 # if defined __USE_MISC || defined __USE_ISOC99
309 /* Return X times (2 to the Nth power). */
310 __MATHCALLI (scalbn,, (_Mdouble_ __x, int __n))
313 /* Return the binary exponent of X, which must be nonzero. */
314 __MATHDECLI (int,ilogb,, (_Mdouble_ __x))
318 /* Return X times (2 to the Nth power). */
319 __MATHCALLI (scalbln,, (_Mdouble_ __x, long int __n))
321 /* Round X to integral value in floating-point format using current
322 rounding direction, but do not raise inexact exception. */
323 __MATHCALLI (nearbyint,, (_Mdouble_ __x))
325 /* Round X to nearest integral value, rounding halfway cases away from
327 __MATHCALLX (round,, (_Mdouble_ __x), (__const__))
329 /* Round X to the integral value in floating-point format nearest but
330 not larger in magnitude. */
331 __MATHCALLX (trunc,, (_Mdouble_ __x), (__const__))
333 /* Compute remainder of X and Y and put in *QUO a value with sign of x/y
334 and magnitude congruent `mod 2^n' to the magnitude of the integral
335 quotient x/y, with n >= 3. */
336 __MATHCALLI (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo))
339 /* Conversion functions. */
341 /* Round X to nearest integral value according to current rounding
343 __MATHDECLI (long int,lrint,, (_Mdouble_ __x))
344 __MATHDECLI (long long int,llrint,, (_Mdouble_ __x))
346 /* Round X to nearest integral value, rounding halfway cases away from
348 __MATHDECLI (long int,lround,, (_Mdouble_ __x))
349 __MATHDECLI (long long int,llround,, (_Mdouble_ __x))
352 /* Return positive difference between X and Y. */
353 __MATHCALLI (fdim,, (_Mdouble_ __x, _Mdouble_ __y))
355 /* Return maximum numeric value from X and Y. */
356 __MATHCALLI (fmax,, (_Mdouble_ __x, _Mdouble_ __y))
358 /* Return minimum numeric value from X and Y. */
359 __MATHCALLI (fmin,, (_Mdouble_ __x, _Mdouble_ __y))
362 /* Classify given number. */
363 __MATHDECL_PRIV (int, fpclassify,, (_Mdouble_ __value), (__const__))
365 /* Test for negative number. */
366 __MATHDECL_PRIV (int, signbit,, (_Mdouble_ __value), (__const__))
369 /* Multiply-add function computed as a ternary operation. */
370 __MATHCALLI (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z))
371 #endif /* Use ISO C99. */
373 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
377 #if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) \
378 && defined __UCLIBC_SUSV3_LEGACY__
379 /* Return X times (2 to the Nth power). */
380 __MATHCALLI (scalb,, (_Mdouble_ __x, _Mdouble_ __n))