1 | #ifndef _MATH_H_ |
---|
2 | |
---|
3 | #define _MATH_H_ |
---|
4 | |
---|
5 | #include <sys/reent.h> |
---|
6 | #include <sys/cdefs.h> |
---|
7 | #include <machine/ieeefp.h> |
---|
8 | #include "_ansi.h" |
---|
9 | |
---|
10 | _BEGIN_STD_C |
---|
11 | |
---|
12 | /* Natural log of 2 */ |
---|
13 | #define _M_LN2 0.693147180559945309417 |
---|
14 | |
---|
15 | #if __GNUC_PREREQ (3, 3) |
---|
16 | /* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */ |
---|
17 | |
---|
18 | # ifndef HUGE_VAL |
---|
19 | # define HUGE_VAL (__builtin_huge_val()) |
---|
20 | # endif |
---|
21 | |
---|
22 | # ifndef HUGE_VALF |
---|
23 | # define HUGE_VALF (__builtin_huge_valf()) |
---|
24 | # endif |
---|
25 | |
---|
26 | # ifndef HUGE_VALL |
---|
27 | # define HUGE_VALL (__builtin_huge_vall()) |
---|
28 | # endif |
---|
29 | |
---|
30 | # ifndef INFINITY |
---|
31 | # define INFINITY (__builtin_inff()) |
---|
32 | # endif |
---|
33 | |
---|
34 | # ifndef NAN |
---|
35 | # define NAN (__builtin_nanf("")) |
---|
36 | # endif |
---|
37 | |
---|
38 | #else /* !gcc >= 3.3 */ |
---|
39 | |
---|
40 | /* No builtins. Use fixed defines instead. (All 3 HUGE plus the INFINITY |
---|
41 | * and NAN macros are required to be constant expressions. Using a variable-- |
---|
42 | * even a static const--does not meet this requirement, as it cannot be |
---|
43 | * evaluated at translation time.) |
---|
44 | * The infinities are done using numbers that are far in excess of |
---|
45 | * something that would be expected to be encountered in a floating-point |
---|
46 | * implementation. (A more certain way uses values from float.h, but that is |
---|
47 | * avoided because system includes are not supposed to include each other.) |
---|
48 | * This method might produce warnings from some compilers. (It does in |
---|
49 | * newer GCCs, but not for ones that would hit this #else.) If this happens, |
---|
50 | * please report details to the Newlib mailing list. */ |
---|
51 | |
---|
52 | #ifndef HUGE_VAL |
---|
53 | #define HUGE_VAL (1.0e999999999) |
---|
54 | #endif |
---|
55 | |
---|
56 | #ifndef HUGE_VALF |
---|
57 | #define HUGE_VALF (1.0e999999999F) |
---|
58 | #endif |
---|
59 | |
---|
60 | #if !defined(HUGE_VALL) && defined(_HAVE_LONG_DOUBLE) |
---|
61 | #define HUGE_VALL (1.0e999999999L) |
---|
62 | #endif |
---|
63 | |
---|
64 | #if !defined(INFINITY) |
---|
65 | #define INFINITY (HUGE_VALF) |
---|
66 | #endif |
---|
67 | |
---|
68 | #if !defined(NAN) |
---|
69 | #if defined(__GNUC__) && defined(__cplusplus) |
---|
70 | /* Exception: older g++ versions warn about the divide by 0 used in the |
---|
71 | * normal case (even though older gccs do not). This trick suppresses the |
---|
72 | * warning, but causes errors for plain gcc, so is only used in the one |
---|
73 | * special case. */ |
---|
74 | static const union { __ULong __i[1]; float __d; } __Nanf = {0x7FC00000}; |
---|
75 | #define NAN (__Nanf.__d) |
---|
76 | #else |
---|
77 | #define NAN (0.0F/0.0F) |
---|
78 | #endif |
---|
79 | #endif |
---|
80 | |
---|
81 | #endif /* !gcc >= 3.3 */ |
---|
82 | |
---|
83 | /* Reentrant ANSI C functions. */ |
---|
84 | |
---|
85 | #ifndef __math_68881 |
---|
86 | extern double atan (double); |
---|
87 | extern double cos (double); |
---|
88 | extern double sin (double); |
---|
89 | extern double tan (double); |
---|
90 | extern double tanh (double); |
---|
91 | extern double frexp (double, int *); |
---|
92 | extern double modf (double, double *); |
---|
93 | extern double ceil (double); |
---|
94 | extern double fabs (double); |
---|
95 | extern double floor (double); |
---|
96 | #endif /* ! defined (__math_68881) */ |
---|
97 | |
---|
98 | /* Non reentrant ANSI C functions. */ |
---|
99 | |
---|
100 | #ifndef _REENT_ONLY |
---|
101 | #ifndef __math_68881 |
---|
102 | extern double acos (double); |
---|
103 | extern double asin (double); |
---|
104 | extern double atan2 (double, double); |
---|
105 | extern double cosh (double); |
---|
106 | extern double sinh (double); |
---|
107 | extern double exp (double); |
---|
108 | extern double ldexp (double, int); |
---|
109 | extern double log (double); |
---|
110 | extern double log10 (double); |
---|
111 | extern double pow (double, double); |
---|
112 | extern double sqrt (double); |
---|
113 | extern double fmod (double, double); |
---|
114 | #endif /* ! defined (__math_68881) */ |
---|
115 | #endif /* ! defined (_REENT_ONLY) */ |
---|
116 | |
---|
117 | #if __MISC_VISIBLE |
---|
118 | extern int finite (double); |
---|
119 | extern int finitef (float); |
---|
120 | extern int finitel (long double); |
---|
121 | extern int isinff (float); |
---|
122 | extern int isnanf (float); |
---|
123 | #ifdef __CYGWIN__ /* not implemented in newlib yet */ |
---|
124 | extern int isinfl (long double); |
---|
125 | extern int isnanl (long double); |
---|
126 | #endif |
---|
127 | #if !defined(__cplusplus) || __cplusplus < 201103L |
---|
128 | extern int isinf (double); |
---|
129 | #endif |
---|
130 | #endif /* __MISC_VISIBLE */ |
---|
131 | #if (__MISC_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 600)) \ |
---|
132 | && (!defined(__cplusplus) || __cplusplus < 201103L) |
---|
133 | extern int isnan (double); |
---|
134 | #endif |
---|
135 | |
---|
136 | #if __ISO_C_VISIBLE >= 1999 |
---|
137 | /* ISO C99 types and macros. */ |
---|
138 | |
---|
139 | /* FIXME: FLT_EVAL_METHOD should somehow be gotten from float.h (which is hard, |
---|
140 | * considering that the standard says the includes it defines should not |
---|
141 | * include other includes that it defines) and that value used. (This can be |
---|
142 | * solved, but autoconf has a bug which makes the solution more difficult, so |
---|
143 | * it has been skipped for now.) */ |
---|
144 | #if !defined(FLT_EVAL_METHOD) && defined(__FLT_EVAL_METHOD__) |
---|
145 | #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ |
---|
146 | #define __TMP_FLT_EVAL_METHOD |
---|
147 | #endif /* FLT_EVAL_METHOD */ |
---|
148 | #if defined FLT_EVAL_METHOD |
---|
149 | #if FLT_EVAL_METHOD == 0 |
---|
150 | typedef float float_t; |
---|
151 | typedef double double_t; |
---|
152 | #elif FLT_EVAL_METHOD == 1 |
---|
153 | typedef double float_t; |
---|
154 | typedef double double_t; |
---|
155 | #elif FLT_EVAL_METHOD == 2 |
---|
156 | typedef long double float_t; |
---|
157 | typedef long double double_t; |
---|
158 | #else |
---|
159 | /* Implementation-defined. Assume float_t and double_t have been |
---|
160 | * defined previously for this configuration (e.g. config.h). */ |
---|
161 | #endif |
---|
162 | #else |
---|
163 | /* Assume basic definitions. */ |
---|
164 | typedef float float_t; |
---|
165 | typedef double double_t; |
---|
166 | #endif |
---|
167 | #if defined(__TMP_FLT_EVAL_METHOD) |
---|
168 | #undef FLT_EVAL_METHOD |
---|
169 | #endif |
---|
170 | |
---|
171 | #define FP_NAN 0 |
---|
172 | #define FP_INFINITE 1 |
---|
173 | #define FP_ZERO 2 |
---|
174 | #define FP_SUBNORMAL 3 |
---|
175 | #define FP_NORMAL 4 |
---|
176 | |
---|
177 | #ifndef FP_ILOGB0 |
---|
178 | # define FP_ILOGB0 (-__INT_MAX__) |
---|
179 | #endif |
---|
180 | #ifndef FP_ILOGBNAN |
---|
181 | # define FP_ILOGBNAN __INT_MAX__ |
---|
182 | #endif |
---|
183 | |
---|
184 | #ifndef MATH_ERRNO |
---|
185 | # define MATH_ERRNO 1 |
---|
186 | #endif |
---|
187 | #ifndef MATH_ERREXCEPT |
---|
188 | # define MATH_ERREXCEPT 2 |
---|
189 | #endif |
---|
190 | #ifndef math_errhandling |
---|
191 | # define math_errhandling MATH_ERRNO |
---|
192 | #endif |
---|
193 | |
---|
194 | extern int __isinff (float x); |
---|
195 | extern int __isinfd (double x); |
---|
196 | extern int __isnanf (float x); |
---|
197 | extern int __isnand (double x); |
---|
198 | extern int __fpclassifyf (float x); |
---|
199 | extern int __fpclassifyd (double x); |
---|
200 | extern int __signbitf (float x); |
---|
201 | extern int __signbitd (double x); |
---|
202 | |
---|
203 | /* Note: isinf and isnan were once functions in newlib that took double |
---|
204 | * arguments. C99 specifies that these names are reserved for macros |
---|
205 | * supporting multiple floating point types. Thus, they are |
---|
206 | * now defined as macros. Implementations of the old functions |
---|
207 | * taking double arguments still exist for compatibility purposes |
---|
208 | * (prototypes for them are earlier in this header). */ |
---|
209 | |
---|
210 | #if __GNUC_PREREQ (4, 4) |
---|
211 | #define fpclassify(__x) (__builtin_fpclassify (FP_NAN, FP_INFINITE, \ |
---|
212 | FP_NORMAL, FP_SUBNORMAL, \ |
---|
213 | FP_ZERO, __x)) |
---|
214 | #ifndef isfinite |
---|
215 | #define isfinite(__x) (__builtin_isfinite (__x)) |
---|
216 | #endif |
---|
217 | #ifndef isinf |
---|
218 | #define isinf(__x) (__builtin_isinf_sign (__x)) |
---|
219 | #endif |
---|
220 | #ifndef isnan |
---|
221 | #define isnan(__x) (__builtin_isnan (__x)) |
---|
222 | #endif |
---|
223 | #define isnormal(__x) (__builtin_isnormal (__x)) |
---|
224 | #else |
---|
225 | #define fpclassify(__x) \ |
---|
226 | ((sizeof(__x) == sizeof(float)) ? __fpclassifyf(__x) : \ |
---|
227 | __fpclassifyd(__x)) |
---|
228 | #ifndef isfinite |
---|
229 | #define isfinite(__y) \ |
---|
230 | (__extension__ ({int __cy = fpclassify(__y); \ |
---|
231 | __cy != FP_INFINITE && __cy != FP_NAN;})) |
---|
232 | #endif |
---|
233 | #ifndef isinf |
---|
234 | #define isinf(__x) (fpclassify(__x) == FP_INFINITE) |
---|
235 | #endif |
---|
236 | #ifndef isnan |
---|
237 | #define isnan(__x) (fpclassify(__x) == FP_NAN) |
---|
238 | #endif |
---|
239 | #define isnormal(__x) (fpclassify(__x) == FP_NORMAL) |
---|
240 | #endif |
---|
241 | |
---|
242 | #if __GNUC_PREREQ (4, 0) |
---|
243 | #if defined(_HAVE_LONG_DOUBLE) |
---|
244 | #define signbit(__x) \ |
---|
245 | ((sizeof(__x) == sizeof(float)) ? __builtin_signbitf(__x) : \ |
---|
246 | (sizeof(__x) == sizeof(double)) ? __builtin_signbit (__x) : \ |
---|
247 | __builtin_signbitl(__x)) |
---|
248 | #else |
---|
249 | #define signbit(__x) \ |
---|
250 | ((sizeof(__x) == sizeof(float)) ? __builtin_signbitf(__x) : \ |
---|
251 | __builtin_signbit (__x)) |
---|
252 | #endif |
---|
253 | #else |
---|
254 | #define signbit(__x) \ |
---|
255 | ((sizeof(__x) == sizeof(float)) ? __signbitf(__x) : \ |
---|
256 | __signbitd(__x)) |
---|
257 | #endif |
---|
258 | |
---|
259 | #if __GNUC_PREREQ (2, 97) |
---|
260 | #define isgreater(__x,__y) (__builtin_isgreater (__x, __y)) |
---|
261 | #define isgreaterequal(__x,__y) (__builtin_isgreaterequal (__x, __y)) |
---|
262 | #define isless(__x,__y) (__builtin_isless (__x, __y)) |
---|
263 | #define islessequal(__x,__y) (__builtin_islessequal (__x, __y)) |
---|
264 | #define islessgreater(__x,__y) (__builtin_islessgreater (__x, __y)) |
---|
265 | #define isunordered(__x,__y) (__builtin_isunordered (__x, __y)) |
---|
266 | #else |
---|
267 | #define isgreater(x,y) \ |
---|
268 | (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ |
---|
269 | !isunordered(__x,__y) && (__x > __y);})) |
---|
270 | #define isgreaterequal(x,y) \ |
---|
271 | (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ |
---|
272 | !isunordered(__x,__y) && (__x >= __y);})) |
---|
273 | #define isless(x,y) \ |
---|
274 | (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ |
---|
275 | !isunordered(__x,__y) && (__x < __y);})) |
---|
276 | #define islessequal(x,y) \ |
---|
277 | (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ |
---|
278 | !isunordered(__x,__y) && (__x <= __y);})) |
---|
279 | #define islessgreater(x,y) \ |
---|
280 | (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ |
---|
281 | !isunordered(__x,__y) && (__x < __y || __x > __y);})) |
---|
282 | |
---|
283 | #define isunordered(a,b) \ |
---|
284 | (__extension__ ({__typeof__(a) __a = (a); __typeof__(b) __b = (b); \ |
---|
285 | fpclassify(__a) == FP_NAN || fpclassify(__b) == FP_NAN;})) |
---|
286 | #endif |
---|
287 | |
---|
288 | /* Non ANSI double precision functions. */ |
---|
289 | |
---|
290 | extern double infinity (void); |
---|
291 | extern double nan (const char *); |
---|
292 | extern double copysign (double, double); |
---|
293 | extern double logb (double); |
---|
294 | extern int ilogb (double); |
---|
295 | |
---|
296 | extern double asinh (double); |
---|
297 | extern double cbrt (double); |
---|
298 | extern double nextafter (double, double); |
---|
299 | extern double rint (double); |
---|
300 | extern double scalbn (double, int); |
---|
301 | |
---|
302 | extern double exp2 (double); |
---|
303 | extern double scalbln (double, long int); |
---|
304 | extern double tgamma (double); |
---|
305 | extern double nearbyint (double); |
---|
306 | extern long int lrint (double); |
---|
307 | extern long long int llrint (double); |
---|
308 | extern double round (double); |
---|
309 | extern long int lround (double); |
---|
310 | extern long long int llround (double); |
---|
311 | extern double trunc (double); |
---|
312 | extern double remquo (double, double, int *); |
---|
313 | extern double fdim (double, double); |
---|
314 | extern double fmax (double, double); |
---|
315 | extern double fmin (double, double); |
---|
316 | extern double fma (double, double, double); |
---|
317 | |
---|
318 | #ifndef __math_68881 |
---|
319 | extern double log1p (double); |
---|
320 | extern double expm1 (double); |
---|
321 | #endif /* ! defined (__math_68881) */ |
---|
322 | |
---|
323 | #ifndef _REENT_ONLY |
---|
324 | extern double acosh (double); |
---|
325 | extern double atanh (double); |
---|
326 | extern double remainder (double, double); |
---|
327 | extern double gamma (double); |
---|
328 | extern double lgamma (double); |
---|
329 | extern double erf (double); |
---|
330 | extern double erfc (double); |
---|
331 | extern double log2 (double); |
---|
332 | #if !defined(__cplusplus) |
---|
333 | #define log2(x) (log (x) / _M_LN2) |
---|
334 | #endif |
---|
335 | |
---|
336 | #ifndef __math_68881 |
---|
337 | extern double hypot (double, double); |
---|
338 | #endif |
---|
339 | |
---|
340 | #endif /* ! defined (_REENT_ONLY) */ |
---|
341 | |
---|
342 | /* Single precision versions of ANSI functions. */ |
---|
343 | |
---|
344 | extern float atanf (float); |
---|
345 | extern float cosf (float); |
---|
346 | extern float sinf (float); |
---|
347 | extern float tanf (float); |
---|
348 | extern float tanhf (float); |
---|
349 | extern float frexpf (float, int *); |
---|
350 | extern float modff (float, float *); |
---|
351 | extern float ceilf (float); |
---|
352 | extern float fabsf (float); |
---|
353 | extern float floorf (float); |
---|
354 | |
---|
355 | #ifndef _REENT_ONLY |
---|
356 | extern float acosf (float); |
---|
357 | extern float asinf (float); |
---|
358 | extern float atan2f (float, float); |
---|
359 | extern float coshf (float); |
---|
360 | extern float sinhf (float); |
---|
361 | extern float expf (float); |
---|
362 | extern float ldexpf (float, int); |
---|
363 | extern float logf (float); |
---|
364 | extern float log10f (float); |
---|
365 | extern float powf (float, float); |
---|
366 | extern float sqrtf (float); |
---|
367 | extern float fmodf (float, float); |
---|
368 | #endif /* ! defined (_REENT_ONLY) */ |
---|
369 | |
---|
370 | /* Other single precision functions. */ |
---|
371 | |
---|
372 | extern float exp2f (float); |
---|
373 | extern float scalblnf (float, long int); |
---|
374 | extern float tgammaf (float); |
---|
375 | extern float nearbyintf (float); |
---|
376 | extern long int lrintf (float); |
---|
377 | extern long long int llrintf (float); |
---|
378 | extern float roundf (float); |
---|
379 | extern long int lroundf (float); |
---|
380 | extern long long int llroundf (float); |
---|
381 | extern float truncf (float); |
---|
382 | extern float remquof (float, float, int *); |
---|
383 | extern float fdimf (float, float); |
---|
384 | extern float fmaxf (float, float); |
---|
385 | extern float fminf (float, float); |
---|
386 | extern float fmaf (float, float, float); |
---|
387 | |
---|
388 | extern float infinityf (void); |
---|
389 | extern float nanf (const char *); |
---|
390 | extern float copysignf (float, float); |
---|
391 | extern float logbf (float); |
---|
392 | extern int ilogbf (float); |
---|
393 | |
---|
394 | extern float asinhf (float); |
---|
395 | extern float cbrtf (float); |
---|
396 | extern float nextafterf (float, float); |
---|
397 | extern float rintf (float); |
---|
398 | extern float scalbnf (float, int); |
---|
399 | extern float log1pf (float); |
---|
400 | extern float expm1f (float); |
---|
401 | |
---|
402 | #ifndef _REENT_ONLY |
---|
403 | extern float acoshf (float); |
---|
404 | extern float atanhf (float); |
---|
405 | extern float remainderf (float, float); |
---|
406 | extern float gammaf (float); |
---|
407 | extern float lgammaf (float); |
---|
408 | extern float erff (float); |
---|
409 | extern float erfcf (float); |
---|
410 | extern float log2f (float); |
---|
411 | extern float hypotf (float, float); |
---|
412 | #endif /* ! defined (_REENT_ONLY) */ |
---|
413 | |
---|
414 | /* Newlib doesn't fully support long double math functions so far. |
---|
415 | On platforms where long double equals double the long double functions |
---|
416 | simply call the double functions. On Cygwin the long double functions |
---|
417 | are implemented independently from newlib to be able to use optimized |
---|
418 | assembler functions despite using the Microsoft x86_64 ABI. */ |
---|
419 | #if defined (_LDBL_EQ_DBL) || defined (__CYGWIN__) |
---|
420 | /* Reentrant ANSI C functions. */ |
---|
421 | #ifndef __math_68881 |
---|
422 | extern long double atanl (long double); |
---|
423 | extern long double cosl (long double); |
---|
424 | extern long double sinl (long double); |
---|
425 | extern long double tanl (long double); |
---|
426 | extern long double tanhl (long double); |
---|
427 | extern long double frexpl (long double, int *); |
---|
428 | extern long double modfl (long double, long double *); |
---|
429 | extern long double ceill (long double); |
---|
430 | extern long double fabsl (long double); |
---|
431 | extern long double floorl (long double); |
---|
432 | extern long double log1pl (long double); |
---|
433 | extern long double expm1l (long double); |
---|
434 | #endif /* ! defined (__math_68881) */ |
---|
435 | /* Non reentrant ANSI C functions. */ |
---|
436 | #ifndef _REENT_ONLY |
---|
437 | #ifndef __math_68881 |
---|
438 | extern long double acosl (long double); |
---|
439 | extern long double asinl (long double); |
---|
440 | extern long double atan2l (long double, long double); |
---|
441 | extern long double coshl (long double); |
---|
442 | extern long double sinhl (long double); |
---|
443 | extern long double expl (long double); |
---|
444 | extern long double ldexpl (long double, int); |
---|
445 | extern long double logl (long double); |
---|
446 | extern long double log10l (long double); |
---|
447 | extern long double powl (long double, long double); |
---|
448 | extern long double sqrtl (long double); |
---|
449 | extern long double fmodl (long double, long double); |
---|
450 | extern long double hypotl (long double, long double); |
---|
451 | #endif /* ! defined (__math_68881) */ |
---|
452 | #endif /* ! defined (_REENT_ONLY) */ |
---|
453 | extern long double copysignl (long double, long double); |
---|
454 | extern long double nanl (const char *); |
---|
455 | extern int ilogbl (long double); |
---|
456 | extern long double asinhl (long double); |
---|
457 | extern long double cbrtl (long double); |
---|
458 | extern long double nextafterl (long double, long double); |
---|
459 | extern float nexttowardf (float, long double); |
---|
460 | extern double nexttoward (double, long double); |
---|
461 | extern long double nexttowardl (long double, long double); |
---|
462 | extern long double logbl (long double); |
---|
463 | extern long double log2l (long double); |
---|
464 | extern long double rintl (long double); |
---|
465 | extern long double scalbnl (long double, int); |
---|
466 | extern long double exp2l (long double); |
---|
467 | extern long double scalblnl (long double, long); |
---|
468 | extern long double tgammal (long double); |
---|
469 | extern long double nearbyintl (long double); |
---|
470 | extern long int lrintl (long double); |
---|
471 | extern long long int llrintl (long double); |
---|
472 | extern long double roundl (long double); |
---|
473 | extern long lroundl (long double); |
---|
474 | extern long long int llroundl (long double); |
---|
475 | extern long double truncl (long double); |
---|
476 | extern long double remquol (long double, long double, int *); |
---|
477 | extern long double fdiml (long double, long double); |
---|
478 | extern long double fmaxl (long double, long double); |
---|
479 | extern long double fminl (long double, long double); |
---|
480 | extern long double fmal (long double, long double, long double); |
---|
481 | #ifndef _REENT_ONLY |
---|
482 | extern long double acoshl (long double); |
---|
483 | extern long double atanhl (long double); |
---|
484 | extern long double remainderl (long double, long double); |
---|
485 | extern long double lgammal (long double); |
---|
486 | extern long double erfl (long double); |
---|
487 | extern long double erfcl (long double); |
---|
488 | #endif /* ! defined (_REENT_ONLY) */ |
---|
489 | #else /* !_LDBL_EQ_DBL && !__CYGWIN__ */ |
---|
490 | extern long double hypotl (long double, long double); |
---|
491 | extern long double sqrtl (long double); |
---|
492 | #ifdef __i386__ |
---|
493 | /* Other long double precision functions. */ |
---|
494 | extern _LONG_DOUBLE rintl (_LONG_DOUBLE); |
---|
495 | extern long int lrintl (_LONG_DOUBLE); |
---|
496 | extern long long int llrintl (_LONG_DOUBLE); |
---|
497 | #endif /* __i386__ */ |
---|
498 | #endif /* !_LDBL_EQ_DBL && !__CYGWIN__ */ |
---|
499 | |
---|
500 | #endif /* __ISO_C_VISIBLE >= 1999 */ |
---|
501 | |
---|
502 | #if __MISC_VISIBLE |
---|
503 | extern double drem (double, double); |
---|
504 | extern float dremf (float, float); |
---|
505 | #ifdef __CYGWIN__ |
---|
506 | extern float dreml (long double, long double); |
---|
507 | #endif /* __CYGWIN__ */ |
---|
508 | extern double gamma_r (double, int *); |
---|
509 | extern double lgamma_r (double, int *); |
---|
510 | extern float gammaf_r (float, int *); |
---|
511 | extern float lgammaf_r (float, int *); |
---|
512 | #endif |
---|
513 | |
---|
514 | #if __MISC_VISIBLE || __XSI_VISIBLE |
---|
515 | extern double y0 (double); |
---|
516 | extern double y1 (double); |
---|
517 | extern double yn (int, double); |
---|
518 | extern double j0 (double); |
---|
519 | extern double j1 (double); |
---|
520 | extern double jn (int, double); |
---|
521 | #endif |
---|
522 | |
---|
523 | #if __MISC_VISIBLE || __XSI_VISIBLE >= 600 |
---|
524 | extern float y0f (float); |
---|
525 | extern float y1f (float); |
---|
526 | extern float ynf (int, float); |
---|
527 | extern float j0f (float); |
---|
528 | extern float j1f (float); |
---|
529 | extern float jnf (int, float); |
---|
530 | #endif |
---|
531 | |
---|
532 | /* GNU extensions */ |
---|
533 | #if __GNU_VISIBLE |
---|
534 | extern void sincos (double, double *, double *); |
---|
535 | extern void sincosf (float, float *, float *); |
---|
536 | #ifdef __CYGWIN__ |
---|
537 | extern void sincosl (long double, long double *, long double *); |
---|
538 | #endif /* __CYGWIN__ */ |
---|
539 | # ifndef exp10 |
---|
540 | extern double exp10 (double); |
---|
541 | # endif |
---|
542 | # ifndef pow10 |
---|
543 | extern double pow10 (double); |
---|
544 | # endif |
---|
545 | # ifndef exp10f |
---|
546 | extern float exp10f (float); |
---|
547 | # endif |
---|
548 | # ifndef pow10f |
---|
549 | extern float pow10f (float); |
---|
550 | # endif |
---|
551 | #ifdef __CYGWIN__ |
---|
552 | # ifndef exp10l |
---|
553 | extern float exp10l (float); |
---|
554 | # endif |
---|
555 | # ifndef pow10l |
---|
556 | extern float pow10l (float); |
---|
557 | # endif |
---|
558 | #endif /* __CYGWIN__ */ |
---|
559 | #endif /* __GNU_VISIBLE */ |
---|
560 | |
---|
561 | #if __MISC_VISIBLE || __XSI_VISIBLE |
---|
562 | /* The gamma functions use a global variable, signgam. */ |
---|
563 | #ifndef _REENT_ONLY |
---|
564 | #define signgam (*__signgam()) |
---|
565 | extern int *__signgam (void); |
---|
566 | #endif /* ! defined (_REENT_ONLY) */ |
---|
567 | |
---|
568 | #define __signgam_r(ptr) _REENT_SIGNGAM(ptr) |
---|
569 | #endif /* __MISC_VISIBLE || __XSI_VISIBLE */ |
---|
570 | |
---|
571 | #if __SVID_VISIBLE |
---|
572 | /* The exception structure passed to the matherr routine. */ |
---|
573 | /* We have a problem when using C++ since `exception' is a reserved |
---|
574 | name in C++. */ |
---|
575 | #ifdef __cplusplus |
---|
576 | struct __exception |
---|
577 | #else |
---|
578 | struct exception |
---|
579 | #endif |
---|
580 | { |
---|
581 | int type; |
---|
582 | char *name; |
---|
583 | double arg1; |
---|
584 | double arg2; |
---|
585 | double retval; |
---|
586 | int err; |
---|
587 | }; |
---|
588 | |
---|
589 | #ifdef __cplusplus |
---|
590 | extern int matherr (struct __exception *e); |
---|
591 | #else |
---|
592 | extern int matherr (struct exception *e); |
---|
593 | #endif |
---|
594 | |
---|
595 | /* Values for the type field of struct exception. */ |
---|
596 | |
---|
597 | #define DOMAIN 1 |
---|
598 | #define SING 2 |
---|
599 | #define OVERFLOW 3 |
---|
600 | #define UNDERFLOW 4 |
---|
601 | #define TLOSS 5 |
---|
602 | #define PLOSS 6 |
---|
603 | |
---|
604 | #endif /* __SVID_VISIBLE */ |
---|
605 | |
---|
606 | /* Useful constants. */ |
---|
607 | |
---|
608 | #if __BSD_VISIBLE || __XSI_VISIBLE |
---|
609 | |
---|
610 | #define MAXFLOAT 3.40282347e+38F |
---|
611 | |
---|
612 | #define M_E 2.7182818284590452354 |
---|
613 | #define M_LOG2E 1.4426950408889634074 |
---|
614 | #define M_LOG10E 0.43429448190325182765 |
---|
615 | #define M_LN2 _M_LN2 |
---|
616 | #define M_LN10 2.30258509299404568402 |
---|
617 | #define M_PI 3.14159265358979323846 |
---|
618 | #define M_PI_2 1.57079632679489661923 |
---|
619 | #define M_PI_4 0.78539816339744830962 |
---|
620 | #define M_1_PI 0.31830988618379067154 |
---|
621 | #define M_2_PI 0.63661977236758134308 |
---|
622 | #define M_2_SQRTPI 1.12837916709551257390 |
---|
623 | #define M_SQRT2 1.41421356237309504880 |
---|
624 | #define M_SQRT1_2 0.70710678118654752440 |
---|
625 | |
---|
626 | #endif |
---|
627 | |
---|
628 | #if __BSD_VISIBLE |
---|
629 | |
---|
630 | #define M_TWOPI (M_PI * 2.0) |
---|
631 | #define M_3PI_4 2.3561944901923448370E0 |
---|
632 | #define M_SQRTPI 1.77245385090551602792981 |
---|
633 | #define M_LN2LO 1.9082149292705877000E-10 |
---|
634 | #define M_LN2HI 6.9314718036912381649E-1 |
---|
635 | #define M_SQRT3 1.73205080756887719000 |
---|
636 | #define M_IVLN10 0.43429448190325182765 /* 1 / log(10) */ |
---|
637 | #define M_LOG2_E _M_LN2 |
---|
638 | #define M_INVLN2 1.4426950408889633870E0 /* 1 / log(2) */ |
---|
639 | |
---|
640 | /* Global control over fdlibm error handling. */ |
---|
641 | |
---|
642 | enum __fdlibm_version |
---|
643 | { |
---|
644 | __fdlibm_ieee = -1, |
---|
645 | __fdlibm_svid, |
---|
646 | __fdlibm_xopen, |
---|
647 | __fdlibm_posix |
---|
648 | }; |
---|
649 | |
---|
650 | #define _LIB_VERSION_TYPE enum __fdlibm_version |
---|
651 | #define _LIB_VERSION __fdlib_version |
---|
652 | |
---|
653 | extern __IMPORT _LIB_VERSION_TYPE _LIB_VERSION; |
---|
654 | |
---|
655 | #define _IEEE_ __fdlibm_ieee |
---|
656 | #define _SVID_ __fdlibm_svid |
---|
657 | #define _XOPEN_ __fdlibm_xopen |
---|
658 | #define _POSIX_ __fdlibm_posix |
---|
659 | |
---|
660 | #endif /* __BSD_VISIBLE */ |
---|
661 | |
---|
662 | _END_STD_C |
---|
663 | |
---|
664 | #ifdef __FAST_MATH__ |
---|
665 | #include <machine/fastmath.h> |
---|
666 | #endif |
---|
667 | |
---|
668 | #endif /* _MATH_H_ */ |
---|