]>
Commit | Line | Data |
---|---|---|
8a0efa53 | 1 | #ifndef _MATH_H_ |
c4ccbcce | 2 | |
8a0efa53 CF |
3 | #define _MATH_H_ |
4 | ||
5 | #include <sys/reent.h> | |
4e8291b8 | 6 | #include <sys/cdefs.h> |
8a0efa53 CF |
7 | #include <machine/ieeefp.h> |
8 | #include "_ansi.h" | |
9 | ||
c1a3171f JJ |
10 | _BEGIN_STD_C |
11 | ||
78e66fb9 | 12 | /* Natural log of 2 */ |
fd451503 | 13 | #define _M_LN2 0.693147180559945309417 |
6494ee83 | 14 | |
5eceb395 | 15 | #if __GNUC_PREREQ (3, 3) |
09968b6d JJ |
16 | /* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */ |
17 | ||
895d76fe EB |
18 | # ifndef HUGE_VAL |
19 | # define HUGE_VAL (__builtin_huge_val()) | |
20 | # endif | |
09968b6d | 21 | |
895d76fe EB |
22 | # ifndef HUGE_VALF |
23 | # define HUGE_VALF (__builtin_huge_valf()) | |
24 | # endif | |
09968b6d | 25 | |
895d76fe EB |
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 | |
09968b6d JJ |
37 | |
38 | #else /* !gcc >= 3.3 */ | |
39 | ||
de8a5b78 JJ |
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. */ | |
09968b6d JJ |
51 | |
52 | #ifndef HUGE_VAL | |
de8a5b78 | 53 | #define HUGE_VAL (1.0e999999999) |
09968b6d JJ |
54 | #endif |
55 | ||
56 | #ifndef HUGE_VALF | |
de8a5b78 JJ |
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) | |
09968b6d | 66 | #endif |
7c110b17 | 67 | |
de8a5b78 JJ |
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 | |
09968b6d | 79 | #endif |
8a0efa53 | 80 | |
09968b6d | 81 | #endif /* !gcc >= 3.3 */ |
8a0efa53 CF |
82 | |
83 | /* Reentrant ANSI C functions. */ | |
84 | ||
85 | #ifndef __math_68881 | |
eea249da YS |
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); | |
8a0efa53 CF |
96 | #endif /* ! defined (__math_68881) */ |
97 | ||
98 | /* Non reentrant ANSI C functions. */ | |
99 | ||
100 | #ifndef _REENT_ONLY | |
823f6f66 | 101 | #ifndef __math_68881 |
eea249da YS |
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); | |
8a0efa53 CF |
114 | #endif /* ! defined (__math_68881) */ |
115 | #endif /* ! defined (_REENT_ONLY) */ | |
116 | ||
722e363c | 117 | #if __MISC_VISIBLE |
eea249da YS |
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); | |
722e363c | 123 | #ifdef __CYGWIN__ /* not implemented in newlib yet */ |
eea249da YS |
124 | extern int isinfl (long double); |
125 | extern int isnanl (long double); | |
722e363c YS |
126 | #endif |
127 | #if !defined(__cplusplus) || __cplusplus < 201103L | |
eea249da | 128 | extern int isinf (double); |
722e363c YS |
129 | #endif |
130 | #endif /* __MISC_VISIBLE */ | |
131 | #if (__MISC_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 600)) \ | |
132 | && (!defined(__cplusplus) || __cplusplus < 201103L) | |
eea249da | 133 | extern int isnan (double); |
722e363c YS |
134 | #endif |
135 | ||
4e8291b8 | 136 | #if __ISO_C_VISIBLE >= 1999 |
0953fe64 TF |
137 | /* ISO C99 types and macros. */ |
138 | ||
b060af22 JJ |
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 | |
0953fe64 | 147 | #endif /* FLT_EVAL_METHOD */ |
b060af22 | 148 | #if defined FLT_EVAL_METHOD |
91f99d32 KC |
149 | /* FLT_EVAL_METHOD == 16 has meaning as defined in ISO/IEC TS 18661-3, |
150 | * which provides non-compliant extensions to C and POSIX (by adding | |
151 | * additional positive values for FLT_EVAL_METHOD). It effectively has | |
152 | * same meaning as the C99 and C11 definitions for value 0, while also | |
153 | * serving as a flag that the _Float16 (float16_t) type exists. | |
154 | * | |
155 | * FLT_EVAL_METHOD could be any number of bits of supported floating point | |
156 | * format (e.g. 32, 64, 128), but currently only AArch64 and few other targets | |
157 | * might define that as 16. */ | |
158 | #if (FLT_EVAL_METHOD == 0) \ | |
159 | || (FLT_EVAL_METHOD == 16) | |
b060af22 JJ |
160 | typedef float float_t; |
161 | typedef double double_t; | |
162 | #elif FLT_EVAL_METHOD == 1 | |
163 | typedef double float_t; | |
164 | typedef double double_t; | |
165 | #elif FLT_EVAL_METHOD == 2 | |
166 | typedef long double float_t; | |
167 | typedef long double double_t; | |
168 | #else | |
169 | /* Implementation-defined. Assume float_t and double_t have been | |
170 | * defined previously for this configuration (e.g. config.h). */ | |
27f0913c AC |
171 | |
172 | /* If __DOUBLE_TYPE is defined (__FLOAT_TYPE is then supposed to be | |
173 | defined as well) float_t and double_t definition is suggested by | |
174 | an arch specific header. */ | |
175 | #ifdef __DOUBLE_TYPE | |
176 | typedef __DOUBLE_TYPE double_t; | |
177 | typedef __FLOAT_TYPE float_t; | |
178 | #endif | |
179 | /* Assume config.h has provided these types. */ | |
b060af22 JJ |
180 | #endif |
181 | #else | |
182 | /* Assume basic definitions. */ | |
183 | typedef float float_t; | |
184 | typedef double double_t; | |
185 | #endif | |
186 | #if defined(__TMP_FLT_EVAL_METHOD) | |
187 | #undef FLT_EVAL_METHOD | |
188 | #endif | |
0953fe64 TF |
189 | |
190 | #define FP_NAN 0 | |
191 | #define FP_INFINITE 1 | |
192 | #define FP_ZERO 2 | |
193 | #define FP_SUBNORMAL 3 | |
194 | #define FP_NORMAL 4 | |
195 | ||
895d76fe | 196 | #ifndef FP_ILOGB0 |
357da5bc | 197 | # define FP_ILOGB0 (-__INT_MAX__) |
895d76fe EB |
198 | #endif |
199 | #ifndef FP_ILOGBNAN | |
357da5bc | 200 | # define FP_ILOGBNAN __INT_MAX__ |
895d76fe EB |
201 | #endif |
202 | ||
203 | #ifndef MATH_ERRNO | |
204 | # define MATH_ERRNO 1 | |
205 | #endif | |
206 | #ifndef MATH_ERREXCEPT | |
207 | # define MATH_ERREXCEPT 2 | |
208 | #endif | |
209 | #ifndef math_errhandling | |
45efe659 KPN |
210 | # ifdef _IEEE_LIBM |
211 | # define _MATH_ERRHANDLING_ERRNO 0 | |
212 | # else | |
213 | # define _MATH_ERRHANDLING_ERRNO MATH_ERRNO | |
214 | # endif | |
215 | # ifdef _SUPPORTS_ERREXCEPT | |
216 | # define _MATH_ERRHANDLING_ERREXCEPT MATH_ERREXCEPT | |
217 | # else | |
218 | # define _MATH_ERRHANDLING_ERREXCEPT 0 | |
219 | # endif | |
220 | # define math_errhandling (_MATH_ERRHANDLING_ERRNO | _MATH_ERRHANDLING_ERREXCEPT) | |
895d76fe EB |
221 | #endif |
222 | ||
4c49accf CL |
223 | extern int __isinff (float); |
224 | extern int __isinfd (double); | |
225 | extern int __isnanf (float); | |
226 | extern int __isnand (double); | |
227 | extern int __fpclassifyf (float); | |
228 | extern int __fpclassifyd (double); | |
229 | extern int __signbitf (float); | |
230 | extern int __signbitd (double); | |
0953fe64 | 231 | |
e48682cf JJ |
232 | /* Note: isinf and isnan were once functions in newlib that took double |
233 | * arguments. C99 specifies that these names are reserved for macros | |
234 | * supporting multiple floating point types. Thus, they are | |
235 | * now defined as macros. Implementations of the old functions | |
664f0076 | 236 | * taking double arguments still exist for compatibility purposes |
cd84d1c2 | 237 | * (prototypes for them are earlier in this header). */ |
976e9d28 | 238 | |
799fdda4 CV |
239 | #if __GNUC_PREREQ (4, 4) |
240 | #define fpclassify(__x) (__builtin_fpclassify (FP_NAN, FP_INFINITE, \ | |
241 | FP_NORMAL, FP_SUBNORMAL, \ | |
242 | FP_ZERO, __x)) | |
243 | #ifndef isfinite | |
244 | #define isfinite(__x) (__builtin_isfinite (__x)) | |
245 | #endif | |
246 | #ifndef isinf | |
247 | #define isinf(__x) (__builtin_isinf_sign (__x)) | |
248 | #endif | |
249 | #ifndef isnan | |
250 | #define isnan(__x) (__builtin_isnan (__x)) | |
251 | #endif | |
252 | #define isnormal(__x) (__builtin_isnormal (__x)) | |
253 | #else | |
254 | #define fpclassify(__x) \ | |
255 | ((sizeof(__x) == sizeof(float)) ? __fpclassifyf(__x) : \ | |
256 | __fpclassifyd(__x)) | |
257 | #ifndef isfinite | |
258 | #define isfinite(__y) \ | |
259 | (__extension__ ({int __cy = fpclassify(__y); \ | |
260 | __cy != FP_INFINITE && __cy != FP_NAN;})) | |
261 | #endif | |
262 | #ifndef isinf | |
263 | #define isinf(__x) (fpclassify(__x) == FP_INFINITE) | |
264 | #endif | |
265 | #ifndef isnan | |
266 | #define isnan(__x) (fpclassify(__x) == FP_NAN) | |
267 | #endif | |
268 | #define isnormal(__x) (fpclassify(__x) == FP_NORMAL) | |
976e9d28 JJ |
269 | #endif |
270 | ||
799fdda4 CV |
271 | #if __GNUC_PREREQ (4, 0) |
272 | #if defined(_HAVE_LONG_DOUBLE) | |
273 | #define signbit(__x) \ | |
274 | ((sizeof(__x) == sizeof(float)) ? __builtin_signbitf(__x) : \ | |
275 | (sizeof(__x) == sizeof(double)) ? __builtin_signbit (__x) : \ | |
276 | __builtin_signbitl(__x)) | |
277 | #else | |
278 | #define signbit(__x) \ | |
279 | ((sizeof(__x) == sizeof(float)) ? __builtin_signbitf(__x) : \ | |
280 | __builtin_signbit (__x)) | |
281 | #endif | |
282 | #else | |
283 | #define signbit(__x) \ | |
284 | ((sizeof(__x) == sizeof(float)) ? __signbitf(__x) : \ | |
285 | __signbitd(__x)) | |
286 | #endif | |
0953fe64 | 287 | |
799fdda4 CV |
288 | #if __GNUC_PREREQ (2, 97) |
289 | #define isgreater(__x,__y) (__builtin_isgreater (__x, __y)) | |
290 | #define isgreaterequal(__x,__y) (__builtin_isgreaterequal (__x, __y)) | |
291 | #define isless(__x,__y) (__builtin_isless (__x, __y)) | |
292 | #define islessequal(__x,__y) (__builtin_islessequal (__x, __y)) | |
293 | #define islessgreater(__x,__y) (__builtin_islessgreater (__x, __y)) | |
294 | #define isunordered(__x,__y) (__builtin_isunordered (__x, __y)) | |
295 | #else | |
0953fe64 TF |
296 | #define isgreater(x,y) \ |
297 | (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ | |
298 | !isunordered(__x,__y) && (__x > __y);})) | |
299 | #define isgreaterequal(x,y) \ | |
300 | (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ | |
301 | !isunordered(__x,__y) && (__x >= __y);})) | |
302 | #define isless(x,y) \ | |
303 | (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ | |
304 | !isunordered(__x,__y) && (__x < __y);})) | |
305 | #define islessequal(x,y) \ | |
306 | (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ | |
307 | !isunordered(__x,__y) && (__x <= __y);})) | |
308 | #define islessgreater(x,y) \ | |
309 | (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ | |
310 | !isunordered(__x,__y) && (__x < __y || __x > __y);})) | |
311 | ||
b59cab1e JJ |
312 | #define isunordered(a,b) \ |
313 | (__extension__ ({__typeof__(a) __a = (a); __typeof__(b) __b = (b); \ | |
314 | fpclassify(__a) == FP_NAN || fpclassify(__b) == FP_NAN;})) | |
799fdda4 | 315 | #endif |
0953fe64 | 316 | |
8a0efa53 CF |
317 | /* Non ANSI double precision functions. */ |
318 | ||
eea249da YS |
319 | extern double infinity (void); |
320 | extern double nan (const char *); | |
321 | extern double copysign (double, double); | |
322 | extern double logb (double); | |
323 | extern int ilogb (double); | |
324 | ||
325 | extern double asinh (double); | |
326 | extern double cbrt (double); | |
327 | extern double nextafter (double, double); | |
328 | extern double rint (double); | |
329 | extern double scalbn (double, int); | |
330 | ||
331 | extern double exp2 (double); | |
332 | extern double scalbln (double, long int); | |
333 | extern double tgamma (double); | |
334 | extern double nearbyint (double); | |
335 | extern long int lrint (double); | |
336 | extern long long int llrint (double); | |
337 | extern double round (double); | |
338 | extern long int lround (double); | |
339 | extern long long int llround (double); | |
340 | extern double trunc (double); | |
341 | extern double remquo (double, double, int *); | |
342 | extern double fdim (double, double); | |
343 | extern double fmax (double, double); | |
344 | extern double fmin (double, double); | |
345 | extern double fma (double, double, double); | |
e0500490 | 346 | |
8a0efa53 | 347 | #ifndef __math_68881 |
eea249da YS |
348 | extern double log1p (double); |
349 | extern double expm1 (double); | |
8a0efa53 CF |
350 | #endif /* ! defined (__math_68881) */ |
351 | ||
352 | #ifndef _REENT_ONLY | |
eea249da YS |
353 | extern double acosh (double); |
354 | extern double atanh (double); | |
355 | extern double remainder (double, double); | |
356 | extern double gamma (double); | |
357 | extern double lgamma (double); | |
358 | extern double erf (double); | |
359 | extern double erfc (double); | |
360 | extern double log2 (double); | |
d8a43935 | 361 | #if !defined(__cplusplus) |
fd451503 | 362 | #define log2(x) (log (x) / _M_LN2) |
d8a43935 | 363 | #endif |
8a0efa53 CF |
364 | |
365 | #ifndef __math_68881 | |
eea249da | 366 | extern double hypot (double, double); |
8a0efa53 CF |
367 | #endif |
368 | ||
8a0efa53 CF |
369 | #endif /* ! defined (_REENT_ONLY) */ |
370 | ||
371 | /* Single precision versions of ANSI functions. */ | |
372 | ||
eea249da YS |
373 | extern float atanf (float); |
374 | extern float cosf (float); | |
375 | extern float sinf (float); | |
376 | extern float tanf (float); | |
377 | extern float tanhf (float); | |
378 | extern float frexpf (float, int *); | |
379 | extern float modff (float, float *); | |
380 | extern float ceilf (float); | |
381 | extern float fabsf (float); | |
382 | extern float floorf (float); | |
8a0efa53 CF |
383 | |
384 | #ifndef _REENT_ONLY | |
eea249da YS |
385 | extern float acosf (float); |
386 | extern float asinf (float); | |
387 | extern float atan2f (float, float); | |
388 | extern float coshf (float); | |
389 | extern float sinhf (float); | |
390 | extern float expf (float); | |
391 | extern float ldexpf (float, int); | |
392 | extern float logf (float); | |
393 | extern float log10f (float); | |
394 | extern float powf (float, float); | |
395 | extern float sqrtf (float); | |
396 | extern float fmodf (float, float); | |
8a0efa53 CF |
397 | #endif /* ! defined (_REENT_ONLY) */ |
398 | ||
399 | /* Other single precision functions. */ | |
400 | ||
eea249da YS |
401 | extern float exp2f (float); |
402 | extern float scalblnf (float, long int); | |
403 | extern float tgammaf (float); | |
404 | extern float nearbyintf (float); | |
405 | extern long int lrintf (float); | |
406 | extern long long int llrintf (float); | |
407 | extern float roundf (float); | |
408 | extern long int lroundf (float); | |
409 | extern long long int llroundf (float); | |
410 | extern float truncf (float); | |
411 | extern float remquof (float, float, int *); | |
412 | extern float fdimf (float, float); | |
413 | extern float fmaxf (float, float); | |
414 | extern float fminf (float, float); | |
415 | extern float fmaf (float, float, float); | |
416 | ||
417 | extern float infinityf (void); | |
418 | extern float nanf (const char *); | |
419 | extern float copysignf (float, float); | |
420 | extern float logbf (float); | |
421 | extern int ilogbf (float); | |
422 | ||
423 | extern float asinhf (float); | |
424 | extern float cbrtf (float); | |
425 | extern float nextafterf (float, float); | |
426 | extern float rintf (float); | |
427 | extern float scalbnf (float, int); | |
428 | extern float log1pf (float); | |
429 | extern float expm1f (float); | |
e0500490 | 430 | |
8a0efa53 | 431 | #ifndef _REENT_ONLY |
eea249da YS |
432 | extern float acoshf (float); |
433 | extern float atanhf (float); | |
434 | extern float remainderf (float, float); | |
435 | extern float gammaf (float); | |
436 | extern float lgammaf (float); | |
437 | extern float erff (float); | |
438 | extern float erfcf (float); | |
439 | extern float log2f (float); | |
440 | extern float hypotf (float, float); | |
c4ccbcce JJ |
441 | #endif /* ! defined (_REENT_ONLY) */ |
442 | ||
792e51b7 CV |
443 | /* Newlib doesn't fully support long double math functions so far. |
444 | On platforms where long double equals double the long double functions | |
445 | simply call the double functions. On Cygwin the long double functions | |
446 | are implemented independently from newlib to be able to use optimized | |
447 | assembler functions despite using the Microsoft x86_64 ABI. */ | |
448 | #if defined (_LDBL_EQ_DBL) || defined (__CYGWIN__) | |
65f414dc JJ |
449 | /* Reentrant ANSI C functions. */ |
450 | #ifndef __math_68881 | |
eea249da YS |
451 | extern long double atanl (long double); |
452 | extern long double cosl (long double); | |
453 | extern long double sinl (long double); | |
454 | extern long double tanl (long double); | |
455 | extern long double tanhl (long double); | |
456 | extern long double frexpl (long double, int *); | |
457 | extern long double modfl (long double, long double *); | |
458 | extern long double ceill (long double); | |
459 | extern long double fabsl (long double); | |
460 | extern long double floorl (long double); | |
461 | extern long double log1pl (long double); | |
462 | extern long double expm1l (long double); | |
65f414dc JJ |
463 | #endif /* ! defined (__math_68881) */ |
464 | /* Non reentrant ANSI C functions. */ | |
465 | #ifndef _REENT_ONLY | |
466 | #ifndef __math_68881 | |
eea249da YS |
467 | extern long double acosl (long double); |
468 | extern long double asinl (long double); | |
469 | extern long double atan2l (long double, long double); | |
470 | extern long double coshl (long double); | |
471 | extern long double sinhl (long double); | |
472 | extern long double expl (long double); | |
473 | extern long double ldexpl (long double, int); | |
474 | extern long double logl (long double); | |
475 | extern long double log10l (long double); | |
476 | extern long double powl (long double, long double); | |
477 | extern long double sqrtl (long double); | |
478 | extern long double fmodl (long double, long double); | |
479 | extern long double hypotl (long double, long double); | |
65f414dc JJ |
480 | #endif /* ! defined (__math_68881) */ |
481 | #endif /* ! defined (_REENT_ONLY) */ | |
eea249da YS |
482 | extern long double copysignl (long double, long double); |
483 | extern long double nanl (const char *); | |
484 | extern int ilogbl (long double); | |
485 | extern long double asinhl (long double); | |
486 | extern long double cbrtl (long double); | |
487 | extern long double nextafterl (long double, long double); | |
488 | extern float nexttowardf (float, long double); | |
489 | extern double nexttoward (double, long double); | |
490 | extern long double nexttowardl (long double, long double); | |
491 | extern long double logbl (long double); | |
492 | extern long double log2l (long double); | |
493 | extern long double rintl (long double); | |
494 | extern long double scalbnl (long double, int); | |
495 | extern long double exp2l (long double); | |
496 | extern long double scalblnl (long double, long); | |
497 | extern long double tgammal (long double); | |
498 | extern long double nearbyintl (long double); | |
499 | extern long int lrintl (long double); | |
500 | extern long long int llrintl (long double); | |
501 | extern long double roundl (long double); | |
502 | extern long lroundl (long double); | |
503 | extern long long int llroundl (long double); | |
504 | extern long double truncl (long double); | |
505 | extern long double remquol (long double, long double, int *); | |
506 | extern long double fdiml (long double, long double); | |
507 | extern long double fmaxl (long double, long double); | |
508 | extern long double fminl (long double, long double); | |
509 | extern long double fmal (long double, long double, long double); | |
65f414dc | 510 | #ifndef _REENT_ONLY |
eea249da YS |
511 | extern long double acoshl (long double); |
512 | extern long double atanhl (long double); | |
513 | extern long double remainderl (long double, long double); | |
514 | extern long double lgammal (long double); | |
515 | extern long double erfl (long double); | |
516 | extern long double erfcl (long double); | |
65f414dc | 517 | #endif /* ! defined (_REENT_ONLY) */ |
792e51b7 | 518 | #else /* !_LDBL_EQ_DBL && !__CYGWIN__ */ |
eea249da YS |
519 | extern long double hypotl (long double, long double); |
520 | extern long double sqrtl (long double); | |
48f6c593 | 521 | extern long double frexpl (long double, int *); |
823f6f66 | 522 | #ifdef __i386__ |
65f414dc | 523 | /* Other long double precision functions. */ |
eea249da YS |
524 | extern _LONG_DOUBLE rintl (_LONG_DOUBLE); |
525 | extern long int lrintl (_LONG_DOUBLE); | |
526 | extern long long int llrintl (_LONG_DOUBLE); | |
823f6f66 | 527 | #endif /* __i386__ */ |
792e51b7 | 528 | #endif /* !_LDBL_EQ_DBL && !__CYGWIN__ */ |
3cc8a378 | 529 | |
4e8291b8 | 530 | #endif /* __ISO_C_VISIBLE >= 1999 */ |
c4ccbcce | 531 | |
4e8291b8 | 532 | #if __MISC_VISIBLE |
eea249da YS |
533 | extern double drem (double, double); |
534 | extern float dremf (float, float); | |
792e51b7 | 535 | #ifdef __CYGWIN__ |
eea249da | 536 | extern float dreml (long double, long double); |
792e51b7 | 537 | #endif /* __CYGWIN__ */ |
eea249da YS |
538 | extern double gamma_r (double, int *); |
539 | extern double lgamma_r (double, int *); | |
540 | extern float gammaf_r (float, int *); | |
541 | extern float lgammaf_r (float, int *); | |
4e8291b8 | 542 | #endif |
c4ccbcce | 543 | |
4e8291b8 | 544 | #if __MISC_VISIBLE || __XSI_VISIBLE |
eea249da YS |
545 | extern double y0 (double); |
546 | extern double y1 (double); | |
547 | extern double yn (int, double); | |
548 | extern double j0 (double); | |
549 | extern double j1 (double); | |
550 | extern double jn (int, double); | |
4e8291b8 | 551 | #endif |
c4ccbcce | 552 | |
4e8291b8 | 553 | #if __MISC_VISIBLE || __XSI_VISIBLE >= 600 |
eea249da YS |
554 | extern float y0f (float); |
555 | extern float y1f (float); | |
556 | extern float ynf (int, float); | |
557 | extern float j0f (float); | |
558 | extern float j1f (float); | |
559 | extern float jnf (int, float); | |
4e8291b8 | 560 | #endif |
8a0efa53 | 561 | |
c4ccbcce | 562 | /* GNU extensions */ |
4e8291b8 | 563 | #if __GNU_VISIBLE |
eea249da YS |
564 | extern void sincos (double, double *, double *); |
565 | extern void sincosf (float, float *, float *); | |
792e51b7 | 566 | #ifdef __CYGWIN__ |
eea249da | 567 | extern void sincosl (long double, long double *, long double *); |
792e51b7 | 568 | #endif /* __CYGWIN__ */ |
c4ccbcce | 569 | # ifndef exp10 |
eea249da | 570 | extern double exp10 (double); |
c4ccbcce JJ |
571 | # endif |
572 | # ifndef pow10 | |
eea249da | 573 | extern double pow10 (double); |
c4ccbcce JJ |
574 | # endif |
575 | # ifndef exp10f | |
eea249da | 576 | extern float exp10f (float); |
c4ccbcce JJ |
577 | # endif |
578 | # ifndef pow10f | |
eea249da | 579 | extern float pow10f (float); |
c4ccbcce | 580 | # endif |
792e51b7 CV |
581 | #ifdef __CYGWIN__ |
582 | # ifndef exp10l | |
eea249da | 583 | extern float exp10l (float); |
792e51b7 CV |
584 | # endif |
585 | # ifndef pow10l | |
eea249da | 586 | extern float pow10l (float); |
792e51b7 CV |
587 | # endif |
588 | #endif /* __CYGWIN__ */ | |
4e8291b8 | 589 | #endif /* __GNU_VISIBLE */ |
8a0efa53 | 590 | |
4e8291b8 | 591 | #if __MISC_VISIBLE || __XSI_VISIBLE |
8a0efa53 | 592 | /* The gamma functions use a global variable, signgam. */ |
3aaa66f8 JJ |
593 | #ifndef _REENT_ONLY |
594 | #define signgam (*__signgam()) | |
eea249da | 595 | extern int *__signgam (void); |
3aaa66f8 | 596 | #endif /* ! defined (_REENT_ONLY) */ |
8a0efa53 | 597 | |
8195aff7 | 598 | #define __signgam_r(ptr) _REENT_SIGNGAM(ptr) |
4e8291b8 | 599 | #endif /* __MISC_VISIBLE || __XSI_VISIBLE */ |
8a0efa53 | 600 | |
8a0efa53 CF |
601 | /* Useful constants. */ |
602 | ||
52d940e2 | 603 | #if __BSD_VISIBLE || __XSI_VISIBLE |
a4a96eb4 | 604 | |
6aec558e JJ |
605 | #define MAXFLOAT 3.40282347e+38F |
606 | ||
8a0efa53 | 607 | #define M_E 2.7182818284590452354 |
78e66fb9 | 608 | #define M_LOG2E 1.4426950408889634074 |
8a0efa53 | 609 | #define M_LOG10E 0.43429448190325182765 |
fd451503 | 610 | #define M_LN2 _M_LN2 |
8a0efa53 CF |
611 | #define M_LN10 2.30258509299404568402 |
612 | #define M_PI 3.14159265358979323846 | |
8a0efa53 CF |
613 | #define M_PI_2 1.57079632679489661923 |
614 | #define M_PI_4 0.78539816339744830962 | |
8a0efa53 CF |
615 | #define M_1_PI 0.31830988618379067154 |
616 | #define M_2_PI 0.63661977236758134308 | |
617 | #define M_2_SQRTPI 1.12837916709551257390 | |
618 | #define M_SQRT2 1.41421356237309504880 | |
619 | #define M_SQRT1_2 0.70710678118654752440 | |
a4a96eb4 JT |
620 | |
621 | #endif | |
622 | ||
4e8291b8 | 623 | #if __BSD_VISIBLE |
a4a96eb4 JT |
624 | |
625 | #define M_TWOPI (M_PI * 2.0) | |
626 | #define M_3PI_4 2.3561944901923448370E0 | |
627 | #define M_SQRTPI 1.77245385090551602792981 | |
8a0efa53 CF |
628 | #define M_LN2LO 1.9082149292705877000E-10 |
629 | #define M_LN2HI 6.9314718036912381649E-1 | |
895d76fe | 630 | #define M_SQRT3 1.73205080756887719000 |
8a0efa53 | 631 | #define M_IVLN10 0.43429448190325182765 /* 1 / log(10) */ |
fd451503 | 632 | #define M_LOG2_E _M_LN2 |
8a0efa53 CF |
633 | #define M_INVLN2 1.4426950408889633870E0 /* 1 / log(2) */ |
634 | ||
4e8291b8 | 635 | #endif /* __BSD_VISIBLE */ |
8a0efa53 | 636 | |
c1a3171f JJ |
637 | _END_STD_C |
638 | ||
8a0efa53 CF |
639 | #ifdef __FAST_MATH__ |
640 | #include <machine/fastmath.h> | |
641 | #endif | |
642 | ||
8a0efa53 | 643 | #endif /* _MATH_H_ */ |