Piotr Caban : msvcp110: Add _Thrd_detach implementation.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Feb 25 10:56:04 CST 2016
Module: wine
Branch: master
Commit: b793e2e4220a3d1c7996d2000d444311230310d4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b793e2e4220a3d1c7996d2000d444311230310d4
Author: Piotr Caban <piotr at codeweavers.com>
Date: Thu Feb 25 10:47:34 2016 +0100
msvcp110: Add _Thrd_detach implementation.
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcp110/msvcp110.spec | 2 +-
dlls/msvcp120/msvcp120.spec | 2 +-
dlls/msvcp120/tests/msvcp120.c | 15 +++++++++++++--
dlls/msvcp120_app/msvcp120_app.spec | 2 +-
dlls/msvcp90/misc.c | 5 +++++
5 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec
index 09aaac9..87b2392 100644
--- a/dlls/msvcp110/msvcp110.spec
+++ b/dlls/msvcp110/msvcp110.spec
@@ -3858,7 +3858,7 @@
@ stub _Thrd_abort
@ cdecl _Thrd_create(ptr ptr ptr)
@ cdecl _Thrd_current()
-@ stub _Thrd_detach
+@ cdecl _Thrd_detach(ptr)
@ cdecl _Thrd_equal(ptr ptr)
@ stub _Thrd_exit
@ cdecl _Thrd_join(ptr long)
diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec
index 737cfe3..8fdd4e7 100644
--- a/dlls/msvcp120/msvcp120.spec
+++ b/dlls/msvcp120/msvcp120.spec
@@ -3805,7 +3805,7 @@
@ stub _Thrd_abort
@ cdecl _Thrd_create(ptr ptr ptr)
@ cdecl _Thrd_current()
-@ stub _Thrd_detach
+@ cdecl _Thrd_detach(ptr)
@ cdecl _Thrd_equal(ptr ptr)
@ stub _Thrd_exit
@ cdecl _Thrd_join(ptr long)
diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c
index 915f58a..8c7c093 100644
--- a/dlls/msvcp120/tests/msvcp120.c
+++ b/dlls/msvcp120/tests/msvcp120.c
@@ -203,6 +203,7 @@ static void (__cdecl *p__Thrd_sleep)(const xtime*);
static _Thrd_t (__cdecl *p__Thrd_current)(void);
static int (__cdecl *p__Thrd_create)(_Thrd_t*, _Thrd_start_t, void*);
static int (__cdecl *p__Thrd_join)(_Thrd_t, int*);
+static int (__cdecl *p__Thrd_detach)(_Thrd_t);
#ifdef __i386__
static ULONGLONG (__cdecl *p_i386_Thrd_current)(void);
@@ -486,6 +487,8 @@ static BOOL init(void)
"_Thrd_create");
SET(p__Thrd_join,
"_Thrd_join");
+ SET(p__Thrd_detach,
+ "_Thrd_detach");
SET(p__Mtx_init,
"_Mtx_init");
@@ -1677,7 +1680,8 @@ static int __cdecl thrd_thread(void *arg)
{
_Thrd_t *thr = arg;
- *thr = p__Thrd_current();
+ if(thr)
+ *thr = p__Thrd_current();
return 0x42;
}
@@ -1759,7 +1763,14 @@ static void test_thrd(void)
ok(ta.id == tb.id, "expected %d, got %d\n", ta.id, tb.id);
ok(ta.hnd != tb.hnd, "same handles, got %p\n", ta.hnd);
ok(r == 0x42, "expected 0x42, got %d\n", r);
- ok(!CloseHandle(ta.hnd), "handle %p not closed\n", ta.hnd);
+ ret = p__Thrd_detach(ta);
+ ok(ret == 4, "_Thrd_detach should have failed with error 4, got %d\n", ret);
+
+ ret = p__Thrd_create(&ta, thrd_thread, NULL);
+ ok(!ret, "failed to create thread, got %d\n", ret);
+ ret = p__Thrd_detach(ta);
+ ok(!ret, "_Thrd_detach failed, got %d\n", ret);
+
}
#define NUM_THREADS 10
diff --git a/dlls/msvcp120_app/msvcp120_app.spec b/dlls/msvcp120_app/msvcp120_app.spec
index af63a39..12a92fd 100644
--- a/dlls/msvcp120_app/msvcp120_app.spec
+++ b/dlls/msvcp120_app/msvcp120_app.spec
@@ -3805,7 +3805,7 @@
@ stub _Thrd_abort
@ cdecl _Thrd_create(ptr ptr ptr) msvcp120._Thrd_create
@ cdecl _Thrd_current() msvcp120._Thrd_current
-@ stub _Thrd_detach
+@ cdecl _Thrd_detach(ptr) msvcp120._Thrd_detach
@ cdecl _Thrd_equal(ptr ptr) msvcp120._Thrd_equal
@ stub _Thrd_exit
@ cdecl _Thrd_join(ptr long) msvcp120._Thrd_join
diff --git a/dlls/msvcp90/misc.c b/dlls/msvcp90/misc.c
index fa4ff7b..b1348d5 100644
--- a/dlls/msvcp90/misc.c
+++ b/dlls/msvcp90/misc.c
@@ -874,6 +874,11 @@ int __cdecl _Thrd_create(_Thrd_t *thr, _Thrd_start_t proc, void *arg)
return ret;
}
+int __cdecl _Thrd_detach(_Thrd_t thr)
+{
+ return CloseHandle(thr.hnd) ? 0 : _THRD_ERROR;
+}
+
typedef struct
{
const vtable_ptr *vtable;
More information about the wine-cvs
mailing list