Piotr Caban : msvcp: Add _Dtest implementation.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Sep 14 09:44:34 CDT 2015
Module: wine
Branch: master
Commit: 1e9402124d57dc982dc399f6e26a6662bc2f90a2
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1e9402124d57dc982dc399f6e26a6662bc2f90a2
Author: Piotr Caban <piotr at codeweavers.com>
Date: Sat Sep 12 16:13:25 2015 +0200
msvcp: Add _Dtest implementation.
---
dlls/msvcp100/msvcp100.spec | 6 ++---
dlls/msvcp110/msvcp110.spec | 6 ++---
dlls/msvcp120/msvcp120.spec | 6 ++---
dlls/msvcp120/tests/msvcp120.c | 45 +++++++++++++++++++++++++++++++++++++
dlls/msvcp120_app/msvcp120_app.spec | 6 ++---
dlls/msvcp60/msvcp60.spec | 6 ++---
dlls/msvcp70/msvcp70.spec | 6 ++---
dlls/msvcp71/msvcp71.spec | 6 ++---
dlls/msvcp80/msvcp80.spec | 6 ++---
dlls/msvcp90/math.c | 34 ++++++++++++++++++++++++++++
dlls/msvcp90/msvcp90.spec | 6 ++---
include/msvcrt/math.h | 6 +++++
12 files changed, 112 insertions(+), 27 deletions(-)
diff --git a/dlls/msvcp100/msvcp100.spec b/dlls/msvcp100/msvcp100.spec
index 39c925c..6738979 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 ff4facb..f907c5b 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 715703e..1f8601c 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 10e0370..9255ff1 100644
--- a/dlls/msvcp120/tests/msvcp120.c
+++ b/dlls/msvcp120/tests/msvcp120.c
@@ -18,10 +18,25 @@
#include <locale.h>
#include <stdio.h>
+#include <math.h>
#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 at sys@tr2 at std@@YA_KPEBD at 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 1e04e77..b689cb9 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 0aa3f1b..10d04e5 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 c9cdef4..f390d8a 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 2946a12..2675c9a 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 4e292c0..ed04def 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 439865a..9b827f3 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 98edb65..d3a314b 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 34aa268..c1333d4 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
More information about the wine-cvs
mailing list