1 /*
2 Copyright (c) 1991, 1993
3 The Regents of the University of California. All rights reserved.
4 c) UNIX System Laboratories, Inc.
5 All or some portions of this file are derived from material licensed
6 to the University of California by American Telephone and Telegraph
7 Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 the permission of UNIX System Laboratories, Inc.
9
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions
12 are met:
13 1. Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15 2. Redistributions in binary form must reproduce the above copyright
16 notice, this list of conditions and the following disclaimer in the
17 documentation and/or other materials provided with the distribution.
18 3. Neither the name of the University nor the names of its contributors
19 may be used to endorse or promote products derived from this software
20 without specific prior written permission.
21
22 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 SUCH DAMAGE.
33 */
34 #ifndef _MATH_H_
35
36 #define _MATH_H_
37
38 #include <sys/cdefs.h>
39 #include <ieeefp.h>
40 #include "_ansi.h"
41
42 _BEGIN_STD_C
43
44 /* Natural log of 2 */
45 #define _M_LN2 0.693147180559945309417
46 #define _M_LN2_LD 0.693147180559945309417232121458176568l
47
48 #if __GNUC_PREREQ (3, 3) || defined(__clang__) || defined(__COMPCERT__)
49 /* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */
50
51 # ifndef HUGE_VAL
52 # define HUGE_VAL (__builtin_huge_val())
53 # endif
54
55 # ifndef HUGE_VALF
56 # define HUGE_VALF (__builtin_huge_valf())
57 # endif
58
59 # ifndef HUGE_VALL
60 # define HUGE_VALL (__builtin_huge_vall())
61 # endif
62
63 # ifndef INFINITY
64 # define INFINITY (__builtin_inff())
65 # endif
66
67 # ifndef NAN
68 # define NAN (__builtin_nanf(""))
69 # endif
70
71 #else /* !gcc >= 3.3 */
72
73 /* No builtins. Use fixed defines instead. (All 3 HUGE plus the INFINITY
74 * and NAN macros are required to be constant expressions. Using a variable--
75 * even a static const--does not meet this requirement, as it cannot be
76 * evaluated at translation time.)
77 * The infinities are done using numbers that are far in excess of
78 * something that would be expected to be encountered in a floating-point
79 * implementation. (A more certain way uses values from float.h, but that is
80 * avoided because system includes are not supposed to include each other.)
81 * This method might produce warnings from some compilers. (It does in
82 * newer GCCs, but not for ones that would hit this #else.) If this happens,
83 * please report details to the Newlib mailing list. */
84
85 #ifndef HUGE_VAL
86 #define HUGE_VAL (1.0e999999999)
87 #endif
88
89 #ifndef HUGE_VALF
90 #define HUGE_VALF (1.0e999999999F)
91 #endif
92
93 #if !defined(HUGE_VALL) && defined(_HAVE_LONG_DOUBLE)
94 #define HUGE_VALL (1.0e999999999L)
95 #endif
96
97 #if !defined(INFINITY)
98 #define INFINITY (HUGE_VALF)
99 #endif
100
101 #if !defined(NAN)
102 #if defined(__GNUC__) && defined(__cplusplus)
103 /* Exception: older g++ versions warn about the divide by 0 used in the
104 * normal case (even though older gccs do not). This trick suppresses the
105 * warning, but causes errors for plain gcc, so is only used in the one
106 * special case. */
107 static const union { __ULong __i[1]; float __d; } __Nanf = {0x7FC00000};
108 #define NAN (__Nanf.__d)
109 #else
110 #define NAN (0.0F/0.0F)
111 #endif
112 #endif
113
114 #endif /* !gcc >= 3.3 */
115
116 extern double atan (double);
117 extern double cos (double);
118 extern double sin (double);
119 extern double tan (double);
120 extern double tanh (double);
121 extern double frexp (double, int *);
122 extern double modf (double, double *);
123 extern double ceil (double);
124 extern double fabs (double);
125 extern double floor (double);
126
127 extern double acos (double);
128 extern double asin (double);
129 extern double atan2 (double, double);
130 extern double cosh (double);
131 extern double sinh (double);
132 extern double exp (double);
133 extern double ldexp (double, int);
134 extern double log (double);
135 extern double log10 (double);
136 extern double pow (double, double);
137 extern double sqrt (double);
138 extern double fmod (double, double);
139
140 #if __MISC_VISIBLE
141 extern int finite (double);
142 extern int finitef (float);
143 extern int isinff (float);
144 extern int isnanf (float);
145 #if defined(_HAVE_LONG_DOUBLE)
146 extern int finitel (long double);
147 extern int isinfl (long double);
148 extern int isnanl (long double);
149 #endif
150 #if !defined(__cplusplus) || __cplusplus < 201103L
151 extern int isinf (double);
152 #endif
153 #endif /* __MISC_VISIBLE */
154 #if (__MISC_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 600)) \
155 && (!defined(__cplusplus) || __cplusplus < 201103L)
156 extern int isnan (double);
157 #endif
158
159 #if __ISO_C_VISIBLE >= 1999
160 /* ISO C99 types and macros. */
161
162 /* FIXME: FLT_EVAL_METHOD should somehow be gotten from float.h (which is hard,
163 * considering that the standard says the includes it defines should not
164 * include other includes that it defines) and that value used. (This can be
165 * solved, but autoconf has a bug which makes the solution more difficult, so
166 * it has been skipped for now.) */
167 #if !defined(FLT_EVAL_METHOD) && defined(__FLT_EVAL_METHOD__)
168 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
169 #define __TMP_FLT_EVAL_METHOD
170 #endif /* FLT_EVAL_METHOD */
171 #if defined FLT_EVAL_METHOD
172 /* FLT_EVAL_METHOD == 16 has meaning as defined in ISO/IEC TS 18661-3,
173 * which provides non-compliant extensions to C and POSIX (by adding
174 * additional positive values for FLT_EVAL_METHOD). It effectively has
175 * same meaning as the C99 and C11 definitions for value 0, while also
176 * serving as a flag that the _Float16 (float16_t) type exists.
177 *
178 * FLT_EVAL_METHOD could be any number of bits of supported floating point
179 * format (e.g. 32, 64, 128), but currently only AArch64 and few other targets
180 * might define that as 16. */
181 #if (FLT_EVAL_METHOD == 0) \
182 || (FLT_EVAL_METHOD == 16)
183 typedef float float_t;
184 typedef double double_t;
185 #elif FLT_EVAL_METHOD == 1
186 typedef double float_t;
187 typedef double double_t;
188 #elif FLT_EVAL_METHOD == 2
189 typedef long double float_t;
190 typedef long double double_t;
191 #else
192 /* Implementation-defined. Assume float_t and double_t have been
193 * defined previously for this configuration (e.g. config.h). */
194
195 /* If __DOUBLE_TYPE is defined (__FLOAT_TYPE is then supposed to be
196 defined as well) float_t and double_t definition is suggested by
197 an arch specific header. */
198 #ifdef __DOUBLE_TYPE
199 typedef __DOUBLE_TYPE double_t;
200 typedef __FLOAT_TYPE float_t;
201 #endif
202 /* Assume config.h has provided these types. */
203 #endif
204 #else
205 /* Assume basic definitions. */
206 typedef float float_t;
207 typedef double double_t;
208 #endif
209 #if defined(__TMP_FLT_EVAL_METHOD)
210 #undef FLT_EVAL_METHOD
211 #endif
212
213 #define FP_NAN 0
214 #define FP_INFINITE 1
215 #define FP_ZERO 2
216 #define FP_SUBNORMAL 3
217 #define FP_NORMAL 4
218
219 #ifndef FP_ILOGB0
220 # define FP_ILOGB0 (-__INT_MAX__)
221 #endif
222 #ifndef FP_ILOGBNAN
223 # define FP_ILOGBNAN __INT_MAX__
224 #endif
225
226 #ifndef MATH_ERRNO
227 # define MATH_ERRNO 1
228 #endif
229 #ifndef MATH_ERREXCEPT
230 # define MATH_ERREXCEPT 2
231 #endif
232 #ifndef math_errhandling
233 # ifdef _IEEE_LIBM
234 # define _MATH_ERRHANDLING_ERRNO 0
235 # else
236 # define _MATH_ERRHANDLING_ERRNO MATH_ERRNO
237 # endif
238 # ifdef _SUPPORTS_ERREXCEPT
239 # define _MATH_ERRHANDLING_ERREXCEPT MATH_ERREXCEPT
240 # else
241 # define _MATH_ERRHANDLING_ERREXCEPT 0
242 # endif
243 # define math_errhandling (_MATH_ERRHANDLING_ERRNO | _MATH_ERRHANDLING_ERREXCEPT)
244 #endif
245
246 extern int __isinff (float);
247 extern int __isinfd (double);
248 extern int __isnanf (float);
249 extern int __isnand (double);
250 extern int __fpclassifyf (float);
251 extern int __fpclassifyd (double);
252 extern int __signbitf (float);
253 extern int __signbitd (double);
254 extern int __finite (double);
255 extern int __finitef (float);
256 #if defined(_HAVE_LONG_DOUBLE)
257 extern int __fpclassifyl (long double);
258 extern int __finitel (long double);
259 #endif
260
261 /* Note: isinf and isnan were once functions in newlib that took double
262 * arguments. C99 specifies that these names are reserved for macros
263 * supporting multiple floating point types. Thus, they are
264 * now defined as macros. Implementations of the old functions
265 * taking double arguments still exist for compatibility purposes
266 * (prototypes for them are earlier in this header). */
267
268 /*
269 * GCC bug 66462 raises INVALID exception when __builtin_fpclassify is
270 * passed snan, so we cannot use it when building with snan support.
271 * clang doesn't appear to have an option to control snan behavior, and
272 * it's builtin fpclassify also raises INVALID for snan, so always use
273 * our version for that.
274 */
275 #if __GNUC_PREREQ (4, 4) && !defined(__SUPPORT_SNAN__) && !defined(__clang__)
276 #define fpclassify(__x) (__builtin_fpclassify (FP_NAN, FP_INFINITE, \
277 FP_NORMAL, FP_SUBNORMAL, \
278 FP_ZERO, __x))
279 #define isfinite(__x) (__builtin_isfinite (__x))
280 #define isinf(__x) (__builtin_isinf_sign (__x))
281 #define isnan(__x) (__builtin_isnan (__x))
282 #define isnormal(__x) (__builtin_isnormal (__x))
283 #define issubnormal(__x) (__builtin_issubnormal (__x))
284 #define iszero(__x) (__builtin_iszero(__x))
285 #else
286 #if defined(_HAVE_LONG_DOUBLE)
287 #define fpclassify(__x) \
288 ((sizeof(__x) == sizeof(float) ? __fpclassifyf(__x) \
289 : (sizeof(__x) == sizeof(double)) ? __fpclassifyd((double) (__x)) \
290 : __fpclassifyl((long double) (__x))))
291 #define isfinite(__x) \
292 ((sizeof(__x) == sizeof(float)) ? __finitef(__x) \
293 : (sizeof(__x) == sizeof(double)) ? __finite((double) (__x)) \
294 : __finitel((long double) (__x)))
295 #else
296 #define fpclassify(__x) \
297 ((sizeof(__x) == sizeof(float)) ? __fpclassifyf(__x) : \
298 __fpclassifyd((double) (__x)))
299 #define isfinite(__x) ((sizeof(__x) == sizeof(float)) ? \
300 __finitef(__x) : __finite((double) __x))
301 #endif
302 #define isinf(__x) (fpclassify(__x) == FP_INFINITE)
303 #define isnan(__x) (fpclassify(__x) == FP_NAN)
304 #define isnormal(__x) (fpclassify(__x) == FP_NORMAL)
305 #define issubnormal(__x) (fpclassify(__x) == FP_SUBNORMAL)
306 #define iszero(__x) (fpclassify(__x) == FP_ZERO)
307 #endif
308
309 #define isfinitef(x) isfinite((float) (x))
310 #define isinff(x) isinf((float) (x))
311 #define isnanf(x) isnan((float) (x))
312 #define isnormalf(x) isnormal((float) (x))
313 #define iszerof(x) iszero((float) (x))
314
315 #ifndef iseqsig
316 int __iseqsigd(double x, double y);
317 int __iseqsigf(float x, float y);
318
319 #ifdef _HAVE_LONG_DOUBLE
320 int __iseqsigl(long double x, long double y);
321 #define iseqsig(__x,__y) \
322 ((sizeof(__x) == sizeof(float) && sizeof(__y) == sizeof(float)) ? \
323 __iseqsigf(__x, __y) : \
324 (sizeof(__x) == sizeof(double) && sizeof(__y) == sizeof(double)) ? \
325 __iseqsigd(__x, __y) : \
326 __iseqsigl(__x, __y))
327 #else
328 #ifdef _DOUBLE_IS_32BITS
329 #define iseqsig(__x, __y) __iseqsigf((float)(__x), (float)(__y))
330 #else
331 #define iseqsig(__x,__y) \
332 ((sizeof(__x) == sizeof(float) && sizeof(__y) == sizeof(float)) ? \
333 __iseqsigf(__x, __y) : __iseqsigd(__x, __y))
334 #endif
335 #endif
336 #endif
337
338 #ifndef issignaling
339 int __issignalingf(float f);
340 int __issignaling(double d);
341
342 #if defined(_HAVE_LONG_DOUBLE)
343 #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ && __SIZEOF_DOUBLE__ > 0
__issignalingl(long double d)344 static inline int __issignalingl(long double d) { return __issignaling((double) d); }
345 #else
346 int __issignalingl(long double d);
347 #endif
348 #define issignaling(__x) \
349 ((sizeof(__x) == sizeof(float)) ? __issignalingf(__x) : \
350 (sizeof(__x) == sizeof(double)) ? __issignaling ((double) (__x)) : \
351 __issignalingl((long double) (__x)))
352 #else
353 #ifdef _DOUBLE_IS_32BITS
354 #define issignaling(__x) __issignalingf((float) (__x))
355 #else
356 #define issignaling(__x) \
357 ((sizeof(__x) == sizeof(float)) ? __issignalingf(__x) : \
358 __issignaling ((double) (__x)))
359 #endif /* _DOUBLE_IS_32BITS */
360 #endif /* _HAVE_LONG_DOUBLE */
361 #endif
362
363 #if __GNUC_PREREQ (4, 0)
364 #if defined(_HAVE_LONG_DOUBLE)
365 #define signbit(__x) \
366 ((sizeof(__x) == sizeof(float)) ? __builtin_signbitf(__x) : \
367 ((sizeof(__x) == sizeof(double)) ? __builtin_signbit ((double)(__x)) : \
368 __builtin_signbitl((long double)(__x))))
369 #else
370 #define signbit(__x) \
371 ((sizeof(__x) == sizeof(float)) ? __builtin_signbitf(__x) : \
372 __builtin_signbit ((double) (__x)))
373 #endif
374 #else
375 #define signbit(__x) \
376 ((sizeof(__x) == sizeof(float)) ? __signbitf(__x) : \
377 __signbitd((double) (__x)))
378 #endif
379
380 #if __GNUC_PREREQ (2, 97) && !(defined(__riscv) && defined(__clang__))
381 #define isgreater(__x,__y) (__builtin_isgreater (__x, __y))
382 #define isgreaterequal(__x,__y) (__builtin_isgreaterequal (__x, __y))
383 #define isless(__x,__y) (__builtin_isless (__x, __y))
384 #define islessequal(__x,__y) (__builtin_islessequal (__x, __y))
385 #define islessgreater(__x,__y) (__builtin_islessgreater (__x, __y))
386 #define isunordered(__x,__y) (__builtin_isunordered (__x, __y))
387 #else
388 #define isgreater(x,y) \
389 (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
390 !isunordered(__x,__y) && (__x > __y);}))
391 #define isgreaterequal(x,y) \
392 (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
393 !isunordered(__x,__y) && (__x >= __y);}))
394 #define isless(x,y) \
395 (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
396 !isunordered(__x,__y) && (__x < __y);}))
397 #define islessequal(x,y) \
398 (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
399 !isunordered(__x,__y) && (__x <= __y);}))
400 #define islessgreater(x,y) \
401 (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
402 !isunordered(__x,__y) && (__x < __y || __x > __y);}))
403
404 #define isunordered(a,b) \
405 (__extension__ ({__typeof__(a) __a = (a); __typeof__(b) __b = (b); \
406 fpclassify(__a) == FP_NAN || fpclassify(__b) == FP_NAN;}))
407 #endif
408
409 /* Non ANSI double precision functions. */
410
411 extern double infinity (void);
412 extern double nan (const char *);
413 extern double copysign (double, double);
414 extern double logb (double);
415 extern int ilogb (double);
416
417 extern double asinh (double);
418 extern double cbrt (double);
419 extern double nextafter (double, double);
420 extern double rint (double);
421 extern double scalbn (double, int);
422 extern double scalb (double, double);
423 extern double getpayload(const double *x);
424 extern double significand (double);
425
426 extern double exp2 (double);
427 extern double scalbln (double, long int);
428 extern double tgamma (double);
429 extern double nearbyint (double);
430 extern long int lrint (double);
431 extern long long int llrint (double);
432 extern double round (double);
433 extern long int lround (double);
434 extern long long int llround (double);
435 extern double trunc (double);
436 extern double remquo (double, double, int *);
437 extern double fdim (double, double);
438 extern double fmax (double, double);
439 extern double fmin (double, double);
440 extern double fma (double, double, double);
441
442 extern double log1p (double);
443 extern double expm1 (double);
444
445 extern double acosh (double);
446 extern double atanh (double);
447 extern double remainder (double, double);
448 extern double gamma (double);
449 extern double lgamma (double);
450 extern double erf (double);
451 extern double erfc (double);
452 extern double log2 (double);
453 #if !defined(__cplusplus)
454 #define log2(x) (log (x) / _M_LN2)
455 #endif
456
457 extern double hypot (double, double);
458
459 /* Single precision versions of ANSI functions. */
460
461 extern float atanf (float);
462 extern float cosf (float);
463 extern float sinf (float);
464 extern float tanf (float);
465 extern float tanhf (float);
466 extern float frexpf (float, int *);
467 extern float modff (float, float *);
468 extern float ceilf (float);
469 extern float fabsf (float);
470 extern float floorf (float);
471
472 extern float acosf (float);
473 extern float asinf (float);
474 extern float atan2f (float, float);
475 extern float coshf (float);
476 extern float sinhf (float);
477 extern float expf (float);
478 extern float ldexpf (float, int);
479 extern float logf (float);
480 extern float log10f (float);
481 extern float powf (float, float);
482 extern float sqrtf (float);
483 extern float fmodf (float, float);
484
485 /* Other single precision functions. */
486
487 extern float exp2f (float);
488 extern float scalblnf (float, long int);
489 extern float tgammaf (float);
490 extern float nearbyintf (float);
491 extern long int lrintf (float);
492 extern long long int llrintf (float);
493 extern float roundf (float);
494 extern long int lroundf (float);
495 extern long long int llroundf (float);
496 extern float truncf (float);
497 extern float remquof (float, float, int *);
498 extern float fdimf (float, float);
499 extern float fmaxf (float, float);
500 extern float fminf (float, float);
501 extern float fmaf (float, float, float);
502
503 extern float infinityf (void);
504 extern float nanf (const char *);
505 extern float copysignf (float, float);
506 extern float logbf (float);
507 extern int ilogbf (float);
508
509 extern float asinhf (float);
510 extern float cbrtf (float);
511 extern float nextafterf (float, float);
512 extern float rintf (float);
513 extern float scalbnf (float, int);
514 extern float scalbf (float, float);
515 extern float log1pf (float);
516 extern float expm1f (float);
517 extern float getpayloadf(const float *x);
518 extern float significandf (float);
519
520 extern float acoshf (float);
521 extern float atanhf (float);
522 extern float remainderf (float, float);
523 extern float gammaf (float);
524 extern float lgammaf (float);
525 extern float erff (float);
526 extern float erfcf (float);
527 extern float log2f (float);
528 extern float hypotf (float, float);
529
530 #ifdef _HAVE_LONG_DOUBLE
531
532 /* These functions are always available for long double */
533
534 extern long double hypotl (long double, long double);
535 extern long double sqrtl (long double);
536 extern long double frexpl (long double, int *);
537 extern long double scalbnl (long double, int);
538 extern long double scalblnl (long double, long);
539 extern long double rintl (long double);
540 extern long int lrintl (long double);
541 extern long long int llrintl (long double);
542 extern int ilogbl (long double);
543 extern long double logbl (long double);
544 extern long double ldexpl (long double, int);
545 extern long double nearbyintl (long double);
546 extern long double ceill (long double);
547 extern long double fmaxl (long double, long double);
548 extern long double fminl (long double, long double);
549 extern long double roundl (long double);
550 extern long lroundl (long double);
551 extern long long int llroundl (long double);
552 extern long double truncl (long double);
553 extern long double nanl (const char *);
554 extern long double floorl (long double);
555 /* Compiler provides these */
556 extern long double fabsl (long double);
557 extern long double copysignl (long double, long double);
558
559 #ifdef _HAVE_LONG_DOUBLE_MATH
560 extern long double atanl (long double);
561 extern long double cosl (long double);
562 extern long double sinl (long double);
563 extern long double tanl (long double);
564 extern long double tanhl (long double);
565 extern long double modfl (long double, long double *);
566 extern long double log1pl (long double);
567 extern long double expm1l (long double);
568 extern long double acosl (long double);
569 extern long double asinl (long double);
570 extern long double atan2l (long double, long double);
571 extern long double coshl (long double);
572 extern long double sinhl (long double);
573 extern long double expl (long double);
574 extern long double logl (long double);
575 extern long double log10l (long double);
576 extern long double powl (long double, long double);
577 extern long double fmodl (long double, long double);
578 extern long double asinhl (long double);
579 extern long double cbrtl (long double);
580 extern long double nextafterl (long double, long double);
581 extern float nexttowardf (float, long double);
582 extern double nexttoward (double, long double);
583 extern long double nexttowardl (long double, long double);
584 extern long double log2l (long double);
585 extern long double exp2l (long double);
586 extern long double scalbl (long double, long double);
587 extern long double tgammal (long double);
588 extern long double remquol (long double, long double, int *);
589 extern long double fdiml (long double, long double);
590 extern long double fmal (long double, long double, long double);
591 extern long double acoshl (long double);
592 extern long double atanhl (long double);
593 extern long double remainderl (long double, long double);
594 extern long double lgammal (long double);
595 extern long double gammal (long double);
596 extern long double erfl (long double);
597 extern long double erfcl (long double);
598 extern long double j0l(long double);
599 extern long double y0l(long double);
600 extern long double j1l(long double);
601 extern long double y1l(long double);
602 extern long double jnl(int, long double);
603 extern long double ynl(int, long double);
604
605 extern long double getpayloadl(const long double *x);
606 extern long double significandl(long double);
607
608 #endif /* _HAVE_LONG_DOUBLE_MATH */
609
610 #endif /* _HAVE_LONG_DOUBLE */
611
612 #endif /* __ISO_C_VISIBLE >= 1999 */
613
614 #if __MISC_VISIBLE
615 extern double drem (double, double);
616 extern float dremf (float, float);
617 #ifdef _HAVE_LONG_DOUBLE_MATH
618 extern long double dreml (long double, long double);
619 extern long double lgammal_r (long double, int *);
620 #endif
621 extern double lgamma_r (double, int *);
622 extern float lgammaf_r (float, int *);
623 #endif
624
625 #if __MISC_VISIBLE || __XSI_VISIBLE
626 extern double y0 (double);
627 extern double y1 (double);
628 extern double yn (int, double);
629 extern double j0 (double);
630 extern double j1 (double);
631 extern double jn (int, double);
632 #endif
633
634 #if __MISC_VISIBLE || __XSI_VISIBLE >= 600
635 extern float y0f (float);
636 extern float y1f (float);
637 extern float ynf (int, float);
638 extern float j0f (float);
639 extern float j1f (float);
640 extern float jnf (int, float);
641 #endif
642
643 /* GNU extensions */
644 #if __GNU_VISIBLE
645 extern void sincos (double, double *, double *);
646 extern void sincosf (float, float *, float *);
647 #ifdef _HAVE_LONG_DOUBLE_MATH
648 extern void sincosl (long double, long double *, long double *);
649 #endif
650 extern double exp10 (double);
651 extern double pow10 (double);
652 extern float exp10f (float);
653 extern float pow10f (float);
654 #ifdef _HAVE_LONG_DOUBLE_MATH
655 extern long double exp10l (long double);
656 extern long double pow10l (long double);
657 #endif
658 #endif /* __GNU_VISIBLE */
659
660 #if __MISC_VISIBLE || __XSI_VISIBLE
661 extern int signgam;
662 #endif /* __MISC_VISIBLE || __XSI_VISIBLE */
663
664 /* Useful constants. */
665
666 #if __BSD_VISIBLE || __XSI_VISIBLE
667
668 #define MAXFLOAT 3.40282347e+38F
669
670 #define M_E 2.7182818284590452354
671 #define _M_E_L 2.718281828459045235360287471352662498L
672 #define M_LOG2E 1.4426950408889634074
673 #define M_LOG10E 0.43429448190325182765
674 #define M_LN2 _M_LN2
675 #define M_LN10 2.30258509299404568402
676 #define M_PI 3.14159265358979323846
677 #define _M_PI_L 3.141592653589793238462643383279502884L
678 #define M_PI_2 1.57079632679489661923
679 #define _M_PI_2 1.57079632679489661923
680 #define _M_PI_2L 1.570796326794896619231321691639751442L
681 #define M_PI_4 0.78539816339744830962
682 #define _M_PI_4L 0.785398163397448309615660845819875721L
683 #define M_1_PI 0.31830988618379067154
684 #define M_2_PI 0.63661977236758134308
685 #define M_2_SQRTPI 1.12837916709551257390
686 #define M_SQRT2 1.41421356237309504880
687 #define M_SQRT1_2 0.70710678118654752440
688
689 #ifdef __GNU_VISIBLE
690 #define M_PIl _M_PI_L
691 #define M_PI_2l _M_PI_2L
692 #define M_PI_4l _M_PI_4L
693 #define M_El _M_E_L
694 #endif
695
696 #endif
697
698 #if __BSD_VISIBLE
699
700 #define M_TWOPI (M_PI * 2.0)
701 #define M_3PI_4 2.3561944901923448370E0
702 #define M_SQRTPI 1.77245385090551602792981
703 #define M_LN2LO 1.9082149292705877000E-10
704 #define M_LN2HI 6.9314718036912381649E-1
705 #define M_SQRT3 1.73205080756887719000
706 #define M_IVLN10 0.43429448190325182765 /* 1 / log(10) */
707 #define _M_IVLN10L 0.43429448190325182765112891891660508229439700580366656611445378316586464920887L
708 #define M_LOG2_E _M_LN2
709 #define M_INVLN2 1.4426950408889633870E0 /* 1 / log(2) */
710
711 #endif /* __BSD_VISIBLE */
712
713 #include <machine/math.h>
714
715 _END_STD_C
716
717 #ifdef __FAST_MATH__
718 #include <machine/fastmath.h>
719 #endif
720
721 #endif /* _MATH_H_ */
722