]>
Commit | Line | Data |
---|---|---|
2aa62f2b | 1 | /* $NetBSD: math.h,v 1.44 2006/03/25 16:41:11 xtraeme Exp $ */\r |
2 | \r | |
3 | /*\r | |
4 | * ====================================================\r | |
5 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\r | |
6 | *\r | |
7 | * Developed at SunPro, a Sun Microsystems, Inc. business.\r | |
8 | * Permission to use, copy, modify, and distribute this\r | |
9 | * software is freely granted, provided that this notice\r | |
10 | * is preserved.\r | |
11 | * ====================================================\r | |
12 | */\r | |
13 | \r | |
14 | /*\r | |
15 | * @(#)fdlibm.h 5.1 93/09/24\r | |
16 | */\r | |
17 | \r | |
18 | #ifndef _MATH_H_\r | |
19 | #define _MATH_H_\r | |
20 | \r | |
21 | #include <sys/EfiCdefs.h>\r | |
22 | #include <sys/featuretest.h>\r | |
23 | \r | |
24 | union __float_u {\r | |
25 | unsigned char __dummy[sizeof(float)];\r | |
26 | float __val;\r | |
27 | };\r | |
28 | \r | |
29 | union __double_u {\r | |
30 | unsigned char __dummy[sizeof(double)];\r | |
31 | double __val;\r | |
32 | };\r | |
33 | \r | |
34 | union __long_double_u {\r | |
35 | unsigned char __dummy[sizeof(long double)];\r | |
36 | long double __val;\r | |
37 | };\r | |
38 | \r | |
39 | #include <machine/math.h> /* may use __float_u, __double_u,\r | |
40 | or __long_double_u */\r | |
41 | \r | |
42 | #ifdef __HAVE_LONG_DOUBLE\r | |
43 | #define __fpmacro_unary_floating(__name, __arg0) \\r | |
44 | /* LINTED */ \\r | |
45 | ((sizeof (__arg0) == sizeof (float)) \\r | |
46 | ? __ ## __name ## f (__arg0) \\r | |
47 | : (sizeof (__arg0) == sizeof (double)) \\r | |
48 | ? __ ## __name ## d (__arg0) \\r | |
49 | : __ ## __name ## l (__arg0))\r | |
50 | #else\r | |
51 | #define __fpmacro_unary_floating(__name, __arg0) \\r | |
52 | /* LINTED */ \\r | |
53 | ((sizeof (__arg0) == sizeof (float)) \\r | |
54 | ? __ ## __name ## f (__arg0) \\r | |
55 | : __ ## __name ## d (__arg0))\r | |
56 | #endif /* __HAVE_LONG_DOUBLE */\r | |
57 | \r | |
58 | /*\r | |
59 | * ANSI/POSIX\r | |
60 | */\r | |
61 | /* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */\r | |
62 | extern const union __double_u __infinity;\r | |
63 | #define HUGE_VAL __infinity.__val\r | |
64 | \r | |
65 | /*\r | |
66 | * ISO C99\r | |
67 | */\r | |
68 | /* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */\r | |
69 | extern const union __float_u __infinityf;\r | |
70 | #define HUGE_VALF __infinityf.__val\r | |
71 | \r | |
72 | extern const union __long_double_u __infinityl;\r | |
73 | #define HUGE_VALL __infinityl.__val\r | |
74 | \r | |
75 | /* 7.12#4 INFINITY */\r | |
76 | #ifdef __INFINITY\r | |
77 | #define INFINITY __INFINITY /* float constant which overflows */\r | |
78 | #else\r | |
79 | #define INFINITY HUGE_VALF /* positive infinity */\r | |
80 | #endif /* __INFINITY */\r | |
81 | \r | |
82 | /* 7.12#5 NAN: a quiet NaN, if supported */\r | |
83 | #ifdef __HAVE_NANF\r | |
84 | extern const union __float_u __nanf;\r | |
85 | #define NAN __nanf.__val\r | |
86 | #endif /* __HAVE_NANF */\r | |
87 | \r | |
88 | /* 7.12#6 number classification macros */\r | |
89 | #define FP_INFINITE 0x00\r | |
90 | #define FP_NAN 0x01\r | |
91 | #define FP_NORMAL 0x02\r | |
92 | #define FP_SUBNORMAL 0x03\r | |
93 | #define FP_ZERO 0x04\r | |
94 | /* NetBSD extensions */\r | |
95 | #define _FP_LOMD 0x80 /* range for machine-specific classes */\r | |
96 | #define _FP_HIMD 0xff\r | |
97 | \r | |
98 | /*\r | |
99 | * XOPEN/SVID\r | |
100 | */\r | |
101 | #define M_E 2.7182818284590452354 /* e */\r | |
102 | #define M_LOG2E 1.4426950408889634074 /* log 2e */\r | |
103 | #define M_LOG10E 0.43429448190325182765 /* log 10e */\r | |
104 | #define M_LN2 0.69314718055994530942 /* log e2 */\r | |
105 | #define M_LN10 2.30258509299404568402 /* log e10 */\r | |
106 | #define M_PI 3.14159265358979323846 /* pi */\r | |
107 | #define M_PI_2 1.57079632679489661923 /* pi/2 */\r | |
108 | #define M_PI_4 0.78539816339744830962 /* pi/4 */\r | |
109 | #define M_1_PI 0.31830988618379067154 /* 1/pi */\r | |
110 | #define M_2_PI 0.63661977236758134308 /* 2/pi */\r | |
111 | #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */\r | |
112 | #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */\r | |
113 | #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */\r | |
114 | \r | |
115 | #define MAXFLOAT ((float)3.40282346638528860e+38)\r | |
116 | extern int signgam;\r | |
117 | \r | |
118 | enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};\r | |
119 | \r | |
120 | #define _LIB_VERSION_TYPE enum fdversion\r | |
121 | #define _LIB_VERSION _fdlib_version\r | |
122 | \r | |
123 | /* if global variable _LIB_VERSION is not desirable, one may\r | |
124 | * change the following to be a constant by:\r | |
125 | * #define _LIB_VERSION_TYPE const enum version\r | |
126 | * In that case, after one initializes the value _LIB_VERSION (see\r | |
127 | * s_lib_version.c) during compile time, it cannot be modified\r | |
128 | * in the middle of a program\r | |
129 | */\r | |
130 | extern _LIB_VERSION_TYPE _LIB_VERSION;\r | |
131 | \r | |
132 | #define _IEEE_ fdlibm_ieee\r | |
133 | #define _SVID_ fdlibm_svid\r | |
134 | #define _XOPEN_ fdlibm_xopen\r | |
135 | #define _POSIX_ fdlibm_posix\r | |
136 | \r | |
137 | #ifndef __cplusplus\r | |
138 | struct exception {\r | |
139 | int type;\r | |
140 | char *name;\r | |
141 | double arg1;\r | |
142 | double arg2;\r | |
143 | double retval;\r | |
144 | };\r | |
145 | #endif\r | |
146 | \r | |
147 | #define HUGE MAXFLOAT\r | |
148 | \r | |
149 | /*\r | |
150 | * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>\r | |
151 | * (one may replace the following line by "#include <values.h>")\r | |
152 | */\r | |
153 | \r | |
154 | #define X_TLOSS 1.41484755040568800000e+16\r | |
155 | \r | |
156 | #define DOMAIN 1\r | |
157 | #define SING 2\r | |
158 | #define OVERFLOW 3\r | |
159 | #define UNDERFLOW 4\r | |
160 | #define TLOSS 5\r | |
161 | #define PLOSS 6\r | |
162 | \r | |
163 | \r | |
164 | __BEGIN_DECLS\r | |
165 | /*\r | |
166 | * ANSI/POSIX\r | |
167 | */\r | |
168 | double acos(double);\r | |
169 | double asin(double);\r | |
170 | double atan(double);\r | |
171 | double atan2(double, double);\r | |
172 | double cos(double);\r | |
173 | double sin(double);\r | |
174 | double tan(double);\r | |
175 | \r | |
176 | double cosh(double);\r | |
177 | double sinh(double);\r | |
178 | double tanh(double);\r | |
179 | \r | |
180 | double exp(double);\r | |
181 | double frexp(double, int *);\r | |
182 | double ldexp(double, int);\r | |
183 | double log(double);\r | |
184 | double log2(double);\r | |
185 | double log10(double);\r | |
186 | double modf(double, double *);\r | |
187 | \r | |
188 | double pow(double, double);\r | |
189 | double sqrt(double);\r | |
190 | \r | |
191 | double ceil(double);\r | |
192 | double fabs(double);\r | |
193 | double floor(double);\r | |
194 | double fmod(double, double);\r | |
195 | \r | |
196 | //#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)\r | |
197 | //double erf(double);\r | |
198 | //double erfc(double);\r | |
199 | //double gamma(double);\r | |
200 | //double hypot(double, double);\r | |
201 | int finite(double);\r | |
202 | //double j0(double);\r | |
203 | //double j1(double);\r | |
204 | //double jn(int, double);\r | |
205 | //double lgamma(double);\r | |
206 | //double y0(double);\r | |
207 | //double y1(double);\r | |
208 | //double yn(int, double);\r | |
209 | \r | |
210 | //#if (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)\r | |
211 | //double acosh(double);\r | |
212 | //double asinh(double);\r | |
213 | //double atanh(double);\r | |
214 | //double cbrt(double);\r | |
215 | double expm1(double);\r | |
216 | //int ilogb(double);\r | |
217 | //double log1p(double);\r | |
218 | //double logb(double);\r | |
219 | //double nextafter(double, double);\r | |
220 | //double remainder(double, double);\r | |
221 | //double rint(double);\r | |
222 | //double scalb(double, double);\r | |
223 | //#endif /* (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)*/\r | |
224 | //#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */\r | |
225 | \r | |
226 | /* 7.12.3.1 int fpclassify(real-floating x) */\r | |
227 | #define fpclassify(__x) __fpmacro_unary_floating(fpclassify, __x)\r | |
228 | \r | |
229 | #if 0\r | |
230 | /*\r | |
231 | * ISO C99\r | |
232 | */\r | |
233 | #if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \\r | |
234 | !defined(_XOPEN_SOURCE) || \\r | |
235 | ((__STDC_VERSION__ - 0) >= 199901L) || \\r | |
236 | ((_POSIX_C_SOURCE - 0) >= 200112L) || \\r | |
237 | ((_XOPEN_SOURCE - 0) >= 600) || \\r | |
238 | defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)\r | |
239 | \r | |
240 | /* 7.12.3.2 int isfinite(real-floating x) */\r | |
241 | #define isfinite(__x) __fpmacro_unary_floating(isfinite, __x)\r | |
242 | \r | |
243 | /* 7.12.3.5 int isnormal(real-floating x) */\r | |
244 | #define isnormal(__x) (fpclassify(__x) == FP_NORMAL)\r | |
245 | \r | |
246 | /* 7.12.3.6 int signbit(real-floating x) */\r | |
247 | #define signbit(__x) __fpmacro_unary_floating(signbit, __x)\r | |
248 | \r | |
249 | /* 7.12.4 trigonometric */\r | |
250 | \r | |
251 | float acosf(float);\r | |
252 | float asinf(float);\r | |
253 | float atanf(float);\r | |
254 | float atan2f(float, float);\r | |
255 | float cosf(float);\r | |
256 | float sinf(float);\r | |
257 | float tanf(float);\r | |
258 | \r | |
259 | /* 7.12.5 hyperbolic */\r | |
260 | \r | |
261 | float acoshf(float);\r | |
262 | float asinhf(float);\r | |
263 | float atanhf(float);\r | |
264 | float coshf(float);\r | |
265 | float sinhf(float);\r | |
266 | float tanhf(float);\r | |
267 | \r | |
268 | /* 7.12.6 exp / log */\r | |
269 | \r | |
270 | float expf(float);\r | |
271 | float expm1f(float);\r | |
272 | float frexpf(float, int *);\r | |
273 | int ilogbf(float);\r | |
274 | float ldexpf(float, int);\r | |
275 | float logf(float);\r | |
276 | float log2f(float);\r | |
277 | float log10f(float);\r | |
278 | float log1pf(float);\r | |
279 | float logbf(float);\r | |
280 | float modff(float, float *);\r | |
281 | float scalbnf(float, int);\r | |
282 | \r | |
283 | /* 7.12.7 power / absolute */\r | |
284 | \r | |
285 | float cbrtf(float);\r | |
286 | float fabsf(float);\r | |
287 | float hypotf(float, float);\r | |
288 | float powf(float, float);\r | |
289 | float sqrtf(float);\r | |
290 | \r | |
291 | /* 7.12.8 error / gamma */\r | |
292 | \r | |
293 | float erff(float);\r | |
294 | float erfcf(float);\r | |
295 | float lgammaf(float);\r | |
296 | \r | |
297 | /* 7.12.9 nearest integer */\r | |
298 | \r | |
299 | float ceilf(float);\r | |
300 | float floorf(float);\r | |
301 | float rintf(float);\r | |
302 | double round(double);\r | |
303 | float roundf(float);\r | |
304 | double trunc(double);\r | |
305 | float truncf(float);\r | |
306 | long int lrint(double);\r | |
307 | long int lrintf(float);\r | |
308 | /* LONGLONG */\r | |
309 | long long int llrint(double);\r | |
310 | /* LONGLONG */\r | |
311 | long long int llrintf(float);\r | |
312 | long int lround(double);\r | |
313 | long int lroundf(float);\r | |
314 | /* LONGLONG */\r | |
315 | long long int llround(double);\r | |
316 | /* LONGLONG */\r | |
317 | long long int llroundf(float);\r | |
318 | \r | |
319 | /* 7.12.10 remainder */\r | |
320 | \r | |
321 | float fmodf(float, float);\r | |
322 | float remainderf(float, float);\r | |
323 | \r | |
324 | /* 7.2.11 manipulation */\r | |
325 | \r | |
326 | float copysignf(float, float);\r | |
327 | double nan(const char *);\r | |
328 | float nanf(const char *);\r | |
329 | long double nanl(const char *);\r | |
330 | float nextafterf(float, float);\r | |
331 | \r | |
332 | \r | |
333 | #endif /* !_ANSI_SOURCE && ... */\r | |
334 | \r | |
335 | #if defined(_NETBSD_SOURCE)\r | |
336 | #ifndef __cplusplus\r | |
337 | int matherr(struct exception *);\r | |
338 | #endif\r | |
339 | #endif /* _NETBSD_SOURCE */\r | |
340 | \r | |
341 | /*\r | |
342 | * IEEE Test Vector\r | |
343 | */\r | |
344 | double significand(double);\r | |
345 | #endif /* if 0 */\r | |
346 | \r | |
347 | /* 7.12.3.3 int isinf(real-floating x) */\r | |
348 | #ifdef __isinf\r | |
349 | #define isinf(__x) __isinf(__x)\r | |
350 | #else\r | |
351 | #define isinf(__x) __fpmacro_unary_floating(isinf, __x)\r | |
352 | #endif\r | |
353 | \r | |
354 | /* 7.12.3.4 int isnan(real-floating x) */\r | |
355 | #ifdef __isnan\r | |
356 | #define isnan(__x) __isnan(__x)\r | |
357 | #else\r | |
358 | #define isnan(__x) __fpmacro_unary_floating(isnan, __x)\r | |
359 | #endif\r | |
360 | \r | |
361 | /*\r | |
362 | * Functions callable from C, intended to support IEEE arithmetic.\r | |
363 | */\r | |
364 | double copysign(double, double);\r | |
365 | double scalbn(double, int);\r | |
366 | \r | |
367 | #if 0\r | |
368 | /*\r | |
369 | * BSD math library entry points\r | |
370 | */\r | |
371 | #ifndef __MATH_PRIVATE__\r | |
372 | double cabs(/* struct complex { double r; double i; } */);\r | |
373 | #endif\r | |
374 | double drem(double, double);\r | |
375 | \r | |
376 | \r | |
377 | #if defined(_NETBSD_SOURCE) || defined(_REENTRANT)\r | |
378 | /*\r | |
379 | * Reentrant version of gamma & lgamma; passes signgam back by reference\r | |
380 | * as the second argument; user must allocate space for signgam.\r | |
381 | */\r | |
382 | double gamma_r(double, int *);\r | |
383 | double lgamma_r(double, int *);\r | |
384 | #endif /* _NETBSD_SOURCE || _REENTRANT */\r | |
385 | \r | |
386 | \r | |
387 | #if defined(_NETBSD_SOURCE)\r | |
388 | \r | |
389 | /* float versions of ANSI/POSIX functions */\r | |
390 | \r | |
391 | float gammaf(float);\r | |
392 | int isinff(float);\r | |
393 | int isnanf(float);\r | |
394 | int finitef(float);\r | |
395 | float j0f(float);\r | |
396 | float j1f(float);\r | |
397 | float jnf(int, float);\r | |
398 | float y0f(float);\r | |
399 | float y1f(float);\r | |
400 | float ynf(int, float);\r | |
401 | \r | |
402 | float scalbf(float, float);\r | |
403 | \r | |
404 | /*\r | |
405 | * float version of IEEE Test Vector\r | |
406 | */\r | |
407 | float significandf(float);\r | |
408 | \r | |
409 | /*\r | |
410 | * float versions of BSD math library entry points\r | |
411 | */\r | |
412 | #ifndef __MATH_PRIVATE__\r | |
413 | float cabsf(/* struct complex { float r; float i; } */);\r | |
414 | #endif\r | |
415 | float dremf(float, float);\r | |
416 | #endif /* _NETBSD_SOURCE */\r | |
417 | \r | |
418 | #if defined(_NETBSD_SOURCE) || defined(_REENTRANT)\r | |
419 | /*\r | |
420 | * Float versions of reentrant version of gamma & lgamma; passes\r | |
421 | * signgam back by reference as the second argument; user must\r | |
422 | * allocate space for signgam.\r | |
423 | */\r | |
424 | float gammaf_r(float, int *);\r | |
425 | float lgammaf_r(float, int *);\r | |
426 | #endif /* !... || _REENTRANT */\r | |
427 | \r | |
428 | #endif /* if 0 */\r | |
429 | \r | |
430 | ///*\r | |
431 | // * Library implementation\r | |
432 | // */\r | |
433 | int __fpclassifyf(float);\r | |
434 | int __fpclassifyd(double);\r | |
435 | //int __isfinitef(float);\r | |
436 | //int __isfinited(double);\r | |
437 | int __isinff(float);\r | |
438 | int __isinfd(double);\r | |
439 | int __isnanf(float);\r | |
440 | int __isnand(double);\r | |
441 | //int __signbitf(float);\r | |
442 | //int __signbitd(double);\r | |
443 | \r | |
444 | //#ifdef __HAVE_LONG_DOUBLE\r | |
445 | int __fpclassifyl(long double);\r | |
446 | //int __isfinitel(long double);\r | |
447 | int __isinfl(long double);\r | |
448 | int __isnanl(long double);\r | |
449 | //int __signbitl(long double);\r | |
450 | //#endif\r | |
451 | __END_DECLS\r | |
452 | \r | |
453 | #endif /* _MATH_H_ */\r |