From 54112e75a9c75c222a82980cf7fbcb0ac32abc6a Mon Sep 17 00:00:00 2001 From: fedor Date: Wed, 20 Aug 2003 03:44:20 +0000 Subject: [PATCH] * thr-win32.c (__objc_thread_detach): Use _beginthreadex (__objc_thread_exit): Use _endthreadex. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/libobjc/trunk@17498 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog.GNUstep | 5 +++++ thr-win32.c | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ChangeLog.GNUstep b/ChangeLog.GNUstep index 3b197ab..83829d7 100644 --- a/ChangeLog.GNUstep +++ b/ChangeLog.GNUstep @@ -1,3 +1,8 @@ +2003-08-19 Jeremy Bettis + + * thr-win32.c (__objc_thread_detach): Use _beginthreadex + (__objc_thread_exit): Use _endthreadex. + 2003-08-12 Adam Fedor * thr-posix.c (__objc_thread_set_priority): Don't use if diff --git a/thr-win32.c b/thr-win32.c index 9fc6321..d145c40 100644 --- a/thr-win32.c +++ b/thr-win32.c @@ -31,6 +31,7 @@ Boston, MA 02111-1307, USA. */ #define __OBJC__ #endif #include +#include /* Key structure for maintaining thread specific storage */ static DWORD __objc_data_tls = (DWORD)-1; @@ -66,10 +67,18 @@ __objc_thread_detach(void (*func)(void *arg), void *arg) DWORD thread_id = 0; HANDLE win32_handle; +#ifndef __MINGW__ if (!(win32_handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)func, arg, 0, &thread_id))) +#else + unsigned thread_id = 0; + unsigned long win32_handle; + // According to MSDN documentation threads which use libc functions should call _beginthreadex not CreateThread + if (-1 == (win32_handle = _beginthreadex(NULL, 0, (void*)func, arg, 0, &thread_id))) +#endif thread_id = 0; - + + CloseHandle((HANDLE)win32_handle); return (objc_thread_t)thread_id; } @@ -141,7 +150,11 @@ int __objc_thread_exit(void) { /* exit the thread */ +#ifndef __MINGW__ ExitThread(__objc_thread_exit_status); +#else + _endthreadex(__objc_thread_exit_status); +#endif /* Failed if we reached here */ return -1;