projects
/
ghc-base.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Tweak the BufferedIO class to enable a memory-mapped file implementation
[ghc-base.git]
/
GHC
/
IO
/
Handle
/
Internals.hs
diff --git
a/GHC/IO/Handle/Internals.hs
b/GHC/IO/Handle/Internals.hs
index
ed32eaa
..
403407f
100644
(file)
--- a/
GHC/IO/Handle/Internals.hs
+++ b/
GHC/IO/Handle/Internals.hs
@@
-63,7
+63,6
@@
import qualified GHC.IO.BufferedIO as Buffered
import GHC.Real
import GHC.Base
import GHC.Real
import GHC.Base
-import GHC.List
import GHC.Exception
import GHC.Num ( Num(..) )
import GHC.Show
import GHC.Exception
import GHC.Num ( Num(..) )
import GHC.Show
@@
-73,9
+72,8
@@
import Data.Typeable
import Control.Monad
import Data.Maybe
import Foreign
import Control.Monad
import Data.Maybe
import Foreign
-import System.IO.Error
+-- import System.IO.Error
import System.Posix.Internals hiding (FD)
import System.Posix.Internals hiding (FD)
-import qualified System.Posix.Internals as Posix
#ifdef DEBUG_DUMP
import Foreign.C
#ifdef DEBUG_DUMP
import Foreign.C
@@
-207,7
+205,8
@@
checkWritableHandle act h_@Handle__{..}
buf <- readIORef haCharBuffer
writeIORef haCharBuffer buf{ bufState = WriteBuffer }
buf <- readIORef haByteBuffer
buf <- readIORef haCharBuffer
writeIORef haCharBuffer buf{ bufState = WriteBuffer }
buf <- readIORef haByteBuffer
- writeIORef haByteBuffer buf{ bufState = WriteBuffer }
+ buf' <- Buffered.emptyWriteBuffer haDevice buf
+ writeIORef haByteBuffer buf'
act h_
_other -> act h_
act h_
_other -> act h_
@@
-336,7
+335,7
@@
handleFinalizer fp m = do
_ -> do flushWriteBuffer handle_ `catchAny` \_ -> return ()
-- ignore errors and async exceptions, and close the
-- descriptor anyway...
_ -> do flushWriteBuffer handle_ `catchAny` \_ -> return ()
-- ignore errors and async exceptions, and close the
-- descriptor anyway...
- hClose_handle_ handle_
+ _ <- hClose_handle_ handle_
return ()
putMVar m (ioe_finalizedHandle fp)
return ()
putMVar m (ioe_finalizedHandle fp)
@@
-523,6
+522,7
@@
mkHandle dev filepath ha_type buffered mb_codec nl finalizer other_side = do
haBuffers = spares,
haEncoder = mb_encoder,
haDecoder = mb_decoder,
haBuffers = spares,
haEncoder = mb_encoder,
haDecoder = mb_decoder,
+ haCodec = mb_codec,
haInputNL = inputNL nl,
haOutputNL = outputNL nl,
haOtherSide = other_side
haInputNL = inputNL nl,
haOutputNL = outputNL nl,
haOtherSide = other_side
@@
-706,8
+706,8
@@
writeTextDevice h_@Handle__{..} cbuf = do
debugIO ("writeTextDevice after encoding: cbuf=" ++ summaryBuffer cbuf' ++
" bbuf=" ++ summaryBuffer bbuf')
debugIO ("writeTextDevice after encoding: cbuf=" ++ summaryBuffer cbuf' ++
" bbuf=" ++ summaryBuffer bbuf')
- Buffered.flushWriteBuffer haDevice bbuf'
- writeIORef haByteBuffer bbuf{bufL=0,bufR=0}
+ bbuf' <- Buffered.flushWriteBuffer haDevice bbuf'
+ writeIORef haByteBuffer bbuf'
if not (isEmptyBuffer cbuf')
then writeTextDevice h_ cbuf'
else return ()
if not (isEmptyBuffer cbuf')
then writeTextDevice h_ cbuf'
else return ()