summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorstanton <stanton>1999-03-11 01:50:26 (GMT)
committerstanton <stanton>1999-03-11 01:50:26 (GMT)
commitda3b0b4ffd7c69cd67f9a48ef39bfec6fd7fa3dd (patch)
treefd4ffd5b672a390d34c3ddbf56a53ecfb2dc89d2 /win
parent0ad8a310e8ae892d27c4981cfd0ea148e0d7984c (diff)
downloadtcl-da3b0b4ffd7c69cd67f9a48ef39bfec6fd7fa3dd.zip
tcl-da3b0b4ffd7c69cd67f9a48ef39bfec6fd7fa3dd.tar.gz
tcl-da3b0b4ffd7c69cd67f9a48ef39bfec6fd7fa3dd.tar.bz2
* generic/tcl.h:
* generic/tcl.decls: Changed Tcl_ReleaseType from an enum to macros so it can be used in .rc files. Added Tcl_GetString. * mac/tclMacNotify.c: * generic/tclNotify.c: * generic/tclInt.h: * win/tclWinNotify.c: * generic/tcl.h: Renamed Tcl_AlertNotifier to TclpAlertNotifier. * generic/tclInt.decls: Added TclWinAddProcess to make it possible for expect to use Tcl_WaitForPid(). This patch is from Gordon Chaffee. * mac/tclMacPort.h: * win/tclWinInit.c: * unix/tclUnixPort.h: * generic/tclAsync.c: Added TclpAsyncMark to fix bug in async handling on Windows where async events don't wake up the event loop. This patch comes from Gordon Chaffee. * generic/tcl.decls: Fixed declarations of reserved slots.
Diffstat (limited to 'win')
-rw-r--r--win/tclWinInit.c48
-rw-r--r--win/tclWinNotify.c8
-rw-r--r--win/tclWinPipe.c50
3 files changed, 84 insertions, 22 deletions
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index 64bcc58..5d13a8d 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.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: tclWinInit.c,v 1.1.2.5 1999/02/10 23:31:28 stanton Exp $
+ * RCS: @(#) $Id: tclWinInit.c,v 1.1.2.6 1999/03/11 01:50:33 stanton Exp $
*/
#include "tclWinInt.h"
@@ -75,6 +75,12 @@ static char* processors[NUMPROCESSORS] = {
};
/*
+ * Thread id used for asynchronous notification from signal handlers.
+ */
+
+static DWORD mainThreadId;
+
+/*
* The Init script (common to Windows and Unix platforms) is
* defined in tkInitScript.h
*/
@@ -86,8 +92,6 @@ static void AppendPath(Tcl_Obj *listPtr, HMODULE hModule,
CONST char *lib);
static void AppendRegistry(Tcl_Obj *listPtr, CONST char *lib);
static int ToUtf(CONST WCHAR *wSrc, char *dst);
-
-
/*
*---------------------------------------------------------------------------
@@ -126,6 +130,16 @@ TclpInitPlatform()
*/
SetErrorMode(SetErrorMode(0) | SEM_FAILCRITICALERRORS);
+
+ /*
+ * Save the id of the first thread to intialize the Tcl library. This
+ * thread will be used to handle notifications from async event
+ * procedures. This is not strictly correct. A better solution involves
+ * using a designated "main" notifier that is kept up to date as threads
+ * come and go.
+ */
+
+ mainThreadId = GetCurrentThreadId();
}
/*
@@ -651,3 +665,31 @@ Tcl_SourceRCFile(interp)
Tcl_DStringFree(&temp);
}
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclpAsyncMark --
+ *
+ * Wake up the main thread from a signal handler.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Sends a message to the main thread.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TclpAsyncMark(async)
+ Tcl_AsyncHandler async; /* Token for handler. */
+{
+ /*
+ * Need a way to kick the Windows event loop and tell it to go look at
+ * asynchronous events.
+ */
+
+ PostThreadMessage(mainThreadId, WM_USER, 0, 0);
+}
diff --git a/win/tclWinNotify.c b/win/tclWinNotify.c
index 328da7c..4892ed7 100644
--- a/win/tclWinNotify.c
+++ b/win/tclWinNotify.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinNotify.c,v 1.1.2.4 1998/12/24 00:14:01 rjohnson Exp $
+ * RCS: @(#) $Id: tclWinNotify.c,v 1.1.2.5 1999/03/11 01:50:34 stanton Exp $
*/
#include "tclWinInt.h"
@@ -25,7 +25,7 @@ static int initialized = 0;
#define INTERVAL_TIMER 1 /* Handle of interval timer. */
#define WM_WAKEUP WM_USER /* Message that is send by
- * Tcl_AlertNotifier. */
+ * TclpAlertNotifier. */
/*
* The following static structure contains the state information for the
* Windows implementation of the Tcl notifier. One of these structures
@@ -178,7 +178,7 @@ Tcl_FinalizeNotifier(clientData)
/*
*----------------------------------------------------------------------
*
- * Tcl_AlertNotifier --
+ * TclpAlertNotifier --
*
* Wake up the specified notifier from any thread. This routine
* is called by the platform independent notifier code whenever
@@ -197,7 +197,7 @@ Tcl_FinalizeNotifier(clientData)
*/
void
-Tcl_AlertNotifier(clientData)
+TclpAlertNotifier(clientData)
ClientData clientData; /* Pointer to thread data. */
{
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) clientData;
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c
index b48ba80..b64c343 100644
--- a/win/tclWinPipe.c
+++ b/win/tclWinPipe.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: tclWinPipe.c,v 1.1.2.6 1999/02/26 02:19:24 redman Exp $
+ * RCS: @(#) $Id: tclWinPipe.c,v 1.1.2.7 1999/03/11 01:50:34 stanton Exp $
*/
#include "tclWinInt.h"
@@ -1144,13 +1144,7 @@ TclpCreateProcess(
}
*pidPtr = (Tcl_Pid) procInfo.hProcess;
if (*pidPtr != 0) {
- ProcInfo *procPtr = (ProcInfo *) ckalloc(sizeof(ProcInfo));
- procPtr->hProcess = procInfo.hProcess;
- procPtr->dwProcessId = procInfo.dwProcessId;
- Tcl_MutexLock(&procMutex);
- procPtr->nextPtr = procList;
- procList = procPtr;
- Tcl_MutexUnlock(&procMutex);
+ TclWinAddProcess(procInfo.hProcess, procInfo.dwProcessId);
}
result = TCL_OK;
}
@@ -1457,13 +1451,7 @@ TclpCreateProcess(
*pidPtr = (Tcl_Pid) procInfo.hProcess;
if (*pidPtr != 0) {
- ProcInfo *procPtr = (ProcInfo *) ckalloc(sizeof(ProcInfo));
- procPtr->hProcess = procInfo.hProcess;
- procPtr->dwProcessId = procInfo.dwProcessId;
- Tcl_MutexLock(&procMutex);
- procPtr->nextPtr = procList;
- procList = procPtr;
- Tcl_MutexUnlock(&procMutex);
+ TclWinAddProcess(procInfo.hProcess, procInfo.dwProcessId);
}
result = TCL_OK;
@@ -2765,6 +2753,38 @@ Tcl_WaitPid(
/*
*----------------------------------------------------------------------
*
+ * TclWinAddProcess --
+ *
+ * Add a process to the process list so that we can use
+ * Tcl_WaitPid on the process.
+ *
+ * Results:
+ * None
+ *
+ * Side effects:
+ * Adds the specified process handle to the process list so
+ * Tcl_WaitPid knows about it.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TclWinAddProcess(hProcess, id)
+ HANDLE hProcess; /* Handle to process */
+ DWORD id; /* Global process identifier */
+{
+ ProcInfo *procPtr = (ProcInfo *) ckalloc(sizeof(ProcInfo));
+ procPtr->hProcess = hProcess;
+ procPtr->dwProcessId = id;
+ Tcl_MutexLock(&procMutex);
+ procPtr->nextPtr = procList;
+ procList = procPtr;
+ Tcl_MutexUnlock(&procMutex);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* Tcl_PidObjCmd --
*
* This procedure is invoked to process the "pid" Tcl command.