1 /* math.h -- Definitions for the math floating point package. */
7 #include <machine/ieeefp.h>
14 /* Define HUGE_VAL as infinity, unless HUGE_VAL is already defined
15 (which might have been done by something like math-68881.h). */
23 /* Declare this as an array without bounds so that no matter what small data
24 support a port and/or library has, this reference will be via the general
25 method for accessing globals. */
26 extern __IMPORT
const union __dmath __infinity
[];
28 #define HUGE_VAL (__infinity[0].d)
30 #endif /* ! defined (HUGE_VAL) */
32 /* Reentrant ANSI C functions. */
35 extern double atan
_PARAMS((double));
36 extern double cos
_PARAMS((double));
37 extern double sin
_PARAMS((double));
38 extern double tan
_PARAMS((double));
39 extern double tanh
_PARAMS((double));
40 extern double frexp
_PARAMS((double, int *));
41 extern double modf
_PARAMS((double, double *));
42 extern double ceil
_PARAMS((double));
43 extern double fabs
_PARAMS((double));
44 extern double floor
_PARAMS((double));
45 #endif /* ! defined (__math_68881) */
47 /* Non reentrant ANSI C functions. */
51 extern double acos
_PARAMS((double));
52 extern double asin
_PARAMS((double));
53 extern double atan2
_PARAMS((double, double));
54 extern double cosh
_PARAMS((double));
55 extern double sinh
_PARAMS((double));
56 extern double exp
_PARAMS((double));
57 extern double ldexp
_PARAMS((double, int));
58 extern double log
_PARAMS((double));
59 extern double log10
_PARAMS((double));
60 extern double pow
_PARAMS((double, double));
61 extern double sqrt
_PARAMS((double));
62 extern double fmod
_PARAMS((double, double));
63 #endif /* ! defined (__math_68881) */
64 #endif /* ! defined (_REENT_ONLY) */
66 #ifndef __STRICT_ANSI__
68 /* ISO C99 types and macros. */
70 #ifndef FLT_EVAL_METHOD
71 #define FLT_EVAL_METHOD 0
72 typedef float float_t
;
73 typedef double double_t
;
74 #endif /* FLT_EVAL_METHOD */
79 #define FP_SUBNORMAL 3
82 extern int __fpclassifyf (float x
);
83 extern int __fpclassifyd (double x
);
84 extern int __signbitf (float x
);
85 extern int __signbitd (double x
);
87 #define fpclassify(x) \
88 (__extension__ ({__typeof__(x) __x = (x); \
89 (sizeof (__x) == sizeof (float)) ? __fpclassifyf(__x) : __fpclassifyd(__x);}))
92 (__extension__ ({__typeof__(x) __x = (x); \
93 fpclassify(__x) != FP_INFINITE && fpclassify(__x) != FP_NAN;}))
95 (__extension__ ({__typeof__(x) __x = (x); \
96 fpclassify(__x) == FP_NORMAL;}))
98 (__extension__ ({__typeof__(x) __x = (x); \
99 (sizeof(__x) == sizeof(float)) ? __signbitf(__x) : __signbitd(__x);}))
101 #define isgreater(x,y) \
102 (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
103 !isunordered(__x,__y) && (__x > __y);}))
104 #define isgreaterequal(x,y) \
105 (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
106 !isunordered(__x,__y) && (__x >= __y);}))
107 #define isless(x,y) \
108 (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
109 !isunordered(__x,__y) && (__x < __y);}))
110 #define islessequal(x,y) \
111 (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
112 !isunordered(__x,__y) && (__x <= __y);}))
113 #define islessgreater(x,y) \
114 (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
115 !isunordered(__x,__y) && (__x < __y || __x > __y);}))
117 #define isunordered(x,y) \
118 (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
119 fpclassify(__x) == FP_NAN || fpclassify(__y) == FP_NAN;}))
121 /* Non ANSI double precision functions. */
123 extern double infinity
_PARAMS((void));
124 extern double nan
_PARAMS((const char *));
125 extern int isnan
_PARAMS((double));
126 extern int isinf
_PARAMS((double));
127 extern int finite
_PARAMS((double));
128 extern double copysign
_PARAMS((double, double));
129 extern int ilogb
_PARAMS((double));
131 extern double asinh
_PARAMS((double));
132 extern double cbrt
_PARAMS((double));
133 extern double nextafter
_PARAMS((double, double));
134 extern double rint
_PARAMS((double));
135 extern double scalbn
_PARAMS((double, int));
137 extern double exp2
_PARAMS((double));
138 extern double scalbln
_PARAMS((double, long int));
139 extern double tgamma
_PARAMS((double));
140 extern double nearbyint
_PARAMS((double));
141 extern long int lrint
_PARAMS((double));
142 extern double round
_PARAMS((double));
143 extern long int lround
_PARAMS((double));
144 extern double trunc
_PARAMS((double));
145 extern double remquo
_PARAMS((double, double, int *));
146 extern double copysign
_PARAMS((double, double));
147 extern double fdim
_PARAMS((double, double));
148 extern double fmax
_PARAMS((double, double));
149 extern double fmin
_PARAMS((double, double));
150 extern double fma
_PARAMS((double, double, double));
151 extern void sincos
_PARAMS((double, double *, double *));
154 extern double log1p
_PARAMS((double));
155 extern double expm1
_PARAMS((double));
156 #endif /* ! defined (__math_68881) */
159 extern double acosh
_PARAMS((double));
160 extern double atanh
_PARAMS((double));
161 extern double remainder
_PARAMS((double, double));
162 extern double gamma
_PARAMS((double));
163 extern double gamma_r
_PARAMS((double, int *));
164 extern double lgamma
_PARAMS((double));
165 extern double lgamma_r
_PARAMS((double, int *));
166 extern double erf
_PARAMS((double));
167 extern double erfc
_PARAMS((double));
168 extern double y0
_PARAMS((double));
169 extern double y1
_PARAMS((double));
170 extern double yn
_PARAMS((int, double));
171 extern double j0
_PARAMS((double));
172 extern double j1
_PARAMS((double));
173 extern double jn
_PARAMS((int, double));
174 #define log2(x) (log (x) / M_LOG2_E)
177 extern double hypot
_PARAMS((double, double));
180 extern double cabs();
181 extern double drem
_PARAMS((double, double));
183 #endif /* ! defined (_REENT_ONLY) */
185 #endif /* ! defined (__STRICT_ANSI__) */
187 #if !defined(__STRICT_ANSI__) || defined(__cplusplus)
189 /* Single precision versions of ANSI functions. */
191 extern float atanf
_PARAMS((float));
192 extern float cosf
_PARAMS((float));
193 extern float sinf
_PARAMS((float));
194 extern float tanf
_PARAMS((float));
195 extern float tanhf
_PARAMS((float));
196 extern float frexpf
_PARAMS((float, int *));
197 extern float modff
_PARAMS((float, float *));
198 extern float ceilf
_PARAMS((float));
199 extern float fabsf
_PARAMS((float));
200 extern float floorf
_PARAMS((float));
203 extern float acosf
_PARAMS((float));
204 extern float asinf
_PARAMS((float));
205 extern float atan2f
_PARAMS((float, float));
206 extern float coshf
_PARAMS((float));
207 extern float sinhf
_PARAMS((float));
208 extern float expf
_PARAMS((float));
209 extern float ldexpf
_PARAMS((float, int));
210 extern float logf
_PARAMS((float));
211 extern float log10f
_PARAMS((float));
212 extern float powf
_PARAMS((float, float));
213 extern float sqrtf
_PARAMS((float));
214 extern float fmodf
_PARAMS((float, float));
215 #endif /* ! defined (_REENT_ONLY) */
217 #endif /* !defined(__STRICT_ANSI__) || defined(__cplusplus) */
219 #ifndef __STRICT_ANSI__
221 /* Other single precision functions. */
223 extern float exp2f
_PARAMS((float));
224 extern float scalblnf
_PARAMS((float, long int));
225 extern float tgammaf
_PARAMS((float));
226 extern float nearbyintf
_PARAMS((float));
227 extern long int lrintf
_PARAMS((float));
228 extern float roundf
_PARAMS((float));
229 extern long int lroundf
_PARAMS((float));
230 extern float truncf
_PARAMS((float));
231 extern float remquof
_PARAMS((float, float, int *));
232 extern float copysignf
_PARAMS((float, float));
233 extern float fdimf
_PARAMS((float, float));
234 extern float fmaxf
_PARAMS((float, float));
235 extern float fminf
_PARAMS((float, float));
236 extern float fmaf
_PARAMS((float, float, float));
238 extern float infinityf
_PARAMS((void));
239 extern float nanf
_PARAMS((const char *));
240 extern int isnanf
_PARAMS((float));
241 extern int isinff
_PARAMS((float));
242 extern int finitef
_PARAMS((float));
243 extern float copysignf
_PARAMS((float, float));
244 extern int ilogbf
_PARAMS((float));
246 extern float asinhf
_PARAMS((float));
247 extern float cbrtf
_PARAMS((float));
248 extern float nextafterf
_PARAMS((float, float));
249 extern float rintf
_PARAMS((float));
250 extern float scalbnf
_PARAMS((float, int));
251 extern float log1pf
_PARAMS((float));
252 extern float expm1f
_PARAMS((float));
253 extern void sincosf
_PARAMS((float, float *, float *));
256 extern float acoshf
_PARAMS((float));
257 extern float atanhf
_PARAMS((float));
258 extern float remainderf
_PARAMS((float, float));
259 extern float gammaf
_PARAMS((float));
260 extern float gammaf_r
_PARAMS((float, int *));
261 extern float lgammaf
_PARAMS((float));
262 extern float lgammaf_r
_PARAMS((float, int *));
263 extern float erff
_PARAMS((float));
264 extern float erfcf
_PARAMS((float));
265 extern float y0f
_PARAMS((float));
266 extern float y1f
_PARAMS((float));
267 extern float ynf
_PARAMS((int, float));
268 extern float j0f
_PARAMS((float));
269 extern float j1f
_PARAMS((float));
270 extern float jnf
_PARAMS((int, float));
271 #define log2f(x) (logf (x) / (float) M_LOG2_E)
272 extern float hypotf
_PARAMS((float, float));
274 extern float cabsf();
275 extern float dremf
_PARAMS((float, float));
277 #endif /* ! defined (_REENT_ONLY) */
279 /* The gamma functions use a global variable, signgam. */
281 #define signgam (*__signgam())
282 extern int *__signgam
_PARAMS((void));
283 #endif /* ! defined (_REENT_ONLY) */
285 #define __signgam_r(ptr) _REENT_SIGNGAM(ptr)
287 /* The exception structure passed to the matherr routine. */
304 extern int matherr
_PARAMS((struct __exception
*e
));
306 extern int matherr
_PARAMS((struct exception
*e
));
309 /* Values for the type field of struct exception. */
318 /* Useful constants. */
320 #define MAXFLOAT 3.40282347e+38F
322 #define M_E 2.7182818284590452354
323 #define M_LOG2E 1.4426950408889634074
324 #define M_LOG10E 0.43429448190325182765
325 #define M_LN2 0.69314718055994530942
326 #define M_LN10 2.30258509299404568402
327 #define M_PI 3.14159265358979323846
328 #define M_TWOPI (M_PI * 2.0)
329 #define M_PI_2 1.57079632679489661923
330 #define M_PI_4 0.78539816339744830962
331 #define M_3PI_4 2.3561944901923448370E0
332 #define M_SQRTPI 1.77245385090551602792981
333 #define M_1_PI 0.31830988618379067154
334 #define M_2_PI 0.63661977236758134308
335 #define M_2_SQRTPI 1.12837916709551257390
336 #define M_SQRT2 1.41421356237309504880
337 #define M_SQRT1_2 0.70710678118654752440
338 #define M_LN2LO 1.9082149292705877000E-10
339 #define M_LN2HI 6.9314718036912381649E-1
340 #define M_SQRT3 1.73205080756887719000
341 #define M_IVLN10 0.43429448190325182765 /* 1 / log(10) */
342 #define M_LOG2_E 0.693147180559945309417
343 #define M_INVLN2 1.4426950408889633870E0 /* 1 / log(2) */
345 /* Global control over fdlibm error handling. */
347 enum __fdlibm_version
355 #define _LIB_VERSION_TYPE enum __fdlibm_version
356 #define _LIB_VERSION __fdlib_version
358 extern __IMPORT _CONST _LIB_VERSION_TYPE _LIB_VERSION
;
360 #define _IEEE_ __fdlibm_ieee
361 #define _SVID_ __fdlibm_svid
362 #define _XOPEN_ __fdlibm_xopen
363 #define _POSIX_ __fdlibm_posix
365 #endif /* ! defined (__STRICT_ANSI__) */
370 #include <machine/fastmath.h>
373 #endif /* _MATH_H_ */