Daniel Lehman : msvcp120: Implement _Thrd_sleep/yield.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Nov 2 09:47:13 CST 2015
Module: wine
Branch: master
Commit: 23095b9debf9ae963e61731ad4b76183c21dfe12
URL: http://source.winehq.org/git/wine.git/?a=commit;h=23095b9debf9ae963e61731ad4b76183c21dfe12
Author: Daniel Lehman <dlehman at esri.com>
Date: Wed Oct 28 11:17:23 2015 -0700
msvcp120: Implement _Thrd_sleep/yield.
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 | 18 ++++++++++++++++++
dlls/msvcp120_app/msvcp120_app.spec | 4 ++--
dlls/msvcp90/misc.c | 12 ++++++++++++
5 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec
index 02ccf44..d227510 100644
--- a/dlls/msvcp110/msvcp110.spec
+++ b/dlls/msvcp110/msvcp110.spec
@@ -3863,9 +3863,9 @@
@ stub _Thrd_exit
@ stub _Thrd_join
@ cdecl _Thrd_lt(ptr ptr)
-@ stub _Thrd_sleep
+@ cdecl _Thrd_sleep(ptr)
@ stub _Thrd_start
-@ stub _Thrd_yield
+@ cdecl _Thrd_yield()
@ cdecl _Tolower(long ptr)
@ cdecl _Toupper(long ptr)
@ cdecl _Towlower(long ptr)
diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec
index 5b7ac61..f316114 100644
--- a/dlls/msvcp120/msvcp120.spec
+++ b/dlls/msvcp120/msvcp120.spec
@@ -3810,9 +3810,9 @@
@ stub _Thrd_exit
@ stub _Thrd_join
@ cdecl _Thrd_lt(ptr ptr)
-@ stub _Thrd_sleep
+@ cdecl _Thrd_sleep(ptr)
@ stub _Thrd_start
-@ stub _Thrd_yield
+@ cdecl _Thrd_yield()
@ cdecl _Tolower(long ptr)
@ cdecl _Toupper(long ptr)
@ cdecl _Towlower(long ptr)
diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c
index 3f24d05..6cf8053 100644
--- a/dlls/msvcp120/tests/msvcp120.c
+++ b/dlls/msvcp120/tests/msvcp120.c
@@ -137,8 +137,11 @@ typedef struct
DWORD id;
} _Thrd_t;
+#define TIMEDELTA 150 /* 150 ms uncertainty allowed */
+
static int (__cdecl *p__Thrd_equal)(_Thrd_t, _Thrd_t);
static int (__cdecl *p__Thrd_lt)(_Thrd_t, _Thrd_t);
+static void (__cdecl *p__Thrd_sleep)(const xtime*);
static HMODULE msvcp;
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
@@ -267,6 +270,8 @@ static BOOL init(void)
"_Thrd_equal");
SET(p__Thrd_lt,
"_Thrd_lt");
+ SET(p__Thrd_sleep,
+ "_Thrd_sleep");
msvcr = GetModuleHandleA("msvcr120.dll");
p_setlocale = (void*)GetProcAddress(msvcr, "setlocale");
@@ -1144,6 +1149,8 @@ static void test_thrd(void)
};
const HANDLE hnd1 = (HANDLE)0xcccccccc;
const HANDLE hnd2 = (HANDLE)0xdeadbeef;
+ xtime xt, before, after;
+ MSVCRT_long diff;
struct test testeq[] = {
{ {0, 0}, {0, 0}, 1 },
@@ -1173,6 +1180,17 @@ static void test_thrd(void)
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);
}
+
+ /* test for sleep */
+ if (0) /* crash on Windows */
+ p__Thrd_sleep(NULL);
+ p_xtime_get(&xt, 1);
+ xt.sec += 2;
+ p_xtime_get(&before, 1);
+ p__Thrd_sleep(&xt);
+ p_xtime_get(&after, 1);
+ diff = p__Xtime_diff_to_millis2(&after, &before);
+ ok(diff > 2000 - TIMEDELTA, "got %d\n", diff);
}
START_TEST(msvcp120)
diff --git a/dlls/msvcp120_app/msvcp120_app.spec b/dlls/msvcp120_app/msvcp120_app.spec
index 2701eee..b5d423b 100644
--- a/dlls/msvcp120_app/msvcp120_app.spec
+++ b/dlls/msvcp120_app/msvcp120_app.spec
@@ -3810,9 +3810,9 @@
@ stub _Thrd_exit
@ stub _Thrd_join
@ cdecl _Thrd_lt(ptr ptr) msvcp120._Thrd_lt
-@ stub _Thrd_sleep
+@ cdecl _Thrd_sleep(ptr) msvcp120._Thrd_sleep
@ stub _Thrd_start
-@ stub _Thrd_yield
+@ cdecl _Thrd_yield() msvcp120._Thrd_yield
@ cdecl _Tolower(long ptr) msvcp120._Tolower
@ cdecl _Toupper(long ptr) msvcp120._Toupper
@ cdecl _Towlower(long ptr) msvcp120._Towlower
diff --git a/dlls/msvcp90/misc.c b/dlls/msvcp90/misc.c
index 2ec34fe..ccf1d04 100644
--- a/dlls/msvcp90/misc.c
+++ b/dlls/msvcp90/misc.c
@@ -702,4 +702,16 @@ 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;
}
+
+void __cdecl _Thrd_sleep(const xtime *t)
+{
+ TRACE("(%p)\n", t);
+ Sleep(_Xtime_diff_to_millis(t));
+}
+
+void __cdecl _Thrd_yield(void)
+{
+ TRACE("()\n");
+ Sleep(0);
+}
#endif
More information about the wine-cvs
mailing list