import PackedString ( nilPS, packCBytesST, unpackPS )
import PrelBase
import GHC
-import Foreign ( makeForeignObj )
+import Foreign ( makeForeignObj, writeForeignObj )
\end{code}
%*********************************************************
then return nilPS
else packCBytesST bytes buf) >>= \ some ->
if bytes < 0 then
- makeForeignObj ``NULL'' ``&freeFile'' >>= \ null_fp ->
- ioToST (writeHandle handle (SemiClosedHandle null_fp (``NULL'', 0)))
- >>
_ccall_ free buf >>= \ () ->
_ccall_ closeFile fp >>
+#ifndef PAR
+ writeForeignObj fp ``NULL'' >>
+ ioToST (writeHandle handle (SemiClosedHandle fp (``NULL'', 0))) >>
+#else
+ ioToST (writeHandle handle (SemiClosedHandle ``NULL'' (``NULL'', 0))) >>
+#endif
returnPrimIO (unpackPS some)
else
ioToST (writeHandle handle htype) >>
then return nilPS
else packCBytesST bytes buf) >>= \ some ->
if bytes < 0 then
- makeForeignObj ``NULL'' ``&freeFile'' >>= \ null_fp ->
- ioToST (writeHandle handle (SemiClosedHandle null_fp (``NULL'', 0)))
- >>
_ccall_ free buf >>= \ () ->
_ccall_ closeFile fp >>
+#ifndef PAR
+ writeForeignObj fp ``NULL'' >>
+ ioToST (writeHandle handle (SemiClosedHandle fp (``NULL'', 0))) >>
+#else
+ ioToST (writeHandle handle (SemiClosedHandle ``NULL'' (``NULL'', 0))) >>
+#endif
returnPrimIO (unpackPS some)
else
ioToST (writeHandle handle htype) >>
SemiClosedHandle fp buf_info ->
_ccall_ readChar fp >>= \ char ->
if char == ``EOF'' then
- makeForeignObj ``NULL'' ``&freeFile'' >>= \ null_fp ->
- ioToST (writeHandle handle (SemiClosedHandle null_fp buf_info))
- >>
_ccall_ closeFile fp >>
+#ifndef PAR
+ writeForeignObj fp ``NULL'' >>
+ ioToST (writeHandle handle (SemiClosedHandle fp (``NULL'', 0))) >>
+#else
+ ioToST (writeHandle handle (SemiClosedHandle ``NULL'' (``NULL'', 0))) >>
+#endif
returnPrimIO ""
else
ioToST (writeHandle handle htype) >>
else
constructErrorAndFail "hPutStr"
where
+#ifndef PAR
writeLines :: ForeignObj -> String -> PrimIO Bool
+#else
+ writeLines :: Addr -> String -> PrimIO Bool
+#endif
writeLines = writeChunks ``BUFSIZ'' True
+#ifndef PAR
writeBlocks :: ForeignObj -> Int -> String -> PrimIO Bool
+#else
+ writeBlocks :: Addr -> Int -> String -> PrimIO Bool
+#endif
writeBlocks fp size s = writeChunks size False fp s
{-
a whole lot quicker. -- SOF 3/96
-}
+#ifndef PAR
writeChunks :: Int -> Bool -> ForeignObj -> String -> PrimIO Bool
-
+#else
+ writeChunks :: Int -> Bool -> Addr -> String -> PrimIO Bool
+#endif
writeChunks (I# bufLen) chopOnNewLine fp s =
newCharArray (0,I# bufLen) >>= \ arr@(MutableByteArray _ arr#) ->
let
in
shoveString 0# s
+#ifndef PAR
writeChars :: ForeignObj -> String -> PrimIO Bool
+#else
+ writeChars :: Addr -> String -> PrimIO Bool
+#endif
writeChars fp "" = returnPrimIO True
writeChars fp (c:cs) =
_ccall_ filePutc fp (ord c) >>= \ rc ->