1 : /*
2 : * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
3 : *
4 : * @APPLE_LICENSE_HEADER_START@
5 : *
6 : * The contents of this file constitute Original Code as defined in and
7 : * are subject to the Apple Public Source License Version 1.1 (the
8 : * "License"). You may not use this file except in compliance with the
9 : * License. Please obtain a copy of the License at
10 : * http://www.apple.com/publicsource and read it before using this file.
11 : *
12 : * This Original Code and all software distributed under the License are
13 : * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 : * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 : * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 : * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 : * License for the specific language governing rights and limitations
18 : * under the License.
19 : *
20 : * @APPLE_LICENSE_HEADER_END@
21 : */
22 :
23 : /*******************************************************************************
24 : * *
25 : * File: math.h *
26 : * *
27 : * Contains: typedefs, prototypes, and macros germane to C99 floating point.*
28 : * *
29 : *******************************************************************************/
30 : #ifndef __MATH__
31 : #define __MATH__
32 :
33 : #include "sys/cdefs.h" /* For definition of __DARWIN_UNIX03 et al */
34 :
35 : #ifdef __cplusplus
36 : extern "C" {
37 : #endif
38 :
39 : /******************************************************************************
40 : * Floating point data types *
41 : ******************************************************************************/
42 :
43 : /* Define float_t and double_t per C standard, ISO/IEC 9899:1999 7.12 2,
44 : taking advantage of GCC's __FLT_EVAL_METHOD__ (which a compiler may
45 : define anytime and GCC does) that shadows FLT_EVAL_METHOD (which a compiler
46 : must and may define only in float.h).
47 : */
48 : #if __FLT_EVAL_METHOD__ == 0
49 : typedef float float_t;
50 : typedef double double_t;
51 : #elif __FLT_EVAL_METHOD__ == 1
52 : typedef double float_t;
53 : typedef double double_t;
54 : #elif __FLT_EVAL_METHOD__ == 2 || __FLT_EVAL_METHOD__ == -1
55 : typedef long double float_t;
56 : typedef long double double_t;
57 : #else /* __FLT_EVAL_METHOD__ */
58 : #error "Unsupported value of __FLT_EVAL_METHOD__."
59 : #endif /* __FLT_EVAL_METHOD__ */
60 :
61 :
62 : #if defined(__GNUC__)
63 : #define HUGE_VAL __builtin_huge_val()
64 : #define HUGE_VALF __builtin_huge_valf()
65 : #define HUGE_VALL __builtin_huge_vall()
66 : #define NAN __builtin_nanf("0x7fc00000") /* Constant expression, can be used as initializer. */
67 : #define __MATH_H_ALWAYS_INLINE__ __attribute__ ((always_inline))
68 : #else
69 : #define HUGE_VAL 1e500
70 : #define HUGE_VALF 1e50f
71 : #define HUGE_VALL 1e5000L
72 : #define NAN __nan( )
73 : #define __MATH_H_ALWAYS_INLINE__
74 : #endif
75 :
76 : #define INFINITY HUGE_VALF
77 :
78 :
79 : /******************************************************************************
80 : * Taxonomy of floating point data types *
81 : ******************************************************************************/
82 :
83 : #define FP_NAN 1
84 : #define FP_INFINITE 2
85 : #define FP_ZERO 3
86 : #define FP_NORMAL 4
87 : #define FP_SUBNORMAL 5
88 : #define FP_SUPERNORMAL 6 /* meaningful only on PowerPC */
89 :
90 : /* fma() *function call* is more costly than equivalent (in-line) multiply and add operations */
91 : /* For single and double precision, the cost isn't too bad, because we can fall back on higher */
92 : /* precision hardware, with the necessary range to handle infinite precision products. However, */
93 : /* expect the long double fma to be at least an order of magnitude slower than a simple multiply */
94 : /* and an add. */
95 : #undef FP_FAST_FMA
96 : #undef FP_FAST_FMAF
97 : #undef FP_FAST_FMAL
98 :
99 : /* The values returned by `ilogb' for 0 and NaN respectively. */
100 : #define FP_ILOGB0 (-2147483647 - 1)
101 : #define FP_ILOGBNAN (-2147483647 - 1)
102 :
103 : /* Bitmasks for the math_errhandling macro. */
104 : #define MATH_ERRNO 1 /* errno set by math functions. */
105 : #define MATH_ERREXCEPT 2 /* Exceptions raised by math functions. */
106 :
107 : #define math_errhandling (__math_errhandling())
108 : extern unsigned int __math_errhandling ( void );
109 :
110 : /********************************************************************************
111 : * *
112 : * Inquiry macros *
113 : * *
114 : * fpclassify Returns one of the FP_Å values. *
115 : * isnormal Non-zero if and only if the argument x is normalized. *
116 : * isfinite Non-zero if and only if the argument x is finite. *
117 : * isnan Non-zero if and only if the argument x is a NaN. *
118 : * signbit Non-zero if and only if the sign of the argument x is *
119 : * negative. This includes, NaNs, infinities and zeros. *
120 : * *
121 : ********************************************************************************/
122 :
123 : #define fpclassify(x) \
124 : ( sizeof (x) == sizeof(float ) ? __fpclassifyf((float)(x)) \
125 : : sizeof (x) == sizeof(double) ? __fpclassifyd((double)(x)) \
126 : : __fpclassify ((long double)(x)))
127 :
128 : extern int __fpclassifyf(float );
129 : extern int __fpclassifyd(double );
130 : extern int __fpclassify (long double);
131 :
132 : #if defined( __GNUC__ ) && 0 == __FINITE_MATH_ONLY__
133 : /* Yes, that's right. You only get the fast iswhatever() macros if you do NOT turn on -ffast-math. */
134 : /* These inline functions require the compiler to be compiling to standard in order to work. */
135 : /* -ffast-math, among other things, implies that NaNs don't happen. The compiler can in that case */
136 : /* optimize x != x to be false always, wheras it would be true for NaNs. That breaks __inline_isnan() */
137 : /* below. */
138 : #define isnormal(x) \
139 : ( sizeof (x) == sizeof(float ) ? __inline_isnormalf((float)(x)) \
140 : : sizeof (x) == sizeof(double) ? __inline_isnormald((double)(x)) \
141 : : __inline_isnormal ((long double)(x)))
142 :
143 : #define isfinite(x) \
144 : ( sizeof (x) == sizeof(float ) ? __inline_isfinitef((float)(x)) \
145 : : sizeof (x) == sizeof(double) ? __inline_isfinited((double)(x)) \
146 : : __inline_isfinite ((long double)(x)))
147 :
148 : #define isinf(x) \
149 : ( sizeof (x) == sizeof(float ) ? __inline_isinff((float)(x)) \
150 : : sizeof (x) == sizeof(double) ? __inline_isinfd((double)(x)) \
151 : : __inline_isinf ((long double)(x)))
152 :
153 : #define isnan(x) \
154 : ( sizeof (x) == sizeof(float ) ? __inline_isnanf((float)(x)) \
155 : : sizeof (x) == sizeof(double) ? __inline_isnand((double)(x)) \
156 : : __inline_isnan ((long double)(x)))
157 :
158 : #define signbit(x) \
159 : ( sizeof (x) == sizeof(float ) ? __inline_signbitf((float)(x)) \
160 : : sizeof (x) == sizeof(double) ? __inline_signbitd((double)(x)) \
161 : : __inline_signbit((long double)(x)))
162 :
163 : static __inline__ int __inline_isfinitef (float ) __MATH_H_ALWAYS_INLINE__;
164 : static __inline__ int __inline_isfinited (double ) __MATH_H_ALWAYS_INLINE__;
165 : static __inline__ int __inline_isfinite (long double) __MATH_H_ALWAYS_INLINE__;
166 : static __inline__ int __inline_isinff (float ) __MATH_H_ALWAYS_INLINE__;
167 : static __inline__ int __inline_isinfd (double ) __MATH_H_ALWAYS_INLINE__;
168 : static __inline__ int __inline_isinf (long double) __MATH_H_ALWAYS_INLINE__;
169 : static __inline__ int __inline_isnanf (float ) __MATH_H_ALWAYS_INLINE__;
170 : static __inline__ int __inline_isnand (double ) __MATH_H_ALWAYS_INLINE__;
171 : static __inline__ int __inline_isnan (long double) __MATH_H_ALWAYS_INLINE__;
172 : static __inline__ int __inline_isnormalf (float ) __MATH_H_ALWAYS_INLINE__;
173 : static __inline__ int __inline_isnormald (double ) __MATH_H_ALWAYS_INLINE__;
174 : static __inline__ int __inline_isnormal (long double) __MATH_H_ALWAYS_INLINE__;
175 : static __inline__ int __inline_signbitf (float ) __MATH_H_ALWAYS_INLINE__;
176 : static __inline__ int __inline_signbitd (double ) __MATH_H_ALWAYS_INLINE__;
177 : static __inline__ int __inline_signbit (long double) __MATH_H_ALWAYS_INLINE__;
178 :
179 : static __inline__ int __inline_isinff( float __x ) { return __builtin_fabsf(__x) == __builtin_inff(); }
180 : static __inline__ int __inline_isinfd( double __x ) { return __builtin_fabs(__x) == __builtin_inf(); }
181 : static __inline__ int __inline_isinf( long double __x ) { return __builtin_fabsl(__x) == __builtin_infl(); }
182 : static __inline__ int __inline_isfinitef( float __x ) { return __x == __x && __builtin_fabsf(__x) != __builtin_inff(); }
183 : static __inline__ int __inline_isfinited( double __x ) { return __x == __x && __builtin_fabs(__x) != __builtin_inf(); }
184 : static __inline__ int __inline_isfinite( long double __x ) { return __x == __x && __builtin_fabsl(__x) != __builtin_infl(); }
185 : static __inline__ int __inline_isnanf( float __x ) { return __x != __x; }
186 60 : static __inline__ int __inline_isnand( double __x ) { return __x != __x; }
187 : static __inline__ int __inline_isnan( long double __x ) { return __x != __x; }
188 : static __inline__ int __inline_signbitf( float __x ) { union{ float __f; unsigned int __u; }__u; __u.__f = __x; return (int)(__u.__u >> 31); }
189 : static __inline__ int __inline_signbitd( double __x ) { union{ double __f; unsigned int __u[2]; }__u; __u.__f = __x; return (int)(__u.__u[1] >> 31); }
190 : static __inline__ int __inline_signbit( long double __x ){ union{ long double __ld; struct{ unsigned int __m[2]; short __sexp; }__p; }__u; __u.__ld = __x; return (int) (((unsigned short) __u.__p.__sexp) >> 15); }
191 : static __inline__ int __inline_isnormalf( float __x ) { float fabsf = __builtin_fabsf(__x); if( __x != __x ) return 0; return fabsf < __builtin_inff() && fabsf >= __FLT_MIN__; }
192 : static __inline__ int __inline_isnormald( double __x ) { double fabsf = __builtin_fabs(__x); if( __x != __x ) return 0; return fabsf < __builtin_inf() && fabsf >= __DBL_MIN__; }
193 : static __inline__ int __inline_isnormal( long double __x ) { long double fabsf = __builtin_fabsl(__x); if( __x != __x ) return 0; return fabsf < __builtin_infl() && fabsf >= __LDBL_MIN__; }
194 :
195 : #else
196 :
197 : #define isnormal(x) \
198 : ( sizeof (x) == sizeof(float ) ? __isnormalf((float)(x)) \
199 : : sizeof (x) == sizeof(double) ? __isnormald((double)(x)) \
200 : : __isnormal ((long double)(x)))
201 :
202 : #define isfinite(x) \
203 : ( sizeof (x) == sizeof(float ) ? __isfinitef((float)(x)) \
204 : : sizeof (x) == sizeof(double) ? __isfinited((double)(x)) \
205 : : __isfinite ((long double)(x)))
206 :
207 : #define isinf(x) \
208 : ( sizeof (x) == sizeof(float ) ? __isinff((float)(x)) \
209 : : sizeof (x) == sizeof(double) ? __isinfd((double)(x)) \
210 : : __isinf ((long double)(x)))
211 :
212 : #define isnan(x) \
213 : ( sizeof (x) == sizeof(float ) ? __isnanf((float)(x)) \
214 : : sizeof (x) == sizeof(double) ? __isnand((double)(x)) \
215 : : __isnan ((long double)(x)))
216 :
217 : #define signbit(x) \
218 : ( sizeof (x) == sizeof(float ) ? __signbitf((float)(x)) \
219 : : sizeof (x) == sizeof(double) ? __signbitd((double)(x)) \
220 : : __signbitl((long double)(x)))
221 :
222 :
223 : extern int __isnormalf (float );
224 : extern int __isnormald (double );
225 : extern int __isnormal (long double);
226 :
227 : extern int __isfinitef (float );
228 : extern int __isfinited (double );
229 : extern int __isfinite (long double);
230 :
231 : extern int __isinff (float );
232 : extern int __isinfd (double );
233 : extern int __isinf (long double);
234 :
235 : extern int __isnanf (float );
236 : extern int __isnand (double );
237 : extern int __isnan (long double);
238 :
239 : extern int __signbitf (float );
240 : extern int __signbitd (double );
241 : extern int __signbitl (long double);
242 :
243 : #endif
244 :
245 :
246 :
247 : /********************************************************************************
248 : * *
249 : * Math Functions *
250 : * *
251 : ********************************************************************************/
252 :
253 : extern double acos( double );
254 : extern float acosf( float );
255 :
256 : extern double asin( double );
257 : extern float asinf( float );
258 :
259 : extern double atan( double );
260 : extern float atanf( float );
261 :
262 : extern double atan2( double, double );
263 : extern float atan2f( float, float );
264 :
265 : extern double cos( double );
266 : extern float cosf( float );
267 :
268 : extern double sin( double );
269 : extern float sinf( float );
270 :
271 : extern double tan( double );
272 : extern float tanf( float );
273 :
274 : extern double acosh( double );
275 : extern float acoshf( float );
276 :
277 : extern double asinh( double );
278 : extern float asinhf( float );
279 :
280 : extern double atanh( double );
281 : extern float atanhf( float );
282 :
283 : extern double cosh( double );
284 : extern float coshf( float );
285 :
286 : extern double sinh( double );
287 : extern float sinhf( float );
288 :
289 : extern double tanh( double );
290 : extern float tanhf( float );
291 :
292 : extern double exp ( double );
293 : extern float expf ( float );
294 :
295 : extern double exp2 ( double );
296 : extern float exp2f ( float );
297 :
298 : extern double expm1 ( double );
299 : extern float expm1f ( float );
300 :
301 : extern double log ( double );
302 : extern float logf ( float );
303 :
304 : extern double log10 ( double );
305 : extern float log10f ( float );
306 :
307 : extern double log2 ( double );
308 : extern float log2f ( float );
309 :
310 : extern double log1p ( double );
311 : extern float log1pf ( float );
312 :
313 : extern double logb ( double );
314 : extern float logbf ( float );
315 :
316 : extern double modf ( double, double * );
317 : extern float modff ( float, float * );
318 :
319 : extern double ldexp ( double, int );
320 : extern float ldexpf ( float, int );
321 :
322 : extern double frexp ( double, int * );
323 : extern float frexpf ( float, int * );
324 :
325 : extern int ilogb ( double );
326 : extern int ilogbf ( float );
327 :
328 : extern double scalbn ( double, int );
329 : extern float scalbnf ( float, int );
330 :
331 : extern double scalbln ( double, long int );
332 : extern float scalblnf ( float, long int );
333 :
334 : extern double fabs( double );
335 : extern float fabsf( float );
336 :
337 : extern double cbrt( double );
338 : extern float cbrtf( float );
339 :
340 : extern double hypot ( double, double );
341 : extern float hypotf ( float, float );
342 :
343 : extern double pow ( double, double );
344 : extern float powf ( float, float );
345 :
346 : extern double sqrt( double );
347 : extern float sqrtf( float );
348 :
349 : extern double erf( double );
350 : extern float erff( float );
351 :
352 : extern double erfc( double );
353 : extern float erfcf( float );
354 :
355 : /* lgamma and lgammaf are not thread-safe. The thread-safe variants
356 : * lgamma_r and lgammaf_r are available on OS X 10.6 and later.
357 : *
358 : * To use the thread-safe variants, you must define the _REENTRANT symbol.
359 : */
360 : extern double lgamma( double );
361 : extern float lgammaf( float );
362 :
363 : extern double tgamma( double );
364 : extern float tgammaf( float );
365 :
366 : extern double ceil ( double );
367 : extern float ceilf ( float );
368 :
369 : extern double floor ( double );
370 : extern float floorf ( float );
371 :
372 : extern double nearbyint ( double );
373 : extern float nearbyintf ( float );
374 :
375 : extern double rint ( double );
376 : extern float rintf ( float );
377 :
378 : extern long int lrint ( double );
379 : extern long int lrintf ( float );
380 :
381 : extern double round ( double );
382 : extern float roundf ( float );
383 :
384 : extern long int lround ( double );
385 : extern long int lroundf ( float );
386 :
387 : #if ( defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ) || ! defined( __STRICT_ANSI__ ) || ! defined( __GNUC__ )
388 :
389 : /* long long is not part of C90. Make sure you are passing -std=c99 or -std=gnu99 or better if you need this. */
390 : extern long long int llrint ( double );
391 : extern long long int llrintf ( float );
392 :
393 : extern long long int llround ( double );
394 : extern long long int llroundf ( float );
395 :
396 : #endif /* #if ( defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ) || ! defined( __STRICT_ANSI__ ) || ! defined( __GNUC__ ) */
397 :
398 : extern double trunc ( double );
399 : extern float truncf ( float );
400 :
401 : extern double fmod ( double, double );
402 : extern float fmodf ( float, float );
403 :
404 : extern double remainder ( double, double );
405 : extern float remainderf ( float, float );
406 :
407 : extern double remquo ( double, double, int * );
408 : extern float remquof ( float, float, int * );
409 :
410 : extern double copysign ( double, double );
411 : extern float copysignf ( float, float );
412 :
413 : extern double nan( const char * );
414 : extern float nanf( const char * );
415 :
416 : extern double nextafter ( double, double );
417 : extern float nextafterf ( float, float );
418 :
419 : extern double fdim ( double, double );
420 : extern float fdimf ( float, float );
421 :
422 : extern double fmax ( double, double );
423 : extern float fmaxf ( float, float );
424 :
425 : extern double fmin ( double, double );
426 : extern float fminf ( float, float );
427 :
428 : extern double fma ( double, double, double );
429 : extern float fmaf ( float, float, float );
430 :
431 : extern long double acosl(long double);
432 : extern long double asinl(long double);
433 : extern long double atanl(long double);
434 : extern long double atan2l(long double, long double);
435 : extern long double cosl(long double);
436 : extern long double sinl(long double);
437 : extern long double tanl(long double);
438 : extern long double acoshl(long double);
439 : extern long double asinhl(long double);
440 : extern long double atanhl(long double);
441 : extern long double coshl(long double);
442 : extern long double sinhl(long double);
443 : extern long double tanhl(long double);
444 : extern long double expl(long double);
445 : extern long double exp2l(long double);
446 : extern long double expm1l(long double);
447 : extern long double logl(long double);
448 : extern long double log10l(long double);
449 : extern long double log2l(long double);
450 : extern long double log1pl(long double);
451 : extern long double logbl(long double);
452 : extern long double modfl(long double, long double *);
453 : extern long double ldexpl(long double, int);
454 : extern long double frexpl(long double, int *);
455 : extern int ilogbl(long double);
456 : extern long double scalbnl(long double, int);
457 : extern long double scalblnl(long double, long int);
458 : extern long double fabsl(long double);
459 : extern long double cbrtl(long double);
460 : extern long double hypotl(long double, long double);
461 : extern long double powl(long double, long double);
462 : extern long double sqrtl(long double);
463 : extern long double erfl(long double);
464 : extern long double erfcl(long double);
465 :
466 : /* lgammal is not thread-safe.
467 : * The thread-safe variant lgammal_r is available on OS X 10.6 and later.
468 : *
469 : * To use the thread-safe variant, you must define the _REENTRANT symbol.
470 : */
471 : extern long double lgammal(long double);
472 :
473 : extern long double tgammal(long double);
474 : extern long double ceill(long double);
475 : extern long double floorl(long double);
476 : extern long double nearbyintl(long double);
477 : extern long double rintl(long double);
478 : extern long int lrintl(long double);
479 : extern long double roundl(long double);
480 : extern long int lroundl(long double);
481 :
482 : #if ( defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ) || ! defined( __STRICT_ANSI__ ) || ! defined( __GNUC__ )
483 : /* long long is not part of C90. Make sure you are passing -std=c99 or -std=gnu99 or better if you need this. */
484 : extern long long int llrintl(long double);
485 : extern long long int llroundl(long double);
486 : #endif /* #if ( defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ) || ! defined( __STRICT_ANSI__ ) || ! defined( __GNUC__ ) */
487 :
488 : extern long double truncl(long double);
489 : extern long double fmodl(long double, long double);
490 : extern long double remainderl(long double, long double);
491 : extern long double remquol(long double, long double, int *);
492 : extern long double copysignl(long double, long double);
493 : extern long double nanl(const char *);
494 : extern long double nextafterl(long double, long double);
495 : extern double nexttoward(double, long double);
496 : extern float nexttowardf(float, long double);
497 : extern long double nexttowardl(long double, long double);
498 : extern long double fdiml(long double, long double);
499 : extern long double fmaxl(long double, long double);
500 : extern long double fminl(long double, long double);
501 : extern long double fmal(long double, long double, long double);
502 :
503 : #define isgreater(x, y) __builtin_isgreater ((x),(y))
504 : #define isgreaterequal(x, y) __builtin_isgreaterequal ((x),(y))
505 : #define isless(x, y) __builtin_isless ((x),(y))
506 : #define islessequal(x, y) __builtin_islessequal ((x),(y))
507 : #define islessgreater(x, y) __builtin_islessgreater ((x),(y))
508 : #define isunordered(x, y) __builtin_isunordered ((x),(y))
509 :
510 : extern double __inf( void );
511 : extern float __inff( void );
512 : extern long double __infl( void );
513 : extern float __nan( void ); /* 10.3 (and later) must retain in ABI for backward compatability */
514 :
515 : #if !defined(_ANSI_SOURCE)
516 : extern double j0 ( double );
517 :
518 : extern double j1 ( double );
519 :
520 : extern double jn ( int, double );
521 :
522 : extern double y0 ( double );
523 :
524 : extern double y1 ( double );
525 :
526 : extern double yn ( int, double );
527 :
528 : extern double scalb ( double, double );
529 :
530 :
531 : #define M_E 2.71828182845904523536028747135266250 /* e */
532 : #define M_LOG2E 1.44269504088896340735992468100189214 /* log 2e */
533 : #define M_LOG10E 0.434294481903251827651128918916605082 /* log 10e */
534 : #define M_LN2 0.693147180559945309417232121458176568 /* log e2 */
535 : #define M_LN10 2.30258509299404568401799145468436421 /* log e10 */
536 : #define M_PI 3.14159265358979323846264338327950288 /* pi */
537 : #define M_PI_2 1.57079632679489661923132169163975144 /* pi/2 */
538 : #define M_PI_4 0.785398163397448309615660845819875721 /* pi/4 */
539 : #define M_1_PI 0.318309886183790671537767526745028724 /* 1/pi */
540 : #define M_2_PI 0.636619772367581343075535053490057448 /* 2/pi */
541 : #define M_2_SQRTPI 1.12837916709551257389615890312154517 /* 2/sqrt(pi) */
542 : #define M_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */
543 : #define M_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */
544 :
545 : #define MAXFLOAT ((float)3.40282346638528860e+38)
546 : extern int signgam; /* required for unix 2003 */
547 :
548 :
549 : #endif /* !defined(_ANSI_SOURCE) */
550 :
551 : #if !defined(__NOEXTENSIONS__) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
552 : #define __WANT_EXTENSIONS__
553 : #endif
554 :
555 : #ifdef __WANT_EXTENSIONS__
556 :
557 : #define FP_SNAN FP_NAN
558 : #define FP_QNAN FP_NAN
559 :
560 : extern long int rinttol ( double ); /* Legacy API: please use C99 lrint() instead. */
561 :
562 : extern long int roundtol ( double ); /* Legacy API: please use C99 lround() instead. */
563 :
564 : /*
565 : * XOPEN/SVID
566 : */
567 : #if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
568 : #if (!defined(_XOPEN_SOURCE) || defined(_DARWIN_C_SOURCE))
569 : #if !defined(__cplusplus)
570 : /* used by matherr below */
571 : struct exception {
572 : int type;
573 : char *name;
574 : double arg1;
575 : double arg2;
576 : double retval;
577 : };
578 : #endif
579 :
580 : #define HUGE MAXFLOAT
581 :
582 : /*
583 : * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
584 : * (one may replace the following line by "#include <values.h>")
585 : */
586 :
587 : #define X_TLOSS 1.41484755040568800000e+16
588 :
589 : #define DOMAIN 1
590 : #define SING 2
591 : #define OVERFLOW 3
592 : #define UNDERFLOW 4
593 : #define TLOSS 5
594 : #define PLOSS 6
595 :
596 : #endif /* (!_XOPEN_SOURCE || _DARWIN_C_SOURCE) */
597 : #endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
598 :
599 : #if !defined( __STRICT_ANSI__) && !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
600 : extern int finite ( double ); /* Legacy API: please use C99 isfinite() instead. */
601 :
602 : extern double gamma ( double ); /* Legacy API: please use C99 tgamma() instead. */
603 :
604 : #if (!defined(_XOPEN_SOURCE) || defined(_DARWIN_C_SOURCE))
605 :
606 : #if !defined(__cplusplus)
607 : extern int matherr ( struct exception * );
608 : #endif
609 :
610 : /*
611 : * IEEE Test Vector
612 : */
613 : extern double significand ( double );
614 :
615 : /*
616 : * BSD math library entry points
617 : */
618 : extern double drem ( double, double ); /* Legacy API: please use C99 remainder() instead. */
619 :
620 : /*
621 : * Reentrant version of lgamma; passes signgam back by reference
622 : * as the second argument; user must allocate space for signgam.
623 : */
624 :
625 : #ifdef _REENTRANT
626 : #include <AvailabilityMacros.h>
627 : // Available on OS X 10.6 and later.
628 : extern float lgammaf_r ( float, int * ) AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
629 : extern double lgamma_r ( double, int * ) AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
630 : extern long double lgammal_r ( long double, int * ) AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
631 : #endif /* _REENTRANT */
632 :
633 : #endif /* (!_XOPEN_SOURCE || _DARWIN_C_SOURCE) */
634 : #endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
635 :
636 : #endif /* __WANT_EXTENSIONS__ */
637 :
638 : #ifdef __cplusplus
639 : }
640 : #endif
641 :
642 : #endif /* __MATH__ */
|