msvcp120: Implement _Thrd_sleep/yield.
Signed-off-by: Daniel Lehman <dlehman@esri.com> Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
bc52901c73
commit
23095b9deb
|
@ -3863,9 +3863,9 @@
|
||||||
@ stub _Thrd_exit
|
@ stub _Thrd_exit
|
||||||
@ stub _Thrd_join
|
@ stub _Thrd_join
|
||||||
@ cdecl _Thrd_lt(ptr ptr)
|
@ cdecl _Thrd_lt(ptr ptr)
|
||||||
@ stub _Thrd_sleep
|
@ cdecl _Thrd_sleep(ptr)
|
||||||
@ stub _Thrd_start
|
@ stub _Thrd_start
|
||||||
@ stub _Thrd_yield
|
@ cdecl _Thrd_yield()
|
||||||
@ cdecl _Tolower(long ptr)
|
@ cdecl _Tolower(long ptr)
|
||||||
@ cdecl _Toupper(long ptr)
|
@ cdecl _Toupper(long ptr)
|
||||||
@ cdecl _Towlower(long ptr)
|
@ cdecl _Towlower(long ptr)
|
||||||
|
|
|
@ -3810,9 +3810,9 @@
|
||||||
@ stub _Thrd_exit
|
@ stub _Thrd_exit
|
||||||
@ stub _Thrd_join
|
@ stub _Thrd_join
|
||||||
@ cdecl _Thrd_lt(ptr ptr)
|
@ cdecl _Thrd_lt(ptr ptr)
|
||||||
@ stub _Thrd_sleep
|
@ cdecl _Thrd_sleep(ptr)
|
||||||
@ stub _Thrd_start
|
@ stub _Thrd_start
|
||||||
@ stub _Thrd_yield
|
@ cdecl _Thrd_yield()
|
||||||
@ cdecl _Tolower(long ptr)
|
@ cdecl _Tolower(long ptr)
|
||||||
@ cdecl _Toupper(long ptr)
|
@ cdecl _Toupper(long ptr)
|
||||||
@ cdecl _Towlower(long ptr)
|
@ cdecl _Towlower(long ptr)
|
||||||
|
|
|
@ -137,8 +137,11 @@ typedef struct
|
||||||
DWORD id;
|
DWORD id;
|
||||||
} _Thrd_t;
|
} _Thrd_t;
|
||||||
|
|
||||||
|
#define TIMEDELTA 150 /* 150 ms uncertainty allowed */
|
||||||
|
|
||||||
static int (__cdecl *p__Thrd_equal)(_Thrd_t, _Thrd_t);
|
static int (__cdecl *p__Thrd_equal)(_Thrd_t, _Thrd_t);
|
||||||
static int (__cdecl *p__Thrd_lt)(_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;
|
static HMODULE msvcp;
|
||||||
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
|
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
|
||||||
|
@ -267,6 +270,8 @@ static BOOL init(void)
|
||||||
"_Thrd_equal");
|
"_Thrd_equal");
|
||||||
SET(p__Thrd_lt,
|
SET(p__Thrd_lt,
|
||||||
"_Thrd_lt");
|
"_Thrd_lt");
|
||||||
|
SET(p__Thrd_sleep,
|
||||||
|
"_Thrd_sleep");
|
||||||
|
|
||||||
msvcr = GetModuleHandleA("msvcr120.dll");
|
msvcr = GetModuleHandleA("msvcr120.dll");
|
||||||
p_setlocale = (void*)GetProcAddress(msvcr, "setlocale");
|
p_setlocale = (void*)GetProcAddress(msvcr, "setlocale");
|
||||||
|
@ -1144,6 +1149,8 @@ static void test_thrd(void)
|
||||||
};
|
};
|
||||||
const HANDLE hnd1 = (HANDLE)0xcccccccc;
|
const HANDLE hnd1 = (HANDLE)0xcccccccc;
|
||||||
const HANDLE hnd2 = (HANDLE)0xdeadbeef;
|
const HANDLE hnd2 = (HANDLE)0xdeadbeef;
|
||||||
|
xtime xt, before, after;
|
||||||
|
MSVCRT_long diff;
|
||||||
|
|
||||||
struct test testeq[] = {
|
struct test testeq[] = {
|
||||||
{ {0, 0}, {0, 0}, 1 },
|
{ {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",
|
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);
|
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)
|
START_TEST(msvcp120)
|
||||||
|
|
|
@ -3810,9 +3810,9 @@
|
||||||
@ stub _Thrd_exit
|
@ stub _Thrd_exit
|
||||||
@ stub _Thrd_join
|
@ stub _Thrd_join
|
||||||
@ cdecl _Thrd_lt(ptr ptr) msvcp120._Thrd_lt
|
@ cdecl _Thrd_lt(ptr ptr) msvcp120._Thrd_lt
|
||||||
@ stub _Thrd_sleep
|
@ cdecl _Thrd_sleep(ptr) msvcp120._Thrd_sleep
|
||||||
@ stub _Thrd_start
|
@ stub _Thrd_start
|
||||||
@ stub _Thrd_yield
|
@ cdecl _Thrd_yield() msvcp120._Thrd_yield
|
||||||
@ cdecl _Tolower(long ptr) msvcp120._Tolower
|
@ cdecl _Tolower(long ptr) msvcp120._Tolower
|
||||||
@ cdecl _Toupper(long ptr) msvcp120._Toupper
|
@ cdecl _Toupper(long ptr) msvcp120._Toupper
|
||||||
@ cdecl _Towlower(long ptr) msvcp120._Towlower
|
@ cdecl _Towlower(long ptr) msvcp120._Towlower
|
||||||
|
|
|
@ -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);
|
TRACE("(%p %u %p %u)\n", a.hnd, a.id, b.hnd, b.id);
|
||||||
return a.id < 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
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue