Annotation of src/include/math.h, Revision 1.17
1.17 ! martynas 1: /* $OpenBSD: math.h,v 1.16 2008/07/16 15:01:19 martynas Exp $ */
1.1 deraadt 2: /*
3: * ====================================================
4: * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5: *
6: * Developed at SunPro, a Sun Microsystems, Inc. business.
7: * Permission to use, copy, modify, and distribute this
8: * software is freely granted, provided that this notice
9: * is preserved.
10: * ====================================================
11: */
12:
13: /*
1.3 millert 14: * from: @(#)fdlibm.h 5.1 93/09/24
1.1 deraadt 15: */
16:
17: #ifndef _MATH_H_
18: #define _MATH_H_
19:
1.17 ! martynas 20: #include <sys/_types.h>
1.11 millert 21: #include <sys/cdefs.h>
22:
1.1 deraadt 23: /*
24: * ANSI/POSIX
25: */
26: extern char __infinity[];
1.12 otto 27: #define HUGE_VAL (*(double *)(void *)__infinity)
1.9 espie 28:
29: /*
30: * C99
31: */
32:
1.17 ! martynas 33: typedef __double_t double_t;
! 34: typedef __float_t float_t;
1.1 deraadt 35:
36: /*
37: * XOPEN/SVID
38: */
1.11 millert 39: #if __BSD_VISIBLE || __XPG_VISIBLE
1.1 deraadt 40: #define M_E 2.7182818284590452354 /* e */
41: #define M_LOG2E 1.4426950408889634074 /* log 2e */
42: #define M_LOG10E 0.43429448190325182765 /* log 10e */
43: #define M_LN2 0.69314718055994530942 /* log e2 */
44: #define M_LN10 2.30258509299404568402 /* log e10 */
45: #define M_PI 3.14159265358979323846 /* pi */
46: #define M_PI_2 1.57079632679489661923 /* pi/2 */
47: #define M_PI_4 0.78539816339744830962 /* pi/4 */
48: #define M_1_PI 0.31830988618379067154 /* 1/pi */
49: #define M_2_PI 0.63661977236758134308 /* 2/pi */
50: #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
51: #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
52: #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
53:
1.7 jason 54: #ifdef __vax__
1.8 jason 55: #define MAXFLOAT ((float)1.70141173319264430e+38)
1.7 jason 56: #else
1.1 deraadt 57: #define MAXFLOAT ((float)3.40282346638528860e+38)
1.7 jason 58: #endif
59:
1.1 deraadt 60: extern int signgam;
1.11 millert 61: #endif /* __BSD_VISIBLE || __XPG_VISIBLE */
1.1 deraadt 62:
1.11 millert 63: #if __BSD_VISIBLE
1.1 deraadt 64: enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
65:
66: #define _LIB_VERSION_TYPE enum fdversion
67: #define _LIB_VERSION _fdlib_version
68:
69: /* if global variable _LIB_VERSION is not desirable, one may
70: * change the following to be a constant by:
71: * #define _LIB_VERSION_TYPE const enum version
72: * In that case, after one initializes the value _LIB_VERSION (see
73: * s_lib_version.c) during compile time, it cannot be modified
74: * in the middle of a program
75: */
76: extern _LIB_VERSION_TYPE _LIB_VERSION;
77:
78: #define _IEEE_ fdlibm_ieee
79: #define _SVID_ fdlibm_svid
80: #define _XOPEN_ fdlibm_xopen
81: #define _POSIX_ fdlibm_posix
82:
1.5 millert 83: #ifndef __cplusplus
1.1 deraadt 84: struct exception {
85: int type;
86: char *name;
87: double arg1;
88: double arg2;
89: double retval;
90: };
1.3 millert 91: #endif
1.1 deraadt 92:
93: #define HUGE MAXFLOAT
94:
95: /*
96: * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
97: * (one may replace the following line by "#include <values.h>")
98: */
99:
100: #define X_TLOSS 1.41484755040568800000e+16
101:
102: #define DOMAIN 1
103: #define SING 2
104: #define OVERFLOW 3
105: #define UNDERFLOW 4
106: #define TLOSS 5
107: #define PLOSS 6
108:
1.11 millert 109: #endif /* __BSD_VISIBLE */
1.1 deraadt 110:
111: __BEGIN_DECLS
112: /*
113: * ANSI/POSIX
114: */
1.6 millert 115: extern double acos(double);
116: extern double asin(double);
117: extern double atan(double);
118: extern double atan2(double, double);
119: extern double cos(double);
120: extern double sin(double);
121: extern double tan(double);
122:
123: extern double cosh(double);
124: extern double sinh(double);
125: extern double tanh(double);
126:
127: extern double exp(double);
128: extern double frexp(double, int *);
129: extern double ldexp(double, int);
130: extern double log(double);
131: extern double log10(double);
132: extern double modf(double, double *);
133:
134: extern double pow(double, double);
135: extern double sqrt(double);
136:
137: extern double ceil(double);
138: extern double fabs(double);
139: extern double floor(double);
140: extern double fmod(double, double);
1.1 deraadt 141:
1.14 brad 142: extern double round(double);
1.13 brad 143: extern double trunc(double);
144:
1.11 millert 145: #if __BSD_VISIBLE || __XPG_VISIBLE
1.6 millert 146: extern double erf(double);
147: extern double erfc(double);
148: extern double gamma(double);
149: extern double hypot(double, double);
150: extern int isinf(double);
151: extern int isnan(double);
152: extern int finite(double);
153: extern double j0(double);
154: extern double j1(double);
155: extern double jn(int, double);
156: extern double lgamma(double);
1.15 martynas 157: extern double tgamma(double);
1.6 millert 158: extern double y0(double);
159: extern double y1(double);
160: extern double yn(int, double);
1.1 deraadt 161:
1.11 millert 162: #if __BSD_VISIBLE || __XPG_VISIBLE >= 500
1.6 millert 163: extern double acosh(double);
164: extern double asinh(double);
165: extern double atanh(double);
166: extern double cbrt(double);
167: extern double logb(double);
168: extern double nextafter(double, double);
169: extern double remainder(double, double);
170: extern double scalb(double, double);
1.1 deraadt 171:
1.3 millert 172: #ifdef __LIBM_PRIVATE
1.6 millert 173: extern int matherr(struct exception *);
1.3 millert 174: #endif
1.1 deraadt 175:
176: /*
177: * IEEE Test Vector
178: */
1.6 millert 179: extern double significand(double);
1.1 deraadt 180:
181: /*
182: * Functions callable from C, intended to support IEEE arithmetic.
183: */
1.6 millert 184: extern double copysign(double, double);
185: extern int ilogb(double);
186: extern double rint(double);
1.10 otto 187: extern long int lrint(double);
188: extern long int lround(double);
189: extern long long int llrint(double);
190: extern long long int llround(double);
1.6 millert 191: extern double scalbn(double, int);
1.1 deraadt 192:
193: /*
194: * BSD math library entry points
195: */
196: extern double cabs();
1.6 millert 197: extern double drem(double, double);
198: extern double expm1(double);
199: extern double log1p(double);
1.1 deraadt 200:
201: /*
202: * Reentrant version of gamma & lgamma; passes signgam back by reference
203: * as the second argument; user must allocate space for signgam.
204: */
1.11 millert 205: #if __BSD_VISIBLE || defined(_REENTRANT)
1.6 millert 206: extern double gamma_r(double, int *);
207: extern double lgamma_r(double, int *);
1.11 millert 208: #endif /* __BSD_VISIBLE || _REENTRANT */
1.1 deraadt 209:
210:
211: /* float versions of ANSI/POSIX functions */
1.6 millert 212: extern float acosf(float);
213: extern float asinf(float);
214: extern float atanf(float);
215: extern float atan2f(float, float);
216: extern float cosf(float);
217: extern float sinf(float);
218: extern float tanf(float);
219:
220: extern float coshf(float);
221: extern float sinhf(float);
222: extern float tanhf(float);
223:
224: extern float expf(float);
225: extern float frexpf(float, int *);
226: extern float ldexpf(float, int);
227: extern float logf(float);
228: extern float log10f(float);
229: extern float modff(float, float *);
230:
231: extern float powf(float, float);
232: extern float sqrtf(float);
233:
234: extern float ceilf(float);
235: extern float fabsf(float);
236: extern float floorf(float);
237: extern float fmodf(float, float);
1.13 brad 238:
1.14 brad 239: extern float roundf(float);
1.13 brad 240: extern float truncf(float);
1.6 millert 241:
242: extern float erff(float);
243: extern float erfcf(float);
244: extern float gammaf(float);
245: extern float hypotf(float, float);
246: extern int isinff(float);
247: extern int isnanf(float);
248: extern int finitef(float);
249: extern float j0f(float);
250: extern float j1f(float);
251: extern float jnf(int, float);
252: extern float lgammaf(float);
1.15 martynas 253: extern float tgammaf(float);
1.6 millert 254: extern float y0f(float);
255: extern float y1f(float);
256: extern float ynf(int, float);
257:
258: extern float acoshf(float);
259: extern float asinhf(float);
260: extern float atanhf(float);
261: extern float cbrtf(float);
262: extern float logbf(float);
263: extern float nextafterf(float, float);
264: extern float remainderf(float, float);
265: extern float scalbf(float, float);
1.1 deraadt 266:
267: /*
268: * float version of IEEE Test Vector
269: */
1.6 millert 270: extern float significandf(float);
1.1 deraadt 271:
272: /*
273: * Float versions of functions callable from C, intended to support
274: * IEEE arithmetic.
275: */
1.6 millert 276: extern float copysignf(float, float);
277: extern int ilogbf(float);
278: extern float rintf(float);
1.10 otto 279: extern long int lrintf(float);
280: extern long int lroundf(float);
281: extern long long int llrintf(float);
282: extern long long int llroundf(float);
1.6 millert 283: extern float scalbnf(float, int);
1.1 deraadt 284:
285: /*
286: * float versions of BSD math library entry points
287: */
288: extern float cabsf ();
1.6 millert 289: extern float dremf(float, float);
290: extern float expm1f(float);
291: extern float log1pf(float);
1.1 deraadt 292:
293: /*
294: * Float versions of reentrant version of gamma & lgamma; passes
295: * signgam back by reference as the second argument; user must
296: * allocate space for signgam.
297: */
1.11 millert 298: #if __BSD_VISIBLE || defined(_REENTRANT)
1.6 millert 299: extern float gammaf_r(float, int *);
300: extern float lgammaf_r(float, int *);
1.11 millert 301: #endif /* __BSD_VISIBLE || _REENTRANT */
1.1 deraadt 302:
1.11 millert 303: #endif /* __BSD_VISIBLE || __XPG_VISIBLE >= 500 */
304: #endif /* __BSD_VISIBLE || __XPG_VISIBLE */
1.16 martynas 305:
306: #if __BSD_VISIBLE && defined(__vax__)
307: extern double infnan(int);
308: #endif /* __BSD_VISIBLE && defined(__vax__) */
1.1 deraadt 309: __END_DECLS
310:
311: #endif /* _MATH_H_ */