From 215280e9692c0b2063b83342b0e900c8028a8eb7 Mon Sep 17 00:00:00 2001 From: sof Date: Thu, 27 Dec 2001 09:28:11 +0000 Subject: [PATCH] [project @ 2001-12-27 09:28:10 by sof] - removed PrelPosix.c_read, PrelPosix.c_write - added Ptr and RawBuffer versions of PrelHandle.write_off, and PrelHandle.read_off and exported them, i.e., PrelHandle now exports: read_off_ba :: FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt read_off :: FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt write_off_ba :: CInt -> Bool -> RawBuffer -> Int -> CInt -> IO CInt write_off :: CInt -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt - make hPutChar (win)socket friendly. --- ghc/lib/std/PrelHandle.hs | 22 ++++++++++++++-------- ghc/lib/std/PrelIO.hs | 8 ++++---- ghc/lib/std/PrelPosix.hsc | 6 ------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ghc/lib/std/PrelHandle.hs b/ghc/lib/std/PrelHandle.hs index 5be5c59..0e9286c 100644 --- a/ghc/lib/std/PrelHandle.hs +++ b/ghc/lib/std/PrelHandle.hs @@ -4,7 +4,7 @@ #undef DEBUG -- ----------------------------------------------------------------------------- --- $Id: PrelHandle.hs,v 1.6 2001/11/27 01:53:23 sof Exp $ +-- $Id: PrelHandle.hs,v 1.7 2001/12/27 09:28:10 sof Exp $ -- -- (c) The University of Glasgow, 1994-2001 -- @@ -16,7 +16,8 @@ module PrelHandle ( newEmptyBuffer, allocateBuffer, readCharFromBuffer, writeCharIntoBuffer, flushWriteBufferOnly, flushWriteBuffer, flushReadBuffer, fillReadBuffer, - read_off, + read_off, read_off_ba, + write_off, write_off_ba, ioe_closedHandle, ioe_EOF, ioe_notReadable, ioe_notWritable, @@ -424,8 +425,8 @@ flushWriteBuffer fd is_stream buf@Buffer{ bufBuf=b, bufRPtr=r, bufWPtr=w } = do then return (buf{ bufRPtr=0, bufWPtr=0 }) else do res <- throwErrnoIfMinus1RetryMayBlock "flushWriteBuffer" - (write_off (fromIntegral fd) is_stream b (fromIntegral r) - (fromIntegral bytes)) + (write_off_ba (fromIntegral fd) is_stream b (fromIntegral r) + (fromIntegral bytes)) (threadWaitWrite fd) let res' = fromIntegral res if res' < bytes @@ -433,8 +434,10 @@ flushWriteBuffer fd is_stream buf@Buffer{ bufBuf=b, bufRPtr=r, bufWPtr=w } = do else return buf{ bufRPtr=0, bufWPtr=0 } foreign import "prel_PrelHandle_write" unsafe - write_off :: CInt -> Bool -> RawBuffer -> Int -> CInt -> IO CInt + write_off_ba :: CInt -> Bool -> RawBuffer -> Int -> CInt -> IO CInt +foreign import "prel_PrelHandle_write" unsafe + write_off :: CInt -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt fillReadBuffer :: FD -> Bool -> Bool -> Buffer -> IO Buffer fillReadBuffer fd is_line is_stream @@ -458,7 +461,7 @@ fillReadBufferLoop fd is_line is_stream buf b w size = do puts ("fillReadBufferLoop: bytes = " ++ show bytes ++ "\n") #endif res <- throwErrnoIfMinus1RetryMayBlock "fillReadBuffer" - (read_off fd is_stream b (fromIntegral w) (fromIntegral bytes)) + (read_off_ba fd is_stream b (fromIntegral w) (fromIntegral bytes)) (threadWaitRead fd) let res' = fromIntegral res #ifdef DEBUG_DUMP @@ -473,7 +476,10 @@ fillReadBufferLoop fd is_line is_stream buf b w size = do else return buf{ bufRPtr=0, bufWPtr=w+res' } foreign import "prel_PrelHandle_read" unsafe - read_off :: FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt + read_off_ba :: FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt + +foreign import "prel_PrelHandle_read" unsafe + read_off :: FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt -- --------------------------------------------------------------------------- -- Standard Handles @@ -1202,7 +1208,7 @@ ioeGetFileName _ = error "IO.ioeGetFileName: not an IO error" #ifdef DEBUG_DUMP puts :: String -> IO () -puts s = withCString s $ \cstr -> do c_write 1 cstr (fromIntegral (length s)) +puts s = withCString s $ \cstr -> do write_off_ba 1 False cstr 0 (fromIntegral (length s)) return () #endif diff --git a/ghc/lib/std/PrelIO.hs b/ghc/lib/std/PrelIO.hs index 5cf8746..335d361 100644 --- a/ghc/lib/std/PrelIO.hs +++ b/ghc/lib/std/PrelIO.hs @@ -3,7 +3,7 @@ #undef DEBUG_DUMP -- ----------------------------------------------------------------------------- --- $Id: PrelIO.hs,v 1.5 2001/12/03 20:59:08 sof Exp $ +-- $Id: PrelIO.hs,v 1.6 2001/12/27 09:28:11 sof Exp $ -- -- (c) The University of Glasgow, 1992-2001 -- @@ -171,7 +171,7 @@ hGetChar handle = -- make use of the minimal buffer we already have let raw = bufBuf buf r <- throwErrnoIfMinus1RetryMayBlock "hGetChar" - (read_off (fromIntegral fd) (haIsStream handle_) raw 0 1) + (read_off_ba (fromIntegral fd) (haIsStream handle_) raw 0 1) (threadWaitRead fd) if r == 0 then ioe_EOF @@ -351,7 +351,7 @@ lazyRead' h handle_ = do -- make use of the minimal buffer we already have let raw = bufBuf buf r <- throwErrnoIfMinus1RetryMayBlock "lazyRead" - (read_off (fromIntegral fd) (haIsStream handle_) raw 0 1) + (read_off_ba (fromIntegral fd) (haIsStream handle_) raw 0 1) (threadWaitRead fd) if r == 0 then do handle_ <- hClose_help handle_ @@ -410,7 +410,7 @@ hPutChar handle c = NoBuffering -> withObject (castCharToCChar c) $ \buf -> throwErrnoIfMinus1RetryMayBlock_ "hPutChar" - (c_write (fromIntegral fd) buf 1) + (write_off (fromIntegral fd) (haIsStream handle_) buf 0 1) (threadWaitWrite fd) diff --git a/ghc/lib/std/PrelPosix.hsc b/ghc/lib/std/PrelPosix.hsc index b558b47..5468061 100644 --- a/ghc/lib/std/PrelPosix.hsc +++ b/ghc/lib/std/PrelPosix.hsc @@ -284,12 +284,6 @@ foreign import "closesocket" unsafe foreign import "lseek" unsafe c_lseek :: CInt -> COff -> CInt -> IO COff -foreign import "write" unsafe - c_write :: CInt -> Ptr CChar -> CSize -> IO CSsize - -foreign import "read" unsafe - c_read :: CInt -> Ptr CChar -> CSize -> IO CSsize - #ifndef mingw32_TARGET_OS foreign import "fcntl" unsafe fcntl_read :: CInt -> CInt -> IO CInt -- 1.7.10.4