create a module to put all the compat necessary for running over a wide range of versions
This commit is contained in:
parent
244b0331ad
commit
6f877c84c3
@ -1,24 +1,9 @@
|
||||
{-# LANGUAGE CPP #-}
|
||||
|
||||
-- |
|
||||
-- Module : Crypto.Hash.Internal
|
||||
-- License : BSD-style
|
||||
-- Maintainer : Vincent Hanquez <vincent@snarc.org>
|
||||
-- Stability : experimental
|
||||
-- Portability : unknown
|
||||
module Crypto.Hash.Internal where
|
||||
|
||||
import System.IO.Unsafe
|
||||
|
||||
-- | perform io for hashes that do allocation and ffi.
|
||||
-- unsafeDupablePerformIO is used when possible as the
|
||||
-- computation is pure and the output is directly linked
|
||||
-- to the input. we also do not modify anything after it has
|
||||
-- been returned to the user.
|
||||
unsafeDoIO :: IO a -> a
|
||||
#if __GLASGOW_HASKELL__ > 704
|
||||
unsafeDoIO = unsafeDupablePerformIO
|
||||
#else
|
||||
unsafeDoIO = unsafePerformIO
|
||||
#endif
|
||||
module Crypto.Hash.Internal (unsafeDoIO) where
|
||||
|
||||
import Crypto.Internal.Compat (unsafeDoIO)
|
||||
|
||||
28
Crypto/Internal/Compat.hs
Normal file
28
Crypto/Internal/Compat.hs
Normal file
@ -0,0 +1,28 @@
|
||||
-- |
|
||||
-- Module : Crypto.Internal.Compat
|
||||
-- License : BSD-style
|
||||
-- Maintainer : Vincent Hanquez <vincent@snarc.org>
|
||||
-- Stability : stable
|
||||
-- Portability : Good
|
||||
--
|
||||
-- This module try to keep all the difference between versions of base
|
||||
-- or other needed packages, so that modules don't need to use CPP
|
||||
--
|
||||
{-# LANGUAGE CPP #-}
|
||||
module Crypto.Internal.Compat
|
||||
( unsafeDoIO
|
||||
) where
|
||||
|
||||
import System.IO.Unsafe
|
||||
|
||||
-- | perform io for hashes that do allocation and ffi.
|
||||
-- unsafeDupablePerformIO is used when possible as the
|
||||
-- computation is pure and the output is directly linked
|
||||
-- to the input. we also do not modify anything after it has
|
||||
-- been returned to the user.
|
||||
unsafeDoIO :: IO a -> a
|
||||
#if __GLASGOW_HASKELL__ > 704
|
||||
unsafeDoIO = unsafeDupablePerformIO
|
||||
#else
|
||||
unsafeDoIO = unsafePerformIO
|
||||
#endif
|
||||
@ -58,6 +58,7 @@ Library
|
||||
, Crypto.Hash.Types
|
||||
, Crypto.Random.Entropy.Source
|
||||
, Crypto.Random.Entropy.Backend
|
||||
, Crypto.Internal.Compat
|
||||
Build-depends: base >= 4.5 && < 5
|
||||
, bytestring
|
||||
, securemem
|
||||
|
||||
Loading…
Reference in New Issue
Block a user