diff --git a/ChangeLog b/ChangeLog index fd948faa8..5196fa3c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ invocation is retaining its contents. * configure.in: Disable ffi and warn about it. * configure: regenerated + * Source/NSRunLoop.m: ([acceptInputForMode:beforeDate:]) block until + limit date even if no I/O is possible. 2002-02-13 Richard Frith-Macdonald diff --git a/Source/GSFormat.m b/Source/GSFormat.m index a1c30b793..143988913 100644 --- a/Source/GSFormat.m +++ b/Source/GSFormat.m @@ -65,7 +65,9 @@ #include #include // for strstr() #include +#if HAVE_UNISTD_H #include +#endif #include #include #include diff --git a/Source/GSHTTPURLHandle.m b/Source/GSHTTPURLHandle.m index bf7d77768..460e00358 100644 --- a/Source/GSHTTPURLHandle.m +++ b/Source/GSHTTPURLHandle.m @@ -38,7 +38,9 @@ #include #include #include +#if HAVE_UNISTD_H #include +#endif #include #ifdef HAVE_SYS_FCNTL_H diff --git a/Source/GSTcpPort.m b/Source/GSTcpPort.m index bfca431a5..f3f6961b4 100644 --- a/Source/GSTcpPort.m +++ b/Source/GSTcpPort.m @@ -41,7 +41,9 @@ #include #include #include +#if HAVE_UNISTD_H #include /* for gethostname() */ +#endif #ifndef __MINGW__ #include /* for MAXHOSTNAMELEN */ diff --git a/Source/GSUnixSSLHandle.m b/Source/GSUnixSSLHandle.m index 86df3c061..495554468 100644 --- a/Source/GSUnixSSLHandle.m +++ b/Source/GSUnixSSLHandle.m @@ -65,7 +65,9 @@ #endif #include #include +#if HAVE_UNISTD_H #include +#endif #include // Maximum data in single I/O operation diff --git a/Source/NSBundle.m b/Source/NSBundle.m index 072462288..92128e206 100644 --- a/Source/NSBundle.m +++ b/Source/NSBundle.m @@ -49,7 +49,9 @@ #include #include #include +#if HAVE_UNISTD_H #include +#endif #include @interface NSObject (PrivateFrameworks) diff --git a/Source/NSData.m b/Source/NSData.m index 0d91c3e21..529f14117 100644 --- a/Source/NSData.m +++ b/Source/NSData.m @@ -79,7 +79,9 @@ #include #include #include /* for memset() */ +#if HAVE_UNISTD_H #include /* SEEK_* on SunOS 4 */ +#endif #if HAVE_MMAP #include diff --git a/Source/NSFileManager.m b/Source/NSFileManager.m index 158266c38..a0ea87d2c 100644 --- a/Source/NSFileManager.m +++ b/Source/NSFileManager.m @@ -56,7 +56,9 @@ # include #endif +#if HAVE_UNISTD_H #include +#endif #if HAVE_WINDOWS_H # include #endif diff --git a/Source/NSHost.m b/Source/NSHost.m index 1b2a2d75d..5752ff69f 100644 --- a/Source/NSHost.m +++ b/Source/NSHost.m @@ -41,7 +41,9 @@ #include #else #include +#if HAVE_UNISTD_H #include +#endif #include #include #include diff --git a/Source/NSLock.m b/Source/NSLock.m index 7e0717c0c..4fc1304f4 100644 --- a/Source/NSLock.m +++ b/Source/NSLock.m @@ -26,7 +26,9 @@ #include #include +#if HAVE_UNISTD_H #include +#endif #include #include #include diff --git a/Source/NSLog.m b/Source/NSLog.m index 0a86e3d36..a24faa158 100644 --- a/Source/NSLog.m +++ b/Source/NSLog.m @@ -40,7 +40,9 @@ #include #endif +#if HAVE_UNISTD_H #include +#endif #include "GSUserDefaults.h" diff --git a/Source/NSPage.m b/Source/NSPage.m index e2b4f6761..3f5bcaac5 100644 --- a/Source/NSPage.m +++ b/Source/NSPage.m @@ -32,7 +32,7 @@ #ifdef __WIN32__ #include #endif -#ifndef __MINGW__ +#if HAVE_UNISTD_H #include #endif #include diff --git a/Source/NSPipe.m b/Source/NSPipe.m index 85eb416f1..7b6fd9e68 100644 --- a/Source/NSPipe.m +++ b/Source/NSPipe.m @@ -29,7 +29,9 @@ #include #include #include +#if HAVE_UNISTD_H #include +#endif @implementation NSPipe diff --git a/Source/NSProcessInfo.m b/Source/NSProcessInfo.m index 16313b49a..bd0faf47a 100644 --- a/Source/NSProcessInfo.m +++ b/Source/NSProcessInfo.m @@ -56,7 +56,9 @@ #include #include +#if HAVE_UNISTD_H #include +#endif #ifdef HAVE_STRERROR #include diff --git a/Source/NSRunLoop.m b/Source/NSRunLoop.m index d9d1cf90e..cbd49a6c4 100644 --- a/Source/NSRunLoop.m +++ b/Source/NSRunLoop.m @@ -50,6 +50,9 @@ #if HAVE_POLL_H #include #endif +#if HAVE_UNISTD_H +#include +#endif #include #include #include /* for memset() */ @@ -565,10 +568,6 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) unsigned i; i = GSIArrayCount(watchers); - if (i == 0) - { - return NO; - } /* * Get ready to listen to file descriptors. @@ -879,14 +878,10 @@ if (0) { fd_set exception_fds; // Mask for exception fds. fd_set write_fds; // Mask for write-ready fds. int num_inputs = 0; - int fdEnd = 0; + int fdEnd = -1; unsigned i; i = GSIArrayCount(watchers); - if (i == 0) - { - return NO; - } /* Find out how much time we should wait, and set SELECT_TIMEOUT. */ if (milliseconds == 0) @@ -1013,6 +1008,7 @@ if (0) { timeout.tv_usec = 0; select_timeout = &timeout; } + select_return = select (fdEnd, &read_fds, &write_fds, &exception_fds, select_timeout); @@ -1839,9 +1835,10 @@ if (0) { /** * Listen to input sources.
- * If limit_date is nil, then don't wait; just poll inputs and return, - * otherwise block until input is available or until all input limit dates - * have passed (whichever comes first).
+ * If limit_date is nil or in the past, then don't wait; + * just poll inputs and return, + * otherwise block until input is available or until the + * earliest limit date has passed (whichever comes first).
* If the supplied mode is nil, uses NSDefaultRunLoopMode. */ - (void) acceptInputForMode: (NSString*)mode @@ -1869,9 +1866,45 @@ if (0) { if (context == nil || (watchers = context->watchers) == 0 || (i = GSIArrayCount(watchers)) == 0) { - GSCheckTasks(); - GSNotifyASAP(); NSDebugMLLog(@"NSRunLoop", @"no inputs in mode %@", mode); + GSNotifyASAP(); + GSNotifyIdle(); + ti = [limit_date timeIntervalSinceNow]; + /* + * Pause for as long as possible (up to the limit date) + */ + if (ti > 0.0) + { +#if defined(HAVE_USLEEP) + if (ti >= INT_MAX / 1000000) + { + ti = INT_MAX; + } + else + { + ti *= 1000000; + } + usleep (ti); +#elif defined(__MINGW__) + if (ti >= INT_MAX / 1000) + { + ti = INT_MAX; + } + else + { + ti *= 1000; + } + Sleep (ti); +#else + sleep (ti); +#endif + } + GSCheckTasks(); + if (context != nil) + { + [self _checkPerformers: context]; + } + GSNotifyASAP(); _currentMode = savedMode; RELEASE(arp); NS_VOIDRETURN; diff --git a/Source/NSString.m b/Source/NSString.m index 599235f55..b15f2c46d 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -67,7 +67,9 @@ #include #include #include +#if HAVE_UNISTD_H #include +#endif #include #include #include diff --git a/Source/NSTask.m b/Source/NSTask.m index 90320b460..ab86cebeb 100644 --- a/Source/NSTask.m +++ b/Source/NSTask.m @@ -45,7 +45,9 @@ #include #include +#if HAVE_UNISTD_H #include +#endif #include #ifdef __FreeBSD__ #include diff --git a/Source/NSThread.m b/Source/NSThread.m index 22254fb7a..2d23da2d3 100644 --- a/Source/NSThread.m +++ b/Source/NSThread.m @@ -32,7 +32,9 @@ #include #include +#if HAVE_UNISTD_H #include +#endif #include #include #include diff --git a/Source/NSUser.m b/Source/NSUser.m index 5be49d186..73948b060 100644 --- a/Source/NSUser.m +++ b/Source/NSUser.m @@ -40,7 +40,7 @@ #include #include // for getenv() -#if !defined(__WIN32__) +#if HAVE_UNISTD_H #include // for getlogin() #endif #if HAVE_PWD_H diff --git a/Source/UnixFileHandle.m b/Source/UnixFileHandle.m index 4e04ea47d..2fc47c050 100644 --- a/Source/UnixFileHandle.m +++ b/Source/UnixFileHandle.m @@ -59,7 +59,9 @@ #endif #include #include +#if HAVE_UNISTD_H #include +#endif #include /* diff --git a/Source/WindowsFileHandle.m b/Source/WindowsFileHandle.m index f81826a31..2dd2aeab8 100644 --- a/Source/WindowsFileHandle.m +++ b/Source/WindowsFileHandle.m @@ -43,7 +43,9 @@ #include #include #include +#if HAVE_UNISTD_H #include +#endif #include // Maximum data in single I/O operation