3 * @copy 2012 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
28 /* All the headers include this file. */
32 * Types for the _exception structure.
35 #define _DOMAIN 1 /* domain error in argument */
36 #define _SING 2 /* singularity */
37 #define _OVERFLOW 3 /* range overflow */
38 #define _UNDERFLOW 4 /* range underflow */
39 #define _TLOSS 5 /* total loss of precision */
40 #define _PLOSS 6 /* partial loss of precision */
43 * Exception types with non-ANSI names for compatibility.
46 #ifndef __STRICT_ANSI__
49 #define DOMAIN _DOMAIN
51 #define OVERFLOW _OVERFLOW
52 #define UNDERFLOW _UNDERFLOW
56 #endif /* Not _NO_OLDNAMES */
57 #endif /* Not __STRICT_ANSI__ */
60 /* Traditional/XOPEN math constants (double precison) */
61 #ifndef __STRICT_ANSI__
62 #define M_E 2.7182818284590452354
63 #define M_LOG2E 1.4426950408889634074
64 #define M_LOG10E 0.43429448190325182765
65 #define M_LN2 0.69314718055994530942
66 #define M_LN10 2.30258509299404568402
67 #define M_PI 3.14159265358979323846
68 #define M_PI_2 1.57079632679489661923
69 #define M_PI_4 0.78539816339744830962
70 #define M_1_PI 0.31830988618379067154
71 #define M_2_PI 0.63661977236758134308
72 #define M_2_SQRTPI 1.12837916709551257390
73 #define M_SQRT2 1.41421356237309504880
74 #define M_SQRT1_2 0.70710678118654752440
77 /* These are also defined in Mingw float.h; needed here as well to work
78 around GCC build issues. */
79 #ifndef __STRICT_ANSI__
80 #ifndef __MINGW_FPCLASS_DEFINED
81 #define __MINGW_FPCLASS_DEFINED 1
82 /* IEEE 754 classication */
83 #define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */
84 #define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */
85 #define _FPCLASS_NINF 0x0004 /* Negative Infinity */
86 #define _FPCLASS_NN 0x0008 /* Negative Normal */
87 #define _FPCLASS_ND 0x0010 /* Negative Denormal */
88 #define _FPCLASS_NZ 0x0020 /* Negative Zero */
89 #define _FPCLASS_PZ 0x0040 /* Positive Zero */
90 #define _FPCLASS_PD 0x0080 /* Positive Denormal */
91 #define _FPCLASS_PN 0x0100 /* Positive Normal */
92 #define _FPCLASS_PINF 0x0200 /* Positive Infinity */
93 #endif /* __MINGW_FPCLASS_DEFINED */
94 #endif /* Not __STRICT_ANSI__ */
103 * HUGE_VAL is returned by strtod when the value would overflow the
104 * representation of 'double'. There are other uses as well.
106 * __imp__HUGE is a pointer to the actual variable _HUGE in
107 * MSVCRT.DLL. If we used _HUGE directly we would get a pointer
108 * to a thunk function.
111 #if __MINGW_GNUC_PREREQ(3, 3)
112 #define HUGE_VAL __builtin_huge_val()
115 #ifndef __DECLSPEC_SUPPORTED
117 extern double* _imp___HUGE;
118 #define HUGE_VAL (*_imp___HUGE)
120 #else /* __DECLSPEC_SUPPORTED */
122 __MINGW_IMPORT double _HUGE;
123 #define HUGE_VAL _HUGE
125 #endif /* __DECLSPEC_SUPPORTED */
126 #endif /* __MINGW_GNUC_PREREQ(3, 3) */
138 _CRTIMP double __cdecl sin (double);
139 _CRTIMP double __cdecl cos (double);
140 _CRTIMP double __cdecl tan (double);
141 _CRTIMP double __cdecl sinh (double);
142 _CRTIMP double __cdecl cosh (double);
143 _CRTIMP double __cdecl tanh (double);
144 _CRTIMP double __cdecl asin (double);
145 _CRTIMP double __cdecl acos (double);
146 _CRTIMP double __cdecl atan (double);
147 _CRTIMP double __cdecl atan2 (double, double);
148 _CRTIMP double __cdecl exp (double);
149 _CRTIMP double __cdecl log (double);
150 _CRTIMP double __cdecl log10 (double);
151 _CRTIMP double __cdecl pow (double, double);
152 _CRTIMP double __cdecl sqrt (double);
153 _CRTIMP double __cdecl ceil (double);
154 _CRTIMP double __cdecl floor (double);
155 _CRTIMP double __cdecl fabs (double);
156 _CRTIMP double __cdecl ldexp (double, int);
157 _CRTIMP double __cdecl frexp (double, int*);
158 _CRTIMP double __cdecl modf (double, double*);
159 _CRTIMP double __cdecl fmod (double, double);
161 /* Excess precision when using a 64-bit mantissa for FPU math ops can
162 cause unexpected results with some of the MSVCRT math functions. For
163 example, unless the function return value is stored (truncating to
164 53-bit mantissa), calls to pow with both x and y as integral values
165 sometimes produce a non-integral result.
166 One workaround is to reset the FPU env to 53-bit mantissa
167 by a call to fesetenv (FE_PC53_ENV). Amother is to force storage
168 of the return value of individual math functions using wrappers.
169 NB, using these wrappers will disable builtin math functions and
170 hence disable the folding of function results at compile time when
171 arguments are constant. */
174 #define __DEFINE_FLOAT_STORE_MATHFN_D1(fn1) \
175 static __inline__ double \
176 __float_store_ ## fn1 (double x) \
178 __volatile__ double res = (fn1) (x); \
182 #define __DEFINE_FLOAT_STORE_MATHFN_D2(fn2) \
183 static __inline__ double \
184 __float_store_ ## fn2 (double x, double y) \
186 __volatile__ double res = (fn2) (x, y); \
191 /* For example, here is how to force the result of the pow function
195 /* Define the ___float_store_pow function and use it instead of pow(). */
196 __DEFINE_FLOAT_STORE_MATHFN_D2 (pow)
197 #define pow __float_store_pow
200 #ifndef __STRICT_ANSI__
202 /* Complex number (for _cabs). This is the MS version. The ISO
203 C99 counterpart _Complex is an intrinsic type in GCC and
204 'complex' is defined as a macro. See complex.h */
207 double x; /* Real part */
208 double y; /* Imaginary part */
211 _CRTIMP double __cdecl _cabs (struct _complex);
213 _CRTIMP double __cdecl _hypot (double, double);
214 _CRTIMP double __cdecl _j0 (double);
215 _CRTIMP double __cdecl _j1 (double);
216 _CRTIMP double __cdecl _jn (int, double);
217 _CRTIMP double __cdecl _y0 (double);
218 _CRTIMP double __cdecl _y1 (double);
219 _CRTIMP double __cdecl _yn (int, double);
220 _CRTIMP int __cdecl _matherr (struct _exception *);
222 /* These are also declared in Mingw float.h; needed here as well to work
223 around GCC build issues. */
224 /* BEGIN FLOAT.H COPY */
226 * IEEE recommended functions
229 _CRTIMP double __cdecl _chgsign (double);
230 _CRTIMP double __cdecl _copysign (double, double);
231 _CRTIMP double __cdecl _logb (double);
232 _CRTIMP double __cdecl _nextafter (double, double);
233 _CRTIMP double __cdecl _scalb (double, long);
235 _CRTIMP int __cdecl _finite (double);
236 _CRTIMP int __cdecl _fpclass (double);
237 _CRTIMP int __cdecl _isnan (double);
239 /* END FLOAT.H COPY */
243 * Non-underscored versions of non-ANSI functions.
244 * These reside in liboldnames.a.
247 #if !defined (_NO_OLDNAMES)
249 _CRTIMP double __cdecl j0 (double);
250 _CRTIMP double __cdecl j1 (double);
251 _CRTIMP double __cdecl jn (int, double);
252 _CRTIMP double __cdecl y0 (double);
253 _CRTIMP double __cdecl y1 (double);
254 _CRTIMP double __cdecl yn (int, double);
256 _CRTIMP double __cdecl chgsign (double);
258 * scalb() is a GCC built-in.
259 * Exclude this _scalb() stub; the semantics are incompatible
260 * with the built-in implementation.
262 _CRTIMP double __cdecl scalb (double, long);
265 _CRTIMP int __cdecl finite (double);
266 _CRTIMP int __cdecl fpclass (double);
268 #define FP_SNAN _FPCLASS_SNAN
269 #define FP_QNAN _FPCLASS_QNAN
270 #define FP_NINF _FPCLASS_NINF
271 #define FP_PINF _FPCLASS_PINF
272 #define FP_NDENORM _FPCLASS_ND
273 #define FP_PDENORM _FPCLASS_PD
274 #define FP_NZERO _FPCLASS_NZ
275 #define FP_PZERO _FPCLASS_PZ
276 #define FP_NNORM _FPCLASS_NN
277 #define FP_PNORM _FPCLASS_PN
279 #endif /* Not _NO_OLDNAMES */
281 /* This require msvcr70.dll or higher. */
282 #if __MSVCRT_VERSION__ >= 0x0700
283 _CRTIMP int __cdecl _set_SSE2_enable (int);
284 #endif /* __MSVCRT_VERSION__ >= 0x0700 */
287 #endif /* __STRICT_ANSI__ */
291 #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
292 || !defined __STRICT_ANSI__ || defined __cplusplus
294 #if __MINGW_GNUC_PREREQ(3, 3)
295 #define HUGE_VALF __builtin_huge_valf()
296 #define HUGE_VALL __builtin_huge_vall()
297 #define INFINITY __builtin_inf()
298 #define NAN __builtin_nan("")
300 extern const float __INFF;
301 #define HUGE_VALF __INFF
302 extern const long double __INFL;
303 #define HUGE_VALL __INFL
304 #define INFINITY HUGE_VALF
305 extern const double __QNAN;
307 #endif /* __MINGW_GNUC_PREREQ(3, 3) */
309 /* Use the compiler's builtin define for FLT_EVAL_METHOD to
310 set float_t and double_t. */
311 #if defined(__FLT_EVAL_METHOD__)
312 # if ( __FLT_EVAL_METHOD__== 0)
313 typedef float float_t;
314 typedef double double_t;
315 # elif (__FLT_EVAL_METHOD__ == 1)
316 typedef double float_t;
317 typedef double double_t;
318 # elif (__FLT_EVAL_METHOD__ == 2)
319 typedef long double float_t;
320 typedef long double double_t;
322 #else /* ix87 FPU default */
323 typedef long double float_t;
324 typedef long double double_t;
329 Return values for fpclassify.
330 These are based on Intel x87 fpu condition codes
331 in the high byte of status word and differ from
332 the return values for MS IEEE 754 extension _fpclass()
334 #define FP_NAN 0x0100
335 #define FP_NORMAL 0x0400
336 #define FP_INFINITE (FP_NAN | FP_NORMAL)
337 #define FP_ZERO 0x4000
338 #define FP_SUBNORMAL (FP_NORMAL | FP_ZERO)
339 /* 0x0200 is signbit mask */
343 We can't inline float or double, because we want to ensure truncation
344 to semantic type before classification.
345 (A normal long double value might become subnormal when
346 converted to double, and zero when converted to float.)
349 extern int __cdecl __fpclassifyf (float);
350 extern int __cdecl __fpclassify (double);
351 extern int __cdecl __fpclassifyl (long double);
353 #ifndef __NO_INLINE__
354 __CRT_INLINE int __cdecl __fpclassifyl (long double x){
356 __asm__ ("fxam; fstsw %%ax;" : "=a" (sw): "t" (x));
357 return sw & (FP_NAN | FP_NORMAL | FP_ZERO );
361 #define fpclassify(x) (sizeof (x) == sizeof (float) ? __fpclassifyf (x) \
362 : sizeof (x) == sizeof (double) ? __fpclassify (x) \
366 #define isfinite(x) ((fpclassify(x) & FP_NAN) == 0)
369 #define isinf(x) (fpclassify(x) == FP_INFINITE)
372 /* We don't need to worry about truncation here:
373 A NaN stays a NaN. */
374 extern int __cdecl __isnan (double);
375 extern int __cdecl __isnanf (float);
376 extern int __cdecl __isnanl (long double);
377 #ifndef __NO_INLINE__
378 __CRT_INLINE int __cdecl __isnan (double _x)
382 "fstsw %%ax": "=a" (sw) : "t" (_x));
383 return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
387 __CRT_INLINE int __cdecl __isnanf (float _x)
391 "fstsw %%ax": "=a" (sw) : "t" (_x));
392 return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
396 __CRT_INLINE int __cdecl __isnanl (long double _x)
400 "fstsw %%ax": "=a" (sw) : "t" (_x));
401 return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
406 #define isnan(x) (sizeof (x) == sizeof (float) ? __isnanf (x) \
407 : sizeof (x) == sizeof (double) ? __isnan (x) \
411 #define isnormal(x) (fpclassify(x) == FP_NORMAL)
413 /* 7.12.3.6 The signbit macro */
414 extern int __cdecl __signbit (double);
415 extern int __cdecl __signbitf (float);
416 extern int __cdecl __signbitl (long double);
417 #ifndef __NO_INLINE__
418 __CRT_INLINE int __cdecl __signbit (double x) {
420 __asm__ ( "fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
421 return (stw & 0x0200) != 0;
424 __CRT_INLINE int __cdecl __signbitf (float x) {
426 __asm__ ("fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
427 return (stw & 0x0200) != 0;
430 __CRT_INLINE int __cdecl __signbitl (long double x) {
432 __asm__ ("fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
433 return (stw & 0x0200) != 0;
437 #define signbit(x) (sizeof (x) == sizeof (float) ? __signbitf (x) \
438 : sizeof (x) == sizeof (double) ? __signbit (x) \
441 /* 7.12.4 Trigonometric functions: Double in C89 */
442 extern float __cdecl sinf (float);
443 extern long double __cdecl sinl (long double);
445 extern float __cdecl cosf (float);
446 extern long double __cdecl cosl (long double);
448 extern float __cdecl tanf (float);
449 extern long double __cdecl tanl (long double);
451 extern float __cdecl asinf (float);
452 extern long double __cdecl asinl (long double);
454 extern float __cdecl acosf (float);
455 extern long double __cdecl acosl (long double);
457 extern float __cdecl atanf (float);
458 extern long double __cdecl atanl (long double);
460 extern float __cdecl atan2f (float, float);
461 extern long double __cdecl atan2l (long double, long double);
463 /* 7.12.5 Hyperbolic functions: Double in C89 */
464 extern float __cdecl sinhf (float);
465 #ifndef __NO_INLINE__
466 __CRT_INLINE float __cdecl sinhf (float x)
467 {return (float) sinh (x);}
469 extern long double __cdecl sinhl (long double);
471 extern float __cdecl coshf (float);
472 #ifndef __NO_INLINE__
473 __CRT_INLINE float __cdecl coshf (float x)
474 {return (float) cosh (x);}
476 extern long double __cdecl coshl (long double);
478 extern float __cdecl tanhf (float);
479 #ifndef __NO_INLINE__
480 __CRT_INLINE float __cdecl tanhf (float x)
481 {return (float) tanh (x);}
483 extern long double __cdecl tanhl (long double);
485 /* Inverse hyperbolic trig functions */
487 extern double __cdecl acosh (double);
488 extern float __cdecl acoshf (float);
489 extern long double __cdecl acoshl (long double);
492 extern double __cdecl asinh (double);
493 extern float __cdecl asinhf (float);
494 extern long double __cdecl asinhl (long double);
497 extern double __cdecl atanh (double);
498 extern float __cdecl atanhf (float);
499 extern long double __cdecl atanhl (long double);
501 /* Exponentials and logarithms */
502 /* 7.12.6.1 Double in C89 */
503 extern float __cdecl expf (float);
504 #ifndef __NO_INLINE__
505 __CRT_INLINE float __cdecl expf (float x)
506 {return (float) exp (x);}
508 extern long double __cdecl expl (long double);
511 extern double __cdecl exp2(double);
512 extern float __cdecl exp2f(float);
513 extern long double __cdecl exp2l(long double);
515 /* 7.12.6.3 The expm1 functions */
516 /* TODO: These could be inlined */
517 extern double __cdecl expm1(double);
518 extern float __cdecl expm1f(float);
519 extern long double __cdecl expm1l(long double);
521 /* 7.12.6.4 Double in C89 */
522 extern float __cdecl frexpf (float, int*);
523 #ifndef __NO_INLINE__
524 __CRT_INLINE float __cdecl frexpf (float x, int* expn)
525 {return (float) frexp (x, expn);}
527 extern long double __cdecl frexpl (long double, int*);
530 #define FP_ILOGB0 ((int)0x80000000)
531 #define FP_ILOGBNAN ((int)0x80000000)
532 extern int __cdecl ilogb (double);
533 extern int __cdecl ilogbf (float);
534 extern int __cdecl ilogbl (long double);
536 /* 7.12.6.6 Double in C89 */
537 extern float __cdecl ldexpf (float, int);
538 #ifndef __NO_INLINE__
539 __CRT_INLINE float __cdecl ldexpf (float x, int expn)
540 {return (float) ldexp (x, expn);}
542 extern long double __cdecl ldexpl (long double, int);
544 /* 7.12.6.7 Double in C89 */
545 extern float __cdecl logf (float);
546 extern long double __cdecl logl (long double);
548 /* 7.12.6.8 Double in C89 */
549 extern float __cdecl log10f (float);
550 extern long double __cdecl log10l (long double);
553 extern double __cdecl log1p(double);
554 extern float __cdecl log1pf(float);
555 extern long double __cdecl log1pl(long double);
558 extern double __cdecl log2 (double);
559 extern float __cdecl log2f (float);
560 extern long double __cdecl log2l (long double);
563 extern double __cdecl logb (double);
564 extern float __cdecl logbf (float);
565 extern long double __cdecl logbl (long double);
567 /* Inline versions. GCC-4.0+ can do a better fast-math optimization
569 #ifndef __NO_INLINE__
570 #if !(__MINGW_GNUC_PREREQ (4, 0) && defined __FAST_MATH__ )
571 __CRT_INLINE double __cdecl logb (double x)
574 __asm__ ("fxtract\n\t"
575 "fstp %%st" : "=t" (res) : "0" (x));
579 __CRT_INLINE float __cdecl logbf (float x)
582 __asm__ ("fxtract\n\t"
583 "fstp %%st" : "=t" (res) : "0" (x));
587 __CRT_INLINE long double __cdecl logbl (long double x)
590 __asm__ ("fxtract\n\t"
591 "fstp %%st" : "=t" (res) : "0" (x));
594 #endif /* !defined __FAST_MATH__ || !__MINGW_GNUC_PREREQ (4, 0) */
595 #endif /* !defined __NO_INLINE__ */
597 /* 7.12.6.12 Double in C89 */
598 extern float __cdecl modff (float, float*);
599 extern long double __cdecl modfl (long double, long double*);
602 extern double __cdecl scalbn (double, int);
603 extern float __cdecl scalbnf (float, int);
604 extern long double __cdecl scalbnl (long double, int);
606 extern double __cdecl scalbln (double, long);
607 extern float __cdecl scalblnf (float, long);
608 extern long double __cdecl scalblnl (long double, long);
611 /* Implementations adapted from Cephes versions */
612 extern double __cdecl cbrt (double);
613 extern float __cdecl cbrtf (float);
614 extern long double __cdecl cbrtl (long double);
616 /* 7.12.7.2 The fabs functions: Double in C89 */
617 extern float __cdecl fabsf (float x);
618 extern long double __cdecl fabsl (long double x);
621 extern double __cdecl hypot (double, double); /* in libmoldname.a */
622 extern float __cdecl hypotf (float, float);
623 #ifndef __NO_INLINE__
624 __CRT_INLINE float __cdecl hypotf (float x, float y)
625 { return (float) hypot (x, y);}
627 extern long double __cdecl hypotl (long double, long double);
629 /* 7.12.7.4 The pow functions. Double in C89 */
630 extern float __cdecl powf (float, float);
631 #ifndef __NO_INLINE__
632 __CRT_INLINE float __cdecl powf (float x, float y)
633 {return (float) pow (x, y);}
635 extern long double __cdecl powl (long double, long double);
637 /* 7.12.7.5 The sqrt functions. Double in C89. */
638 extern float __cdecl sqrtf (float);
639 extern long double __cdecl sqrtl (long double);
641 /* 7.12.8.1 The erf functions */
642 extern double __cdecl erf (double);
643 extern float __cdecl erff (float);
644 extern long double __cdecl erfl (long double);
646 /* 7.12.8.2 The erfc functions */
647 extern double __cdecl erfc (double);
648 extern float __cdecl erfcf (float);
649 extern long double __cdecl erfcl (long double);
651 /* 7.12.8.3 The lgamma functions */
652 extern double __cdecl lgamma (double);
653 extern float __cdecl lgammaf (float);
654 extern long double __cdecl lgammal (long double);
656 /* 7.12.8.4 The tgamma functions */
657 extern double __cdecl tgamma (double);
658 extern float __cdecl tgammaf (float);
659 extern long double __cdecl tgammal (long double);
661 /* 7.12.9.1 Double in C89 */
662 extern float __cdecl ceilf (float);
663 extern long double __cdecl ceill (long double);
665 /* 7.12.9.2 Double in C89 */
666 extern float __cdecl floorf (float);
667 extern long double __cdecl floorl (long double);
670 extern double __cdecl nearbyint ( double);
671 extern float __cdecl nearbyintf (float);
672 extern long double __cdecl nearbyintl (long double);
675 /* round, using fpu control word settings */
676 extern double __cdecl rint (double);
677 extern float __cdecl rintf (float);
678 extern long double __cdecl rintl (long double);
681 extern long __cdecl lrint (double);
682 extern long __cdecl lrintf (float);
683 extern long __cdecl lrintl (long double);
685 extern long long __cdecl llrint (double);
686 extern long long __cdecl llrintf (float);
687 extern long long __cdecl llrintl (long double);
689 /* Inline versions of above.
690 GCC 4.0+ can do a better fast-math job with __builtins. */
691 #ifndef __NO_INLINE__
692 #if !(__MINGW_GNUC_PREREQ (4, 0) && defined __FAST_MATH__ )
693 __CRT_INLINE double __cdecl rint (double x)
696 __asm__ ("frndint;": "=t" (retval) : "0" (x));
700 __CRT_INLINE float __cdecl rintf (float x)
703 __asm__ ("frndint;" : "=t" (retval) : "0" (x) );
707 __CRT_INLINE long double __cdecl rintl (long double x)
710 __asm__ ("frndint;" : "=t" (retval) : "0" (x) );
714 __CRT_INLINE long __cdecl lrint (double x)
718 ("fistpl %0" : "=m" (retval) : "t" (x) : "st");
722 __CRT_INLINE long __cdecl lrintf (float x)
726 ("fistpl %0" : "=m" (retval) : "t" (x) : "st");
730 __CRT_INLINE long __cdecl lrintl (long double x)
734 ("fistpl %0" : "=m" (retval) : "t" (x) : "st");
738 __CRT_INLINE long long __cdecl llrint (double x)
742 ("fistpll %0" : "=m" (retval) : "t" (x) : "st");
746 __CRT_INLINE long long __cdecl llrintf (float x)
750 ("fistpll %0" : "=m" (retval) : "t" (x) : "st");
754 __CRT_INLINE long long __cdecl llrintl (long double x)
758 ("fistpll %0" : "=m" (retval) : "t" (x) : "st");
761 #endif /* !__FAST_MATH__ || !__MINGW_GNUC_PREREQ (4,0) */
762 #endif /* !defined __NO_INLINE */
765 /* round away from zero, regardless of fpu control word settings */
766 extern double __cdecl round (double);
767 extern float __cdecl roundf (float);
768 extern long double __cdecl roundl (long double);
771 extern long __cdecl lround (double);
772 extern long __cdecl lroundf (float);
773 extern long __cdecl lroundl (long double);
775 extern long long __cdecl llround (double);
776 extern long long __cdecl llroundf (float);
777 extern long long __cdecl llroundl (long double);
780 /* round towards zero, regardless of fpu control word settings */
781 extern double __cdecl trunc (double);
782 extern float __cdecl truncf (float);
783 extern long double __cdecl truncl (long double);
785 /* 7.12.10.1 Double in C89 */
786 extern float __cdecl fmodf (float, float);
787 extern long double __cdecl fmodl (long double, long double);
790 extern double __cdecl remainder (double, double);
791 extern float __cdecl remainderf (float, float);
792 extern long double __cdecl remainderl (long double, long double);
795 extern double __cdecl remquo(double, double, int *);
796 extern float __cdecl remquof(float, float, int *);
797 extern long double __cdecl remquol(long double, long double, int *);
800 extern double __cdecl copysign (double, double); /* in libmoldname.a */
801 extern float __cdecl copysignf (float, float);
802 extern long double __cdecl copysignl (long double, long double);
804 /* 7.12.11.2 Return a NaN */
805 extern double __cdecl nan(const char *tagp);
806 extern float __cdecl nanf(const char *tagp);
807 extern long double __cdecl nanl(const char *tagp);
809 #ifndef __STRICT_ANSI__
810 #define _nan() nan("")
811 #define _nanf() nanf("")
812 #define _nanl() nanl("")
816 extern double __cdecl nextafter (double, double); /* in libmoldname.a */
817 extern float __cdecl nextafterf (float, float);
818 extern long double __cdecl nextafterl (long double, long double);
820 /* 7.12.11.4 The nexttoward functions */
821 extern double __cdecl nexttoward (double, long double);
822 extern float __cdecl nexttowardf (float, long double);
823 extern long double __cdecl nexttowardl (long double, long double);
826 /* x > y ? (x - y) : 0.0 */
827 extern double __cdecl fdim (double x, double y);
828 extern float __cdecl fdimf (float x, float y);
829 extern long double __cdecl fdiml (long double x, long double y);
832 NaN arguments are treated as missing data: if one argument is a NaN
833 and the other numeric, then these functions choose the numeric
837 extern double __cdecl fmax (double, double);
838 extern float __cdecl fmaxf (float, float);
839 extern long double __cdecl fmaxl (long double, long double);
842 extern double __cdecl fmin (double, double);
843 extern float __cdecl fminf (float, float);
844 extern long double __cdecl fminl (long double, long double);
847 /* return x * y + z as a ternary op */
848 extern double __cdecl fma (double, double, double);
849 extern float __cdecl fmaf (float, float, float);
850 extern long double __cdecl fmal (long double, long double, long double);
855 * With these functions, comparisons involving quiet NaNs set the FP
856 * condition code to "unordered". The IEEE floating-point spec
857 * dictates that the result of floating-point comparisons should be
858 * false whenever a NaN is involved, with the exception of the != op,
859 * which always returns true: yes, (NaN != NaN) is true).
862 #define isgreater(x, y) __builtin_isgreater(x, y)
863 #define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
864 #define isless(x, y) __builtin_isless(x, y)
865 #define islessequal(x, y) __builtin_islessequal(x, y)
866 #define islessgreater(x, y) __builtin_islessgreater(x, y)
867 #define isunordered(x, y) __builtin_isunordered(x, y)
869 #endif /* __STDC_VERSION__ >= 199901L */
870 #endif /* __NO_ISOCEXT */
875 #endif /* Not RC_INVOKED */
878 #endif /* Not _MATH_H_ */