Update.
[glibc.git] / math / bits / mathcalls.h
blob97bda451aae5ab673932041658e65253eaa737be
1 /* Prototype declarations for math functions; helper file for <math.h>.
2 Copyright (C) 1996, 1997, 1998, 1999 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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 /* NOTE: Because of the special way this file is used by <math.h>, this
21 file must NOT be protected from multiple inclusion as header files
22 usually are.
24 This file provides prototype declarations for the math functions.
25 Most functions are declared using the macro:
27 __MATHCALL (NAME,[_r], (ARGS...));
29 This means there is a function `NAME' returning `double' and a function
30 `NAMEf' returning `float'. Each place `_Mdouble_' appears in the
31 prototype, that is actually `double' in the prototype for `NAME' and
32 `float' in the prototype for `NAMEf'. Reentrant variant functions are
33 called `NAME_r' and `NAMEf_r'.
35 Functions returning other types like `int' are declared using the macro:
37 __MATHDECL (TYPE, NAME,[_r], (ARGS...));
39 This is just like __MATHCALL but for a function returning `TYPE'
40 instead of `_Mdouble_'. In all of these cases, there is still
41 both a `NAME' and a `NAMEf' that takes `float' arguments.
43 Note that there must be no whitespace before the argument passed for
44 NAME, to make token pasting work with -traditional. */
46 #ifndef _MATH_H
47 #error "Never include <bits/mathcalls.h> directly; include <math.h> instead."
48 #endif
51 /* Trigonometric functions. */
53 /* Arc cosine of X. */
54 __MATHCALL (acos,, (_Mdouble_ __x));
55 /* Arc sine of X. */
56 __MATHCALL (asin,, (_Mdouble_ __x));
57 /* Arc tangent of X. */
58 __MATHCALL (atan,, (_Mdouble_ __x));
59 /* Arc tangent of Y/X. */
60 __MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x));
62 /* Cosine of X. */
63 __MATHCALL (cos,, (_Mdouble_ __x));
64 /* Sine of X. */
65 __MATHCALL (sin,, (_Mdouble_ __x));
66 /* Tangent of X. */
67 __MATHCALL (tan,, (_Mdouble_ __x));
69 #ifdef __USE_GNU
70 /* Cosine and sine of X. */
71 __MATHDECL (void,sincos,,
72 (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx));
73 #endif
75 /* Hyperbolic functions. */
77 /* Hyperbolic cosine of X. */
78 __MATHCALL (cosh,, (_Mdouble_ __x));
79 /* Hyperbolic sine of X. */
80 __MATHCALL (sinh,, (_Mdouble_ __x));
81 /* Hyperbolic tangent of X. */
82 __MATHCALL (tanh,, (_Mdouble_ __x));
84 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X
85 /* Hyperbolic arc cosine of X. */
86 __MATHCALL (acosh,, (_Mdouble_ __x));
87 /* Hyperbolic arc sine of X. */
88 __MATHCALL (asinh,, (_Mdouble_ __x));
89 /* Hyperbolic arc tangent of X. */
90 __MATHCALL (atanh,, (_Mdouble_ __x));
91 #endif
93 /* Exponential and logarithmic functions. */
95 /* Exponential function of X. */
96 __MATHCALL (exp,, (_Mdouble_ __x));
98 #ifdef __USE_GNU
99 /* A function missing in all standards: compute exponent to base ten. */
100 __MATHCALL (exp10,, (_Mdouble_ __x));
101 /* Another name occasionally used. */
102 __MATHCALL (pow10,, (_Mdouble_ __x));
103 #endif
105 /* Break VALUE into a normalized fraction and an integral power of 2. */
106 __MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent));
108 /* X times (two to the EXP power). */
109 __MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent));
111 /* Natural logarithm of X. */
112 __MATHCALL (log,, (_Mdouble_ __x));
114 /* Base-ten logarithm of X. */
115 __MATHCALL (log10,, (_Mdouble_ __x));
117 /* Break VALUE into integral and fractional parts. */
118 __MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr));
120 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X
121 /* Return exp(X) - 1. */
122 __MATHCALL (expm1,, (_Mdouble_ __x));
124 /* Return log(1 + X). */
125 __MATHCALL (log1p,, (_Mdouble_ __x));
127 /* Return the base 2 signed integral exponent of X. */
128 __MATHCALL (logb,, (_Mdouble_ __x));
129 #endif
131 #ifdef __USE_ISOC9X
132 /* Compute base-2 exponential of X. */
133 __MATHCALL (exp2,, (_Mdouble_ __x));
135 /* Compute base-2 logarithm of X. */
136 __MATHCALL (log2,, (_Mdouble_ __x));
137 #endif
140 /* Power functions. */
142 /* Return X to the Y power. */
143 __MATHCALL (pow,, (_Mdouble_ __x, _Mdouble_ __y));
145 /* Return the square root of X. */
146 __MATHCALL (sqrt,, (_Mdouble_ __x));
148 #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC9X
149 /* Return `sqrt(X*X + Y*Y)'. */
150 __MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
151 #endif
153 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X
154 /* Return the cube root of X. */
155 __MATHCALL (cbrt,, (_Mdouble_ __x));
156 #endif
159 /* Nearest integer, absolute value, and remainder functions. */
161 /* Smallest integral value not less than X. */
162 __MATHCALL (ceil,, (_Mdouble_ __x));
164 /* Absolute value of X. */
165 __MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
167 /* Largest integer not greater than X. */
168 __MATHCALL (floor,, (_Mdouble_ __x));
170 /* Floating-point modulo remainder of X/Y. */
171 __MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
174 /* Return 0 if VALUE is finite or NaN, +1 if it
175 is +Infinity, -1 if it is -Infinity. */
176 __MATHDECL_1 (int,__isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
178 /* Return nonzero if VALUE is finite and not NaN. */
179 __MATHDECL_1 (int,__finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
181 #ifdef __USE_MISC
182 /* Return 0 if VALUE is finite or NaN, +1 if it
183 is +Infinity, -1 if it is -Infinity. */
184 __MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
186 /* Return nonzero if VALUE is finite and not NaN. */
187 __MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
189 /* Deal with an infinite or NaN result.
190 If ERROR is ERANGE, result is +Inf;
191 if ERROR is - ERANGE, result is -Inf;
192 otherwise result is NaN.
193 This will set `errno' to either ERANGE or EDOM,
194 and may return an infinity or NaN, or may do something else. */
195 __MATHCALLX (infnan,, (int __error), (__const__));
197 /* Return the remainder of X/Y. */
198 __MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
201 /* Return the fractional part of X after dividing out `ilogb (X)'. */
202 __MATHCALL (significand,, (_Mdouble_ __x));
203 #endif /* Use misc. */
205 #if defined __USE_MISC || defined __USE_ISOC9X
206 /* Return X with its signed changed to Y's. */
207 __MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
208 #endif
210 #ifdef __USE_ISOC9X
211 /* Return representation of NaN for double type. */
212 __MATHCALLX (nan,, (__const char *__tagb), (__const__));
213 #endif
216 /* Return nonzero if VALUE is not a number. */
217 __MATHDECL_1 (int,__isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
219 #if defined __USE_MISC || defined __USE_XOPEN
220 /* Return nonzero if VALUE is not a number. */
221 __MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
223 /* Bessel functions. */
224 __MATHCALL (j0,, (_Mdouble_));
225 __MATHCALL (j1,, (_Mdouble_));
226 __MATHCALL (jn,, (int, _Mdouble_));
227 __MATHCALL (y0,, (_Mdouble_));
228 __MATHCALL (y1,, (_Mdouble_));
229 __MATHCALL (yn,, (int, _Mdouble_));
230 #endif
233 #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC9X
234 /* Error and gamma functions. */
235 __MATHCALL (erf,, (_Mdouble_));
236 __MATHCALL (erfc,, (_Mdouble_));
237 __MATHCALL (lgamma,, (_Mdouble_));
238 __MATHCALL (tgamma,, (_Mdouble_));
239 #endif
241 #if defined __USE_MISC || defined __USE_XOPEN
242 /* Obsolete alias for `lgamma'. */
243 __MATHCALL (gamma,, (_Mdouble_));
244 #endif
246 #ifdef __USE_MISC
247 /* Reentrant version of lgamma. This function uses the global variable
248 `signgam'. The reentrant version instead takes a pointer and stores
249 the value through it. */
250 __MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp));
251 #endif
254 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X
255 /* Return the integer nearest X in the direction of the
256 prevailing rounding mode. */
257 __MATHCALL (rint,, (_Mdouble_ __x));
259 /* Return X + epsilon if X < Y, X - epsilon if X > Y. */
260 __MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
261 # ifdef __USE_ISOC9X
262 __MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__));
263 # endif
265 /* Return the remainder of integer divison X / Y with infinite precision. */
266 __MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
268 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
269 /* Return X times (2 to the Nth power). */
270 __MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
271 # endif
273 /* Return X times (2 to the Nth power). */
274 __MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
276 /* Return the binary exponent of X, which must be nonzero. */
277 __MATHDECL (int,ilogb,, (_Mdouble_ __x));
278 #endif
280 #ifdef __USE_ISOC9X
281 /* Return X times (2 to the Nth power). */
282 __MATHCALL (scalbln,, (_Mdouble_ __x, long int __n));
284 /* Round X to integral value in floating-point format using current
285 rounding direction, but do not raise inexact exception. */
286 __MATHCALL (nearbyint,, (_Mdouble_ __x));
288 /* Round X to nearest integral value, rounding halfway cases away from
289 zero. */
290 __MATHCALL (round,, (_Mdouble_ __x));
292 /* Round X to the integral value in floating-point format nearest but
293 not larger in magnitude. */
294 __MATHCALLX (trunc,, (_Mdouble_ __x), (__const__));
296 /* Compute remainder of X and Y and put in *QUO a value with sign of x/y
297 and magnitude congruent `mod 2^n' to the magnitude of the integral
298 quotient x/y, with n >= 3. */
299 __MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));
302 /* Conversion functions. */
304 /* Round X to nearest integral value according to current rounding
305 direction. */
306 __MATHDECL (long int,lrint,, (_Mdouble_ __x));
307 __MATHDECL (long long int,llrint,, (_Mdouble_ __x));
309 /* Round X to nearest integral value, rounding halfway cases away from
310 zero. */
311 __MATHDECL (long int,lround,, (_Mdouble_ __x));
312 __MATHDECL (long long int,llround,, (_Mdouble_ __x));
315 /* Return positive difference between X and Y. */
316 __MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y));
318 /* Return maximum numeric value from X and Y. */
319 __MATHCALL (fmax,, (_Mdouble_ __x, _Mdouble_ __y));
321 /* Return minimum numeric value from X and Y. */
322 __MATHCALL (fmin,, (_Mdouble_ __x, _Mdouble_ __y));
325 /* Classify given number. */
326 __MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value))
327 __attribute__ ((__const__));
329 /* Test for negative number. */
330 __MATHDECL_1 (int, __signbit,, (_Mdouble_ __value))
331 __attribute__ ((__const__));
334 /* Multiply-add function computed as a ternary operation. */
335 __MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));
336 #endif /* Use ISO C 9X. */