Deleted Added
sdiff udiff text old ( 110566 ) new ( 110734 )
full compact
1/*
2 * ====================================================
3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
4 *
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 * ====================================================
10 */
11
12/*
13 * from: @(#)fdlibm.h 5.1 93/09/24
14 * $FreeBSD: head/lib/msun/src/math.h 110566 2003-02-08 20:37:55Z mike $
15 */
16
17#ifndef _MATH_H_
18#define _MATH_H_
19
20#include <sys/_types.h>
21
22/*
23 * ANSI/POSIX
24 */
25extern const union __infinity_un {
26 unsigned char __uc[8];
27 double __ud;
28} __infinity;
29
30extern const union __nan_un {
31 unsigned char __uc[sizeof(float)];
32 float __uf;
33} __nan;
34
35#define FP_ILOGB0 (-0x7fffffff - 1) /* INT_MIN */
36#define FP_ILOGBNAN 0x7fffffff /* INT_MAX */
37#define HUGE_VAL (__infinity.__ud)
38#define HUGE_VALF (float)HUGE_VAL
39#define HUGE_VALL (long double)HUGE_VAL
40#define INFINITY HUGE_VALF
41#define NAN (__nan.__uf)
42
43/* Symbolic constants to classify floating point numbers. */
44#define FP_INFINITE 1
45#define FP_NAN 2
46#define FP_NORMAL 3
47#define FP_SUBNORMAL 4
48#define FP_ZERO 5
49#define fpclassify(x) \
50 ((sizeof (x) == sizeof (float)) ? __fpclassifyf(x) \
51 : (sizeof (x) == sizeof (double)) ? __fpclassifyd(x) \
52 : __fpclassifyl(x))
53
54typedef __double_t double_t;
55typedef __float_t float_t;
56
57/*
58 * XOPEN/SVID
59 */
60#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
61#define M_E 2.7182818284590452354 /* e */
62#define M_LOG2E 1.4426950408889634074 /* log 2e */
63#define M_LOG10E 0.43429448190325182765 /* log 10e */
64#define M_LN2 0.69314718055994530942 /* log e2 */
65#define M_LN10 2.30258509299404568402 /* log e10 */
66#define M_PI 3.14159265358979323846 /* pi */
67#define M_PI_2 1.57079632679489661923 /* pi/2 */
68#define M_PI_4 0.78539816339744830962 /* pi/4 */
69#define M_1_PI 0.31830988618379067154 /* 1/pi */
70#define M_2_PI 0.63661977236758134308 /* 2/pi */
71#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
72#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
73#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
74
75#define MAXFLOAT ((float)3.40282346638528860e+38)
76extern int signgam;
77
78#if !defined(_XOPEN_SOURCE)
79enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
80
81#define _LIB_VERSION_TYPE enum fdversion
82#define _LIB_VERSION _fdlib_version
83
84/* if global variable _LIB_VERSION is not desirable, one may
85 * change the following to be a constant by:
86 * #define _LIB_VERSION_TYPE const enum version
87 * In that case, after one initializes the value _LIB_VERSION (see
88 * s_lib_version.c) during compile time, it cannot be modified
89 * in the middle of a program
90 */
91extern _LIB_VERSION_TYPE _LIB_VERSION;
92
93#define _IEEE_ fdlibm_ieee
94#define _SVID_ fdlibm_svid
95#define _XOPEN_ fdlibm_xopen
96#define _POSIX_ fdlibm_posix
97
98/* We have a problem when using C++ since `exception' is a reserved
99 name in C++. */
100#ifndef __cplusplus
101struct exception {
102 int type;
103 char *name;
104 double arg1;
105 double arg2;
106 double retval;
107};
108#endif
109
110#if 0
111/* Old value from 4.4BSD-Lite math.h; this is probably better. */
112#define HUGE HUGE_VAL
113#else
114#define HUGE MAXFLOAT
115#endif
116
117/*
118 * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
119 * (one may replace the following line by "#include <values.h>")
120 */
121
122#define X_TLOSS 1.41484755040568800000e+16
123
124#define DOMAIN 1
125#define SING 2
126#define OVERFLOW 3
127#define UNDERFLOW 4
128#define TLOSS 5
129#define PLOSS 6
130
131#endif /* !_XOPEN_SOURCE */
132#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
133
134#include <sys/cdefs.h>
135
136/*
137 * Most of these functions have the side effect of setting errno, so they
138 * are not declared as __pure2. (XXX: this point needs to be revisited,
139 * since C99 doesn't require the mistake of setting errno, and we mostly
140 * don't set it anyway. In C99, pragmas and functions for changing the
141 * rounding mode affect the purity of these functions.)
142 */
143__BEGIN_DECLS
144/*
145 * ANSI/POSIX
146 */
147int __fpclassifyd(double);
148int __fpclassifyf(float);
149int __fpclassifyl(long double);
150
151double acos(double);
152double asin(double);
153double atan(double);
154double atan2(double, double);
155double cos(double);
156double sin(double);
157double tan(double);
158
159double cosh(double);
160double sinh(double);
161double tanh(double);
162
163double exp(double);
164double frexp(double, int *); /* fundamentally !__pure2 */
165double ldexp(double, int);
166double log(double);
167double log10(double);
168double modf(double, double *); /* fundamentally !__pure2 */
169
170double pow(double, double);
171double sqrt(double);
172
173double ceil(double);
174double fabs(double);
175double floor(double);
176double fmod(double, double);
177
178/*
179 * These functions are not in C90 so they can be "right". The ones that
180 * never set errno in lib/msun are declared as __pure2.
181 */
182#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
183double erf(double);
184double erfc(double) __pure2;
185int finite(double) __pure2;
186double gamma(double);
187double hypot(double, double);
188int isinf(double) __pure2;
189int isnan(double) __pure2;
190double j0(double);
191double j1(double);
192double jn(int, double);
193double lgamma(double);
194double y0(double);
195double y1(double);
196double yn(int, double);
197
198#if !defined(_XOPEN_SOURCE)
199double acosh(double);
200double asinh(double);
201double atanh(double);
202double cbrt(double) __pure2;
203double logb(double) __pure2;
204double nextafter(double, double);
205double remainder(double, double);
206double scalb(double, double);
207double tgamma(double);
208
209#ifndef __cplusplus
210int matherr(struct exception *);
211#endif
212
213/*
214 * IEEE Test Vector
215 */
216double significand(double);
217
218/*
219 * Functions callable from C, intended to support IEEE arithmetic.
220 */
221double copysign(double, double) __pure2;
222int ilogb(double);
223double rint(double) __pure2;
224double scalbn(double, int);
225
226/*
227 * BSD math library entry points
228 */
229double drem(double, double);
230double expm1(double) __pure2;
231double log1p(double) __pure2;
232
233/*
234 * Reentrant version of gamma & lgamma; passes signgam back by reference
235 * as the second argument; user must allocate space for signgam.
236 */
237#ifdef _REENTRANT
238double gamma_r(double, int *);
239double lgamma_r(double, int *);
240#endif /* _REENTRANT */
241
242/* float versions of ANSI/POSIX functions */
243float acosf(float);
244float asinf(float);
245float atanf(float);
246float atan2f(float, float);
247float cosf(float);
248float sinf(float);
249float tanf(float);
250
251float coshf(float);
252float sinhf(float);
253float tanhf(float);
254
255float expf(float);
256float frexpf(float, int *); /* fundamentally !__pure2 */
257float ldexpf(float, int);
258float logf(float);
259float log10f(float);
260float modff(float, float *); /* fundamentally !__pure2 */
261
262float powf(float, float);
263float sqrtf(float);
264
265float ceilf(float);
266float fabsf(float);
267float floorf(float);
268float fmodf(float, float);
269
270float erff(float);
271float erfcf(float) __pure2;
272int finitef(float) __pure2;
273float gammaf(float);
274float hypotf(float, float) __pure2;
275int isnanf(float) __pure2;
276float j0f(float);
277float j1f(float);
278float jnf(int, float);
279float lgammaf(float);
280float y0f(float);
281float y1f(float);
282float ynf(int, float);
283
284float acoshf(float);
285float asinhf(float);
286float atanhf(float);
287float cbrtf(float) __pure2;
288float logbf(float) __pure2;
289float nextafterf(float, float);
290float remainderf(float, float);
291float scalbf(float, float);
292
293/*
294 * float version of IEEE Test Vector
295 */
296float significandf(float);
297
298/*
299 * Float versions of functions callable from C, intended to support
300 * IEEE arithmetic.
301 */
302float copysignf(float, float) __pure2;
303int ilogbf(float);
304float rintf(float);
305float scalbnf(float, int);
306
307/*
308 * float versions of BSD math library entry points
309 */
310float dremf(float, float);
311float expm1f(float) __pure2;
312float log1pf(float) __pure2;
313
314/*
315 * Float versions of reentrant version of gamma & lgamma; passes
316 * signgam back by reference as the second argument; user must
317 * allocate space for signgam.
318 */
319#ifdef _REENTRANT
320float gammaf_r(float, int *);
321float lgammaf_r(float, int *);
322#endif /* _REENTRANT */
323
324#endif /* !_XOPEN_SOURCE */
325#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
326__END_DECLS
327
328#endif /* !_MATH_H_ */