From 8655eb046884ffcfbd6af5bb68ee4a8a8a9107c7 Mon Sep 17 00:00:00 2001 From: Vincent Hanquez Date: Sat, 11 Apr 2015 08:26:30 +0100 Subject: [PATCH] [Internal] move all primitives stuff in CompatPrim --- Crypto/Internal/Compat.hs | 13 ------------- Crypto/Internal/CompatPrim.hs | 9 +++++++++ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Crypto/Internal/Compat.hs b/Crypto/Internal/Compat.hs index 71cd25a..a3712a7 100644 --- a/Crypto/Internal/Compat.hs +++ b/Crypto/Internal/Compat.hs @@ -9,20 +9,15 @@ -- or other needed packages, so that modules don't need to use CPP -- {-# LANGUAGE CPP #-} -{-# LANGUAGE MagicHash #-} module Crypto.Internal.Compat ( unsafeDoIO , popCount , byteSwap64 - , booleanPrim ) where import System.IO.Unsafe import Data.Word import Data.Bits -#if __GLASGOW_HASKELL__ >= 708 -import GHC.Prim -#endif -- | perform io for hashes that do allocation and ffi. -- unsafeDupablePerformIO is used when possible as the @@ -51,11 +46,3 @@ byteSwap64 w = .|. ((w `shiftR` 24) .&. 0xff0000) .|. ((w .&. 0xff0000) `shiftL` 24) .|. ((w `shiftR` 8) .&. 0xff000000) .|. ((w .&. 0xff000000) `shiftL` 8) #endif - -#if __GLASGOW_HASKELL__ >= 708 -booleanPrim :: Int# -> Bool -booleanPrim v = tagToEnum# v -#else -booleanPrim :: Bool -> Bool -booleanPrim b = b -#endif diff --git a/Crypto/Internal/CompatPrim.hs b/Crypto/Internal/CompatPrim.hs index 16ab8f3..4e8db8d 100644 --- a/Crypto/Internal/CompatPrim.hs +++ b/Crypto/Internal/CompatPrim.hs @@ -16,6 +16,7 @@ module Crypto.Internal.CompatPrim ( be32Prim , byteswap32Prim + , booleanPrim ) where import GHC.Prim @@ -38,3 +39,11 @@ byteswap32Prim w = d = and# (uncheckedShiftRL# w 24#) 0x000000ff## in or# a (or# b (or# c d)) #endif + +#if __GLASGOW_HASKELL__ >= 708 +booleanPrim :: Int# -> Bool +booleanPrim v = tagToEnum# v +#else +booleanPrim :: Bool -> Bool +booleanPrim b = b +#endif