Fix FD changes on Windows
authorIan Lynagh <igloo@earth.li>
Tue, 20 Feb 2007 09:15:16 +0000 (09:15 +0000)
committerIan Lynagh <igloo@earth.li>
Tue, 20 Feb 2007 09:15:16 +0000 (09:15 +0000)
GHC/Handle.hs
GHC/IO.hs

index 3b7a3dc..c2f3946 100644 (file)
@@ -599,7 +599,7 @@ readRawBufferNoBlock = readRawBuffer
 -- Async versions of the read/write primitives, for the non-threaded RTS
 
 asyncReadRawBuffer loc fd is_stream buf off len = do
-    (l, rc) <- asyncReadBA fd (if is_stream then 1 else 0) 
+    (l, rc) <- asyncReadBA (fromIntegral fd) (if is_stream then 1 else 0) 
                 (fromIntegral len) off buf
     if l == (-1)
       then 
@@ -607,7 +607,7 @@ asyncReadRawBuffer loc fd is_stream buf off len = do
       else return (fromIntegral l)
 
 asyncReadRawBufferPtr loc fd is_stream buf off len = do
-    (l, rc) <- asyncRead fd (if is_stream then 1 else 0) 
+    (l, rc) <- asyncRead (fromIntegral fd) (if is_stream then 1 else 0) 
                        (fromIntegral len) (buf `plusPtr` off)
     if l == (-1)
       then 
@@ -615,7 +615,7 @@ asyncReadRawBufferPtr loc fd is_stream buf off len = do
       else return (fromIntegral l)
 
 asyncWriteRawBuffer loc fd is_stream buf off len = do
-    (l, rc) <- asyncWriteBA fd (if is_stream then 1 else 0) 
+    (l, rc) <- asyncWriteBA (fromIntegral fd) (if is_stream then 1 else 0) 
                        (fromIntegral len) off buf
     if l == (-1)
       then 
@@ -623,7 +623,7 @@ asyncWriteRawBuffer loc fd is_stream buf off len = do
       else return (fromIntegral l)
 
 asyncWriteRawBufferPtr loc fd is_stream buf off len = do
-    (l, rc) <- asyncWrite fd (if is_stream then 1 else 0) 
+    (l, rc) <- asyncWrite (fromIntegral fd) (if is_stream then 1 else 0) 
                  (fromIntegral len) (buf `plusPtr` off)
     if l == (-1)
       then 
index 4d70295..ee1f2b7 100644 (file)
--- a/GHC/IO.hs
+++ b/GHC/IO.hs
@@ -730,7 +730,7 @@ writeChunkNonBlocking fd is_stream ptr bytes = loop 0 bytes
   loop off bytes | bytes <= 0 = return off
   loop off bytes = do
 #ifndef mingw32_HOST_OS
-    ssize <- c_write (fromIntegral fd) (ptr `plusPtr` off) (fromIntegral bytes)
+    ssize <- c_write fd (ptr `plusPtr` off) (fromIntegral bytes)
     let r = fromIntegral ssize :: Int
     if (r == -1)
       then do errno <- getErrno
@@ -739,7 +739,8 @@ writeChunkNonBlocking fd is_stream ptr bytes = loop 0 bytes
                 else throwErrno "writeChunk"
       else loop (off + r) (bytes - r)
 #else
-    (ssize, rc) <- asyncWrite fd (fromIntegral $ fromEnum is_stream)
+    (ssize, rc) <- asyncWrite (fromIntegral fd)
+                              (fromIntegral $ fromEnum is_stream)
                                 (fromIntegral bytes)
                                 (ptr `plusPtr` off)
     let r = fromIntegral ssize :: Int