diff --git a/binary.cabal b/binary.cabal index 288117eea189051d612f843d56b1afe7b9a30479..2808714efcf84138ece48a58264ad6ebdadeb7d0 100644 --- a/binary.cabal +++ b/binary.cabal @@ -39,7 +39,11 @@ source-repository head location: git://github.com/kolmodin/binary.git library - build-depends: base >= 4.5.0.0 && < 5, bytestring >= 0.10.4, containers, array + build-depends: base >= 4.5.0.0 && < 5, + ghc-prim >= 0.5.0 && <0.9, + bytestring >= 0.10.4, + containers, + array hs-source-dirs: src exposed-modules: Data.Binary, Data.Binary.Put, @@ -181,7 +185,7 @@ benchmark generics-bench unordered-containers, zlib, criterion - + other-modules: Cabal24 GenericsBenchCache diff --git a/src/Data/Binary/Get.hs b/src/Data/Binary/Get.hs index 65f7c754354775e507d6ab9e8a0352ca84b533e1..bf8a1dfd7873c599f0028c90c83b9fb2ef06d2cb 100644 --- a/src/Data/Binary/Get.hs +++ b/src/Data/Binary/Get.hs @@ -231,14 +231,28 @@ import qualified Data.ByteString.Lazy.Internal as L import Data.Binary.Get.Internal hiding ( Decoder(..), runGetIncremental ) import qualified Data.Binary.Get.Internal as I +-- needed for casting words to float/double +import Data.Binary.FloatCast (wordToFloat, wordToDouble) + #if defined(__GLASGOW_HASKELL__) && !defined(__HADDOCK__) -- needed for (# unboxing #) with magic hash -import GHC.Base +import GHC.Base hiding (extendWord8#, extendWord16#, extendWord32#, narrowWord8#, narrowWord16#, narrowWord32#) import GHC.Word +#if MIN_VERSION_ghc_prim(0,8,0) +import GHC.Base (extendWord8#, extendWord16#, extendWord32#) +import GHC.Base (narrowWord8#, narrowWord16#, narrowWord32#) +#else +import GHC.Prim (Word#) +extendWord8#, extendWord16#, extendWord32# :: Word# -> Word# +narrowWord8#, narrowWord16#, narrowWord32# :: Word# -> Word# +extendWord8# w = w +extendWord16# w = w +extendWord32# w = w +narrowWord8# w = w +narrowWord16# w = w +narrowWord32# w = w +#endif #endif - --- needed for casting words to float/double -import Data.Binary.FloatCast (wordToFloat, wordToDouble) -- $lazyinterface -- The lazy interface consumes a single lazy 'L.ByteString'. It's the easiest @@ -660,8 +674,8 @@ shiftl_w32 :: Word32 -> Int -> Word32 shiftl_w64 :: Word64 -> Int -> Word64 #if defined(__GLASGOW_HASKELL__) && !defined(__HADDOCK__) -shiftl_w16 (W16# w) (I# i) = W16# (w `uncheckedShiftL#` i) -shiftl_w32 (W32# w) (I# i) = W32# (w `uncheckedShiftL#` i) +shiftl_w16 (W16# w) (I# i) = W16# (narrowWord16# ((extendWord16# w) `uncheckedShiftL#` i)) +shiftl_w32 (W32# w) (I# i) = W32# (narrowWord32# ((extendWord32# w) `uncheckedShiftL#` i)) #if WORD_SIZE_IN_BITS < 64 shiftl_w64 (W64# w) (I# i) = W64# (w `uncheckedShiftL64#` i)