-\begin{code}
-hPutFS :: Handle -> FastString -> IO ()
-#if __GLASGOW_HASKELL__ <= 302
-hPutFS handle (FastString _ l# ba#) =
- if l# ==# 0# then
- return ()
- else
- readHandle handle >>= \ htype ->
- case htype of
- ErrorHandle ioError ->
- writeHandle handle htype >>
- fail ioError
- ClosedHandle ->
- writeHandle handle htype >>
- fail MkIOError(handle,IllegalOperation,"handle is closed")
- SemiClosedHandle _ _ ->
- writeHandle handle htype >>
- fail MkIOError(handle,IllegalOperation,"handle is closed")
- ReadHandle _ _ _ ->
- writeHandle handle htype >>
- fail MkIOError(handle,IllegalOperation,"handle is not open for writing")
- other ->
- let fp = filePtr htype in
- -- here we go..
- _ccall_ writeFile (ByteArray ((error "")::(Int,Int)) ba#) fp (I# l#) >>= \rc ->
- if rc==0 then
- return ()
- else
- constructError "hPutFS" >>= \ err ->
- fail err
-hPutFS handle (CharStr a# l#) =
- if l# ==# 0# then
- return ()
- else
- readHandle handle >>= \ htype ->
- case htype of
- ErrorHandle ioError ->
- writeHandle handle htype >>
- fail ioError
- ClosedHandle ->
- writeHandle handle htype >>
- fail MkIOError(handle,IllegalOperation,"handle is closed")
- SemiClosedHandle _ _ ->
- writeHandle handle htype >>
- fail MkIOError(handle,IllegalOperation,"handle is closed")
- ReadHandle _ _ _ ->
- writeHandle handle htype >>
- fail MkIOError(handle,IllegalOperation,"handle is not open for writing")
- other ->
- let fp = filePtr htype in
- -- here we go..
- _ccall_ writeFile (A# a#) fp (I# l#) >>= \rc ->
- if rc==0 then
- return ()
- else
- constructError "hPutFS" >>= \ err ->
- fail err
+-- this is our own version of hPutBuf for FastStrings, because in
+-- 5.04+ we don't have mutable byte arrays and therefore hPutBufBA.
+-- The closest is hPutArray in Data.Array.IO, but that does some extra
+-- range checks that we want to avoid here.
+
+foreign import ccall unsafe "__hscore_memcpy_dst_off"
+ memcpy_baoff_ba :: RawBuffer -> Int -> RawBuffer -> CSize -> IO (Ptr ())