Diff
Not logged in

Differences From Artifact [a3587ab37b]:

To Artifact [72481dd9bc]:


1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
1
2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
19











-
+







/* 
 * tclWinThread.c --
 *
 *	This file implements the Windows-specific thread operations.
 *
 * Copyright (c) 1998 by Sun Microsystems, Inc.
 * Copyright (c) 1999 by Scriptics Corporation
 *
 * 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"

#include <fcntl.h>
#include <io.h>
#include <sys/stat.h>
129
130
131
132
133
134
135
136




137
138
139
140
141
142
143
144
145

146
147
148
149
150
151
152
153
154
155
156

157
158
159
160
161
162
163
129
130
131
132
133
134
135

136
137
138
139
140
141
142



143
144

145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164







-
+
+
+
+



-
-
-


-
+











+







    int flags;				/* Flags controlling behaviour of
					 * the new thread */
{
    HANDLE tHandle;

    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 {
        if (flags & TCL_THREAD_JOINABLE) {
	    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;
    }
}

/*
207
208
209
210
211
212
213
214
215


216
217

218
219
220
221
222
223
224
208
209
210
211
212
213
214


215
216
217

218
219
220
221
222
223
224
225







-
-
+
+

-
+







TclpThreadExit(status)
    int status;
{
    EnterCriticalSection(&joinLock);
    TclSignalExitThread (Tcl_GetCurrentThread (), status);
    LeaveCriticalSection(&joinLock);

#ifdef __CYGWIN__
    ExitThread((DWORD) status);
#if defined(__MSVCRT__) || defined(__BORLANDC__)
    _endthreadex((DWORD)status);
#else
    _endthreadex((DWORD)status);
    ExitThread((DWORD) status);
#endif
}


/*
 *----------------------------------------------------------------------
 *