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