Piotr Caban : msvcr120: Add _dpcomp implementation.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Jan 18 11:09:03 CST 2016
Module: wine
Branch: master
Commit: 4083af404b2ef9e0b0928a6f685f2efa8567c80b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4083af404b2ef9e0b0928a6f685f2efa8567c80b
Author: Piotr Caban <piotr at codeweavers.com>
Date: Mon Jan 18 12:57:39 2016 +0100
msvcr120: Add _dpcomp implementation.
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcr120/msvcr120.spec | 6 +++---
dlls/msvcr120/tests/msvcr120.c | 37 +++++++++++++++++++++++++++++++++++++
dlls/msvcr120_app/msvcr120_app.spec | 6 +++---
dlls/msvcrt/math.c | 21 +++++++++++++++++++++
4 files changed, 64 insertions(+), 6 deletions(-)
diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec
index b738155..361e3d2 100644
--- a/dlls/msvcr120/msvcr120.spec
+++ b/dlls/msvcr120/msvcr120.spec
@@ -1110,7 +1110,7 @@
@ cdecl _difftime32(long long) MSVCRT__difftime32
@ cdecl _difftime64(long long) MSVCRT__difftime64
@ stub _dosmaperr
-@ stub _dpcomp
+@ cdecl _dpcomp(double double) MSVCR120__dpcomp
@ cdecl _dsign(double) MSVCR120__dsign
@ extern _dstbias MSVCRT__dstbias
@ cdecl _dtest(ptr) MSVCR120__dtest
@@ -1144,7 +1144,7 @@
@ cdecl _fcvt_s(ptr long double long ptr ptr) MSVCRT__fcvt_s
@ cdecl _fdclass(float) MSVCR120__fdclass
@ cdecl _fdopen(long str) MSVCRT__fdopen
-@ stub _fdpcomp
+@ cdecl _fdpcomp(float float) MSVCR120__fdpcomp
@ cdecl _fdsign(float) MSVCR120__fdsign
@ cdecl _fdtest(ptr) MSVCR120__fdtest
@ cdecl _fflush_nolock(ptr) MSVCRT__fflush_nolock
@@ -1392,7 +1392,7 @@
@ cdecl _jn(long double) MSVCRT__jn
@ cdecl _kbhit()
@ cdecl _ldclass(double) MSVCR120__ldclass
-@ stub _ldpcomp
+@ cdecl _ldpcomp(double double) MSVCR120__dpcomp
@ cdecl _ldsign(double) MSVCR120__dsign
@ cdecl _ldtest(ptr) MSVCR120__ldtest
@ cdecl _lfind(ptr ptr ptr long ptr)
diff --git a/dlls/msvcr120/tests/msvcr120.c b/dlls/msvcr120/tests/msvcr120.c
index 330c6b1..708fada 100644
--- a/dlls/msvcr120/tests/msvcr120.c
+++ b/dlls/msvcr120/tests/msvcr120.c
@@ -28,6 +28,20 @@
#include <locale.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()
+
struct MSVCRT_lconv
{
char* decimal_point;
@@ -63,6 +77,7 @@ static struct MSVCRT_lconv* (CDECL *p_localeconv)(void);
static size_t (CDECL *p_wcstombs_s)(size_t *ret, char* dest, size_t sz, const wchar_t* src, size_t max);
static int (CDECL *p__dsign)(double);
static int (CDECL *p__fdsign)(float);
+static int (__cdecl *p__dpcomp)(double x, double y);
static wchar_t** (CDECL *p____lc_locale_name_func)(void);
static unsigned int (CDECL *p__GetConcurrency)(void);
@@ -82,6 +97,7 @@ static BOOL init(void)
p_wcstombs_s = (void*)GetProcAddress(module, "wcstombs_s");
p__dsign = (void*)GetProcAddress(module, "_dsign");
p__fdsign = (void*)GetProcAddress(module, "_fdsign");
+ p__dpcomp = (void*)GetProcAddress(module, "_dpcomp");
p____lc_locale_name_func = (void*)GetProcAddress(module, "___lc_locale_name_func");
p__GetConcurrency = (void*)GetProcAddress(module,"?_GetConcurrency at details@Concurrency@@YAIXZ");
return TRUE;
@@ -175,6 +191,26 @@ static void test__dsign(void)
ok(ret == 0x8000, "p_fdsign(-1) = %x\n", ret);
}
+static void test__dpcomp(void)
+{
+ struct {
+ double x, y;
+ int ret;
+ } tests[] = {
+ {0, 0, 2}, {1, 1, 2}, {-1, -1, 2},
+ {-2, -1, 1}, {-1, 1, 1}, {1, 2, 1},
+ {1, -1, 4}, {2, 1, 4}, {-1, -2, 4},
+ {NAN, NAN, 0}, {NAN, 1, 0}, {1, NAN, 0},
+ {INFINITY, INFINITY, 2}, {-1, INFINITY, 1}, {1, INFINITY, 1},
+ };
+ int i, ret;
+
+ for(i=0; i<sizeof(tests)/sizeof(*tests); i++) {
+ ret = p__dpcomp(tests[i].x, tests[i].y);
+ ok(ret == tests[i].ret, "%d) dpcomp(%f, %f) = %x\n", i, tests[i].x, tests[i].y, ret);
+ }
+}
+
static void test____lc_locale_name_func(void)
{
struct {
@@ -238,6 +274,7 @@ START_TEST(msvcr120)
if (!init()) return;
test_lconv();
test__dsign();
+ test__dpcomp();
test____lc_locale_name_func();
test__GetConcurrency();
}
diff --git a/dlls/msvcr120_app/msvcr120_app.spec b/dlls/msvcr120_app/msvcr120_app.spec
index ec18f21..1e4554f 100644
--- a/dlls/msvcr120_app/msvcr120_app.spec
+++ b/dlls/msvcr120_app/msvcr120_app.spec
@@ -1049,7 +1049,7 @@
@ cdecl _difftime32(long long) msvcr120._difftime32
@ cdecl _difftime64(long long) msvcr120._difftime64
@ stub _dosmaperr
-@ stub _dpcomp
+@ cdecl _dpcomp(double double) msvcr120._dpcomp
@ cdecl _dsign(double) msvcr120._dsign
@ extern _dstbias msvcr120._dstbias
@ cdecl _dtest(ptr) msvcr120._dtest
@@ -1072,7 +1072,7 @@
@ cdecl _fcvt_s(ptr long double long ptr ptr) msvcr120._fcvt_s
@ cdecl _fdclass(float) msvcr120._fdclass
@ cdecl _fdopen(long str) msvcr120._fdopen
-@ stub _fdpcomp
+@ cdecl _fdpcomp(float float) msvcr120._fdpcomp
@ cdecl _fdsign(float) msvcr120._fdsign
@ cdecl _fdtest(ptr) msvcr120._fdtest
@ cdecl _fflush_nolock(ptr) msvcr120._fflush_nolock
@@ -1256,7 +1256,7 @@
@ cdecl _j1(double) msvcr120._j1
@ cdecl _jn(long double) msvcr120._jn
@ cdecl _ldclass(double) msvcr120._ldclass
-@ stub _ldpcomp
+@ cdecl _ldpcomp(double double) msvcr120._ldpcomp
@ cdecl _ldsign(double) msvcr120._ldsign
@ cdecl _ldtest(ptr) msvcr120._ldtest
@ cdecl _lfind(ptr ptr ptr long ptr) msvcr120._lfind
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index 661a1b4..fc88f03 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -2684,6 +2684,27 @@ int CDECL MSVCR120__dsign(double x)
return signbit(x) ? 0x8000 : 0;
}
+
+/*********************************************************************
+ * _dpcomp (MSVCR120.@)
+ */
+int CDECL MSVCR120__dpcomp(double x, double y)
+{
+ if(isnan(x) || isnan(y))
+ return 0;
+
+ if(x == y) return 2;
+ return x < y ? 1 : 4;
+}
+
+/*********************************************************************
+ * _fdpcomp (MSVCR120.@)
+ */
+int CDECL MSVCR120__fdpcomp(float x, float y)
+{
+ return MSVCR120__dpcomp(x, y);
+}
+
/*********************************************************************
* fminf (MSVCR120.@)
*/
More information about the wine-cvs
mailing list