From 7face33ee236bd41dc1aa0b476b04d4d1e512cbe Mon Sep 17 00:00:00 2001 From: davygrvy Date: Wed, 5 Sep 2001 00:32:31 +0000 Subject: * tclWinThrd.c: Revisited _beginthreadex() stuff. Instead of assuming a c-runtime implimentation of _beginethreadex normal, I reversed the logic to not assume, and use when is. --- win/tclWinThrd.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c index dd82617..b806630 100644 --- a/win/tclWinThrd.c +++ b/win/tclWinThrd.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinThrd.c,v 1.16 2001/09/03 01:28:42 davygrvy Exp $ + * RCS: @(#) $Id: tclWinThrd.c,v 1.17 2001/09/05 00:32:31 davygrvy Exp $ */ #include "tclWinInt.h" @@ -133,16 +133,16 @@ Tcl_CreateThread(idPtr, proc, clientData, stackSize, flags) EnterCriticalSection(&joinLock); -#ifdef __CYGWIN__ +#if defined(__MSVCRT__) || defined(__BORLANDC__) + tHandle = (HANDLE) _beginthreadex(NULL, (unsigned) stackSize, proc, + clientData, 0, (unsigned *)idPtr); +#else tHandle = CreateThread(NULL, (DWORD) stackSize, (LPTHREAD_START_ROUTINE) proc, (LPVOID) clientData, (DWORD) 0, (LPDWORD)idPtr); -#else - tHandle = (HANDLE) _beginthreadex(NULL, (unsigned) stackSize, proc, - clientData, 0, (unsigned *)idPtr); #endif - if (tHandle == 0) { + if (tHandle == NULL) { LeaveCriticalSection(&joinLock); return TCL_ERROR; } else { @@ -154,6 +154,7 @@ Tcl_CreateThread(idPtr, proc, clientData, stackSize, flags) * The only purpose of this is to decrement the reference count so the * OS resources will be reaquired when the thread closes. */ + CloseHandle(tHandle); LeaveCriticalSection(&joinLock); return TCL_OK; @@ -211,10 +212,10 @@ TclpThreadExit(status) TclSignalExitThread (Tcl_GetCurrentThread (), status); LeaveCriticalSection(&joinLock); -#ifdef __CYGWIN__ - ExitThread((DWORD) status); -#else +#if defined(__MSVCRT__) || defined(__BORLANDC__) _endthreadex((DWORD)status); +#else + ExitThread((DWORD) status); #endif } -- cgit v0.12