Tcl Source Code

Artifact [b4d599682d]
Login

Artifact b4d599682d3bb33c581ff0df21115d1afe8540c4:

Attachment "patch_some_mingw_support.txt" to ticket [418737ffff] added by davygrvy 2001-04-25 13:53:15.
Index: tclWinThrd.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinThrd.c,v
retrieving revision 1.11
diff -c -r1.11 tclWinThrd.c
*** tclWinThrd.c	2000/06/13 20:30:24	1.11
--- tclWinThrd.c	2001/04/25 06:44:59
***************
*** 136,143 ****
  
      EnterCriticalSection(&joinLock);
  
      code = _beginthreadex(NULL, (unsigned) stackSize, proc, clientData, 0,
! 	(unsigned *)idPtr);
  
      if (code == 0) {
          LeaveCriticalSection(&joinLock);
--- 136,156 ----
  
      EnterCriticalSection(&joinLock);
  
+ #if !defined(__GNUC__) || (defined(__GNUC__) && defined(__MSVCRT__))
      code = _beginthreadex(NULL, (unsigned) stackSize, proc, clientData, 0,
! 	    (unsigned *)idPtr);
! #else
!     /* 
!      * MS CRTDLL runtime, one of two supported GCC/Mingw, does not support 
!      * the _beginthreadex and _endthreadex interfaces, and we resort to using
!      * Win32 API CreateThread and ExitThread interfaces instead. A side 
!      * effect is that there is a potential resource leak after each thread 
!      * exits. 
!      */
! 
!     code = (unsigned long) CreateThread(NULL, (unsigned) stackSize, proc,
! 	    clientData, 0, (DWORD *)idPtr);
! #endif
  
      if (code == 0) {
          LeaveCriticalSection(&joinLock);
***************
*** 200,209 ****
      int status;
  {
      EnterCriticalSection(&joinLock);
!     TclSignalExitThread (Tcl_GetCurrentThread (), status);
      LeaveCriticalSection(&joinLock);
  
      _endthreadex((DWORD)status);
  }
  
  
--- 213,226 ----
      int status;
  {
      EnterCriticalSection(&joinLock);
!     TclSignalExitThread (Tcl_GetCurrentThread(), status);
      LeaveCriticalSection(&joinLock);
  
+ #if !defined(__GNUC__) || (defined(__GNUC__) && defined(__MSVCRT__))
      _endthreadex((DWORD)status);
+ #else
+     ExitThread((DWORD)status);
+ #endif
  }