From ba5ac466c37317ded61fbe5b05be58a83efd4f0c Mon Sep 17 00:00:00 2001 From: davygrvy Date: Mon, 3 Sep 2001 00:37:45 +0000 Subject: * win/tclWinThrd.c: Portability fix for Cygwin who's c-runtime, not surprisingly, doesn't have the MSVCRT specific _beginthreadex / _endthreadex pair. This might have to be revisited for proper Borland, lcc32, Watcom and other support as well. --- win/tclWinThrd.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c index e0e466d..3877729 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.14 2001/08/07 00:43:02 hobbs Exp $ + * RCS: @(#) $Id: tclWinThrd.c,v 1.15 2001/09/03 00:37:45 davygrvy Exp $ */ #include "tclWinInt.h" @@ -135,8 +135,14 @@ Tcl_CreateThread(idPtr, proc, clientData, stackSize, flags) EnterCriticalSection(&joinLock); +#ifdef __CYGWIN__ + 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) { LeaveCriticalSection(&joinLock); @@ -146,6 +152,10 @@ Tcl_CreateThread(idPtr, proc, clientData, stackSize, flags) TclRememberJoinableThread (*idPtr); } + /* + * 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; @@ -203,7 +213,11 @@ TclpThreadExit(status) TclSignalExitThread (Tcl_GetCurrentThread (), status); LeaveCriticalSection(&joinLock); +#ifdef __CYGWIN__ + ExitThread((DWORD) status); +#else _endthreadex((DWORD)status); +#endif } -- cgit v0.12