math: add exception handling functionality
[uclibc-ng.git] / libc / sysdeps / linux / common / bits / mathcalls.h
bloba9e8a2931a77e0eca9cd0c9534bd52294ece242f
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
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 /* __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))
68 /* Arc sine of 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))
75 /* Cosine of X. */
76 __MATHCALLI (cos,, (_Mdouble_ __x))
77 # if defined _LIBC && defined _Mlong_double_
78 libm_hidden_proto(cosl)
79 # endif
80 # if defined _LIBC && defined _Mfloat_
81 libm_hidden_proto(cosf)
82 # endif
84 /* Sine of X. */
85 __MATHCALLI (sin,, (_Mdouble_ __x))
86 # if defined _LIBC && defined _Mlong_double_
87 libm_hidden_proto(sinl)
88 # endif
89 # if defined _LIBC && defined _Mfloat_
90 libm_hidden_proto(sinf)
91 # endif
93 /* Tangent of X. */
94 __MATHCALLI (tan,, (_Mdouble_ __x))
96 /* Hyperbolic functions. */
98 /* Hyperbolic cosine of X. */
99 __MATHCALLI (cosh,, (_Mdouble_ __x))
100 /* Hyperbolic sine of X. */
101 __MATHCALLI (sinh,, (_Mdouble_ __x))
102 /* Hyperbolic tangent of X. */
103 __MATHCALLI (tanh,, (_Mdouble_ __x))
104 _Mdouble_END_NAMESPACE
106 #if defined __USE_GNU
107 /* Cosine and sine of X. */
108 __MATHDECL (void,sincos,,
109 (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx))
110 #endif
112 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
113 __BEGIN_NAMESPACE_C99
114 /* Hyperbolic arc cosine of X. */
115 __MATHCALLI (acosh,, (_Mdouble_ __x))
116 /* Hyperbolic arc sine of X. */
117 __MATHCALLI (asinh,, (_Mdouble_ __x))
118 /* Hyperbolic arc tangent of X. */
119 __MATHCALLI (atanh,, (_Mdouble_ __x))
120 __END_NAMESPACE_C99
121 #endif
123 /* Exponential and logarithmic functions. */
125 _Mdouble_BEGIN_NAMESPACE
126 /* Exponential function of X. */
127 __MATHCALLI (exp,, (_Mdouble_ __x))
128 # if defined _LIBC && defined _Mlong_double_
129 libm_hidden_proto(expl)
130 # endif
132 /* Break VALUE into a normalized fraction and an integral power of 2. */
133 __MATHCALLI (frexp,, (_Mdouble_ __x, int *__exponent))
135 /* X times (two to the EXP power). */
136 __MATHCALLI (ldexp,, (_Mdouble_ __x, int __exponent))
138 /* Natural logarithm of X. */
139 __MATHCALLI (log,, (_Mdouble_ __x))
141 /* Base-ten logarithm of X. */
142 __MATHCALLI (log10,, (_Mdouble_ __x))
144 /* Break VALUE into integral and fractional parts. */
145 __MATHCALLI (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr))
146 _Mdouble_END_NAMESPACE
148 #if defined __USE_GNU
149 /* A function missing in all standards: compute exponent to base ten. */
150 __MATHCALLI (exp10,, (_Mdouble_ __x))
151 /* Another name occasionally used. */
152 __MATHCALLI (pow10,, (_Mdouble_ __x))
153 #endif
155 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
156 __BEGIN_NAMESPACE_C99
157 /* Return exp(X) - 1. */
158 __MATHCALLI (expm1,, (_Mdouble_ __x))
160 /* Return log(1 + X). */
161 __MATHCALLI (log1p,, (_Mdouble_ __x))
163 /* Return the base 2 signed integral exponent of X. */
164 __MATHCALLI (logb,, (_Mdouble_ __x))
165 __END_NAMESPACE_C99
166 #endif
168 #ifdef __USE_ISOC99
169 __BEGIN_NAMESPACE_C99
170 /* Compute base-2 exponential of X. */
171 __MATHCALLI (exp2,, (_Mdouble_ __x))
173 /* Compute base-2 logarithm of X. */
174 __MATHCALLI (log2,, (_Mdouble_ __x))
175 __END_NAMESPACE_C99
176 #endif
179 /* Power functions. */
181 _Mdouble_BEGIN_NAMESPACE
182 /* Return X to the Y power. */
183 __MATHCALLI (pow,, (_Mdouble_ __x, _Mdouble_ __y))
185 /* Return the square root of X. */
186 __MATHCALLI (sqrt,, (_Mdouble_ __x))
187 _Mdouble_END_NAMESPACE
189 #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
190 __BEGIN_NAMESPACE_C99
191 /* Return `sqrt(X*X + Y*Y)'. */
192 __MATHCALLI (hypot,, (_Mdouble_ __x, _Mdouble_ __y))
193 # if defined _LIBC && defined _Mlong_double_
194 libm_hidden_proto(hypotl)
195 # endif
196 __END_NAMESPACE_C99
197 #endif
199 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
200 __BEGIN_NAMESPACE_C99
201 /* Return the cube root of X. */
202 __MATHCALLI (cbrt,, (_Mdouble_ __x))
203 __END_NAMESPACE_C99
204 #endif
207 /* Nearest integer, absolute value, and remainder functions. */
209 _Mdouble_BEGIN_NAMESPACE
210 /* Smallest integral value not less than X. */
211 __MATHCALLX (ceil,, (_Mdouble_ __x), (__const__))
213 /* Absolute value of X. */
214 __MATHCALLX (fabs,, (_Mdouble_ __x), (__const__))
216 /* Largest integer not greater than X. */
217 __MATHCALLX (floor,, (_Mdouble_ __x), (__const__))
219 /* Floating-point modulo remainder of X/Y. */
220 __MATHCALLI (fmod,, (_Mdouble_ __x, _Mdouble_ __y))
223 /* Return 0 if VALUE is finite or NaN, +1 if it
224 is +Infinity, -1 if it is -Infinity. */
225 __MATHDECL_PRIV (int,isinf,, (_Mdouble_ __value), (__const__))
227 /* Return nonzero if VALUE is finite and not NaN. */
228 __MATHDECL_PRIV (int,finite,, (_Mdouble_ __value), (__const__))
229 _Mdouble_END_NAMESPACE
231 #ifdef __USE_MISC
232 #if 0
233 /* Return 0 if VALUE is finite or NaN, +1 if it
234 is +Infinity, -1 if it is -Infinity. */
235 __MATHDECL_PRIV (int,isinf,, (_Mdouble_ __value), (__const__))
237 /* Return nonzero if VALUE is finite and not NaN. */
238 __MATHDECL_PRIV (int,finite,, (_Mdouble_ __value), (__const__))
239 #endif
240 /* Return the remainder of X/Y. */
241 __MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y))
244 /* Return the fractional part of X after dividing out `ilogb (X)'. */
245 __MATHCALLI (significand,, (_Mdouble_ __x))
246 #endif /* Use misc. */
248 #if defined __USE_MISC || defined __USE_ISOC99
249 __BEGIN_NAMESPACE_C99
250 /* Return X with its signed changed to Y's. */
251 __MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__))
252 __END_NAMESPACE_C99
253 #endif
255 #ifdef __USE_ISOC99
256 __BEGIN_NAMESPACE_C99
257 /* Return representation of NaN for double type. */
258 __MATHCALLX (nan,, (const char *__tagb), (__const__))
259 __END_NAMESPACE_C99
260 #endif
262 #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
263 /* Return nonzero if VALUE is not a number. */
264 __BEGIN_NAMESPACE_C99
265 __MATHDECL_PRIV (int,isnan,, (_Mdouble_ __value), (__const__))
266 __END_NAMESPACE_C99
267 #endif
269 #if defined __USE_MISC || defined __USE_XOPEN
270 # ifdef __DO_XSI_MATH__
271 /* Bessel functions. */
272 __MATHCALL (j0,, (_Mdouble_))
273 __MATHCALL (j1,, (_Mdouble_))
274 __MATHCALL (jn,, (int, _Mdouble_))
275 __MATHCALL (y0,, (_Mdouble_))
276 __MATHCALL (y1,, (_Mdouble_))
277 __MATHCALL (yn,, (int, _Mdouble_))
278 # endif
279 #endif
282 #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
283 __BEGIN_NAMESPACE_C99
284 /* Error and gamma functions. */
285 __MATHCALLI (erf,, (_Mdouble_))
286 __MATHCALLI (erfc,, (_Mdouble_))
287 __MATHCALLI (lgamma,, (_Mdouble_))
288 __END_NAMESPACE_C99
289 #endif
291 #ifdef __USE_ISOC99
292 __BEGIN_NAMESPACE_C99
293 /* True gamma function. */
294 __MATHCALLI (tgamma,, (_Mdouble_))
295 __END_NAMESPACE_C99
296 #endif
298 #if defined __USE_MISC || defined __USE_XOPEN
299 /* Obsolete alias for `lgamma'. */
300 __MATHCALLI (gamma,, (_Mdouble_))
301 #endif
303 //#ifdef __USE_MISC
304 /* To provide compatibility with finite-math-only in C99 and C11
305 * standerts function lgamma_r should be declared, when defined __USE_MISC.
307 /* Reentrant version of lgamma. This function uses the global variable
308 `signgam'. The reentrant version instead takes a pointer and stores
309 the value through it. */
310 __MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp))
311 /* __MATHCALLI does not work here, probably due to ,_r, */
312 libm_hidden_proto(lgamma_r)
313 //#endif
316 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
317 __BEGIN_NAMESPACE_C99
318 /* Return the integer nearest X in the direction of the
319 prevailing rounding mode. */
320 __MATHCALLI (rint,, (_Mdouble_ __x))
322 /* Return X + epsilon if X < Y, X - epsilon if X > Y. */
323 __MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__))
324 # if defined _LIBC && defined _Mlong_double_
325 libm_hidden_proto(nextafterl)
326 # endif
327 # if defined __USE_ISOC99 && !defined __LDBL_COMPAT
328 __MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__))
329 # endif
331 /* Return the remainder of integer divison X / Y with infinite precision. */
332 __MATHCALLI (remainder,, (_Mdouble_ __x, _Mdouble_ __y))
334 # if defined __USE_MISC || defined __USE_ISOC99
335 /* Return X times (2 to the Nth power). */
336 __MATHCALLI (scalbn,, (_Mdouble_ __x, int __n))
337 # endif
339 /* Return the binary exponent of X, which must be nonzero. */
340 __MATHDECLI (int,ilogb,, (_Mdouble_ __x))
341 #endif
343 #ifdef __USE_ISOC99
344 /* Return X times (2 to the Nth power). */
345 __MATHCALLI (scalbln,, (_Mdouble_ __x, long int __n))
347 /* Round X to integral value in floating-point format using current
348 rounding direction, but do not raise inexact exception. */
349 __MATHCALLI (nearbyint,, (_Mdouble_ __x))
351 /* Round X to nearest integral value, rounding halfway cases away from
352 zero. */
353 __MATHCALLX (round,, (_Mdouble_ __x), (__const__))
355 /* Round X to the integral value in floating-point format nearest but
356 not larger in magnitude. */
357 __MATHCALLX (trunc,, (_Mdouble_ __x), (__const__))
359 /* Compute remainder of X and Y and put in *QUO a value with sign of x/y
360 and magnitude congruent `mod 2^n' to the magnitude of the integral
361 quotient x/y, with n >= 3. */
362 __MATHCALLI (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo))
365 /* Conversion functions. */
367 /* Round X to nearest integral value according to current rounding
368 direction. */
369 __MATHDECLI (long int,lrint,, (_Mdouble_ __x))
370 __MATHDECLI (long long int,llrint,, (_Mdouble_ __x))
372 /* Round X to nearest integral value, rounding halfway cases away from
373 zero. */
374 __MATHDECLI (long int,lround,, (_Mdouble_ __x))
375 __MATHDECLI (long long int,llround,, (_Mdouble_ __x))
378 /* Return positive difference between X and Y. */
379 __MATHCALLI (fdim,, (_Mdouble_ __x, _Mdouble_ __y))
381 /* Return maximum numeric value from X and Y. */
382 __MATHCALLI (fmax,, (_Mdouble_ __x, _Mdouble_ __y))
384 /* Return minimum numeric value from X and Y. */
385 __MATHCALLI (fmin,, (_Mdouble_ __x, _Mdouble_ __y))
388 /* Classify given number. */
389 __MATHDECL_PRIV (int, fpclassify,, (_Mdouble_ __value), (__const__))
391 /* Test for negative number. */
392 __MATHDECL_PRIV (int, signbit,, (_Mdouble_ __value), (__const__))
395 /* Multiply-add function computed as a ternary operation. */
396 __MATHCALLI (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z))
397 #endif /* Use ISO C99. */
399 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
400 __END_NAMESPACE_C99
401 #endif
403 #if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) \
404 && defined __UCLIBC_SUSV3_LEGACY__
405 /* Return X times (2 to the Nth power). */
406 __MATHCALLI (scalb,, (_Mdouble_ __x, _Mdouble_ __n))
407 #endif