diff --git a/ghc/lib/misc/cbits/acceptSocket.c b/ghc/lib/misc/cbits/acceptSocket.c index 3995795dd5d371a3a68587ff54f2f815cb0406ca..9fb0e563c51bb58b347d6d13851abf9a9f4d5170 100644 --- a/ghc/lib/misc/cbits/acceptSocket.c +++ b/ghc/lib/misc/cbits/acceptSocket.c @@ -55,8 +55,10 @@ acceptSocket(I_ sockfd, A_ peer, A_ addrlen) } /* set the non-blocking flag on this file descriptor */ +#if !defined(_WIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__) flags = fcntl(fd, F_GETFL); fcntl(fd, F_SETFL, flags | O_NONBLOCK); +#endif return fd; } diff --git a/ghc/lib/misc/cbits/createSocket.c b/ghc/lib/misc/cbits/createSocket.c index 297fcb21b5dec98d6525840c9d31567f12957ebc..9a8ccaa1cc112ce7522aae5c0c17d8cfaf51bb68 100644 --- a/ghc/lib/misc/cbits/createSocket.c +++ b/ghc/lib/misc/cbits/createSocket.c @@ -51,8 +51,10 @@ createSocket(I_ family, I_ type, I_ protocol) } /* set the non-blocking flag on this file descriptor */ +#if !defined(_WIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__) flags = fcntl(fd, F_GETFL); fcntl(fd, F_SETFL, flags | O_NONBLOCK); +#endif return (StgInt)fd; } diff --git a/ghc/lib/std/PrelHandle.lhs b/ghc/lib/std/PrelHandle.lhs index ba3cc2c2e16a28914aa5cc43204e3634b0884bbf..fc03be00b7742db18812c62b65e17c54da1ab589 100644 --- a/ghc/lib/std/PrelHandle.lhs +++ b/ghc/lib/std/PrelHandle.lhs @@ -216,7 +216,7 @@ stdout = unsafePerformIO (do case (rc::Int) of 0 -> newHandle (mkClosedHandle__) 1 -> do -#ifndef __CONCURRENT_HASKELL__ +#if !defined(__CONCURRENT_HASKELL__) || defined(mingw32_TARGET_OS) fo <- CCALL(openStdFile) (1::Int) (1::Int){-flush on close-} (0::Int){-writeable-} -- ConcHask: SAFE, won't block @@ -250,7 +250,7 @@ stdin = unsafePerformIO (do case (rc::Int) of 0 -> newHandle (mkClosedHandle__) 1 -> do -#ifndef __CONCURRENT_HASKELL__ +#if !defined(__CONCURRENT_HASKELL__) || defined(mingw32_TARGET_OS) fo <- CCALL(openStdFile) (0::Int) (0::Int){-don't flush on close -} (1::Int){-readable-} -- ConcHask: SAFE, won't block @@ -282,7 +282,7 @@ stderr = unsafePerformIO (do case (rc::Int) of 0 -> newHandle (mkClosedHandle__) 1 -> do -#ifndef __CONCURRENT_HASKELL__ +#if !defined(__CONCURRENT_HASKELL__) || defined(mingw32_TARGET_OS) fo <- CCALL(openStdFile) (2::Int) (1::Int){-flush on close-} (0::Int){-writeable-} -- ConcHask: SAFE, won't block diff --git a/ghc/lib/std/cbits/openFile.c b/ghc/lib/std/cbits/openFile.c index 5f24491fb6665fc99c2fe27fa048eeee5e4c76fd..ca34e4987582a4ad60766fd9a333f20134fab1d4 100644 --- a/ghc/lib/std/cbits/openFile.c +++ b/ghc/lib/std/cbits/openFile.c @@ -1,7 +1,7 @@ /* * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998 * - * $Id: openFile.c,v 1.7 1999/09/16 13:14:43 simonmar Exp $ + * $Id: openFile.c,v 1.8 1999/09/17 09:38:35 sof Exp $ * * openFile Runtime Support */ @@ -51,9 +51,15 @@ StgInt rd; fo->flags = flags | FILEOBJ_STD | ( rd ? FILEOBJ_READ : FILEOBJ_WRITE); fo->connectedTo = NULL; + /* MS Win32 CRT doesn't support fcntl() -- the workaround is to + start using 'completion ports', but I'm punting on implementing + support for using those. + */ +#if !defined(_WIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__) /* set the non-blocking flag on this file descriptor */ fd_flags = fcntl(fd, F_GETFL); fcntl(fd, F_SETFL, fd_flags | O_NONBLOCK); +#endif return fo; } @@ -78,6 +84,10 @@ StgInt flags; struct stat sb; IOFileObject* fo; +#if defined(_WIN32) && !(defined(__CYGWIN__) || defined(__CYGWIN32__)) +#define O_NONBLOCK 0 +#endif + /* * Since we aren't supposed to succeed when we're opening for writing and * there's another writer, we can't just do an open() with O_WRONLY.