[project @ 1999-09-17 09:38:33 by sof]
authorsof <unknown>
Fri, 17 Sep 1999 09:38:35 +0000 (09:38 +0000)
committersof <unknown>
Fri, 17 Sep 1999 09:38:35 +0000 (09:38 +0000)
Non-blocking I/O isn't supported on 'pure' Win32 platforms.

ghc/lib/misc/cbits/acceptSocket.c
ghc/lib/misc/cbits/createSocket.c
ghc/lib/std/PrelHandle.lhs
ghc/lib/std/cbits/openFile.c

index 3995795..9fb0e56 100644 (file)
@@ -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;
 }
index 297fcb2..9a8ccaa 100644 (file)
@@ -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;
 }
index ba3cc2c..fc03be0 100644 (file)
@@ -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
index 5f24491..ca34e49 100644 (file)
@@ -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.