- Fix up mingw build after changes to hGetBuf etc.
I don't think that hGetBufNonBlocking works correctly on Windows,
because there doesn't seem to be a non-blocking read primitive. I
haven't tested it, however.
- Clean up Unix versions of the low-level read/write functions in
Handle.hs. Now that these aren't used on Windows, they can be
made simpler.
writeRawBuffer, writeRawBufferPtr,
unlockFile,
writeRawBuffer, writeRawBufferPtr,
unlockFile,
- {- ought to be unnecessary, but just in case.. -}
- write_off, write_rawBuffer,
- read_off, read_rawBuffer,
-
ioe_closedHandle, ioe_EOF, ioe_notReadable, ioe_notWritable,
stdin, stdout, stderr,
ioe_closedHandle, ioe_EOF, ioe_notReadable, ioe_notWritable,
stdin, stdout, stderr,
readRawBuffer :: String -> FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
readRawBuffer loc fd is_stream buf off len =
throwErrnoIfMinus1RetryMayBlock loc
readRawBuffer :: String -> FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
readRawBuffer loc fd is_stream buf off len =
throwErrnoIfMinus1RetryMayBlock loc
- (read_rawBuffer fd is_stream buf off len)
+ (read_rawBuffer fd buf off len)
(threadWaitRead fd)
readRawBufferNoBlock :: String -> FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
readRawBufferNoBlock loc fd is_stream buf off len =
throwErrnoIfMinus1RetryOnBlock loc
(threadWaitRead fd)
readRawBufferNoBlock :: String -> FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
readRawBufferNoBlock loc fd is_stream buf off len =
throwErrnoIfMinus1RetryOnBlock loc
- (read_rawBuffer fd is_stream buf off len)
+ (read_rawBuffer fd buf off len)
(return 0)
readRawBufferPtr :: String -> FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
readRawBufferPtr loc fd is_stream buf off len =
throwErrnoIfMinus1RetryMayBlock loc
(return 0)
readRawBufferPtr :: String -> FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
readRawBufferPtr loc fd is_stream buf off len =
throwErrnoIfMinus1RetryMayBlock loc
- (read_off fd is_stream buf off len)
+ (read_off fd buf off len)
(threadWaitRead fd)
writeRawBuffer :: String -> FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
writeRawBuffer loc fd is_stream buf off len =
throwErrnoIfMinus1RetryMayBlock loc
(threadWaitRead fd)
writeRawBuffer :: String -> FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
writeRawBuffer loc fd is_stream buf off len =
throwErrnoIfMinus1RetryMayBlock loc
- (write_rawBuffer (fromIntegral fd) is_stream buf off len)
+ (write_rawBuffer (fromIntegral fd) buf off len)
(threadWaitWrite fd)
writeRawBufferPtr :: String -> FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
writeRawBufferPtr loc fd is_stream buf off len =
throwErrnoIfMinus1RetryMayBlock loc
(threadWaitWrite fd)
writeRawBufferPtr :: String -> FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
writeRawBufferPtr loc fd is_stream buf off len =
throwErrnoIfMinus1RetryMayBlock loc
- (write_off (fromIntegral fd) is_stream buf off len)
+ (write_off (fromIntegral fd) buf off len)
(threadWaitWrite fd)
foreign import ccall unsafe "__hscore_PrelHandle_read"
(threadWaitWrite fd)
foreign import ccall unsafe "__hscore_PrelHandle_read"
- read_rawBuffer :: FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
+ read_rawBuffer :: FD -> RawBuffer -> Int -> CInt -> IO CInt
foreign import ccall unsafe "__hscore_PrelHandle_read"
foreign import ccall unsafe "__hscore_PrelHandle_read"
- read_off :: FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
+ read_off :: FD -> Ptr CChar -> Int -> CInt -> IO CInt
foreign import ccall unsafe "__hscore_PrelHandle_write"
foreign import ccall unsafe "__hscore_PrelHandle_write"
- write_rawBuffer :: CInt -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
+ write_rawBuffer :: CInt -> RawBuffer -> Int -> CInt -> IO CInt
foreign import ccall unsafe "__hscore_PrelHandle_write"
foreign import ccall unsafe "__hscore_PrelHandle_write"
- write_off :: CInt -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
+ write_off :: CInt -> Ptr CChar -> Int -> CInt -> IO CInt
#else
readRawBuffer :: String -> FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
#else
readRawBuffer :: String -> FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
ioError (errnoToIOError loc (Errno (fromIntegral rc)) Nothing Nothing)
else return (fromIntegral l)
ioError (errnoToIOError loc (Errno (fromIntegral rc)) Nothing Nothing)
else return (fromIntegral l)
+readRawBufferNoBlock :: String -> FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
+readRawBufferNoBlock loc fd is_stream buf off len = do
+ (l, rc) <- asyncReadBA fd (if is_stream then 1 else 0) (fromIntegral len) off buf
+ if l == (-1)
+ then
+ ioError (errnoToIOError loc (Errno (fromIntegral rc)) Nothing Nothing)
+ else return (fromIntegral l)
+
readRawBufferPtr :: String -> FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
readRawBufferPtr loc fd is_stream buf off len = do
(l, rc) <- asyncRead fd (if is_stream then 1 else 0) (fromIntegral len) (buf `plusPtr` off)
readRawBufferPtr :: String -> FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
readRawBufferPtr loc fd is_stream buf off len = do
(l, rc) <- asyncRead fd (if is_stream then 1 else 0) (fromIntegral len) (buf `plusPtr` off)
then
ioError (errnoToIOError loc (Errno (fromIntegral rc)) Nothing Nothing)
else return (fromIntegral l)
then
ioError (errnoToIOError loc (Errno (fromIntegral rc)) Nothing Nothing)
else return (fromIntegral l)
-
-foreign import ccall unsafe "__hscore_PrelHandle_read"
- read_rawBuffer :: FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
-
-foreign import ccall unsafe "__hscore_PrelHandle_read"
- read_off :: FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
-
-foreign import ccall unsafe "__hscore_PrelHandle_write"
- write_rawBuffer :: CInt -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
-
-foreign import ccall unsafe "__hscore_PrelHandle_write"
- write_off :: CInt -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
-
#endif
-- ---------------------------------------------------------------------------
#endif
-- ---------------------------------------------------------------------------
import GHC.List
import GHC.Exception ( ioError, catch )
import GHC.List
import GHC.Exception ( ioError, catch )
+#ifdef mingw32_TARGET_OS
+import GHC.Conc
+#endif
+
-- ---------------------------------------------------------------------------
-- Simple input operations
-- ---------------------------------------------------------------------------
-- Simple input operations
-__hscore_PrelHandle_write( HsInt fd, HsBool isSock, HsAddr ptr,
- HsInt off, int sz )
+__hscore_PrelHandle_write( HsInt fd, HsAddr ptr, HsInt off, int sz )
-#if defined(mingw32_TARGET_OS) || defined(_MSC_VER)
- if (isSock) {
- return send(fd,(char *)ptr + off, sz, 0);
- }
-#endif
return write(fd,(char *)ptr + off, sz);
}
INLINE HsInt
return write(fd,(char *)ptr + off, sz);
}
INLINE HsInt
-__hscore_PrelHandle_read( HsInt fd, HsBool isSock, HsAddr ptr,
- HsInt off, int sz )
+__hscore_PrelHandle_read( HsInt fd, HsAddr ptr, HsInt off, int sz )
-#if defined(mingw32_TARGET_OS) || defined(_MSC_VER)
- if (isSock) {
- return recv(fd,(char *)ptr + off, sz, 0);
- }
-#endif
return read(fd,(char *)ptr + off, sz);
}
return read(fd,(char *)ptr + off, sz);
}