File: threadWin.c

package info (click to toggle)
tclthread 1%3A2.6.5-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,648 kB
  • ctags: 873
  • sloc: ansic: 7,192; tcl: 1,640; sh: 117; makefile: 112; cpp: 31
file content (56 lines) | stat: -rw-r--r-- 1,473 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * threadWin.c --
 *
 * Windows specific aspects for the thread extension.
 *
 * see http://dev.activestate.com/doc/howto/thread_model.html
 *
 * Some of this code is based on work done by Richard Hipp on behalf of
 * Conservation Through Innovation, Limited, with their permission.
 *
 * Copyright (c) 1998 by Sun Microsystems, Inc.
 * Copyright (c) 1999,2000 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: threadWin.c,v 1.5 2002/01/27 04:52:21 davygrvy Exp $
 */

#include "../generic/tclThread.h"
#include <windows.h>
#include <process.h>

#if 0
/* only Windows 2000 (XP, too??) has this function */
HANDLE (WINAPI *winOpenThreadProc)(DWORD, BOOL, DWORD);

void
ThreadpInit (void)
{
    HMODULE hKernel = GetModuleHandle("kernel32.dll");
    winOpenThreadProc = (HANDLE (WINAPI *)(DWORD, BOOL, DWORD))
	    GetProcAddress(hKernel, "OpenThread");
}

int
ThreadpKill (Tcl_Interp *interp, long id)
{
    HANDLE hThread;
    int result = TCL_OK;

    if (winOpenThreadProc) {
	hThread = winOpenThreadProc(THREAD_TERMINATE, FALSE, id);
	/* 
	 * not to be misunderstood as "devilishly clever",
	 * but evil in it's pure form.
	 */
	TerminateThread(hThread, 666);
    } else {
	Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
		"Can't (yet) kill threads on this OS, sorry.", NULL);
	result = TCL_ERROR;
    }
    return result;
}
#endif