diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-06-22 08:29:53 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-06-22 08:29:53 (GMT) |
commit | 5680fa44dbfafeed01f328dd8cde4310c3c95ba6 (patch) | |
tree | 1b855b6b0ffa0d3e208cf79e38d1b38d47dab3c2 /unix | |
parent | 4731d0ccca76a01ad1401b71b70c9e6f1e372050 (diff) | |
parent | b6f50b1321a5cd34af747eb670aad924fc66d7b7 (diff) | |
download | tcl-5680fa44dbfafeed01f328dd8cde4310c3c95ba6.zip tcl-5680fa44dbfafeed01f328dd8cde4310c3c95ba6.tar.gz tcl-5680fa44dbfafeed01f328dd8cde4310c3c95ba6.tar.bz2 |
first working version of Cygwin notifierbug_3508771
Diffstat (limited to 'unix')
-rw-r--r-- | unix/tcl.m4 | 6 | ||||
-rw-r--r-- | unix/tclUnixNotfy.c | 34 |
2 files changed, 34 insertions, 6 deletions
diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 2391a41..7161c91 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1226,6 +1226,12 @@ dnl AC_CHECK_TOOL(AR, ar) if test "$ac_cv_cygwin" = "no"; then AC_MSG_ERROR([${CC} is not a cygwin compiler.]) fi + if test "x${TCL_THREADS}" = "x0"; then + AC_MSG_ERROR([CYGWIN compile is only supported with --enable-threads]) + fi + if test ! -f "../win/tcldde12.dll" -a ! -f "../win/tk84.dll"; then + AC_MSG_ERROR([Please configure and make the ../win directory first.]) + fi ;; dgux*) SHLIB_CFLAGS="-K PIC" diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c index aff51b1..ab1f160 100644 --- a/unix/tclUnixNotfy.c +++ b/unix/tclUnixNotfy.c @@ -103,10 +103,11 @@ typedef struct ThreadSpecificData { * that an event is ready to be processed * by sending this event. */ void *hwnd; /* Messaging window. */ -#endif /* __CYGWIN__ */ +#else /* !__CYGWIN__ */ Tcl_Condition waitCV; /* Any other thread alerts a notifier * that an event is ready to be processed * by signaling this condition variable. */ +#endif /* __CYGWIN__ */ int eventReady; /* True if an event is ready to be processed. * Used as condition flag together with * waitCV above. */ @@ -354,8 +355,9 @@ Tcl_FinalizeNotifier(clientData) #ifdef __CYGWIN__ CloseHandle(tsdPtr->event); -#endif /* __CYGWIN__ */ +#else /* __CYGWIN__ */ Tcl_ConditionFinalize(&(tsdPtr->waitCV)); +#endif /* __CYGWIN__ */ Tcl_MutexUnlock(¬ifierMutex); #endif @@ -390,7 +392,11 @@ Tcl_AlertNotifier(clientData) ThreadSpecificData *tsdPtr = (ThreadSpecificData *) clientData; Tcl_MutexLock(¬ifierMutex); tsdPtr->eventReady = 1; +#ifdef __CYGWIN__ + PostMessageW(tsdPtr->hwnd, 1024, 0, 0); +#else Tcl_ConditionNotify(&tsdPtr->waitCV); +#endif Tcl_MutexUnlock(¬ifierMutex); #endif } @@ -832,9 +838,7 @@ Tcl_WaitForEvent(timePtr) class.hIcon = NULL; class.hCursor = NULL; - if (!RegisterClassW(&class)) { - Tcl_Panic("Unable to register TclNotifier window class"); - } + RegisterClassW(&class); tsdPtr->hwnd = CreateWindowExW(NULL, class.lpszClassName, class.lpszClassName, 0, 0, 0, 0, 0, NULL, NULL, TclWinGetTclInstance(), NULL); tsdPtr->event = CreateEventW(NULL, 1 /* manual */, @@ -866,7 +870,21 @@ Tcl_WaitForEvent(timePtr) FD_ZERO( &(tsdPtr->readyMasks.exceptional) ); if (!tsdPtr->eventReady) { - Tcl_ConditionWait(&tsdPtr->waitCV, ¬ifierMutex, timePtr); +#ifdef __CYGWIN__ + if (!PeekMessageW(&msg, NULL, 0, 0, 0)) { + DWORD timeout; + if (timePtr) { + timeout = timePtr->sec * 1000 + timePtr->usec / 1000; + } else { + timeout = 0xFFFFFFFF; + } + Tcl_MutexUnlock(¬ifierMutex); + MsgWaitForMultipleObjects(1, &tsdPtr->event, 0, timeout, 1279); + Tcl_MutexLock(¬ifierMutex); + } +#else + Tcl_ConditionWait(&tsdPtr->waitCV, ¬ifierMutex, timePtr); +#endif } tsdPtr->eventReady = 0; @@ -1159,7 +1177,11 @@ NotifierThreadProc(clientData) tsdPtr->onList = 0; tsdPtr->pollState = 0; } +#ifdef __CYGWIN__ + PostMessageW(tsdPtr->hwnd, 1024, 0, 0); +#else /* __CYGWIN__ */ Tcl_ConditionNotify(&tsdPtr->waitCV); +#endif /* __CYGWIN__ */ } } Tcl_MutexUnlock(¬ifierMutex); |