diff --git a/dlls/msvcp100/msvcp100.spec b/dlls/msvcp100/msvcp100.spec index 39c925cd8e1..67389791bb2 100644 --- a/dlls/msvcp100/msvcp100.spec +++ b/dlls/msvcp100/msvcp100.spec @@ -2892,14 +2892,14 @@ @ extern _Denorm @ stub _Dnorm @ stub _Dscale -@ stub _Dtest +@ cdecl _Dtest(ptr) @ extern _Eps @ stub _Exp @ stub _FCosh @ extern _FDenorm @ stub _FDnorm @ stub _FDscale -@ stub _FDtest +@ cdecl _FDtest(ptr) @ extern _FEps @ stub _FExp @ extern _FInf @@ -2920,7 +2920,7 @@ @ stub _LCosh @ extern _LDenorm @ stub _LDscale -@ stub _LDtest +@ cdecl _LDtest(ptr) _Dtest @ extern _LEps @ stub _LExp @ extern _LInf diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec index ff4facbd66a..f907c5b47f2 100644 --- a/dlls/msvcp110/msvcp110.spec +++ b/dlls/msvcp110/msvcp110.spec @@ -3745,7 +3745,7 @@ @ cdecl _Do_call(ptr) @ stub _Dscale @ stub _Dtento -@ stub _Dtest +@ cdecl _Dtest(ptr) @ stub _Dunscale @ extern _Eps @ stub _Exp @@ -3755,7 +3755,7 @@ @ stub _FDnorm @ stub _FDscale @ stub _FDtento -@ stub _FDtest +@ cdecl _FDtest(ptr) @ stub _FDunscale @ extern _FEps @ stub _FExp @@ -3791,7 +3791,7 @@ @ stub _LDint @ stub _LDscale @ stub _LDtento -@ stub _LDtest +@ cdecl _LDtest(ptr) _Dtest @ stub _LDunscale @ extern _LEps @ stub _LExp diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec index 715703e0e6c..1f8601ccc63 100644 --- a/dlls/msvcp120/msvcp120.spec +++ b/dlls/msvcp120/msvcp120.spec @@ -3686,7 +3686,7 @@ @ cdecl _Do_call(ptr) @ stub _Dscale @ stub _Dtento -@ stub _Dtest +@ cdecl _Dtest(ptr) @ stub _Dunscale @ extern _Eps @ stub _Exp @@ -3696,7 +3696,7 @@ @ stub _FDnorm @ stub _FDscale @ stub _FDtento -@ stub _FDtest +@ cdecl _FDtest(ptr) @ stub _FDunscale @ extern _FEps @ stub _FExp @@ -3734,7 +3734,7 @@ @ stub _LDint @ stub _LDscale @ stub _LDtento -@ stub _LDtest +@ cdecl _LDtest(ptr) _Dtest @ stub _LDunscale @ extern _LEps @ stub _LExp diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c index 10e03705600..9255ff1cf12 100644 --- a/dlls/msvcp120/tests/msvcp120.c +++ b/dlls/msvcp120/tests/msvcp120.c @@ -18,10 +18,25 @@ #include #include +#include #include "wine/test.h" #include "winbase.h" +static inline float __port_infinity(void) +{ + static const unsigned __inf_bytes = 0x7f800000; + return *(const float *)&__inf_bytes; +} +#define INFINITY __port_infinity() + +static inline float __port_nan(void) +{ + static const unsigned __nan_bytes = 0x7fc00000; + return *(const float *)&__nan_bytes; +} +#define NAN __port_nan() + typedef int MSVCRT_long; typedef unsigned char MSVCP_bool; @@ -70,6 +85,7 @@ static _Cvtvec* (__cdecl *p__Getcvt)(_Cvtvec*); static void (CDECL *p__Call_once)(int *once, void (CDECL *func)(void)); static void (CDECL *p__Call_onceEx)(int *once, void (CDECL *func)(void*), void *argv); static void (CDECL *p__Do_call)(void *this); +static short (__cdecl *p__Dtest)(double *d); /* filesystem */ static ULONGLONG(__cdecl *p_tr2_sys__File_size)(char const*); @@ -119,6 +135,8 @@ static BOOL init(void) "_Call_onceEx"); SET(p__Do_call, "_Do_call"); + SET(p__Dtest, + "_Dtest"); if(sizeof(void*) == 8) { /* 64-bit initialization */ SET(p_tr2_sys__File_size, "?_File_size@sys@tr2@std@@YA_KPEBD@Z"); @@ -407,6 +425,32 @@ static void test__Do_call(void) ok(cnt == 1, "func was not called\n"); } +static void test__Dtest(void) +{ + double d; + short ret; + + d = 0; + ret = p__Dtest(&d); + ok(ret == FP_ZERO, "_Dtest(0) returned %x\n", ret); + + d = 1; + ret = p__Dtest(&d); + ok(ret == FP_NORMAL, "_Dtest(1) returned %x\n", ret); + + d = -1; + ret = p__Dtest(&d); + ok(ret == FP_NORMAL, "_Dtest(-1) returned %x\n", ret); + + d = INFINITY; + ret = p__Dtest(&d); + ok(ret == FP_INFINITE, "_Dtest(INF) returned %x\n", ret); + + d = NAN; + ret = p__Dtest(&d); + ok(ret == FP_NAN, "_Dtest(NAN) returned %x\n", ret); +} + static void test_tr2_sys__File_size(void) { ULONGLONG val; @@ -910,6 +954,7 @@ START_TEST(msvcp120) test__Getcvt(); test__Call_once(); test__Do_call(); + test__Dtest(); test_tr2_sys__File_size(); test_tr2_sys__Equivalent(); diff --git a/dlls/msvcp120_app/msvcp120_app.spec b/dlls/msvcp120_app/msvcp120_app.spec index 1e04e7754be..b689cb913b8 100644 --- a/dlls/msvcp120_app/msvcp120_app.spec +++ b/dlls/msvcp120_app/msvcp120_app.spec @@ -3686,7 +3686,7 @@ @ cdecl _Do_call(ptr) msvcp120._Do_call @ stub _Dscale @ stub _Dtento -@ stub _Dtest +@ cdecl _Dtest(ptr) msvcp120._Dtest @ stub _Dunscale @ extern _Eps msvcp120._Eps @ stub _Exp @@ -3696,7 +3696,7 @@ @ stub _FDnorm @ stub _FDscale @ stub _FDtento -@ stub _FDtest +@ cdecl _FDtest(ptr) msvcp120._FDtest @ stub _FDunscale @ extern _FEps msvcp120._FEps @ stub _FExp @@ -3734,7 +3734,7 @@ @ stub _LDint @ stub _LDscale @ stub _LDtento -@ stub _LDtest +@ cdecl _LDtest(ptr) msvcp120._LDtest @ stub _LDunscale @ extern _LEps msvcp120._LEps @ stub _LExp diff --git a/dlls/msvcp60/msvcp60.spec b/dlls/msvcp60/msvcp60.spec index 0aa3f1bb078..10d04e529ee 100644 --- a/dlls/msvcp60/msvcp60.spec +++ b/dlls/msvcp60/msvcp60.spec @@ -4258,14 +4258,14 @@ @ extern _Denorm _Denorm @ stub _Dnorm @ stub _Dscale -@ stub _Dtest +@ cdecl _Dtest(ptr) @ extern _Eps _Eps @ stub _Exp @ stub _FCosh @ extern _FDenorm _FDenorm @ stub _FDnorm @ stub _FDscale -@ stub _FDtest +@ cdecl _FDtest(ptr) @ extern _FEps _FEps @ stub _FExp @ extern _FInf _FInf @@ -4282,7 +4282,7 @@ @ stub _LCosh @ extern _LDenorm _LDenorm @ stub _LDscale -@ stub _LDtest +@ cdecl _LDtest(ptr) _Dtest @ extern _LEps _LEps @ stub _LExp @ extern _LInf _LInf diff --git a/dlls/msvcp70/msvcp70.spec b/dlls/msvcp70/msvcp70.spec index c9cdef4a0d0..f390d8a1956 100644 --- a/dlls/msvcp70/msvcp70.spec +++ b/dlls/msvcp70/msvcp70.spec @@ -5044,14 +5044,14 @@ @ extern _Denorm @ stub _Dnorm @ stub _Dscale -@ stub _Dtest +@ cdecl _Dtest(ptr) @ extern _Eps @ stub _Exp @ stub _FCosh @ extern _FDenorm @ stub _FDnorm @ stub _FDscale -@ stub _FDtest +@ cdecl _FDtest(ptr) @ extern _FEps @ stub _FExp @ extern _FInf @@ -5069,7 +5069,7 @@ @ stub _LCosh @ extern _LDenorm @ stub _LDscale -@ stub _LDtest +@ cdecl _LDtest(ptr) _Dtest @ extern _LEps @ stub _LExp @ extern _LInf diff --git a/dlls/msvcp71/msvcp71.spec b/dlls/msvcp71/msvcp71.spec index 2946a120796..2675c9a0be1 100644 --- a/dlls/msvcp71/msvcp71.spec +++ b/dlls/msvcp71/msvcp71.spec @@ -5098,14 +5098,14 @@ @ extern _Denorm @ stub _Dnorm @ stub _Dscale -@ stub _Dtest +@ cdecl _Dtest(ptr) @ extern _Eps @ stub _Exp @ stub _FCosh @ extern _FDenorm @ stub _FDnorm @ stub _FDscale -@ stub _FDtest +@ cdecl _FDtest(ptr) @ extern _FEps @ stub _FExp @ extern _FInf @@ -5125,7 +5125,7 @@ @ stub _LCosh @ extern _LDenorm @ stub _LDscale -@ stub _LDtest +@ cdecl _LDtest(ptr) _Dtest @ extern _LEps @ stub _LExp @ extern _LInf diff --git a/dlls/msvcp80/msvcp80.spec b/dlls/msvcp80/msvcp80.spec index 4e292c0dd82..ed04defa6ef 100644 --- a/dlls/msvcp80/msvcp80.spec +++ b/dlls/msvcp80/msvcp80.spec @@ -5705,7 +5705,7 @@ @ stub _Dnorm @ stub _Dscale @ stub _Dtentox -@ stub _Dtest +@ cdecl _Dtest(ptr) @ stub _Dunscale @ extern _Eps @ stub _Exp @@ -5714,7 +5714,7 @@ @ stub _FDnorm @ stub _FDscale @ stub _FDtentox -@ stub _FDtest +@ cdecl _FDtest(ptr) @ stub _FDunscale @ extern _FEps @ stub _FExp @@ -5736,7 +5736,7 @@ @ extern _LDenorm @ stub _LDscale @ stub _LDtentox -@ stub _LDtest +@ cdecl _LDtest(ptr) _Dtest @ stub _LDunscale @ extern _LEps @ stub _LExp diff --git a/dlls/msvcp90/math.c b/dlls/msvcp90/math.c index 439865a197f..9b827f396c8 100644 --- a/dlls/msvcp90/math.c +++ b/dlls/msvcp90/math.c @@ -2226,3 +2226,37 @@ complex_double* __cdecl complex_double_sqrt(complex_double *ret, const complex_d complex_double c = { 0.5, 0 }; return complex_double_pow(ret, l, &c); } + +static short dclass(double x) +{ + switch(_fpclass(x)) { + case _FPCLASS_SNAN: + case _FPCLASS_QNAN: + return FP_NAN; + case _FPCLASS_NINF: + case _FPCLASS_PINF: + return FP_INFINITE; + case _FPCLASS_ND: + case _FPCLASS_PD: + return FP_SUBNORMAL; + case _FPCLASS_NN: + case _FPCLASS_PN: + default: + return FP_NORMAL; + case _FPCLASS_NZ: + case _FPCLASS_PZ: + return FP_ZERO; + } +} + +/* _Dtest */ +short __cdecl _Dtest(double *x) +{ + return dclass(*x); +} + +/* _FDtest */ +short __cdecl _FDtest(float *x) +{ + return dclass(*x); +} diff --git a/dlls/msvcp90/msvcp90.spec b/dlls/msvcp90/msvcp90.spec index 98edb65450e..d3a314bc3ec 100644 --- a/dlls/msvcp90/msvcp90.spec +++ b/dlls/msvcp90/msvcp90.spec @@ -6480,14 +6480,14 @@ @ extern _Denorm @ stub _Dnorm @ stub _Dscale -@ stub _Dtest +@ cdecl _Dtest(ptr) @ extern _Eps @ stub _Exp @ stub _FCosh @ extern _FDenorm @ stub _FDnorm @ stub _FDscale -@ stub _FDtest +@ cdecl _FDtest(ptr) @ extern _FEps @ stub _FExp @ extern _FInf @@ -6507,7 +6507,7 @@ @ stub _LCosh @ extern _LDenorm @ stub _LDscale -@ stub _LDtest +@ cdecl _LDtest(ptr) _Dtest @ extern _LEps @ stub _LExp @ extern _LInf diff --git a/include/msvcrt/math.h b/include/msvcrt/math.h index 34aa2685fca..c1333d4afef 100644 --- a/include/msvcrt/math.h +++ b/include/msvcrt/math.h @@ -146,6 +146,12 @@ static const union { # endif #endif +#define FP_INFINITE 1 +#define FP_NAN 2 +#define FP_NORMAL -1 +#define FP_SUBNORMAL -2 +#define FP_ZERO 0 + #ifdef __cplusplus } #endif