diff options
author | James Crayne <jim.crayne@gmail.com> | 2019-09-28 13:43:29 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-01 19:27:53 -0500 |
commit | 11987749fc6e6d3e53ea737d46d5ab13a16faeb8 (patch) | |
tree | 5716463275c2d3e902889db619908ded2a73971c /cryptonite-backport/Crypto/Internal | |
parent | add2c76bced51fde5e9917e7449ef52be70faf87 (diff) |
Factor out some new libraries
word64-map:
Data.Word64Map
network-addr:
Network.Address
tox-crypto:
Crypto.Tox
lifted-concurrent:
Control.Concurrent.Lifted.Instrument
Control.Concurrent.Async.Lifted.Instrument
psq-wrap:
Data.Wrapper.PSQInt
Data.Wrapper.PSQ
minmax-psq:
Data.MinMaxPSQ
tasks:
Control.Concurrent.Tasks
kad:
Network.Kademlia
Network.Kademlia.Bootstrap
Network.Kademlia.Routing
Network.Kademlia.CommonAPI
Network.Kademlia.Persistence
Network.Kademlia.Search
Diffstat (limited to 'cryptonite-backport/Crypto/Internal')
-rw-r--r-- | cryptonite-backport/Crypto/Internal/ByteArray.hs | 19 | ||||
-rw-r--r-- | cryptonite-backport/Crypto/Internal/Compat.hs | 48 | ||||
-rw-r--r-- | cryptonite-backport/Crypto/Internal/DeepSeq.hs | 33 | ||||
-rw-r--r-- | cryptonite-backport/Crypto/Internal/Imports.hs | 16 |
4 files changed, 0 insertions, 116 deletions
diff --git a/cryptonite-backport/Crypto/Internal/ByteArray.hs b/cryptonite-backport/Crypto/Internal/ByteArray.hs deleted file mode 100644 index 3a23152d..00000000 --- a/cryptonite-backport/Crypto/Internal/ByteArray.hs +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | -- | | ||
2 | -- Module : Crypto.Internal.ByteArray | ||
3 | -- License : BSD-style | ||
4 | -- Maintainer : Vincent Hanquez <vincent@snarc.org> | ||
5 | -- Stability : stable | ||
6 | -- Portability : Good | ||
7 | -- | ||
8 | -- Simple and efficient byte array types | ||
9 | -- | ||
10 | {-# OPTIONS_HADDOCK hide #-} | ||
11 | module Crypto.Internal.ByteArray | ||
12 | ( module Data.ByteArray | ||
13 | , module Data.ByteArray.Mapping | ||
14 | , module Data.ByteArray.Encoding | ||
15 | ) where | ||
16 | |||
17 | import Data.ByteArray | ||
18 | import Data.ByteArray.Mapping | ||
19 | import Data.ByteArray.Encoding | ||
diff --git a/cryptonite-backport/Crypto/Internal/Compat.hs b/cryptonite-backport/Crypto/Internal/Compat.hs deleted file mode 100644 index a3712a7c..00000000 --- a/cryptonite-backport/Crypto/Internal/Compat.hs +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | -- | | ||
2 | -- Module : Crypto.Internal.Compat | ||
3 | -- License : BSD-style | ||
4 | -- Maintainer : Vincent Hanquez <vincent@snarc.org> | ||
5 | -- Stability : stable | ||
6 | -- Portability : Good | ||
7 | -- | ||
8 | -- This module try to keep all the difference between versions of base | ||
9 | -- or other needed packages, so that modules don't need to use CPP | ||
10 | -- | ||
11 | {-# LANGUAGE CPP #-} | ||
12 | module Crypto.Internal.Compat | ||
13 | ( unsafeDoIO | ||
14 | , popCount | ||
15 | , byteSwap64 | ||
16 | ) where | ||
17 | |||
18 | import System.IO.Unsafe | ||
19 | import Data.Word | ||
20 | import Data.Bits | ||
21 | |||
22 | -- | perform io for hashes that do allocation and ffi. | ||
23 | -- unsafeDupablePerformIO is used when possible as the | ||
24 | -- computation is pure and the output is directly linked | ||
25 | -- to the input. we also do not modify anything after it has | ||
26 | -- been returned to the user. | ||
27 | unsafeDoIO :: IO a -> a | ||
28 | #if __GLASGOW_HASKELL__ > 704 | ||
29 | unsafeDoIO = unsafeDupablePerformIO | ||
30 | #else | ||
31 | unsafeDoIO = unsafePerformIO | ||
32 | #endif | ||
33 | |||
34 | #if !(MIN_VERSION_base(4,5,0)) | ||
35 | popCount :: Word64 -> Int | ||
36 | popCount n = loop 0 n | ||
37 | where loop c 0 = c | ||
38 | loop c i = loop (c + if testBit c 0 then 1 else 0) (i `shiftR` 1) | ||
39 | #endif | ||
40 | |||
41 | #if !(MIN_VERSION_base(4,7,0)) | ||
42 | byteSwap64 :: Word64 -> Word64 | ||
43 | byteSwap64 w = | ||
44 | (w `shiftR` 56) .|. (w `shiftL` 56) | ||
45 | .|. ((w `shiftR` 40) .&. 0xff00) .|. ((w .&. 0xff00) `shiftL` 40) | ||
46 | .|. ((w `shiftR` 24) .&. 0xff0000) .|. ((w .&. 0xff0000) `shiftL` 24) | ||
47 | .|. ((w `shiftR` 8) .&. 0xff000000) .|. ((w .&. 0xff000000) `shiftL` 8) | ||
48 | #endif | ||
diff --git a/cryptonite-backport/Crypto/Internal/DeepSeq.hs b/cryptonite-backport/Crypto/Internal/DeepSeq.hs deleted file mode 100644 index 9da79881..00000000 --- a/cryptonite-backport/Crypto/Internal/DeepSeq.hs +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | -- | | ||
2 | -- Module : Crypto.Internal.DeepSeq | ||
3 | -- License : BSD-style | ||
4 | -- Maintainer : Vincent Hanquez <vincent@snarc.org> | ||
5 | -- Stability : experimental | ||
6 | -- Portability : unknown | ||
7 | -- | ||
8 | -- Simple abstraction module to allow compilation without deepseq | ||
9 | -- by defining our own NFData class if not compiling with deepseq | ||
10 | -- support. | ||
11 | -- | ||
12 | {-# LANGUAGE CPP #-} | ||
13 | module Crypto.Internal.DeepSeq | ||
14 | ( NFData(..) | ||
15 | ) where | ||
16 | |||
17 | #ifdef WITH_DEEPSEQ_SUPPORT | ||
18 | import Control.DeepSeq | ||
19 | #else | ||
20 | import Data.Word | ||
21 | import Data.ByteArray | ||
22 | |||
23 | class NFData a where rnf :: a -> () | ||
24 | |||
25 | instance NFData Word8 where rnf w = w `seq` () | ||
26 | instance NFData Word16 where rnf w = w `seq` () | ||
27 | instance NFData Word32 where rnf w = w `seq` () | ||
28 | instance NFData Word64 where rnf w = w `seq` () | ||
29 | |||
30 | instance NFData Bytes where rnf b = b `seq` () | ||
31 | instance NFData ScrubbedBytes where rnf b = b `seq` () | ||
32 | |||
33 | #endif | ||
diff --git a/cryptonite-backport/Crypto/Internal/Imports.hs b/cryptonite-backport/Crypto/Internal/Imports.hs deleted file mode 100644 index 4ed44e16..00000000 --- a/cryptonite-backport/Crypto/Internal/Imports.hs +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | -- | | ||
2 | -- Module : Crypto.Internal.Imports | ||
3 | -- License : BSD-style | ||
4 | -- Maintainer : Vincent Hanquez <vincent@snarc.org> | ||
5 | -- Stability : experimental | ||
6 | -- Portability : unknown | ||
7 | -- | ||
8 | module Crypto.Internal.Imports | ||
9 | ( module X | ||
10 | ) where | ||
11 | |||
12 | import Data.Word as X | ||
13 | import Control.Applicative as X | ||
14 | import Control.Monad as X (forM, forM_, void) | ||
15 | import Control.Arrow as X (first, second) | ||
16 | import Crypto.Internal.DeepSeq as X | ||