X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FBinary.hs;h=69413701e87f4b9ca004c3e2a0d8349ebdf2c3da;hb=2eb04ca0f8d0ec72b417cddc60672c696b4a3daa;hp=1d5ab0e5ed83532fb66422f3620691ab60ede7cc;hpb=b00b5bc04ff36a551552470060064f0b7d84ca30;p=ghc-hetmet.git diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs index 1d5ab0e..6941370 100644 --- a/compiler/utils/Binary.hs +++ b/compiler/utils/Binary.hs @@ -1,6 +1,6 @@ {-# OPTIONS -cpp #-} -- --- (c) The University of Glasgow 2002 +-- (c) The University of Glasgow 2002-2006 -- -- Binary I/O library, with special tweaks for GHC -- @@ -59,7 +59,7 @@ import Unique import Panic import UniqFM import FastMutInt -import PackageConfig ( PackageId, packageIdFS, fsToPackageId ) +import PackageConfig import Foreign import Data.Array.IO @@ -202,12 +202,6 @@ writeBinMem (BinMem _ ix_r sz_r arr_r) fn = do arr <- readIORef arr_r ix <- readFastMutInt ix_r hPutArray h arr ix -#if __GLASGOW_HASKELL__ <= 500 - -- workaround a bug in old implementation of hPutBuf (it doesn't - -- set the FILEOBJ_RW_WRITTEN flag on the file object, so the file doens't - -- get flushed properly). Adding an extra '\0' doens't do any harm. - hPutChar h '\0' -#endif hClose h readBinMem :: FilePath -> IO BinHandle @@ -272,11 +266,7 @@ getWord8 (BinMem _ ix_r sz_r arr_r) = do ix <- readFastMutInt ix_r sz <- readFastMutInt sz_r when (ix >= sz) $ -#if __GLASGOW_HASKELL__ <= 408 - throw (mkIOError eofErrorType "Data.Binary.getWord8" Nothing Nothing) -#else ioError (mkIOError eofErrorType "Data.Binary.getWord8" Nothing Nothing) -#endif arr <- readIORef arr_r w <- unsafeRead arr ix writeFastMutInt ix_r (ix+1) @@ -516,23 +506,12 @@ freezeByteArray arr = IO $ \s -> (# s, BA arr #) } writeByteArray :: MutableByteArray# RealWorld -> Int# -> Word8 -> IO () - -#if __GLASGOW_HASKELL__ < 503 -writeByteArray arr i w8 = IO $ \s -> - case word8ToWord w8 of { W# w# -> - case writeCharArray# arr i (chr# (word2Int# w#)) s of { s -> - (# s , () #) }} -#else writeByteArray arr i (W8# w) = IO $ \s -> case writeWord8Array# arr i w s of { s -> (# s, () #) } -#endif -#if __GLASGOW_HASKELL__ < 503 -indexByteArray a# n# = fromIntegral (I# (ord# (indexCharArray# a# n#))) -#else +indexByteArray :: ByteArray# -> Int# -> Word8 indexByteArray a# n# = W8# (indexWord8Array# a# n#) -#endif instance (Integral a, Binary a) => Binary (Ratio a) where put_ bh (a :% b) = do put_ bh a; put_ bh b @@ -681,16 +660,6 @@ getFS bh = do -- go 0 -#if __GLASGOW_HASKELL__ < 600 -mallocForeignPtrBytes :: Int -> IO (ForeignPtr a) -mallocForeignPtrBytes n = do - r <- mallocBytes n - newForeignPtr r (finalizerFree r) - -foreign import ccall unsafe "stdlib.h free" - finalizerFree :: Ptr a -> IO () -#endif - instance Binary PackageId where put_ bh pid = put_ bh (packageIdFS pid) get bh = do { fs <- get bh; return (fsToPackageId fs) }