Daniel Lehman : msvcp120: Implement _Thrd_equal/lt.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Oct 29 09:32:12 CDT 2015
Module: wine
Branch: master
Commit: 95cde2c8b8e1af1b58223a40e2dac9beb320183c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=95cde2c8b8e1af1b58223a40e2dac9beb320183c
Author: Daniel Lehman <dlehman at esri.com>
Date: Tue Oct 27 23:21:07 2015 -0700
msvcp120: Implement _Thrd_equal/lt.
Signed-off-by: Daniel Lehman <dlehman at esri.com>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcp110/msvcp110.spec | 4 +--
dlls/msvcp120/msvcp120.spec | 4 +--
dlls/msvcp120/tests/msvcp120.c | 58 +++++++++++++++++++++++++++++++++++++
dlls/msvcp120_app/msvcp120_app.spec | 4 +--
dlls/msvcp90/misc.c | 20 +++++++++++++
5 files changed, 84 insertions(+), 6 deletions(-)
diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec
index b8d21eb..9fb938a 100644
--- a/dlls/msvcp110/msvcp110.spec
+++ b/dlls/msvcp110/msvcp110.spec
@@ -3859,10 +3859,10 @@
@ stub _Thrd_create
@ stub _Thrd_current
@ stub _Thrd_detach
-@ stub _Thrd_equal
+@ cdecl _Thrd_equal(ptr ptr)
@ stub _Thrd_exit
@ stub _Thrd_join
-@ stub _Thrd_lt
+@ cdecl _Thrd_lt(ptr ptr)
@ stub _Thrd_sleep
@ stub _Thrd_start
@ stub _Thrd_yield
diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec
index 0458b01..c25e2e4 100644
--- a/dlls/msvcp120/msvcp120.spec
+++ b/dlls/msvcp120/msvcp120.spec
@@ -3806,10 +3806,10 @@
@ stub _Thrd_create
@ stub _Thrd_current
@ stub _Thrd_detach
-@ stub _Thrd_equal
+@ cdecl _Thrd_equal(ptr ptr)
@ stub _Thrd_exit
@ stub _Thrd_join
-@ stub _Thrd_lt
+@ cdecl _Thrd_lt(ptr ptr)
@ stub _Thrd_sleep
@ stub _Thrd_start
@ stub _Thrd_yield
diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c
index d754191..fc69fd0 100644
--- a/dlls/msvcp120/tests/msvcp120.c
+++ b/dlls/msvcp120/tests/msvcp120.c
@@ -130,6 +130,16 @@ static enum file_type (__cdecl *p_tr2_sys__Lstat)(char const*, int *);
static __int64 (__cdecl *p_tr2_sys__Last_write_time)(char const*);
static void (__cdecl *p_tr2_sys__Last_write_time_set)(char const*, __int64);
+/* thrd */
+typedef struct
+{
+ HANDLE hnd;
+ DWORD id;
+} _Thrd_t;
+
+static int (__cdecl *p__Thrd_equal)(_Thrd_t, _Thrd_t);
+static int (__cdecl *p__Thrd_lt)(_Thrd_t, _Thrd_t);
+
static HMODULE msvcp;
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
#define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
@@ -253,6 +263,10 @@ static BOOL init(void)
SET(p_tr2_sys__Last_write_time_set,
"?_Last_write_time at sys@tr2 at std@@YAXPBD_J at Z");
}
+ SET(p__Thrd_equal,
+ "_Thrd_equal");
+ SET(p__Thrd_lt,
+ "_Thrd_lt");
msvcr = GetModuleHandleA("msvcr120.dll");
p_setlocale = (void*)GetProcAddress(msvcr, "setlocale");
@@ -1120,6 +1134,47 @@ static void test_tr2_sys__Last_write_time(void)
ok(ret == 1, "test_tr2_sys__Remove_dir(): expect 1 got %d\n", ret);
}
+static void test_thrd(void)
+{
+ int ret, i;
+ struct test {
+ _Thrd_t a;
+ _Thrd_t b;
+ int r;
+ };
+ const HANDLE hnd1 = (HANDLE)0xcccccccc;
+ const HANDLE hnd2 = (HANDLE)0xdeadbeef;
+
+ struct test testeq[] = {
+ { {0, 0}, {0, 0}, 1 },
+ { {0, 1}, {0, 0}, 0 },
+ { {hnd1, 0}, {hnd1, 1}, 0 },
+ { {hnd1, 0}, {hnd2, 0}, 1 }
+ };
+
+ struct test testlt[] = {
+ { {0, 0}, {0, 0}, 0 },
+ { {0, 0}, {0, 1}, 1 },
+ { {0, 1}, {0, 0}, 0 },
+ { {hnd1, 0}, {hnd2, 0}, 0 },
+ { {hnd1, 0}, {hnd2, 1}, 1 }
+ };
+
+ /* test for equal */
+ for(i=0; i<sizeof(testeq)/sizeof(testeq[0]); i++) {
+ ret = p__Thrd_equal(testeq[i].a, testeq[i].b);
+ ok(ret == testeq[i].r, "(%p %u) = (%p %u) expected %d, got %d\n",
+ testeq[i].a.hnd, testeq[i].a.id, testeq[i].b.hnd, testeq[i].b.id, testeq[i].r, ret);
+ }
+
+ /* test for less than */
+ for(i=0; i<sizeof(testlt)/sizeof(testlt[0]); i++) {
+ ret = p__Thrd_lt(testlt[i].a, testlt[i].b);
+ ok(ret == testlt[i].r, "(%p %u) < (%p %u) expected %d, got %d\n",
+ testlt[i].a.hnd, testlt[i].a.id, testlt[i].b.hnd, testlt[i].b.id, testlt[i].r, ret);
+ }
+}
+
START_TEST(msvcp120)
{
if(!init()) return;
@@ -1143,5 +1198,8 @@ START_TEST(msvcp120)
test_tr2_sys__Statvfs();
test_tr2_sys__Stat();
test_tr2_sys__Last_write_time();
+
+ test_thrd();
+
FreeLibrary(msvcp);
}
diff --git a/dlls/msvcp120_app/msvcp120_app.spec b/dlls/msvcp120_app/msvcp120_app.spec
index 2598904..6fd94ae 100644
--- a/dlls/msvcp120_app/msvcp120_app.spec
+++ b/dlls/msvcp120_app/msvcp120_app.spec
@@ -3806,10 +3806,10 @@
@ stub _Thrd_create
@ stub _Thrd_current
@ stub _Thrd_detach
-@ stub _Thrd_equal
+@ cdecl _Thrd_equal(ptr ptr) msvcp120._Thrd_equal
@ stub _Thrd_exit
@ stub _Thrd_join
-@ stub _Thrd_lt
+@ cdecl _Thrd_lt(ptr ptr) msvcp120._Thrd_lt
@ stub _Thrd_sleep
@ stub _Thrd_start
@ stub _Thrd_yield
diff --git a/dlls/msvcp90/misc.c b/dlls/msvcp90/misc.c
index 6501ff9..2ec34fe 100644
--- a/dlls/msvcp90/misc.c
+++ b/dlls/msvcp90/misc.c
@@ -683,3 +683,23 @@ void init_misc(void *base)
iostream_category_ctor(&iostream_category);
#endif
}
+
+#if _MSVCP_VER >= 110
+typedef struct
+{
+ HANDLE hnd;
+ DWORD id;
+} _Thrd_t;
+
+int __cdecl _Thrd_equal(_Thrd_t a, _Thrd_t b)
+{
+ TRACE("(%p %u %p %u)\n", a.hnd, a.id, b.hnd, b.id);
+ return a.id == b.id;
+}
+
+int __cdecl _Thrd_lt(_Thrd_t a, _Thrd_t b)
+{
+ TRACE("(%p %u %p %u)\n", a.hnd, a.id, b.hnd, b.id);
+ return a.id < b.id;
+}
+#endif
More information about the wine-cvs
mailing list