diff options
| author | simonmar <unknown> | 2001-12-17 10:12:34 +0000 |
|---|---|---|
| committer | simonmar <unknown> | 2001-12-17 10:12:34 +0000 |
| commit | 2088394ebb0f619b4d481159fa3d263724b33a8e (patch) | |
| tree | 09decdda8eb6f5954e42e10c89dfdf3353cf7e45 /ghc/lib/std/cbits/inputReady.c | |
| parent | 02b476c45a103751687a8d87723ac955f6b460a0 (diff) | |
| download | haskell-2088394ebb0f619b4d481159fa3d263724b33a8e.tar.gz | |
[project @ 2001-12-17 10:12:34 by simonmar]
slightly clearer fix for previous bogon, and re-indent the function
Diffstat (limited to 'ghc/lib/std/cbits/inputReady.c')
| -rw-r--r-- | ghc/lib/std/cbits/inputReady.c | 82 |
1 files changed, 42 insertions, 40 deletions
diff --git a/ghc/lib/std/cbits/inputReady.c b/ghc/lib/std/cbits/inputReady.c index 6014d67309..0a1a0ee6e1 100644 --- a/ghc/lib/std/cbits/inputReady.c +++ b/ghc/lib/std/cbits/inputReady.c @@ -16,50 +16,52 @@ int inputReady(int fd, int msecs, int isSock) { - if + if #ifndef mingw32_TARGET_OS ( 1 ) { #else ( isSock ) { #endif - int maxfd, ready; - fd_set rfd; - struct timeval tv; - - FD_ZERO(&rfd); - FD_SET(fd, &rfd); - - /* select() will consider the descriptor set in the range of 0 to - * (maxfd-1) - */ - maxfd = fd + 1; - tv.tv_sec = msecs / 1000; - tv.tv_usec = msecs % 1000; - - while ((ready = select(maxfd, &rfd, NULL, NULL, &tv)) < 0 ) { - if (errno != EINTR ) { - return -1; - } - } - - /* 1 => Input ready, 0 => not ready, -1 => error */ - return (ready); + int maxfd, ready; + fd_set rfd; + struct timeval tv; + + FD_ZERO(&rfd); + FD_SET(fd, &rfd); + + /* select() will consider the descriptor set in the range of 0 to + * (maxfd-1) + */ + maxfd = fd + 1; + tv.tv_sec = msecs / 1000; + tv.tv_usec = msecs % 1000; + + while ((ready = select(maxfd, &rfd, NULL, NULL, &tv)) < 0 ) { + if (errno != EINTR ) { + return -1; + } + } + + /* 1 => Input ready, 0 => not ready, -1 => error */ + return (ready); + } #ifdef mingw32_TARGET_OS - } else { - DWORD rc; - HANDLE hFile = (HANDLE)_get_osfhandle(fd); - - rc = MsgWaitForMultipleObjects( 1, - &hFile, - FALSE, /* wait all */ - msecs, /*millisecs*/ - QS_ALLEVENTS); - - /* 1 => Input ready, 0 => not ready, -1 => error */ - switch (rc) { - case WAIT_TIMEOUT: return 0; - case WAIT_OBJECT_0: return 1; - default: return -1; - } + else { + DWORD rc; + HANDLE hFile = (HANDLE)_get_osfhandle(fd); + + rc = MsgWaitForMultipleObjects( 1, + &hFile, + FALSE, /* wait all */ + msecs, /*millisecs*/ + QS_ALLEVENTS); + + /* 1 => Input ready, 0 => not ready, -1 => error */ + switch (rc) { + case WAIT_TIMEOUT: return 0; + case WAIT_OBJECT_0: return 1; + default: return -1; + } + } #endif - }} +} |
