summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-03-08 13:56:55 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-03-08 13:56:55 (GMT)
commit067066361a88c28c0b5e34a3b04de3a8799eb6f2 (patch)
treec1d0c8174f9fd32a09d74f2bf659b535a3144fad /unix
parent02cf886320e28b6ddbdb02991292a241a8ad4127 (diff)
downloadtcl-067066361a88c28c0b5e34a3b04de3a8799eb6f2.zip
tcl-067066361a88c28c0b5e34a3b04de3a8799eb6f2.tar.gz
tcl-067066361a88c28c0b5e34a3b04de3a8799eb6f2.tar.bz2
Fix compile error on Cygwin, and double definition of TclUnixWaitForFile()
Diffstat (limited to 'unix')
-rw-r--r--unix/tclEpollNotfy.c2
-rw-r--r--unix/tclUnixChan.c160
-rw-r--r--unix/tclUnixNotfy.c4
3 files changed, 2 insertions, 164 deletions
diff --git a/unix/tclEpollNotfy.c b/unix/tclEpollNotfy.c
index 7355564..28fc834 100644
--- a/unix/tclEpollNotfy.c
+++ b/unix/tclEpollNotfy.c
@@ -745,7 +745,7 @@ Tcl_WaitForEvent(
* Wait or poll for new events, queue Tcl events for the FileHandlers
* corresponding to them, and update the FileHandlers' mask of events
* of interest registered by the last call to Tcl_CreateFileHandler().
- *
+ *
* Events for the eventfd(2)/trigger pipe are processed here in order
* to facilitate inter-thread IPC. If another thread intends to wake
* up this thread whilst it's blocking on PlatformEventsWait(), it
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 6418f48..08b4805 100644
--- a/unix/tclUnixChan.c
+++ b/unix/tclUnixChan.c
@@ -1726,166 +1726,6 @@ Tcl_GetOpenFile(
return TCL_ERROR;
}
-#ifndef HAVE_COREFOUNDATION /* Darwin/Mac OS X CoreFoundation notifier is
- * in tclMacOSXNotify.c */
-/*
- *----------------------------------------------------------------------
- *
- * TclUnixWaitForFile --
- *
- * This function waits synchronously for a file to become readable or
- * writable, with an optional timeout.
- *
- * Results:
- * The return value is an OR'ed combination of TCL_READABLE,
- * TCL_WRITABLE, and TCL_EXCEPTION, indicating the conditions that are
- * present on file at the time of the return. This function will not
- * return until either "timeout" milliseconds have elapsed or at least
- * one of the conditions given by mask has occurred for file (a return
- * value of 0 means that a timeout occurred). No normal events will be
- * serviced during the execution of this function.
- *
- * Side effects:
- * Time passes.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TclUnixWaitForFile(
- int fd, /* Handle for file on which to wait. */
- int mask, /* What to wait for: OR'ed combination of
- * TCL_READABLE, TCL_WRITABLE, and
- * TCL_EXCEPTION. */
- int timeout) /* Maximum amount of time to wait for one of
- * the conditions in mask to occur, in
- * milliseconds. A value of 0 means don't wait
- * at all, and a value of -1 means wait
- * forever. */
-{
- Tcl_Time abortTime = {0, 0}, now; /* silence gcc 4 warning */
- struct timeval blockTime, *timeoutPtr;
- int numFound, result = 0;
- fd_set readableMask;
- fd_set writableMask;
- fd_set exceptionMask;
-
-#ifndef _DARWIN_C_SOURCE
- /*
- * Sanity check fd.
- */
-
- if (fd >= FD_SETSIZE) {
- Tcl_Panic("TclUnixWaitForFile can't handle file id %d", fd);
- /* must never get here, or select masks overrun will occur below */
- }
-#endif
-
- /*
- * If there is a non-zero finite timeout, compute the time when we give
- * up.
- */
-
- if (timeout > 0) {
- Tcl_GetTime(&now);
- abortTime.sec = now.sec + timeout/1000;
- abortTime.usec = now.usec + (timeout%1000)*1000;
- if (abortTime.usec >= 1000000) {
- abortTime.usec -= 1000000;
- abortTime.sec += 1;
- }
- timeoutPtr = &blockTime;
- } else if (timeout == 0) {
- timeoutPtr = &blockTime;
- blockTime.tv_sec = 0;
- blockTime.tv_usec = 0;
- } else {
- timeoutPtr = NULL;
- }
-
- /*
- * Initialize the select masks.
- */
-
- FD_ZERO(&readableMask);
- FD_ZERO(&writableMask);
- FD_ZERO(&exceptionMask);
-
- /*
- * Loop in a mini-event loop of our own, waiting for either the file to
- * become ready or a timeout to occur.
- */
-
- while (1) {
- if (timeout > 0) {
- blockTime.tv_sec = abortTime.sec - now.sec;
- blockTime.tv_usec = abortTime.usec - now.usec;
- if (blockTime.tv_usec < 0) {
- blockTime.tv_sec -= 1;
- blockTime.tv_usec += 1000000;
- }
- if (blockTime.tv_sec < 0) {
- blockTime.tv_sec = 0;
- blockTime.tv_usec = 0;
- }
- }
-
- /*
- * Setup the select masks for the fd.
- */
-
- if (mask & TCL_READABLE) {
- FD_SET(fd, &readableMask);
- }
- if (mask & TCL_WRITABLE) {
- FD_SET(fd, &writableMask);
- }
- if (mask & TCL_EXCEPTION) {
- FD_SET(fd, &exceptionMask);
- }
-
- /*
- * Wait for the event or a timeout.
- */
-
- numFound = select(fd + 1, &readableMask, &writableMask,
- &exceptionMask, timeoutPtr);
- if (numFound == 1) {
- if (FD_ISSET(fd, &readableMask)) {
- SET_BITS(result, TCL_READABLE);
- }
- if (FD_ISSET(fd, &writableMask)) {
- SET_BITS(result, TCL_WRITABLE);
- }
- if (FD_ISSET(fd, &exceptionMask)) {
- SET_BITS(result, TCL_EXCEPTION);
- }
- result &= mask;
- if (result) {
- break;
- }
- }
- if (timeout == 0) {
- break;
- }
- if (timeout < 0) {
- continue;
- }
-
- /*
- * The select returned early, so we need to recompute the timeout.
- */
-
- Tcl_GetTime(&now);
- if ((abortTime.sec < now.sec)
- || (abortTime.sec==now.sec && abortTime.usec<=now.usec)) {
- break;
- }
- }
- return result;
-}
-#endif /* HAVE_COREFOUNDATION */
-
/*
*----------------------------------------------------------------------
*
diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c
index 248504b..eb3e8ba 100644
--- a/unix/tclUnixNotfy.c
+++ b/unix/tclUnixNotfy.c
@@ -322,7 +322,7 @@ AlertSingleThread(
* continuously spinning on epoll_wait until the other
* threads runs and services the file event.
*/
-
+
if (tsdPtr->prevPtr) {
tsdPtr->prevPtr->nextPtr = tsdPtr->nextPtr;
} else {
@@ -396,8 +396,6 @@ AtForkChild(void)
* The tsdPtr from before the fork is copied as well. But since
* we are paranoic, we don't trust its condvar and reset it.
*/
- pthread_cond_destroy(&tsdPtr->waitCV);
- pthread_cond_init(&tsdPtr->waitCV, NULL);
#ifdef __CYGWIN__
DestroyWindow(tsdPtr->hwnd);
tsdPtr->hwnd = CreateWindowExW(NULL, className,