3 * Copyright 2012, 2013 MinGW.org project
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
26 #pragma GCC system_header
30 * Types for the _exception structure.
33 #define _DOMAIN 1 /* domain error in argument */
34 #define _SING 2 /* singularity */
35 #define _OVERFLOW 3 /* range overflow */
36 #define _UNDERFLOW 4 /* range underflow */
37 #define _TLOSS 5 /* total loss of precision */
38 #define _PLOSS 6 /* partial loss of precision */
41 * Exception types with non-ANSI names for compatibility.
44 #ifndef __STRICT_ANSI__
47 #define DOMAIN _DOMAIN
49 #define OVERFLOW _OVERFLOW
50 #define UNDERFLOW _UNDERFLOW
54 #endif /* Not _NO_OLDNAMES */
55 #endif /* Not __STRICT_ANSI__ */
58 /* Traditional/XOPEN math constants (double precison) */
59 #ifndef __STRICT_ANSI__
60 #define M_E 2.7182818284590452354
61 #define M_LOG2E 1.4426950408889634074
62 #define M_LOG10E 0.43429448190325182765
63 #define M_LN2 0.69314718055994530942
64 #define M_LN10 2.30258509299404568402
65 #define M_PI 3.14159265358979323846
66 #define M_PI_2 1.57079632679489661923
67 #define M_PI_4 0.78539816339744830962
68 #define M_1_PI 0.31830988618379067154
69 #define M_2_PI 0.63661977236758134308
70 #define M_2_SQRTPI 1.12837916709551257390
71 #define M_SQRT2 1.41421356237309504880
72 #define M_SQRT1_2 0.70710678118654752440
75 /* These are also defined in Mingw float.h; needed here as well to work
76 around GCC build issues. */
77 #ifndef __STRICT_ANSI__
78 #ifndef __MINGW_FPCLASS_DEFINED
79 #define __MINGW_FPCLASS_DEFINED 1
80 /* IEEE 754 classication */
81 #define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */
82 #define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */
83 #define _FPCLASS_NINF 0x0004 /* Negative Infinity */
84 #define _FPCLASS_NN 0x0008 /* Negative Normal */
85 #define _FPCLASS_ND 0x0010 /* Negative Denormal */
86 #define _FPCLASS_NZ 0x0020 /* Negative Zero */
87 #define _FPCLASS_PZ 0x0040 /* Positive Zero */
88 #define _FPCLASS_PD 0x0080 /* Positive Denormal */
89 #define _FPCLASS_PN 0x0100 /* Positive Normal */
90 #define _FPCLASS_PINF 0x0200 /* Positive Infinity */
91 #endif /* __MINGW_FPCLASS_DEFINED */
92 #endif /* Not __STRICT_ANSI__ */
101 * HUGE_VAL is returned by strtod when the value would overflow the
102 * representation of 'double'. There are other uses as well.
104 * __imp__HUGE is a pointer to the actual variable _HUGE in
105 * MSVCRT.DLL. If we used _HUGE directly we would get a pointer
106 * to a thunk function.
109 #define HUGE_VAL __builtin_huge_val()
120 _CRTIMP double __cdecl sin (double);
121 _CRTIMP double __cdecl cos (double);
122 _CRTIMP double __cdecl tan (double);
123 _CRTIMP double __cdecl sinh (double);
124 _CRTIMP double __cdecl cosh (double);
125 _CRTIMP double __cdecl tanh (double);
126 _CRTIMP double __cdecl asin (double);
127 _CRTIMP double __cdecl acos (double);
128 _CRTIMP double __cdecl atan (double);
129 _CRTIMP double __cdecl atan2 (double, double);
130 _CRTIMP double __cdecl exp (double);
131 _CRTIMP double __cdecl log (double);
132 _CRTIMP double __cdecl log10 (double);
133 _CRTIMP double __cdecl pow (double, double);
134 _CRTIMP double __cdecl sqrt (double);
135 _CRTIMP double __cdecl ceil (double);
136 _CRTIMP double __cdecl floor (double);
137 _CRTIMP double __cdecl fabs (double);
138 _CRTIMP double __cdecl ldexp (double, int);
139 _CRTIMP double __cdecl frexp (double, int*);
140 _CRTIMP double __cdecl modf (double, double*);
141 _CRTIMP double __cdecl fmod (double, double);
143 /* Excess precision when using a 64-bit mantissa for FPU math ops can
144 cause unexpected results with some of the MSVCRT math functions. For
145 example, unless the function return value is stored (truncating to
146 53-bit mantissa), calls to pow with both x and y as integral values
147 sometimes produce a non-integral result.
148 One workaround is to reset the FPU env to 53-bit mantissa
149 by a call to fesetenv (FE_PC53_ENV). Amother is to force storage
150 of the return value of individual math functions using wrappers.
151 NB, using these wrappers will disable builtin math functions and
152 hence disable the folding of function results at compile time when
153 arguments are constant. */
156 #define __DEFINE_FLOAT_STORE_MATHFN_D1(fn1) \
157 static __inline__ double \
158 __float_store_ ## fn1 (double x) \
160 __volatile__ double res = (fn1) (x); \
164 #define __DEFINE_FLOAT_STORE_MATHFN_D2(fn2) \
165 static __inline__ double \
166 __float_store_ ## fn2 (double x, double y) \
168 __volatile__ double res = (fn2) (x, y); \
173 /* For example, here is how to force the result of the pow function
177 /* Define the ___float_store_pow function and use it instead of pow(). */
178 __DEFINE_FLOAT_STORE_MATHFN_D2 (pow)
179 #define pow __float_store_pow
182 #ifndef __STRICT_ANSI__
184 /* Complex number (for _cabs). This is the MS version. The ISO
185 C99 counterpart _Complex is an intrinsic type in GCC and
186 'complex' is defined as a macro. See complex.h */
189 double x; /* Real part */
190 double y; /* Imaginary part */
193 _CRTIMP double __cdecl _cabs (struct _complex);
195 _CRTIMP double __cdecl _hypot (double, double);
196 _CRTIMP double __cdecl _j0 (double);
197 _CRTIMP double __cdecl _j1 (double);
198 _CRTIMP double __cdecl _jn (int, double);
199 _CRTIMP double __cdecl _y0 (double);
200 _CRTIMP double __cdecl _y1 (double);
201 _CRTIMP double __cdecl _yn (int, double);
202 _CRTIMP int __cdecl _matherr (struct _exception *);
204 /* These are also declared in Mingw float.h; needed here as well to work
205 around GCC build issues. */
206 /* BEGIN FLOAT.H COPY */
208 * IEEE recommended functions
211 _CRTIMP double __cdecl _chgsign (double);
212 _CRTIMP double __cdecl _copysign (double, double);
213 _CRTIMP double __cdecl _logb (double);
214 _CRTIMP double __cdecl _nextafter (double, double);
215 _CRTIMP double __cdecl _scalb (double, long);
217 _CRTIMP int __cdecl _finite (double);
218 _CRTIMP int __cdecl _fpclass (double);
219 _CRTIMP int __cdecl _isnan (double);
221 /* END FLOAT.H COPY */
225 * Non-underscored versions of non-ANSI functions.
226 * These reside in liboldnames.a.
229 #if !defined (_NO_OLDNAMES)
231 _CRTIMP double __cdecl j0 (double);
232 _CRTIMP double __cdecl j1 (double);
233 _CRTIMP double __cdecl jn (int, double);
234 _CRTIMP double __cdecl y0 (double);
235 _CRTIMP double __cdecl y1 (double);
236 _CRTIMP double __cdecl yn (int, double);
238 _CRTIMP double __cdecl chgsign (double);
240 * scalb() is a GCC built-in.
241 * Exclude this _scalb() stub; the semantics are incompatible
242 * with the built-in implementation.
244 _CRTIMP double __cdecl scalb (double, long);
247 _CRTIMP int __cdecl finite (double);
248 _CRTIMP int __cdecl fpclass (double);
250 #define FP_SNAN _FPCLASS_SNAN
251 #define FP_QNAN _FPCLASS_QNAN
252 #define FP_NINF _FPCLASS_NINF
253 #define FP_PINF _FPCLASS_PINF
254 #define FP_NDENORM _FPCLASS_ND
255 #define FP_PDENORM _FPCLASS_PD
256 #define FP_NZERO _FPCLASS_NZ
257 #define FP_PZERO _FPCLASS_PZ
258 #define FP_NNORM _FPCLASS_NN
259 #define FP_PNORM _FPCLASS_PN
261 #endif /* Not _NO_OLDNAMES */
263 /* This require msvcr70.dll or higher. */
264 _CRTIMP int __cdecl _set_SSE2_enable (int);
267 #endif /* __STRICT_ANSI__ */
271 #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
272 || !defined __STRICT_ANSI__ || defined __cplusplus
274 #define HUGE_VALF __builtin_huge_valf()
275 #define HUGE_VALL __builtin_huge_vall()
276 #define INFINITY __builtin_inf()
277 #define NAN __builtin_nan("")
279 /* Use the compiler's builtin define for FLT_EVAL_METHOD to
280 set float_t and double_t. */
281 #if defined(__FLT_EVAL_METHOD__)
282 # if ( __FLT_EVAL_METHOD__== 0)
283 typedef float float_t;
284 typedef double double_t;
285 # elif (__FLT_EVAL_METHOD__ == 1)
286 typedef double float_t;
287 typedef double double_t;
288 # elif (__FLT_EVAL_METHOD__ == 2)
289 typedef long double float_t;
290 typedef long double double_t;
292 #else /* ix87 FPU default */
293 typedef long double float_t;
294 typedef long double double_t;
299 Return values for fpclassify.
300 These are based on Intel x87 fpu condition codes
301 in the high byte of status word and differ from
302 the return values for MS IEEE 754 extension _fpclass()
304 #define FP_NAN 0x0100
305 #define FP_NORMAL 0x0400
306 #define FP_INFINITE (FP_NAN | FP_NORMAL)
307 #define FP_ZERO 0x4000
308 #define FP_SUBNORMAL (FP_NORMAL | FP_ZERO)
309 /* 0x0200 is signbit mask */
313 We can't inline float or double, because we want to ensure truncation
314 to semantic type before classification.
315 (A normal long double value might become subnormal when
316 converted to double, and zero when converted to float.)
319 extern int __cdecl __fpclassifyf (float);
320 extern int __cdecl __fpclassify (double);
321 extern int __cdecl __fpclassifyl (long double);
323 #ifndef __NO_INLINE__
324 __CRT_INLINE int __cdecl __fpclassifyl (long double x){
326 __asm__ ("fxam; fstsw %%ax;" : "=a" (sw): "t" (x));
327 return sw & (FP_NAN | FP_NORMAL | FP_ZERO );
331 #define fpclassify(x) (sizeof (x) == sizeof (float) ? __fpclassifyf (x) \
332 : sizeof (x) == sizeof (double) ? __fpclassify (x) \
336 #define isfinite(x) ((fpclassify(x) & FP_NAN) == 0)
339 #define isinf(x) (fpclassify(x) == FP_INFINITE)
342 /* We don't need to worry about truncation here:
343 A NaN stays a NaN. */
344 extern int __cdecl __isnan (double);
345 extern int __cdecl __isnanf (float);
346 extern int __cdecl __isnanl (long double);
347 #ifndef __NO_INLINE__
348 __CRT_INLINE int __cdecl __isnan (double _x)
352 "fstsw %%ax": "=a" (sw) : "t" (_x));
353 return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
357 __CRT_INLINE int __cdecl __isnanf (float _x)
361 "fstsw %%ax": "=a" (sw) : "t" (_x));
362 return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
366 __CRT_INLINE int __cdecl __isnanl (long double _x)
370 "fstsw %%ax": "=a" (sw) : "t" (_x));
371 return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
376 #define isnan(x) (sizeof (x) == sizeof (float) ? __isnanf (x) \
377 : sizeof (x) == sizeof (double) ? __isnan (x) \
381 #define isnormal(x) (fpclassify(x) == FP_NORMAL)
383 /* 7.12.3.6 The signbit macro */
384 extern int __cdecl __signbit (double);
385 extern int __cdecl __signbitf (float);
386 extern int __cdecl __signbitl (long double);
387 #ifndef __NO_INLINE__
388 __CRT_INLINE int __cdecl __signbit (double x) {
390 __asm__ ( "fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
391 return (stw & 0x0200) != 0;
394 __CRT_INLINE int __cdecl __signbitf (float x) {
396 __asm__ ("fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
397 return (stw & 0x0200) != 0;
400 __CRT_INLINE int __cdecl __signbitl (long double x) {
402 __asm__ ("fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
403 return (stw & 0x0200) != 0;
407 #define signbit(x) (sizeof (x) == sizeof (float) ? __signbitf (x) \
408 : sizeof (x) == sizeof (double) ? __signbit (x) \
411 /* 7.12.4 Trigonometric functions: Double in C89 */
412 extern float __cdecl sinf (float);
413 extern long double __cdecl sinl (long double);
415 extern float __cdecl cosf (float);
416 extern long double __cdecl cosl (long double);
418 extern float __cdecl tanf (float);
419 extern long double __cdecl tanl (long double);
421 extern float __cdecl asinf (float);
422 extern long double __cdecl asinl (long double);
424 extern float __cdecl acosf (float);
425 extern long double __cdecl acosl (long double);
427 extern float __cdecl atanf (float);
428 extern long double __cdecl atanl (long double);
430 extern float __cdecl atan2f (float, float);
431 extern long double __cdecl atan2l (long double, long double);
433 /* 7.12.5 Hyperbolic functions: Double in C89 */
434 extern float __cdecl sinhf (float);
435 #ifndef __NO_INLINE__
436 __CRT_INLINE float __cdecl sinhf (float x)
437 {return (float) sinh (x);}
439 extern long double __cdecl sinhl (long double);
441 extern float __cdecl coshf (float);
442 #ifndef __NO_INLINE__
443 __CRT_INLINE float __cdecl coshf (float x)
444 {return (float) cosh (x);}
446 extern long double __cdecl coshl (long double);
448 extern float __cdecl tanhf (float);
449 #ifndef __NO_INLINE__
450 __CRT_INLINE float __cdecl tanhf (float x)
451 {return (float) tanh (x);}
453 extern long double __cdecl tanhl (long double);
455 /* Inverse hyperbolic trig functions */
457 extern double __cdecl acosh (double);
458 extern float __cdecl acoshf (float);
459 extern long double __cdecl acoshl (long double);
462 extern double __cdecl asinh (double);
463 extern float __cdecl asinhf (float);
464 extern long double __cdecl asinhl (long double);
467 extern double __cdecl atanh (double);
468 extern float __cdecl atanhf (float);
469 extern long double __cdecl atanhl (long double);
471 /* Exponentials and logarithms */
472 /* 7.12.6.1 Double in C89 */
473 extern float __cdecl expf (float);
474 #ifndef __NO_INLINE__
475 __CRT_INLINE float __cdecl expf (float x)
476 {return (float) exp (x);}
478 extern long double __cdecl expl (long double);
481 extern double __cdecl exp2(double);
482 extern float __cdecl exp2f(float);
483 extern long double __cdecl exp2l(long double);
485 /* 7.12.6.3 The expm1 functions */
486 /* TODO: These could be inlined */
487 extern double __cdecl expm1(double);
488 extern float __cdecl expm1f(float);
489 extern long double __cdecl expm1l(long double);
491 /* 7.12.6.4 Double in C89 */
492 extern float __cdecl frexpf (float, int*);
493 #ifndef __NO_INLINE__
494 __CRT_INLINE float __cdecl frexpf (float x, int* expn)
495 {return (float) frexp (x, expn);}
497 extern long double __cdecl frexpl (long double, int*);
500 #define FP_ILOGB0 ((int)0x80000000)
501 #define FP_ILOGBNAN ((int)0x80000000)
502 extern int __cdecl ilogb (double);
503 extern int __cdecl ilogbf (float);
504 extern int __cdecl ilogbl (long double);
506 /* 7.12.6.6 Double in C89 */
507 extern float __cdecl ldexpf (float, int);
508 #ifndef __NO_INLINE__
509 __CRT_INLINE float __cdecl ldexpf (float x, int expn)
510 {return (float) ldexp (x, expn);}
512 extern long double __cdecl ldexpl (long double, int);
514 /* 7.12.6.7 Double in C89 */
515 extern float __cdecl logf (float);
516 extern long double __cdecl logl (long double);
518 /* 7.12.6.8 Double in C89 */
519 extern float __cdecl log10f (float);
520 extern long double __cdecl log10l (long double);
523 extern double __cdecl log1p(double);
524 extern float __cdecl log1pf(float);
525 extern long double __cdecl log1pl(long double);
528 extern double __cdecl log2 (double);
529 extern float __cdecl log2f (float);
530 extern long double __cdecl log2l (long double);
533 extern double __cdecl logb (double);
534 extern float __cdecl logbf (float);
535 extern long double __cdecl logbl (long double);
537 /* Inline versions. GCC-4.0+ can do a better fast-math optimization
539 #ifndef __NO_INLINE__
540 #if !(__MINGW_GNUC_PREREQ (4, 0) && defined __FAST_MATH__ )
541 __CRT_INLINE double __cdecl logb (double x)
544 __asm__ ("fxtract\n\t"
545 "fstp %%st" : "=t" (res) : "0" (x));
549 __CRT_INLINE float __cdecl logbf (float x)
552 __asm__ ("fxtract\n\t"
553 "fstp %%st" : "=t" (res) : "0" (x));
557 __CRT_INLINE long double __cdecl logbl (long double x)
560 __asm__ ("fxtract\n\t"
561 "fstp %%st" : "=t" (res) : "0" (x));
564 #endif /* !defined __FAST_MATH__ || !__MINGW_GNUC_PREREQ (4, 0) */
565 #endif /* !defined __NO_INLINE__ */
567 /* 7.12.6.12 Double in C89 */
568 extern float __cdecl modff (float, float*);
569 extern long double __cdecl modfl (long double, long double*);
572 extern double __cdecl scalbn (double, int);
573 extern float __cdecl scalbnf (float, int);
574 extern long double __cdecl scalbnl (long double, int);
576 extern double __cdecl scalbln (double, long);
577 extern float __cdecl scalblnf (float, long);
578 extern long double __cdecl scalblnl (long double, long);
581 /* Implementations adapted from Cephes versions */
582 extern double __cdecl cbrt (double);
583 extern float __cdecl cbrtf (float);
584 extern long double __cdecl cbrtl (long double);
586 /* 7.12.7.2 The fabs functions: Double in C89 */
587 extern float __cdecl fabsf (float x);
588 extern long double __cdecl fabsl (long double x);
591 extern double __cdecl hypot (double, double); /* in libmoldname.a */
592 extern float __cdecl hypotf (float, float);
593 #ifndef __NO_INLINE__
594 __CRT_INLINE float __cdecl hypotf (float x, float y)
595 { return (float) hypot (x, y);}
597 extern long double __cdecl hypotl (long double, long double);
599 /* 7.12.7.4 The pow functions. Double in C89 */
600 extern float __cdecl powf (float, float);
601 #ifndef __NO_INLINE__
602 __CRT_INLINE float __cdecl powf (float x, float y)
603 {return (float) pow (x, y);}
605 extern long double __cdecl powl (long double, long double);
607 /* 7.12.7.5 The sqrt functions. Double in C89. */
608 extern float __cdecl sqrtf (float);
609 extern long double __cdecl sqrtl (long double);
611 /* 7.12.8.1 The erf functions */
612 extern double __cdecl erf (double);
613 extern float __cdecl erff (float);
614 extern long double __cdecl erfl (long double);
616 /* 7.12.8.2 The erfc functions */
617 extern double __cdecl erfc (double);
618 extern float __cdecl erfcf (float);
619 extern long double __cdecl erfcl (long double);
621 /* 7.12.8.3 The lgamma functions */
622 extern double __cdecl lgamma (double);
623 extern float __cdecl lgammaf (float);
624 extern long double __cdecl lgammal (long double);
626 /* 7.12.8.4 The tgamma functions */
627 extern double __cdecl tgamma (double);
628 extern float __cdecl tgammaf (float);
629 extern long double __cdecl tgammal (long double);
631 /* 7.12.9.1 Double in C89 */
632 extern float __cdecl ceilf (float);
633 extern long double __cdecl ceill (long double);
635 /* 7.12.9.2 Double in C89 */
636 extern float __cdecl floorf (float);
637 extern long double __cdecl floorl (long double);
640 extern double __cdecl nearbyint ( double);
641 extern float __cdecl nearbyintf (float);
642 extern long double __cdecl nearbyintl (long double);
645 /* round, using fpu control word settings */
646 extern double __cdecl rint (double);
647 extern float __cdecl rintf (float);
648 extern long double __cdecl rintl (long double);
651 extern long __cdecl lrint (double);
652 extern long __cdecl lrintf (float);
653 extern long __cdecl lrintl (long double);
655 extern long long __cdecl llrint (double);
656 extern long long __cdecl llrintf (float);
657 extern long long __cdecl llrintl (long double);
659 /* Inline versions of above.
660 GCC 4.0+ can do a better fast-math job with __builtins. */
661 #ifndef __NO_INLINE__
662 #if !(__MINGW_GNUC_PREREQ (4, 0) && defined __FAST_MATH__ )
663 __CRT_INLINE double __cdecl rint (double x)
666 __asm__ ("frndint;": "=t" (retval) : "0" (x));
670 __CRT_INLINE float __cdecl rintf (float x)
673 __asm__ ("frndint;" : "=t" (retval) : "0" (x) );
677 __CRT_INLINE long double __cdecl rintl (long double x)
680 __asm__ ("frndint;" : "=t" (retval) : "0" (x) );
684 __CRT_INLINE long __cdecl lrint (double x)
688 ("fistpl %0" : "=m" (retval) : "t" (x) : "st");
692 __CRT_INLINE long __cdecl lrintf (float x)
696 ("fistpl %0" : "=m" (retval) : "t" (x) : "st");
700 __CRT_INLINE long __cdecl lrintl (long double x)
704 ("fistpl %0" : "=m" (retval) : "t" (x) : "st");
708 __CRT_INLINE long long __cdecl llrint (double x)
712 ("fistpll %0" : "=m" (retval) : "t" (x) : "st");
716 __CRT_INLINE long long __cdecl llrintf (float x)
720 ("fistpll %0" : "=m" (retval) : "t" (x) : "st");
724 __CRT_INLINE long long __cdecl llrintl (long double x)
728 ("fistpll %0" : "=m" (retval) : "t" (x) : "st");
731 #endif /* !__FAST_MATH__ || !__MINGW_GNUC_PREREQ (4,0) */
732 #endif /* !defined __NO_INLINE */
735 /* round away from zero, regardless of fpu control word settings */
736 extern double __cdecl round (double);
737 extern float __cdecl roundf (float);
738 extern long double __cdecl roundl (long double);
741 extern long __cdecl lround (double);
742 extern long __cdecl lroundf (float);
743 extern long __cdecl lroundl (long double);
745 extern long long __cdecl llround (double);
746 extern long long __cdecl llroundf (float);
747 extern long long __cdecl llroundl (long double);
750 /* round towards zero, regardless of fpu control word settings */
751 extern double __cdecl trunc (double);
752 extern float __cdecl truncf (float);
753 extern long double __cdecl truncl (long double);
755 /* 7.12.10.1 Double in C89 */
756 extern float __cdecl fmodf (float, float);
757 extern long double __cdecl fmodl (long double, long double);
760 extern double __cdecl remainder (double, double);
761 extern float __cdecl remainderf (float, float);
762 extern long double __cdecl remainderl (long double, long double);
765 extern double __cdecl remquo(double, double, int *);
766 extern float __cdecl remquof(float, float, int *);
767 extern long double __cdecl remquol(long double, long double, int *);
770 extern double __cdecl copysign (double, double); /* in libmoldname.a */
771 extern float __cdecl copysignf (float, float);
772 extern long double __cdecl copysignl (long double, long double);
774 /* 7.12.11.2 Return a NaN */
775 extern double __cdecl nan(const char *tagp);
776 extern float __cdecl nanf(const char *tagp);
777 extern long double __cdecl nanl(const char *tagp);
779 #ifndef __STRICT_ANSI__
780 #define _nan() nan("")
781 #define _nanf() nanf("")
782 #define _nanl() nanl("")
786 extern double __cdecl nextafter (double, double); /* in libmoldname.a */
787 extern float __cdecl nextafterf (float, float);
788 extern long double __cdecl nextafterl (long double, long double);
790 /* 7.12.11.4 The nexttoward functions */
791 extern double __cdecl nexttoward (double, long double);
792 extern float __cdecl nexttowardf (float, long double);
793 extern long double __cdecl nexttowardl (long double, long double);
796 /* x > y ? (x - y) : 0.0 */
797 extern double __cdecl fdim (double x, double y);
798 extern float __cdecl fdimf (float x, float y);
799 extern long double __cdecl fdiml (long double x, long double y);
802 NaN arguments are treated as missing data: if one argument is a NaN
803 and the other numeric, then these functions choose the numeric
807 extern double __cdecl fmax (double, double);
808 extern float __cdecl fmaxf (float, float);
809 extern long double __cdecl fmaxl (long double, long double);
812 extern double __cdecl fmin (double, double);
813 extern float __cdecl fminf (float, float);
814 extern long double __cdecl fminl (long double, long double);
817 /* return x * y + z as a ternary op */
818 extern double __cdecl fma (double, double, double);
819 extern float __cdecl fmaf (float, float, float);
820 extern long double __cdecl fmal (long double, long double, long double);
825 * With these functions, comparisons involving quiet NaNs set the FP
826 * condition code to "unordered". The IEEE floating-point spec
827 * dictates that the result of floating-point comparisons should be
828 * false whenever a NaN is involved, with the exception of the != op,
829 * which always returns true: yes, (NaN != NaN) is true).
832 #define isgreater(x, y) __builtin_isgreater(x, y)
833 #define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
834 #define isless(x, y) __builtin_isless(x, y)
835 #define islessequal(x, y) __builtin_islessequal(x, y)
836 #define islessgreater(x, y) __builtin_islessgreater(x, y)
837 #define isunordered(x, y) __builtin_isunordered(x, y)
839 #endif /* __STDC_VERSION__ >= 199901L */
840 #endif /* __NO_ISOCEXT */
845 #endif /* Not RC_INVOKED */
848 #endif /* Not _MATH_H_ */