Module: wine Branch: master Commit: fb7af057a16ce9d01a358dc0adaf9935d581b9aa URL: http://source.winehq.org/git/wine.git/?a=commit;h=fb7af057a16ce9d01a358dc0ad...
Author: Piotr Caban piotr@codeweavers.com Date: Tue Feb 23 13:13:07 2016 +0100
msvcp120: Add _Thrd_start implementation.
Signed-off-by: Piotr Caban piotr@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/msvcp110/msvcp110.spec | 2 +- dlls/msvcp120/msvcp120.spec | 2 +- dlls/msvcp120_app/msvcp120_app.spec | 2 +- dlls/msvcp90/misc.c | 35 +++++++++++++++++++++++++++++++++-- 4 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec index ae11097..52d292c 100644 --- a/dlls/msvcp110/msvcp110.spec +++ b/dlls/msvcp110/msvcp110.spec @@ -3864,7 +3864,7 @@ @ cdecl _Thrd_join(ptr long) @ cdecl _Thrd_lt(ptr ptr) @ cdecl _Thrd_sleep(ptr) -@ stub _Thrd_start +@ cdecl _Thrd_start(ptr ptr ptr) @ cdecl _Thrd_yield() @ cdecl _Tolower(long ptr) @ cdecl _Toupper(long ptr) diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec index e78d5ea..c70939b 100644 --- a/dlls/msvcp120/msvcp120.spec +++ b/dlls/msvcp120/msvcp120.spec @@ -3811,7 +3811,7 @@ @ cdecl _Thrd_join(ptr long) @ cdecl _Thrd_lt(ptr ptr) @ cdecl _Thrd_sleep(ptr) -@ stub _Thrd_start +@ cdecl _Thrd_start(ptr ptr ptr) @ cdecl _Thrd_yield() @ cdecl _Tolower(long ptr) @ cdecl _Toupper(long ptr) diff --git a/dlls/msvcp120_app/msvcp120_app.spec b/dlls/msvcp120_app/msvcp120_app.spec index 0330d53..6b6e24c 100644 --- a/dlls/msvcp120_app/msvcp120_app.spec +++ b/dlls/msvcp120_app/msvcp120_app.spec @@ -3811,7 +3811,7 @@ @ cdecl _Thrd_join(ptr long) msvcp120._Thrd_join @ cdecl _Thrd_lt(ptr ptr) msvcp120._Thrd_lt @ cdecl _Thrd_sleep(ptr) msvcp120._Thrd_sleep -@ stub _Thrd_start +@ cdecl _Thrd_start(ptr ptr ptr) msvcp120._Thrd_start @ cdecl _Thrd_yield() msvcp120._Thrd_yield @ cdecl _Tolower(long ptr) msvcp120._Tolower @ cdecl _Toupper(long ptr) msvcp120._Toupper diff --git a/dlls/msvcp90/misc.c b/dlls/msvcp90/misc.c index b2adc72..a9efe0a 100644 --- a/dlls/msvcp90/misc.c +++ b/dlls/msvcp90/misc.c @@ -872,10 +872,41 @@ int __cdecl _Thrd_join(_Thrd_t thr, int *code) return 0; }
+int __cdecl _Thrd_start(_Thrd_t *thr, LPTHREAD_START_ROUTINE proc, void *arg) +{ + TRACE("(%p %p %p)\n", thr, proc, arg); + thr->hnd = CreateThread(NULL, 0, proc, arg, 0, &thr->id); + return thr->hnd ? 0 : _THRD_ERROR; +} + +typedef struct +{ + _Thrd_start_t proc; + void *arg; +} thread_proc_arg; + +static DWORD WINAPI thread_proc_wrapper(void *arg) +{ + thread_proc_arg wrapped_arg = *((thread_proc_arg*)arg); + free(arg); + return wrapped_arg.proc(wrapped_arg.arg); +} + int __cdecl _Thrd_create(_Thrd_t *thr, _Thrd_start_t proc, void *arg) { + thread_proc_arg *wrapped_arg; + int ret; + TRACE("(%p %p %p)\n", thr, proc, arg); - thr->hnd = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)proc, arg, 0, &thr->id); - return !thr->hnd; + + wrapped_arg = malloc(sizeof(*wrapped_arg)); + if(!wrapped_arg) + return _THRD_ERROR; /* TODO: probably different error should be returned here */ + + wrapped_arg->proc = proc; + wrapped_arg->arg = arg; + ret = _Thrd_start(thr, thread_proc_wrapper, wrapped_arg); + if(ret) free(wrapped_arg); + return ret; } #endif