diff options
author | sof <unknown> | 2001-12-03 20:59:08 +0000 |
---|---|---|
committer | sof <unknown> | 2001-12-03 20:59:08 +0000 |
commit | 1948094b82efa68b8aacad52b9b6322bc76f762a (patch) | |
tree | 7cf53b10cd26feb396c6a31560c20f722bde835c /ghc/lib/std/cbits/inputReady.c | |
parent | d765456fe89060c148e8f875f7d3ed8dda9fd4e6 (diff) | |
download | haskell-1948094b82efa68b8aacad52b9b6322bc76f762a.tar.gz |
[project @ 2001-12-03 20:59:08 by sof]
Support IO.hWaitForInput on Win32 platforms (on file and socket handles).
Diffstat (limited to 'ghc/lib/std/cbits/inputReady.c')
-rw-r--r-- | ghc/lib/std/cbits/inputReady.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/ghc/lib/std/cbits/inputReady.c b/ghc/lib/std/cbits/inputReady.c index 69737c583b..bf86afb9a0 100644 --- a/ghc/lib/std/cbits/inputReady.c +++ b/ghc/lib/std/cbits/inputReady.c @@ -1,7 +1,7 @@ /* * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998 * - * $Id: inputReady.c,v 1.9 2001/08/14 13:40:08 sewardj Exp $ + * $Id: inputReady.c,v 1.10 2001/12/03 20:59:08 sof Exp $ * * hReady Runtime Support */ @@ -16,17 +16,17 @@ * *character* from this file object without blocking?' */ int -inputReady(int fd, int msecs) +inputReady(int fd, int msecs, int isSock) { + if #ifndef mingw32_TARGET_OS + ( 1 ) { +#else + ( isSock ) { int maxfd, ready; fd_set rfd; struct timeval tv; -#endif -#ifdef mingw32_TARGET_OS - return 1; -#else FD_ZERO(&rfd); FD_SET(fd, &rfd); @@ -45,6 +45,21 @@ inputReady(int fd, int msecs) /* 1 => Input ready, 0 => not ready, -1 => error */ return (ready); - +#endif +#ifdef mingw32_TARGET_OS + } else { + DWORD rc; + HANDLE hFile = (HANDLE)_get_osfhandle(fd); + + rc = WaitForSingleObject( hFile, + msecs /*millisecs*/); + + /* 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 } |