msi/pci: Adjust pci_alloc_msi method interface
[dragonfly.git] / include / math.h
blob52ba5ec27004e7710426de86b8319c41156de8fe
1 /*
2 * ====================================================
3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 * Developed at SunPro, a Sun Microsystems, Inc. business.
6 * Permission to use, copy, modify, and distribute this
7 * software is freely granted, provided that this notice
8 * is preserved.
9 * ====================================================
11 * $NetBSD: math.h,v 1.46 2007/02/22 22:08:19 drochner Exp $
15 * @(#)fdlibm.h 5.1 93/09/24
18 #ifndef _MATH_H_
19 #define _MATH_H_
21 #include <sys/cdefs.h>
22 #include <machine/limits.h>
24 #if __GNUC_PREREQ__(3, 3) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
25 #define __MATH_BUILTIN_CONSTANTS
26 #endif
28 #if __GNUC_PREREQ__(3, 0) && !defined(__INTEL_COMPILER)
29 #define __MATH_BUILTIN_RELOPS
30 #endif
32 union __float_u {
33 unsigned char __dummy[sizeof(float)];
34 float __val;
37 union __double_u {
38 unsigned char __dummy[sizeof(double)];
39 double __val;
42 union __long_double_u {
43 unsigned char __dummy[sizeof(long double)];
44 long double __val;
47 #include <machine/math.h>
49 #ifdef __HAVE_LONG_DOUBLE
50 #define __fpmacro_unary_floating(__name, __arg0) \
51 /* LINTED */ \
52 ((sizeof (__arg0) == sizeof (float)) \
53 ? __ ## __name ## f (__arg0) \
54 : (sizeof (__arg0) == sizeof (double)) \
55 ? __ ## __name ## d (__arg0) \
56 : __ ## __name ## l (__arg0))
57 #else
58 #define __fpmacro_unary_floating(__name, __arg0) \
59 /* LINTED */ \
60 ((sizeof (__arg0) == sizeof (float)) \
61 ? __ ## __name ## f (__arg0) \
62 : __ ## __name ## d (__arg0))
63 #endif /* __HAVE_LONG_DOUBLE */
66 * ANSI/POSIX
68 /* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */
69 extern const union __double_u __infinity;
70 #ifdef __MATH_BUILTIN_CONSTANTS
71 #define HUGE_VAL __builtin_huge_val()
72 #else
73 #define HUGE_VAL __infinity.__val
74 #endif
77 * ISO C99
79 #if __ISO_C_VISIBLE >= 1999
80 /* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */
81 extern const union __float_u __infinityf;
82 #ifdef __MATH_BUILTIN_CONSTANTS
83 #define HUGE_VALF __builtin_huge_valf()
84 #else
85 #define HUGE_VALF __infinityf.__val
86 #endif
88 extern const union __long_double_u __infinityl;
89 #ifdef __MATH_BUILTIN_CONSTANTS
90 #define HUGE_VALL __builtin_huge_vall()
91 #else
92 #define HUGE_VALL __infinityl.__val
93 #endif
95 /* 7.12#4 INFINITY */
96 #ifdef __MATH_BUILTIN_CONSTANTS
97 #define INFINITY __builtin_inf()
98 #elif defined(__INFINITY)
99 #define INFINITY __INFINITY /* float constant which overflows */
100 #else
101 #define INFINITY HUGE_VALF /* positive infinity */
102 #endif /* __INFINITY */
104 /* 7.12#5 NAN: a quiet NaN, if supported */
105 #ifdef __MATH_BUILTIN_CONSTANTS
106 #define NAN __builtin_nan("")
107 #elif defined(__HAVE_NANF)
108 extern const union __float_u __nanf;
109 #define NAN __nanf.__val
110 #endif /* __HAVE_NANF */
112 /* 7.12#6 number classification macros */
113 #define FP_INFINITE 0x00
114 #define FP_NAN 0x01
115 #define FP_NORMAL 0x02
116 #define FP_SUBNORMAL 0x03
117 #define FP_ZERO 0x04
118 /* NetBSD extensions */
119 #define _FP_LOMD 0x80 /* range for machine-specific classes */
120 #define _FP_HIMD 0xff
122 /* 7.12#8 values returned by ilogb(0) or ilogb(NAN), respectively */
123 #define FP_ILOGB0 INT_MIN
124 #define FP_ILOGBNAN INT_MIN
126 #endif /* ISO C99 */
129 * XOPEN/SVID
131 #if __XSI_VISIBLE > 0
132 #define M_E 2.7182818284590452354 /* e */
133 #define M_LOG2E 1.4426950408889634074 /* log 2e */
134 #define M_LOG10E 0.43429448190325182765 /* log 10e */
135 #define M_LN2 0.69314718055994530942 /* log e2 */
136 #define M_LN10 2.30258509299404568402 /* log e10 */
137 #define M_PI 3.14159265358979323846 /* pi */
138 #define M_PI_2 1.57079632679489661923 /* pi/2 */
139 #define M_PI_4 0.78539816339744830962 /* pi/4 */
140 #define M_1_PI 0.31830988618379067154 /* 1/pi */
141 #define M_2_PI 0.63661977236758134308 /* 2/pi */
142 #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
143 #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
144 #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
146 #define MAXFLOAT ((float)3.40282346638528860e+38)
147 extern int signgam;
148 #endif /* _XSI_VISIBLE */
150 #if __DF_VISIBLE
151 #define HUGE MAXFLOAT
154 * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
155 * (one may replace the following line by "#include <values.h>")
158 #define X_TLOSS 1.41484755040568800000e+16
160 #define DOMAIN 1
161 #define SING 2
162 #define OVERFLOW 3
163 #define UNDERFLOW 4
164 #define TLOSS 5
165 #define PLOSS 6
167 #endif /* __DF_VISIBLE */
169 __BEGIN_DECLS
171 * ANSI/POSIX
173 double acos(double);
174 double asin(double);
175 double atan(double);
176 double atan2(double, double);
177 double cos(double);
178 double sin(double);
179 double tan(double);
181 double cosh(double);
182 double sinh(double);
183 double tanh(double);
185 double exp(double);
186 double exp2(double);
187 double frexp(double, int *);
188 double ldexp(double, int);
189 double log(double);
190 double log2(double);
191 double log10(double);
192 double modf(double, double *);
194 double pow(double, double);
195 double sqrt(double);
197 double ceil(double);
198 double fabs(double);
199 double floor(double);
200 double fmod(double, double);
202 #if __XSI_VISIBLE > 0
203 double erf(double);
204 double erfc(double);
205 double gamma(double);
206 double hypot(double, double);
207 int finite(double);
208 double j0(double);
209 double j1(double);
210 double jn(int, double);
211 double lgamma(double);
212 double tgamma(double);
213 double y0(double);
214 double y1(double);
215 double yn(int, double);
216 #endif /* __XSI_VISIBLE */
218 #if __XSI_VISIBLE >= 500
219 double acosh(double);
220 double asinh(double);
221 double atanh(double);
222 double cbrt(double);
223 double expm1(double);
224 int ilogb(double);
225 double log1p(double);
226 double logb(double);
227 double nextafter(double, double);
228 double remainder(double, double);
229 double rint(double);
230 double scalb(double, double);
231 #endif /* __XSI_VISIBLE >= 500 */
234 * ISO C99
236 #if __ISO_C_VISIBLE >= 1999
237 /* 7.12.3.1 int fpclassify(real-floating x) */
238 #define fpclassify(__x) __fpmacro_unary_floating(fpclassify, __x)
240 /* 7.12.3.2 int isfinite(real-floating x) */
241 #define isfinite(__x) __fpmacro_unary_floating(isfinite, __x)
243 /* 7.12.3.5 int isnormal(real-floating x) */
244 #define isnormal(__x) (fpclassify(__x) == FP_NORMAL)
246 /* 7.12.3.6 int signbit(real-floating x) */
247 #define signbit(__x) __fpmacro_unary_floating(signbit, __x)
249 /* 7.12.4 trigonometric */
251 float acosf(float);
252 float asinf(float);
253 float atanf(float);
254 float atan2f(float, float);
255 float cosf(float);
256 float sinf(float);
257 float tanf(float);
259 /* 7.12.5 hyperbolic */
261 float acoshf(float);
262 float asinhf(float);
263 float atanhf(float);
264 float coshf(float);
265 float sinhf(float);
266 float tanhf(float);
268 /* 7.12.6 exp / log */
270 float expf(float);
271 float exp2f(float);
272 float expm1f(float);
273 float frexpf(float, int *);
274 int ilogbf(float);
275 float ldexpf(float, int);
276 float logf(float);
277 float log2f(float);
278 float log10f(float);
279 float log1pf(float);
280 float logbf(float);
281 float modff(float, float *);
282 float scalblnf(float, long);
283 float scalbnf(float, int);
285 /* 7.12.7 power / absolute */
287 float cbrtf(float);
288 float fabsf(float);
289 float hypotf(float, float);
290 float powf(float, float);
291 float sqrtf(float);
293 /* 7.12.8 error / gamma */
295 float erff(float);
296 float erfcf(float);
297 float lgammaf(float);
298 float tgammaf(float);
300 /* 7.12.9 nearest integer */
302 float ceilf(float);
303 float floorf(float);
304 float nearbyintf(float);
305 double nearbyint(double);
306 float rintf(float);
307 double round(double);
308 float roundf(float);
309 double trunc(double);
310 float truncf(float);
311 long int lrint(double);
312 long int lrintf(float);
313 /* LONGLONG */
314 long long int llrint(double);
315 /* LONGLONG */
316 long long int llrintf(float);
317 long int lround(double);
318 long int lroundf(float);
319 /* LONGLONG */
320 long long int llround(double);
321 /* LONGLONG */
322 long long int llroundf(float);
324 /* 7.12.10 remainder */
326 float fmodf(float, float);
327 float remainderf(float, float);
329 /* 7.12.10.3 The remquo functions */
330 double remquo(double, double, int *);
331 float remquof(float, float, int *);
333 /* 7.12.11 manipulation */
335 float copysignf(float, float);
336 double nan(const char *);
337 float nanf(const char *);
338 float nextafterf(float, float);
340 /* 7.12.12 maximum, minimum, positive difference */
341 double fdim(double, double);
342 float fdimf(float, float);
344 double fmax(double, double);
345 float fmaxf(float, float);
347 double fmin(double, double);
348 float fminf(float, float);
351 /* isoC99 */
352 double fma (double, double, double);
353 float fmaf (float, float, float);
358 #endif /* __ISO_C_VISIBLE >= 1999 */
360 #if __ISO_C_VISIBLE >= 1999
361 /* 7.12.3.3 int isinf(real-floating x) */
362 #ifdef __isinf
363 #define isinf(__x) __isinf(__x)
364 #else
365 #define isinf(__x) __fpmacro_unary_floating(isinf, __x)
366 #endif
368 /* 7.12.3.4 int isnan(real-floating x) */
369 #ifdef __isnan
370 #define isnan(__x) __isnan(__x)
371 #else
372 #define isnan(__x) __fpmacro_unary_floating(isnan, __x)
373 #endif
375 /* 7.12.14 Comparision macros */
376 #ifdef __MATH_BUILTIN_RELOPS
377 #define isgreater(x, y) __builtin_isgreater((x), (y))
378 #define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y))
379 #define isless(x, y) __builtin_isless((x), (y))
380 #define islessequal(x, y) __builtin_islessequal((x), (y))
381 #define islessgreater(x, y) __builtin_islessgreater((x), (y))
382 #define isunordered(x, y) __builtin_isunordered((x), (y))
383 #else
384 #define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y))
385 #define isgreaterequal(x, y) (!isunordered((x), (y)) && (x) >= (y))
386 #define isless(x, y) (!isunordered((x), (y)) && (x) < (y))
387 #define islessequal(x, y) (!isunordered((x), (y)) && (x) <= (y))
388 #define islessgreater(x, y) (!isunordered((x), (y)) && \
389 ((x) > (y) || (y) > (x)))
390 #define isunordered(x, y) (isnan(x) || isnan(y))
391 #endif /* __MATH_BUILTIN_RELOPS */
393 #endif /* __ISO_C_VISIBLE >= 1999 */
395 #if __DF_VISIBLE
397 * IEEE Test Vector
399 double significand(double);
402 * Functions callable from C, intended to support IEEE arithmetic.
404 double copysign(double, double);
405 double scalbln(double, long);
406 double scalbn(double, int);
409 * BSD math library entry points
411 double drem(double, double);
414 * Reentrant version of gamma & lgamma; passes signgam back by reference
415 * as the second argument; user must allocate space for signgam.
417 double gamma_r(double, int *);
418 double lgamma_r(double, int *);
419 #endif /* __DF_VISIBLE */
422 #if __DF_VISIBLE
424 /* float versions of ANSI/POSIX functions */
426 float gammaf(float);
427 int finitef(float);
428 float j0f(float);
429 float j1f(float);
430 float jnf(int, float);
431 float y0f(float);
432 float y1f(float);
433 float ynf(int, float);
435 float scalbf(float, float);
438 * float version of IEEE Test Vector
440 float significandf(float);
443 * float versions of BSD math library entry points
445 float dremf(float, float);
448 * Float versions of reentrant version of gamma & lgamma; passes
449 * signgam back by reference as the second argument; user must
450 * allocate space for signgam.
452 float gammaf_r(float, int *);
453 float lgammaf_r(float, int *);
454 #endif /* __DF_VISIBLE */
457 * Library implementation
459 int __fpclassifyf(float);
460 int __fpclassifyd(double);
461 int __isfinitef(float);
462 int __isfinited(double);
463 int __isinff(float);
464 int __isinfd(double);
465 int __isnanf(float);
466 int __isnand(double);
467 int __signbitf(float);
468 int __signbitd(double);
470 #ifdef __HAVE_LONG_DOUBLE
471 int __fpclassifyl (long double);
472 int __isfinitel (long double);
473 int __isinfl (long double);
474 int __isnanl (long double);
475 int __signbitl (long double);
477 long double acosl (long double);
478 long double asinl (long double);
479 long double atan2l (long double, long double);
480 long double atanl (long double);
481 long double ceill (long double);
482 long double cosl (long double);
483 long double cbrtl (long double);
484 long double copysignl (long double, long double);
485 long double fdiml (long double, long double);
486 long double exp2l (long double);
487 long double fabsl (long double);
488 long double floorl (long double);
489 long double fmal (long double, long double, long double);
490 long double frexpl (long double, int *);
491 long double fmaxl (long double, long double);
492 long double fminl (long double, long double);
493 long double fmodl (long double, long double);
494 long double hypotl (long double, long double);
495 int ilogbl (long double);
496 long double ldexpl (long double, int);
497 long long llrintl (long double);
498 long long llroundl (long double);
499 long double logbl (long double);
500 long lrintl (long double);
501 long lroundl (long double);
502 long double modfl (long double, long double *);
503 long double nanl (const char *);
504 long double nearbyintl (long double);
505 long double nextafterl (long double, long double);
506 double nexttoward (double, long double);
507 float nexttowardf (float, long double);
508 long double remainderl (long double, long double);
509 long double remquol (long double, long double, int *);
510 long double rintl (long double);
511 long double roundl (long double);
512 long double scalblnl (long double, long);
513 long double scalbnl (long double, int);
514 long double sinl (long double);
515 long double sqrtl (long double);
516 long double tanl (long double);
517 long double truncl (long double);
518 #endif
519 __END_DECLS
521 #endif /* _MATH_H_ */