Author: tkreuzer
Date: Wed Jan 26 17:16:07 2011
New Revision: 50500
URL:
http://svn.reactos.org/svn/reactos?rev=50500&view=rev
Log:
[CRT]
Cleanup math.h from unixism. For now move everything that doesn't belong there into
mingw_math.h.
Added:
trunk/reactos/include/crt/mingw_math.h (with props)
Modified:
trunk/reactos/include/crt/math.h
Modified: trunk/reactos/include/crt/math.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/crt/math.h?rev=505…
==============================================================================
--- trunk/reactos/include/crt/math.h [iso-8859-1] (original)
+++ trunk/reactos/include/crt/math.h [iso-8859-1] Wed Jan 26 17:16:07 2011
@@ -40,178 +40,166 @@
#define _UNDERFLOW 4
#define _TLOSS 5
#define _PLOSS 6
-
#define EDOM 33
#define ERANGE 34
_CRTIMP extern double _HUGE;
#define HUGE_VAL _HUGE
+#define _matherrl _matherr
#ifndef _CRT_ABS_DEFINED
#define _CRT_ABS_DEFINED
- int __cdecl abs(int _X);
- long __cdecl labs(long _X);
-#endif
- double __cdecl acos(double _X);
- double __cdecl asin(double _X);
- double __cdecl atan(double _X);
- double __cdecl atan2(double _Y,double _X);
+ int __cdecl abs(int x);
+ long __cdecl labs(long x);
+#endif
+ double __cdecl acos(double x);
+ double __cdecl asin(double x);
+ double __cdecl atan(double x);
+ double __cdecl atan2(double y, double x);
+ double __cdecl cos(double x);
+ double __cdecl cosh(double x);
+ double __cdecl exp(double x);
+ double __cdecl fabs(double x);
+ double __cdecl fmod(double x, double y);
+ double __cdecl log(double x);
+ double __cdecl log10(double x);
+ double __cdecl pow(double x, double y);
+ double __cdecl sin(double x);
+ double __cdecl sinh(double x);
+ double __cdecl sqrt(double x);
+ double __cdecl tan(double x);
+ double __cdecl tanh(double x);
+#ifndef _CRT_MATHERR_DEFINED
+#define _CRT_MATHERR_DEFINED
+ int __cdecl _matherr(struct _exception *except);
+#endif
+
+#ifndef _CRT_ATOF_DEFINED
+#define _CRT_ATOF_DEFINED
+ _CRTIMP double __cdecl atof(const char *str);
+ _CRTIMP double __cdecl _atof_l(const char *str ,_locale_t locale);
+#endif
#ifndef _SIGN_DEFINED
#define _SIGN_DEFINED
- _CRTIMP double __cdecl _copysign (double _Number,double _Sign);
- _CRTIMP double __cdecl _chgsign (double _X);
-#endif
- double __cdecl cos(double _X);
- double __cdecl cosh(double _X);
- double __cdecl exp(double _X);
- double expm1(double _X);
- double __cdecl fabs(double _X);
- double __cdecl fmod(double _X,double _Y);
- double __cdecl log(double _X);
- double __cdecl log10(double _X);
- double __cdecl pow(double _X,double _Y);
- double __cdecl sin(double _X);
- double __cdecl sinh(double _X);
- double __cdecl tan(double _X);
- double __cdecl tanh(double _X);
- double __cdecl sqrt(double _X);
-#ifndef _CRT_ATOF_DEFINED
-#define _CRT_ATOF_DEFINED
- double __cdecl atof(const char *_String);
- double __cdecl _atof_l(const char *_String,_locale_t _Locale);
-#endif
-
- _CRTIMP double __cdecl _cabs(struct _complex _ComplexA);
- _CRTIMP double __cdecl ceil(double _X);
- _CRTIMP double __cdecl floor(double _X);
- _CRTIMP double __cdecl frexp(double _X,int *_Y);
- _CRTIMP double __cdecl _hypot(double _X,double _Y);
- _CRTIMP double __cdecl _j0(double _X);
- _CRTIMP double __cdecl _j1(double _X);
- _CRTIMP double __cdecl _jn(int _X,double _Y);
- _CRTIMP double __cdecl ldexp(double _X,int _Y);
-#ifndef _CRT_MATHERR_DEFINED
-#define _CRT_MATHERR_DEFINED
- int __cdecl _matherr(struct _exception *_Except);
-#endif
- _CRTIMP double __cdecl modf(double _X,double *_Y);
- _CRTIMP double __cdecl _y0(double _X);
- _CRTIMP double __cdecl _y1(double _X);
- _CRTIMP double __cdecl _yn(int _X,double _Y);
+ _CRTIMP double __cdecl _copysign(double x,double sgn);
+ _CRTIMP double __cdecl _chgsign(double x);
+#endif
+ _CRTIMP double __cdecl _cabs(struct _complex a);
+ _CRTIMP double __cdecl ceil(double x);
+ _CRTIMP double __cdecl floor(double x);
+ _CRTIMP double __cdecl frexp(double x, int *y);
+ _CRTIMP double __cdecl _hypot(double x, double y);
+ _CRTIMP double __cdecl _j0(double x);
+ _CRTIMP double __cdecl _j1(double x);
+ _CRTIMP double __cdecl _jn(int x, double y);
+ _CRTIMP double __cdecl ldexp(double x, int y);
+ _CRTIMP double __cdecl modf(double x, double *y);
+ _CRTIMP double __cdecl _y0(double x);
+ _CRTIMP double __cdecl _y1(double x);
+ _CRTIMP double __cdecl _yn(int x, double y);
+ _CRTIMP float __cdecl _hypotf(float x, float y);
#if defined(__i386__) || defined(_M_IX86)
- _CRTIMP int __cdecl _set_SSE2_enable(int _Flag);
- /* from libmingwex */
- float __cdecl _hypotf(float _X,float _Y);
-#endif
-
- float frexpf(float _X,int *_Y);
- float __cdecl ldexpf(float _X,int _Y);
- long double __cdecl ldexpl(long double _X,int _Y);
- float __cdecl acosf(float _X);
- float __cdecl asinf(float _X);
- float __cdecl atanf(float _X);
- float __cdecl atan2f(float _X,float _Y);
- float __cdecl cosf(float _X);
- float __cdecl sinf(float _X);
- float __cdecl tanf(float _X);
- float __cdecl coshf(float _X);
- float __cdecl sinhf(float _X);
- float __cdecl tanhf(float _X);
- float __cdecl expf(float _X);
- float expm1f(float _X);
- float __cdecl logf(float _X);
- float __cdecl log10f(float _X);
- float __cdecl modff(float _X,float *_Y);
- float __cdecl powf(float _X,float _Y);
- float __cdecl sqrtf(float _X);
- float __cdecl ceilf(float _X);
- float __cdecl floorf(float _X);
- float __cdecl fmodf(float _X,float _Y);
- float __cdecl _hypotf(float _X,float _Y);
- float __cdecl fabsf(float _X);
-#if !defined(__ia64__) && !defined(_M_IA64)
- /* from libmingwex */
- float __cdecl _copysignf (float _Number,float _Sign);
- float __cdecl _chgsignf (float _X);
- float __cdecl _logbf(float _X);
- float __cdecl _nextafterf(float _X,float _Y);
- int __cdecl _finitef(float _X);
- int __cdecl _isnanf(float _X);
- int __cdecl _fpclassf(float _X);
-#endif
-
-#if defined(__GNUC__)
-
-#define __fabs(x, res) \
- __asm__ ("fabs;" : "=t" (res) : "0" (x))
-
-#elif defined(_MSC_VER)
-
-#define __fabs(x, res) \
- __asm { fld [(x)] } \
- __asm { fabs } \
- __asm { fstp [(res)] }
-
-#endif
-
- __CRT_INLINE long double __cdecl fabsl (long double x)
- {
- long double res;
- __fabs(x, res);
- return res;
+ _CRTIMP int __cdecl _set_SSE2_enable(int flag);
+#endif
+
+#if defined(__x86_64) || defined(_M_AMD64)
+ _CRTIMP float __cdecl _copysignf(float x, float sgn);
+ _CRTIMP float __cdecl _chgsignf(float x);
+ _CRTIMP float __cdecl _logbf(float x);
+ _CRTIMP float __cdecl _nextafterf(float x,float y);
+ _CRTIMP int __cdecl _finitef(float x);
+ _CRTIMP int __cdecl _isnanf(float x);
+ _CRTIMP int __cdecl _fpclassf(float x);
+#endif
+
+#if defined(__ia64__) || defined (_M_IA64)
+ _CRTIMP float __cdecl fabsf(float x);
+ _CRTIMP float __cdecl ldexpf(float x, int y);
+ _CRTIMP long double __cdecl tanl(long double x);
+#else
+ __CRT_INLINE float __cdecl fabsf(float x) { return ((float)fabs((double)x)); }
+ __CRT_INLINE float __cdecl ldexpf(float x, int expn) { return (float)ldexp (x, expn);
}
+ __CRT_INLINE long double tanl(long double x) { return (tan((double)x)); }
+#endif
+
+#if defined(__x86_64) || defined(_M_AMD64) || \
+ defined (__ia64__) || defined (_M_IA64)
+ _CRTIMP float __cdecl acosf(float x);
+ _CRTIMP float __cdecl asinf(float x);
+ _CRTIMP float __cdecl atanf(float x);
+ _CRTIMP float __cdecl atan2f(float x, float y);
+ _CRTIMP float __cdecl ceilf(float x);
+ _CRTIMP float __cdecl cosf(float x);
+ _CRTIMP float __cdecl coshf(float x);
+ _CRTIMP float __cdecl expf(float x);
+ _CRTIMP float __cdecl floorf(float x);
+ _CRTIMP float __cdecl fmodf(float x, float y);
+ _CRTIMP float __cdecl logf(float x);
+ _CRTIMP float __cdecl log10f(float x);
+ _CRTIMP float __cdecl modff(float x, float *y);
+ _CRTIMP float __cdecl powf(float b, float e);
+ _CRTIMP float __cdecl sinf(float x);
+ _CRTIMP float __cdecl sinhf(float x);
+ _CRTIMP float __cdecl sqrtf(float x);
+ _CRTIMP float __cdecl tanf(float x);
+ _CRTIMP float __cdecl tanhf(float x);
+#else
+ __CRT_INLINE float acosf(float x) { return ((float)acos((double)x)); }
+ __CRT_INLINE float asinf(float x) { return ((float)asin((double)x)); }
+ __CRT_INLINE float atanf(float x) { return ((float)atan((double)x)); }
+ __CRT_INLINE float atan2f(float x,float y) { return
((float)atan2((double)x,(double)y)); }
+ __CRT_INLINE float ceilf(float x) { return ((float)ceil((double)x)); }
+ __CRT_INLINE float cosf(float x) { return ((float)cos((double)x)); }
+ __CRT_INLINE float coshf(float x) { return ((float)cosh((double)x)); }
+ __CRT_INLINE float expf(float x) { return ((float)exp((double)x)); }
+ __CRT_INLINE float floorf(float x) { return ((float)floor((double)x)); }
+ __CRT_INLINE float fmodf(float x,float y) { return ((float)fmod((double)x,(double)y));
}
+ __CRT_INLINE float logf(float x) { return ((float)log((double)x)); }
+ __CRT_INLINE float log10f(float x) { return ((float)log10((double)x)); }
+ __CRT_INLINE float modff(float x,float *y) {
+ double _Di,_Df = modf((double)x,&_Di);
+ *y = (float)_Di;
+ return ((float)_Df);
}
-
+ __CRT_INLINE float powf(float x,float y) { return ((float)pow((double)x,(double)y)); }
+ __CRT_INLINE float sinf(float x) { return ((float)sin((double)x)); }
+ __CRT_INLINE float sinhf(float x) { return ((float)sinh((double)x)); }
+ __CRT_INLINE float sqrtf(float x) { return ((float)sqrt((double)x)); }
+ __CRT_INLINE float tanf(float x) { return ((float)tan((double)x)); }
+ __CRT_INLINE float tanhf(float x) { return ((float)tanh((double)x)); }
+#endif
+
+ __CRT_INLINE long double acosl(long double x) { return (acos((double)x)); }
+ __CRT_INLINE long double asinl(long double x) { return (asin((double)x)); }
+ __CRT_INLINE long double atanl(long double x) { return (atan((double)x)); }
+ __CRT_INLINE long double atan2l(long double y, long double x) { return
(atan2((double)y, (double)x)); }
+ __CRT_INLINE long double ceill(long double x) { return (ceil((double)x)); }
+ __CRT_INLINE long double cosl(long double x) { return (cos((double)x)); }
+ __CRT_INLINE long double coshl(long double x) { return (cosh((double)x)); }
+ __CRT_INLINE long double expl(long double x) { return (exp((double)x)); }
+ __CRT_INLINE long double floorl(long double x) { return (floor((double)x)); }
+ __CRT_INLINE long double fmodl(long double x, long double y) { return (fmod((double)x,
(double)y)); }
+ __CRT_INLINE long double frexpl(long double x, int *y) { return (frexp((double)x, y));
}
+ __CRT_INLINE long double logl(long double x) { return (log((double)x)); }
+ __CRT_INLINE long double log10l(long double x) { return (log10((double)x)); }
+ __CRT_INLINE long double powl(long double x, long double y) { return (pow((double)x,
(double)y)); }
+ __CRT_INLINE long double sinl(long double x) { return (sin((double)x)); }
+ __CRT_INLINE long double sinhl(long double x) { return (sinh((double)x)); }
+ __CRT_INLINE long double sqrtl(long double x) { return (sqrt((double)x)); }
+ __CRT_INLINE long double tanhl(long double x) {return (tanh((double)x)); }
+ __CRT_INLINE long double __cdecl fabsl(long double x) { return fabs((double)x); }
__CRT_INLINE long double _chgsignl(long double _Number) { return
_chgsign((double)(_Number)); }
- __CRT_INLINE long double _copysignl(long double _Number,long double _Sign) { return
_copysign((double)(_Number),(double)(_Sign)); }
- __CRT_INLINE long double _hypotl(long double _X,long double _Y) { return
_hypot((double)(_X),(double)(_Y)); }
- __CRT_INLINE float frexpf(float _X,int *_Y) { return ((float)frexp((double)_X,_Y)); }
-
-#if !defined (__ia64__) && !defined (_M_IA64)
- __CRT_INLINE float __cdecl fabsf (float x)
- {
- float res;
- __fabs(x, res);
- return res;
- }
-
- __CRT_INLINE float __cdecl ldexpf (float x, int expn) { return (float) ldexp (x, expn);
}
-#endif
-
-#define _matherrl _matherr
-
- __CRT_INLINE long double modfl(long double _X,long double *_Y) {
- double _Di,_Df = modf((double)_X,&_Di);
- *_Y = (long double)_Di;
+ __CRT_INLINE long double _copysignl(long double _Number, long double _Sign) { return
_copysign((double)(_Number),(double)(_Sign)); }
+ __CRT_INLINE long double _hypotl(long double x,long double y) { return
_hypot((double)(x),(double)(y)); }
+ __CRT_INLINE float frexpf(float x, int *y) { return ((float)frexp((double)x,y)); }
+ __CRT_INLINE long double ldexpl(long double x, int y) { return ldexp((double)x, y); }
+ __CRT_INLINE long double modfl(long double x,long double *y) {
+ double _Di,_Df = modf((double)x,&_Di);
+ *y = (long double)_Di;
return (_Df);
}
-
-#if !defined(__x86_64) && !defined(_M_AMD64)
- __CRT_INLINE float acosf(float _X) { return ((float)acos((double)_X)); }
- __CRT_INLINE float asinf(float _X) { return ((float)asin((double)_X)); }
- __CRT_INLINE float atanf(float _X) { return ((float)atan((double)_X)); }
- __CRT_INLINE float atan2f(float _X,float _Y) { return
((float)atan2((double)_X,(double)_Y)); }
- __CRT_INLINE float ceilf(float _X) { return ((float)ceil((double)_X)); }
- __CRT_INLINE float cosf(float _X) { return ((float)cos((double)_X)); }
- __CRT_INLINE float coshf(float _X) { return ((float)cosh((double)_X)); }
- __CRT_INLINE float expf(float _X) { return ((float)exp((double)_X)); }
- __CRT_INLINE float floorf(float _X) { return ((float)floor((double)_X)); }
- __CRT_INLINE float fmodf(float _X,float _Y) { return
((float)fmod((double)_X,(double)_Y)); }
- __CRT_INLINE float logf(float _X) { return ((float)log((double)_X)); }
- __CRT_INLINE float log10f(float _X) { return ((float)log10((double)_X)); }
- __CRT_INLINE float modff(float _X,float *_Y) {
- double _Di,_Df = modf((double)_X,&_Di);
- *_Y = (float)_Di;
- return ((float)_Df);
- }
- __CRT_INLINE float powf(float _X,float _Y) { return
((float)pow((double)_X,(double)_Y)); }
- __CRT_INLINE float sinf(float _X) { return ((float)sin((double)_X)); }
- __CRT_INLINE float sinhf(float _X) { return ((float)sinh((double)_X)); }
- __CRT_INLINE float sqrtf(float _X) { return ((float)sqrt((double)_X)); }
- __CRT_INLINE float tanf(float _X) { return ((float)tan((double)_X)); }
- __CRT_INLINE float tanhf(float _X) { return ((float)tanh((double)_X)); }
-#endif
#ifndef NO_OLDNAMES
#define DOMAIN _DOMAIN
@@ -221,540 +209,29 @@
#define TLOSS _TLOSS
#define PLOSS _PLOSS
#define matherr _matherr
-
-#define HUGE _HUGE
- /* double __cdecl cabs(struct _complex _X); */
- double __cdecl hypot(double _X,double _Y);
- __CRT_INLINE float __cdecl hypotf (float x, float y)
- { return (float) hypot (x, y);}
- _CRTIMP double __cdecl j0(double _X);
- _CRTIMP double __cdecl j1(double _X);
- _CRTIMP double __cdecl jn(int _X,double _Y);
- _CRTIMP double __cdecl y0(double _X);
- _CRTIMP double __cdecl y1(double _X);
- _CRTIMP double __cdecl yn(int _X,double _Y);
-#endif
-
-#ifndef __NO_ISOCEXT
-#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
- || !defined __STRICT_ANSI__ || defined __GLIBCPP__
-
-#if !defined(_MSC_VER)
-#define NAN (0.0F/0.0F)
-#define HUGE_VALF (1.0F/0.0F)
-#define HUGE_VALL (1.0L/0.0L)
-#define INFINITY (1.0F/0.0F)
-#endif
-
-
-#define FP_NAN 0x0100
-#define FP_NORMAL 0x0400
-#define FP_INFINITE (FP_NAN | FP_NORMAL)
-#define FP_ZERO 0x4000
-#define FP_SUBNORMAL (FP_NORMAL | FP_ZERO)
- /* 0x0200 is signbit mask */
-
-#if defined(__GNUC__)
-
-#define __fxam(x, sw) \
- __asm__ ("fxam; fstsw %%ax;" : "=a" (sw): "t" (x))
-
-#elif defined(_MSC_VER)
-
-#define __fxam(x, sw) \
- __asm { fld [(x)] } \
- __asm { fxam } \
- __asm { wait } \
- __asm { fnstsw [(sw)] } \
- __asm { fstp st(0) }
-
-#endif
-
- /*
- We can't __CRT_INLINE float or double, because we want to ensure truncation
- to semantic type before classification.
- (A normal long double value might become subnormal when
- converted to double, and zero when converted to float.)
- */
-
- extern int __cdecl __fpclassifyf (float);
- extern int __cdecl __fpclassify (double);
-
- __CRT_INLINE int __cdecl __fpclassifyl (long double x){
- unsigned short sw;
- __fxam(x, sw);
- return sw & (FP_NAN | FP_NORMAL | FP_ZERO );
- }
-
- __CRT_INLINE int __cdecl __fpclassify (double x){
- return __fpclassifyl((long double)x);
- }
-
-#define fpclassify(x) (sizeof (x) == sizeof (float) ? __fpclassifyf (x) \
- : sizeof (x) == sizeof (double) ? __fpclassify (x) \
- : __fpclassifyl (x))
-
- /* 7.12.3.2 */
-#define isfinite(x) ((fpclassify(x) & FP_NAN) == 0)
-
- /* 7.12.3.3 */
-/* #define isinf(x) (fpclassify(x) == FP_INFINITE) */
-
- /* we don't have fpclassify */
-__CRT_INLINE int isinf (double d) {
- int expon = 0;
- double val = frexp (d, &expon);
- if (expon == 1025) {
- if (val == 0.5) {
- return 1;
- } else if (val == -0.5) {
- return -1;
- } else {
- return 0;
- }
- } else {
- return 0;
- }
-}
-
- /* 7.12.3.4 */
- /* We don't need to worry about truncation here:
- A NaN stays a NaN. */
-
- __CRT_INLINE int __cdecl __isnan (double _x)
- {
- unsigned short sw;
- __fxam(_x, sw);
- return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
- == FP_NAN;
- }
-
- __CRT_INLINE int __cdecl __isnanf (float _x)
- {
- unsigned short sw;
- __fxam(_x, sw);
- return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
- == FP_NAN;
- }
-
- __CRT_INLINE int __cdecl __isnanl (long double _x)
- {
- unsigned short sw;
- __fxam(_x, sw);
- return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
- == FP_NAN;
- }
-
-
-#define isnan(x) (sizeof (x) == sizeof (float) ? __isnanf (x) \
- : sizeof (x) == sizeof (double) ? __isnan (x) \
- : __isnanl (x))
-
- /* 7.12.3.5 */
-#define isnormal(x) (fpclassify(x) == FP_NORMAL)
-
- /* 7.12.3.6 The signbit macro */
- __CRT_INLINE int __cdecl __signbit (double x) {
- unsigned short stw;
- __fxam(x, stw);
- return stw & 0x0200;
- }
-
- __CRT_INLINE int __cdecl __signbitf (float x) {
- unsigned short stw;
- __fxam(x, stw);
- return stw & 0x0200;
- }
-
- __CRT_INLINE int __cdecl __signbitl (long double x) {
- unsigned short stw;
- __fxam(x, stw);
- return stw & 0x0200;
- }
-
-#define signbit(x) (sizeof (x) == sizeof (float) ? __signbitf (x) \
- : sizeof (x) == sizeof (double) ? __signbit (x) \
- : __signbitl (x))
-
- extern double __cdecl exp2(double);
- extern float __cdecl exp2f(float);
- extern long double __cdecl exp2l(long double);
-
-#define FP_ILOGB0 ((int)0x80000000)
-#define FP_ILOGBNAN ((int)0x80000000)
- extern int __cdecl ilogb (double);
- extern int __cdecl ilogbf (float);
- extern int __cdecl ilogbl (long double);
-
- extern double __cdecl log1p(double);
- extern float __cdecl log1pf(float);
- extern long double __cdecl log1pl(long double);
-
- extern double __cdecl log2 (double);
- extern float __cdecl log2f (float);
- extern long double __cdecl log2l (long double);
-
- extern double __cdecl logb (double);
- extern float __cdecl logbf (float);
- extern long double __cdecl logbl (long double);
-
-#if defined(__GNUC__)
-
-#define __fxtract(x, res) \
- __asm__ ("fxtract\n\t" \
- "fstp %%st" : "=t" (res) : "0" (x))
-
-#elif defined(_MSC_VER)
-
-#define __fxtract(x, res) \
- __asm { fld [(x)] } \
- __asm { fxtract } \
- __asm { fstp st(0) } \
- __asm { fstp [(res)] }
-
-#endif
-
- __CRT_INLINE double __cdecl logb (double x)
- {
- double res;
- __fxtract(x, res);
- return res;
- }
-
- __CRT_INLINE float __cdecl logbf (float x)
- {
- float res;
- __fxtract(x, res);
- return res;
- }
-
- __CRT_INLINE long double __cdecl logbl (long double x)
- {
- long double res;
- __fxtract(x, res);
- return res;
- }
-
- /* 7.12.6.13 */
- extern double __cdecl scalbn (double, int);
- extern float __cdecl scalbnf (float, int);
- extern long double __cdecl scalbnl (long double, int);
-
- extern double __cdecl scalbln (double, long);
- extern float __cdecl scalblnf (float, long);
- extern long double __cdecl scalblnl (long double, long);
-
- /* 7.12.7.1 */
- /* Implementations adapted from Cephes versions */
- extern double __cdecl cbrt (double);
- extern float __cdecl cbrtf (float);
- extern long double __cdecl cbrtl (long double);
-
- extern long double __cdecl hypotl (long double, long double);
-
- extern long double __cdecl powl (long double, long double);
- extern long double __cdecl expl(long double);
- extern long double expm1l(long double);
- extern long double __cdecl coshl(long double);
- extern long double __cdecl acosl(long double);
- extern long double __cdecl asinl(long double);
- extern long double __cdecl atanl(long double);
- extern long double __cdecl atan2l(long double,long double);
- extern long double __cdecl sinhl(long double);
- extern long double __cdecl tanhl(long double);
-
- /* 7.12.8.1 The erf functions */
- extern double __cdecl erf (double);
- extern float __cdecl erff (float);
- /* TODO
- extern long double __cdecl erfl (long double);
- */
-
- /* 7.12.8.2 The erfc functions */
- extern double __cdecl erfc (double);
- extern float __cdecl erfcf (float);
- /* TODO
- extern long double __cdecl erfcl (long double);
- */
-
- /* 7.12.8.3 The lgamma functions */
- extern double __cdecl lgamma (double);
- extern float __cdecl lgammaf (float);
- extern long double __cdecl lgammal (long double);
-
- /* 7.12.8.4 The tgamma functions */
- extern double __cdecl tgamma (double);
- extern float __cdecl tgammaf (float);
- extern long double __cdecl tgammal (long double);
-
- extern long double __cdecl ceill (long double);
- extern long double __cdecl floorl (long double);
- extern long double __cdecl frexpl(long double,int *);
- extern long double __cdecl log10l(long double);
- extern long double __cdecl logl(long double);
- extern long double __cdecl cosl(long double);
- extern long double __cdecl sinl(long double);
- extern long double __cdecl tanl(long double);
- extern long double sqrtl(long double);
-
- /* 7.12.9.3 */
- extern double __cdecl nearbyint ( double);
- extern float __cdecl nearbyintf (float);
- extern long double __cdecl nearbyintl (long double);
-
- /* 7.12.9.4 */
- /* round, using fpu control word settings */
-#if defined(__GNUC__)
-
-#define __frndint(x, res) \
- __asm__ ("fabs;" : "=t" (res) : "0" (x))
-
-#elif defined(_MSC_VER)
-
-#define __frndint(x, res) \
- __asm { fld [(x)] } \
- __asm { frndint } \
- __asm { fstp [(res)] }
-
-#endif
-
- __CRT_INLINE double __cdecl rint (double x)
- {
- double retval;
- __frndint(x, retval);
- return retval;
- }
-
- __CRT_INLINE float __cdecl rintf (float x)
- {
- float retval;
- __frndint(x, retval);
- return retval;
- }
-
- __CRT_INLINE long double __cdecl rintl (long double x)
- {
- long double retval;
- __frndint(x, retval);
- return retval;
- }
-
- /* 7.12.9.5 */
-#if defined(__GNUC__)
-
-#define __fistpl(x, res) \
- __asm__ __volatile__("fistpl %0" : "=m" (res) : "t" (x)
: "st")
-
-#define __fistpll(x, res) \
- __asm__ __volatile__("fistpll %0" : "=m" (res) : "t" (x)
: "st")
-
-#elif defined(_MSC_VER)
-
-#define __fistpl(x, res) \
- __asm { fld [(x)] } \
- __asm { fistp [(res)] }
-
-#define __fistpll(x, res) \
- __asm { fld [(x)] } \
- __asm { fistp [(res)] }
-
-#endif
-
- __CRT_INLINE long __cdecl lrint (double x)
- {
- long retval;
- __fistpl(x, retval);
- return retval;
- }
-
- __CRT_INLINE long __cdecl lrintf (float x)
- {
- long retval;
- __fistpl(x, retval);
- return retval;
- }
-
- __CRT_INLINE long __cdecl lrintl (long double x)
- {
- long retval;
- __fistpl(x, retval);
- return retval;
- }
-
- __MINGW_EXTENSION __CRT_INLINE long long __cdecl llrint (double x)
- {
- __MINGW_EXTENSION long long retval;
- __fistpll(x, retval);
- return retval;
- }
-
- __MINGW_EXTENSION __CRT_INLINE long long __cdecl llrintf (float x)
- {
- __MINGW_EXTENSION long long retval;
- __fistpll(x, retval);
- return retval;
- }
-
- __MINGW_EXTENSION __CRT_INLINE long long __cdecl llrintl (long double x)
- {
- __MINGW_EXTENSION long long retval;
- __fistpll(x, retval);
- return retval;
- }
-
- /* 7.12.9.6 */
- /* round away from zero, regardless of fpu control word settings */
- extern double __cdecl round (double);
- extern float __cdecl roundf (float);
- extern long double __cdecl roundl (long double);
-
- /* 7.12.9.7 */
- extern long __cdecl lround (double);
- extern long __cdecl lroundf (float);
- extern long __cdecl lroundl (long double);
-
- __MINGW_EXTENSION extern long long __cdecl llround (double);
- __MINGW_EXTENSION extern long long __cdecl llroundf (float);
- __MINGW_EXTENSION extern long long __cdecl llroundl (long double);
-
- /* 7.12.9.8 */
- /* round towards zero, regardless of fpu control word settings */
- extern double __cdecl trunc (double);
- extern float __cdecl truncf (float);
- extern long double __cdecl truncl (long double);
-
- extern long double __cdecl fmodl (long double, long double);
-
- /* 7.12.10.2 */
- extern double __cdecl remainder (double, double);
- extern float __cdecl remainderf (float, float);
- extern long double __cdecl remainderl (long double, long double);
-
- /* 7.12.10.3 */
- extern double __cdecl remquo(double, double, int *);
- extern float __cdecl remquof(float, float, int *);
- extern long double __cdecl remquol(long double, long double, int *);
-
- /* 7.12.11.1 */
- extern double __cdecl copysign (double, double); /* in libmoldname.a */
- extern float __cdecl copysignf (float, float);
- extern long double __cdecl copysignl (long double, long double);
-
- /* 7.12.11.2 Return a NaN */
- extern double __cdecl nan(const char *tagp);
- extern float __cdecl nanf(const char *tagp);
- extern long double __cdecl nanl(const char *tagp);
-
-#ifndef __STRICT_ANSI__
-#define _nan() nan("")
-#define _nanf() nanf("")
-#define _nanl() nanl("")
-#endif
-
- /* 7.12.11.3 */
- extern double __cdecl nextafter (double, double); /* in libmoldname.a */
- extern float __cdecl nextafterf (float, float);
- extern long double __cdecl nextafterl (long double, long double);
-
- /* 7.12.11.4 The nexttoward functions: TODO */
-
- /* 7.12.12.1 */
- /* x > y ? (x - y) : 0.0 */
- extern double __cdecl fdim (double x, double y);
- extern float __cdecl fdimf (float x, float y);
- extern long double __cdecl fdiml (long double x, long double y);
-
- /* fmax and fmin.
- NaN arguments are treated as missing data: if one argument is a NaN
- and the other numeric, then these functions choose the numeric
- value. */
-
- /* 7.12.12.2 */
- extern double __cdecl fmax (double, double);
- extern float __cdecl fmaxf (float, float);
- extern long double __cdecl fmaxl (long double, long double);
-
- /* 7.12.12.3 */
- extern double __cdecl fmin (double, double);
- extern float __cdecl fminf (float, float);
- extern long double __cdecl fminl (long double, long double);
-
- /* 7.12.13.1 */
- /* return x * y + z as a ternary op */
- extern double __cdecl fma (double, double, double);
- extern float __cdecl fmaf (float, float, float);
- extern long double __cdecl fmal (long double, long double, long double);
-
-
- /* 7.12.14 */
- /*
- * With these functions, comparisons involving quiet NaNs set the FP
- * condition code to "unordered". The IEEE floating-point spec
- * dictates that the result of floating-point comparisons should be
- * false whenever a NaN is involved, with the exception of the != op,
- * which always returns true: yes, (NaN != NaN) is true).
- */
-
-#if defined(__GNUC__) && __GNUC__ >= 3
-
-#define isgreater(x, y) __builtin_isgreater(x, y)
-#define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
-#define isless(x, y) __builtin_isless(x, y)
-#define islessequal(x, y) __builtin_islessequal(x, y)
-#define islessgreater(x, y) __builtin_islessgreater(x, y)
-#define isunordered(x, y) __builtin_isunordered(x, y)
-
-#else
- /* helper */
- __CRT_INLINE int __cdecl
- __fp_unordered_compare (long double x, long double y){
- unsigned short retval;
-#if defined(__GNUC__)
- __asm__ ("fucom %%st(1);"
- "fnstsw;": "=a" (retval) : "t" (x), "u" (y));
-#elif defined(_MSC_VER)
- __asm {
- fld [x]
- fld [y]
- fxch st(1)
- fucom st(1)
- fnstsw [retval]
- fstp st(0)
- fstp st(0)
- }
-#endif
- return retval;
- }
-
-#define isgreater(x, y) ((__fp_unordered_compare(x, y) \
- & 0x4500) == 0)
-#define isless(x, y) ((__fp_unordered_compare (y, x) \
- & 0x4500) == 0)
-#define isgreaterequal(x, y) ((__fp_unordered_compare (x, y) \
- & FP_INFINITE) == 0)
-#define islessequal(x, y) ((__fp_unordered_compare(y, x) \
- & FP_INFINITE) == 0)
-#define islessgreater(x, y) ((__fp_unordered_compare(x, y) \
- & FP_SUBNORMAL) == 0)
-#define isunordered(x, y) ((__fp_unordered_compare(x, y) \
- & 0x4500) == 0x4500)
-
-#endif
-
-
-#endif /* __STDC_VERSION__ >= 199901L */
-#endif /* __NO_ISOCEXT */
+#define HUGE _HUGE
+ // _CRTIMP double __cdecl cabs(struct _complex x);
+ #define cabs _cabs
+ _CRTIMP double __cdecl hypot(double x,double y);
+ _CRTIMP double __cdecl j0(double x);
+ _CRTIMP double __cdecl j1(double x);
+ _CRTIMP double __cdecl jn(int x,double y);
+ _CRTIMP double __cdecl y0(double x);
+ _CRTIMP double __cdecl y1(double x);
+ _CRTIMP double __cdecl yn(int x,double y);
+ __CRT_INLINE float __cdecl hypotf(float x, float y) { return (float) hypot (x, y); }
+#endif
#ifdef __cplusplus
}
extern "C++" {
- template<class _Ty> inline _Ty _Pow_int(_Ty _X,int _Y) {
+ template<class _Ty> inline _Ty _Pow_int(_Ty x,int y) {
unsigned int _N;
- if(_Y >= 0) _N = (unsigned int)_Y;
- else _N = (unsigned int)(-_Y);
- for(_Ty _Z = _Ty(1);;_X *= _X) {
- if((_N & 1)!=0) _Z *= _X;
- if((_N >>= 1)==0) return (_Y < 0 ? _Ty(1) / _Z : _Z);
+ if(y >= 0) _N = (unsigned int)y;
+ else _N = (unsigned int)(-y);
+ for(_Ty _Z = _Ty(1);;x *= x) {
+ if((_N & 1)!=0) _Z *= x;
+ if((_N >>= 1)==0) return (y < 0 ? _Ty(1) / _Z : _Z);
}
}
}
@@ -762,7 +239,9 @@
#pragma pack(pop)
-#if !defined(__STRICT_ANSI__) && !defined(_MATH_DEFINES_DEFINED)
+#endif /* !_INC_MATH */
+
+#if defined(_USE_MATH_DEFINES) && !defined(_MATH_DEFINES_DEFINED)
#define _MATH_DEFINES_DEFINED
#define M_E 2.71828182845904523536
@@ -778,20 +257,5 @@
#define M_2_SQRTPI 1.12837916709551257390
#define M_SQRT2 1.41421356237309504880
#define M_SQRT1_2 0.707106781186547524401
-#endif
-
-#ifndef __MINGW_FPCLASS_DEFINED
-#define __MINGW_FPCLASS_DEFINED 1
-#define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */
-#define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */
-#define _FPCLASS_NINF 0x0004 /* Negative Infinity */
-#define _FPCLASS_NN 0x0008 /* Negative Normal */
-#define _FPCLASS_ND 0x0010 /* Negative Denormal */
-#define _FPCLASS_NZ 0x0020 /* Negative Zero */
-#define _FPCLASS_PZ 0x0040 /* Positive Zero */
-#define _FPCLASS_PD 0x0080 /* Positive Denormal */
-#define _FPCLASS_PN 0x0100 /* Positive Normal */
-#define _FPCLASS_PINF 0x0200 /* Positive Infinity */
-#endif /* __MINGW_FPCLASS_DEFINED */
-
-#endif /* !_INC_MATH */
+
+#endif /* _USE_MATH_DEFINES */
Added: trunk/reactos/include/crt/mingw_math.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/crt/mingw_math.h?r…
==============================================================================
--- trunk/reactos/include/crt/mingw_math.h (added)
+++ trunk/reactos/include/crt/mingw_math.h [iso-8859-1] Wed Jan 26 17:16:07 2011
@@ -1,0 +1,534 @@
+
+
+ float expm1f(float _X);
+ double expm1(double _X);
+
+
+#ifndef __NO_ISOCEXT
+#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
+ || !defined __STRICT_ANSI__ || defined __GLIBCPP__
+
+#if !defined(_MSC_VER)
+#define NAN (0.0F/0.0F)
+#define HUGE_VALF (1.0F/0.0F)
+#define HUGE_VALL (1.0L/0.0L)
+#define INFINITY (1.0F/0.0F)
+#endif
+
+
+#define FP_NAN 0x0100
+#define FP_NORMAL 0x0400
+#define FP_INFINITE (FP_NAN | FP_NORMAL)
+#define FP_ZERO 0x4000
+#define FP_SUBNORMAL (FP_NORMAL | FP_ZERO)
+ /* 0x0200 is signbit mask */
+
+#if defined(__GNUC__)
+
+#define __fxam(x, sw) \
+ __asm__ ("fxam; fstsw %%ax;" : "=a" (sw): "t" (x))
+
+#elif defined(_MSC_VER)
+
+#ifdef _M_IX86
+#define __fxam(x, sw) \
+ __asm { fld [(x)] } \
+ __asm { fxam } \
+ __asm { wait } \
+ __asm { fnstsw [(sw)] } \
+ __asm { fstp st(0) }
+#else
+#define __fxam(x, sw)
+#pragma message("WARNING: __fxam is undefined")
+#endif
+
+#endif
+
+ /*
+ We can't __CRT_INLINE float or double, because we want to ensure truncation
+ to semantic type before classification.
+ (A normal long double value might become subnormal when
+ converted to double, and zero when converted to float.)
+ */
+
+ extern int __cdecl __fpclassifyf (float);
+ extern int __cdecl __fpclassify (double);
+
+ __CRT_INLINE int __cdecl __fpclassifyl (long double x){
+ unsigned short sw;
+ __fxam(x, sw);
+ return sw & (FP_NAN | FP_NORMAL | FP_ZERO );
+ }
+
+ __CRT_INLINE int __cdecl __fpclassify (double x){
+ return __fpclassifyl((long double)x);
+ }
+
+#define fpclassify(x) (sizeof (x) == sizeof (float) ? __fpclassifyf (x) \
+ : sizeof (x) == sizeof (double) ? __fpclassify (x) \
+ : __fpclassifyl (x))
+
+ /* 7.12.3.2 */
+#define isfinite(x) ((fpclassify(x) & FP_NAN) == 0)
+
+ /* 7.12.3.3 */
+/* #define isinf(x) (fpclassify(x) == FP_INFINITE) */
+
+ /* we don't have fpclassify */
+__CRT_INLINE int isinf (double d) {
+ int expon = 0;
+ double val = frexp (d, &expon);
+ if (expon == 1025) {
+ if (val == 0.5) {
+ return 1;
+ } else if (val == -0.5) {
+ return -1;
+ } else {
+ return 0;
+ }
+ } else {
+ return 0;
+ }
+}
+
+ /* 7.12.3.4 */
+ /* We don't need to worry about truncation here:
+ A NaN stays a NaN. */
+
+ __CRT_INLINE int __cdecl __isnan (double _x)
+ {
+ unsigned short sw;
+ __fxam(_x, sw);
+ return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
+ == FP_NAN;
+ }
+
+ __CRT_INLINE int __cdecl __isnanf (float _x)
+ {
+ unsigned short sw;
+ __fxam(_x, sw);
+ return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
+ == FP_NAN;
+ }
+
+ __CRT_INLINE int __cdecl __isnanl (long double _x)
+ {
+ unsigned short sw;
+ __fxam(_x, sw);
+ return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
+ == FP_NAN;
+ }
+
+
+#define isnan(x) (sizeof (x) == sizeof (float) ? __isnanf (x) \
+ : sizeof (x) == sizeof (double) ? __isnan (x) \
+ : __isnanl (x))
+
+ /* 7.12.3.5 */
+#define isnormal(x) (fpclassify(x) == FP_NORMAL)
+
+ /* 7.12.3.6 The signbit macro */
+ __CRT_INLINE int __cdecl __signbit (double x) {
+ unsigned short stw;
+ __fxam(x, stw);
+ return stw & 0x0200;
+ }
+
+ __CRT_INLINE int __cdecl __signbitf (float x) {
+ unsigned short stw;
+ __fxam(x, stw);
+ return stw & 0x0200;
+ }
+
+ __CRT_INLINE int __cdecl __signbitl (long double x) {
+ unsigned short stw;
+ __fxam(x, stw);
+ return stw & 0x0200;
+ }
+
+#define signbit(x) (sizeof (x) == sizeof (float) ? __signbitf (x) \
+ : sizeof (x) == sizeof (double) ? __signbit (x) \
+ : __signbitl (x))
+
+ extern double __cdecl exp2(double);
+ extern float __cdecl exp2f(float);
+ extern long double __cdecl exp2l(long double);
+
+#define FP_ILOGB0 ((int)0x80000000)
+#define FP_ILOGBNAN ((int)0x80000000)
+ extern int __cdecl ilogb (double);
+ extern int __cdecl ilogbf (float);
+ extern int __cdecl ilogbl (long double);
+
+ extern double __cdecl log1p(double);
+ extern float __cdecl log1pf(float);
+ extern long double __cdecl log1pl(long double);
+
+ extern double __cdecl log2 (double);
+ extern float __cdecl log2f (float);
+ extern long double __cdecl log2l (long double);
+
+ extern double __cdecl logb (double);
+ extern float __cdecl logbf (float);
+ extern long double __cdecl logbl (long double);
+
+#if defined(__GNUC__)
+
+#define __fxtract(x, res) \
+ __asm__ ("fxtract\n\t" \
+ "fstp %%st" : "=t" (res) : "0" (x))
+
+#elif defined(_MSC_VER)
+
+#define __fxtract(x, res) \
+ __asm { fld [(x)] } \
+ __asm { fxtract } \
+ __asm { fstp st(0) } \
+ __asm { fstp [(res)] }
+
+#endif
+
+ __CRT_INLINE double __cdecl logb (double x)
+ {
+ double res;
+ __fxtract(x, res);
+ return res;
+ }
+
+ __CRT_INLINE float __cdecl logbf (float x)
+ {
+ float res;
+ __fxtract(x, res);
+ return res;
+ }
+
+ __CRT_INLINE long double __cdecl logbl (long double x)
+ {
+ long double res;
+ __fxtract(x, res);
+ return res;
+ }
+
+ /* 7.12.6.13 */
+ extern double __cdecl scalbn (double, int);
+ extern float __cdecl scalbnf (float, int);
+ extern long double __cdecl scalbnl (long double, int);
+
+ extern double __cdecl scalbln (double, long);
+ extern float __cdecl scalblnf (float, long);
+ extern long double __cdecl scalblnl (long double, long);
+
+ /* 7.12.7.1 */
+ /* Implementations adapted from Cephes versions */
+ extern double __cdecl cbrt (double);
+ extern float __cdecl cbrtf (float);
+ extern long double __cdecl cbrtl (long double);
+
+ extern long double __cdecl hypotl (long double, long double);
+
+ extern long double __cdecl powl (long double, long double);
+ extern long double __cdecl expl(long double);
+ extern long double expm1l(long double);
+ extern long double __cdecl coshl(long double);
+ extern long double __cdecl acosl(long double);
+ extern long double __cdecl asinl(long double);
+ extern long double __cdecl atanl(long double);
+ extern long double __cdecl atan2l(long double,long double);
+ extern long double __cdecl sinhl(long double);
+ extern long double __cdecl tanhl(long double);
+
+ /* 7.12.8.1 The erf functions */
+ extern double __cdecl erf (double);
+ extern float __cdecl erff (float);
+ /* TODO
+ extern long double __cdecl erfl (long double);
+ */
+
+ /* 7.12.8.2 The erfc functions */
+ extern double __cdecl erfc (double);
+ extern float __cdecl erfcf (float);
+ /* TODO
+ extern long double __cdecl erfcl (long double);
+ */
+
+ /* 7.12.8.3 The lgamma functions */
+ extern double __cdecl lgamma (double);
+ extern float __cdecl lgammaf (float);
+ extern long double __cdecl lgammal (long double);
+
+ /* 7.12.8.4 The tgamma functions */
+ extern double __cdecl tgamma (double);
+ extern float __cdecl tgammaf (float);
+ extern long double __cdecl tgammal (long double);
+
+ extern long double __cdecl ceill (long double);
+ extern long double __cdecl floorl (long double);
+ extern long double __cdecl frexpl(long double,int *);
+ extern long double __cdecl log10l(long double);
+ extern long double __cdecl logl(long double);
+ extern long double __cdecl cosl(long double);
+ extern long double __cdecl sinl(long double);
+ extern long double __cdecl tanl(long double);
+ extern long double sqrtl(long double);
+
+ /* 7.12.9.3 */
+ extern double __cdecl nearbyint ( double);
+ extern float __cdecl nearbyintf (float);
+ extern long double __cdecl nearbyintl (long double);
+
+ /* 7.12.9.4 */
+ /* round, using fpu control word settings */
+#if defined(__GNUC__)
+
+#define __frndint(x, res) \
+ __asm__ ("fabs;" : "=t" (res) : "0" (x))
+
+#elif defined(_MSC_VER)
+
+#define __frndint(x, res) \
+ __asm { fld [(x)] } \
+ __asm { frndint } \
+ __asm { fstp [(res)] }
+
+#endif
+
+ __CRT_INLINE double __cdecl rint (double x)
+ {
+ double retval;
+ __frndint(x, retval);
+ return retval;
+ }
+
+ __CRT_INLINE float __cdecl rintf (float x)
+ {
+ float retval;
+ __frndint(x, retval);
+ return retval;
+ }
+
+ __CRT_INLINE long double __cdecl rintl (long double x)
+ {
+ long double retval;
+ __frndint(x, retval);
+ return retval;
+ }
+
+ /* 7.12.9.5 */
+#if defined(__GNUC__)
+
+#define __fistpl(x, res) \
+ __asm__ __volatile__("fistpl %0" : "=m" (res) : "t" (x)
: "st")
+
+#define __fistpll(x, res) \
+ __asm__ __volatile__("fistpll %0" : "=m" (res) : "t" (x)
: "st")
+
+#elif defined(_MSC_VER)
+
+#define __fistpl(x, res) \
+ __asm { fld [(x)] } \
+ __asm { fistp [(res)] }
+
+#define __fistpll(x, res) \
+ __asm { fld [(x)] } \
+ __asm { fistp [(res)] }
+
+#endif
+
+ __CRT_INLINE long __cdecl lrint (double x)
+ {
+ long retval;
+ __fistpl(x, retval);
+ return retval;
+ }
+
+ __CRT_INLINE long __cdecl lrintf (float x)
+ {
+ long retval;
+ __fistpl(x, retval);
+ return retval;
+ }
+
+ __CRT_INLINE long __cdecl lrintl (long double x)
+ {
+ long retval;
+ __fistpl(x, retval);
+ return retval;
+ }
+
+ __MINGW_EXTENSION __CRT_INLINE long long __cdecl llrint (double x)
+ {
+ __MINGW_EXTENSION long long retval;
+ __fistpll(x, retval);
+ return retval;
+ }
+
+ __MINGW_EXTENSION __CRT_INLINE long long __cdecl llrintf (float x)
+ {
+ __MINGW_EXTENSION long long retval;
+ __fistpll(x, retval);
+ return retval;
+ }
+
+ __MINGW_EXTENSION __CRT_INLINE long long __cdecl llrintl (long double x)
+ {
+ __MINGW_EXTENSION long long retval;
+ __fistpll(x, retval);
+ return retval;
+ }
+
+ /* 7.12.9.6 */
+ /* round away from zero, regardless of fpu control word settings */
+ extern double __cdecl round (double);
+ extern float __cdecl roundf (float);
+ extern long double __cdecl roundl (long double);
+
+ /* 7.12.9.7 */
+ extern long __cdecl lround (double);
+ extern long __cdecl lroundf (float);
+ extern long __cdecl lroundl (long double);
+
+ __MINGW_EXTENSION extern long long __cdecl llround (double);
+ __MINGW_EXTENSION extern long long __cdecl llroundf (float);
+ __MINGW_EXTENSION extern long long __cdecl llroundl (long double);
+
+ /* 7.12.9.8 */
+ /* round towards zero, regardless of fpu control word settings */
+ extern double __cdecl trunc (double);
+ extern float __cdecl truncf (float);
+ extern long double __cdecl truncl (long double);
+
+ extern long double __cdecl fmodl (long double, long double);
+
+ /* 7.12.10.2 */
+ extern double __cdecl remainder (double, double);
+ extern float __cdecl remainderf (float, float);
+ extern long double __cdecl remainderl (long double, long double);
+
+ /* 7.12.10.3 */
+ extern double __cdecl remquo(double, double, int *);
+ extern float __cdecl remquof(float, float, int *);
+ extern long double __cdecl remquol(long double, long double, int *);
+
+ /* 7.12.11.1 */
+ extern double __cdecl copysign (double, double); /* in libmoldname.a */
+ extern float __cdecl copysignf (float, float);
+ extern long double __cdecl copysignl (long double, long double);
+
+ /* 7.12.11.2 Return a NaN */
+ extern double __cdecl nan(const char *tagp);
+ extern float __cdecl nanf(const char *tagp);
+ extern long double __cdecl nanl(const char *tagp);
+
+#ifndef __STRICT_ANSI__
+#define _nan() nan("")
+#define _nanf() nanf("")
+#define _nanl() nanl("")
+#endif
+
+ /* 7.12.11.3 */
+ extern double __cdecl nextafter (double, double); /* in libmoldname.a */
+ extern float __cdecl nextafterf (float, float);
+ extern long double __cdecl nextafterl (long double, long double);
+
+ /* 7.12.11.4 The nexttoward functions: TODO */
+
+ /* 7.12.12.1 */
+ /* x > y ? (x - y) : 0.0 */
+ extern double __cdecl fdim (double x, double y);
+ extern float __cdecl fdimf (float x, float y);
+ extern long double __cdecl fdiml (long double x, long double y);
+
+ /* fmax and fmin.
+ NaN arguments are treated as missing data: if one argument is a NaN
+ and the other numeric, then these functions choose the numeric
+ value. */
+
+ /* 7.12.12.2 */
+ extern double __cdecl fmax (double, double);
+ extern float __cdecl fmaxf (float, float);
+ extern long double __cdecl fmaxl (long double, long double);
+
+ /* 7.12.12.3 */
+ extern double __cdecl fmin (double, double);
+ extern float __cdecl fminf (float, float);
+ extern long double __cdecl fminl (long double, long double);
+
+ /* 7.12.13.1 */
+ /* return x * y + z as a ternary op */
+ extern double __cdecl fma (double, double, double);
+ extern float __cdecl fmaf (float, float, float);
+ extern long double __cdecl fmal (long double, long double, long double);
+
+
+ /* 7.12.14 */
+ /*
+ * With these functions, comparisons involving quiet NaNs set the FP
+ * condition code to "unordered". The IEEE floating-point spec
+ * dictates that the result of floating-point comparisons should be
+ * false whenever a NaN is involved, with the exception of the != op,
+ * which always returns true: yes, (NaN != NaN) is true).
+ */
+
+#if defined(__GNUC__) && __GNUC__ >= 3
+
+#define isgreater(x, y) __builtin_isgreater(x, y)
+#define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
+#define isless(x, y) __builtin_isless(x, y)
+#define islessequal(x, y) __builtin_islessequal(x, y)
+#define islessgreater(x, y) __builtin_islessgreater(x, y)
+#define isunordered(x, y) __builtin_isunordered(x, y)
+
+#else
+ /* helper */
+ __CRT_INLINE int __cdecl
+ __fp_unordered_compare (long double x, long double y){
+ unsigned short retval;
+#if defined(__GNUC__)
+ __asm__ ("fucom %%st(1);"
+ "fnstsw;": "=a" (retval) : "t" (x), "u" (y));
+#elif defined(_MSC_VER)
+ __asm {
+ fld [x]
+ fld [y]
+ fxch st(1)
+ fucom st(1)
+ fnstsw [retval]
+ fstp st(0)
+ fstp st(0)
+ }
+#endif
+ return retval;
+ }
+
+#define isgreater(x, y) ((__fp_unordered_compare(x, y) \
+ & 0x4500) == 0)
+#define isless(x, y) ((__fp_unordered_compare (y, x) \
+ & 0x4500) == 0)
+#define isgreaterequal(x, y) ((__fp_unordered_compare (x, y) \
+ & FP_INFINITE) == 0)
+#define islessequal(x, y) ((__fp_unordered_compare(y, x) \
+ & FP_INFINITE) == 0)
+#define islessgreater(x, y) ((__fp_unordered_compare(x, y) \
+ & FP_SUBNORMAL) == 0)
+#define isunordered(x, y) ((__fp_unordered_compare(x, y) \
+ & 0x4500) == 0x4500)
+
+#endif
+
+
+#endif /* __STDC_VERSION__ >= 199901L */
+#endif /* __NO_ISOCEXT */
+
+#ifndef __MINGW_FPCLASS_DEFINED
+#define __MINGW_FPCLASS_DEFINED 1
+#define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */
+#define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */
+#define _FPCLASS_NINF 0x0004 /* Negative Infinity */
+#define _FPCLASS_NN 0x0008 /* Negative Normal */
+#define _FPCLASS_ND 0x0010 /* Negative Denormal */
+#define _FPCLASS_NZ 0x0020 /* Negative Zero */
+#define _FPCLASS_PZ 0x0040 /* Positive Zero */
+#define _FPCLASS_PD 0x0080 /* Positive Denormal */
+#define _FPCLASS_PN 0x0100 /* Positive Normal */
+#define _FPCLASS_PINF 0x0200 /* Positive Infinity */
+#endif /* __MINGW_FPCLASS_DEFINED */
Propchange: trunk/reactos/include/crt/mingw_math.h
------------------------------------------------------------------------------
svn:eol-style = native