summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-09-02 11:04:44 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-09-02 15:56:48 -0400
commit85e621234916e9b5d40174831a3b422bd99f8f83 (patch)
treecdb3a1ff034bbd42bc0d2a6864ce4da4577c2536
parentffc3da474bd6febf8a120ebd432ad69f92fe03e0 (diff)
downloadhaskell-85e621234916e9b5d40174831a3b422bd99f8f83.tar.gz
Bignum: add missing compat import/export functions
-rw-r--r--libraries/integer-gmp/src/GHC/Integer/GMP/Internals.hs33
1 files changed, 30 insertions, 3 deletions
diff --git a/libraries/integer-gmp/src/GHC/Integer/GMP/Internals.hs b/libraries/integer-gmp/src/GHC/Integer/GMP/Internals.hs
index 97625fb586..e414846d96 100644
--- a/libraries/integer-gmp/src/GHC/Integer/GMP/Internals.hs
+++ b/libraries/integer-gmp/src/GHC/Integer/GMP/Internals.hs
@@ -57,9 +57,6 @@ module GHC.Integer.GMP.Internals
, bigNatToInt
, bigNatToWord
, indexBigNat#
- , importBigNatFromByteArray
- , exportBigNatToMutableByteArray
-
-- ** 'BigNat' arithmetic operations
, plusBigNat
@@ -112,9 +109,17 @@ module GHC.Integer.GMP.Internals
-- ** Export
, exportBigNatToAddr
+ , exportIntegerToAddr
+
+ , exportBigNatToMutableByteArray
+ , exportIntegerToMutableByteArray
-- ** Import
, importBigNatFromAddr
+ , importIntegerFromAddr
+
+ , importBigNatFromByteArray
+ , importIntegerFromByteArray
) where
import GHC.Integer
@@ -373,6 +378,18 @@ exportBigNatToAddr (BN# b) addr endian = IO \s ->
case B.bigNatToAddr# b addr endian s of
(# s', w #) -> (# s', W# w #)
+{-# DEPRECATED importIntegerFromAddr "Use integerFromAddr# instead" #-}
+importIntegerFromAddr :: Addr# -> Word# -> Int# -> IO Integer
+importIntegerFromAddr addr sz endian = IO \s ->
+ case I.integerFromAddr# sz addr endian s of
+ (# s', i #) -> (# s', i #)
+
+{-# DEPRECATED exportIntegerToAddr "Use integerToAddr# instead" #-}
+exportIntegerToAddr :: Integer -> Addr# -> Int# -> IO Word
+exportIntegerToAddr i addr endian = IO \s ->
+ case I.integerToAddr# i addr endian s of
+ (# s', w #) -> (# s', W# w #)
+
wordToBigNat :: Word# -> BigNat
wordToBigNat w = BN# (B.bigNatFromWord# w)
@@ -398,3 +415,13 @@ importBigNatFromByteArray ba off sz endian = case runRW# (B.bigNatFromByteArray#
exportBigNatToMutableByteArray :: BigNat -> MutableByteArray# RealWorld -> Word# -> Int# -> IO Word
exportBigNatToMutableByteArray (BN# ba) mba off endian = IO (\s -> case B.bigNatToMutableByteArray# ba mba off endian s of
(# s', r #) -> (# s', W# r #))
+
+{-# DEPRECATED importIntegerFromByteArray "Use integerFromByteArray# instead" #-}
+importIntegerFromByteArray :: ByteArray# -> Word# -> Word# -> Int# -> Integer
+importIntegerFromByteArray ba off sz endian = case runRW# (I.integerFromByteArray# sz ba off endian) of
+ (# _, r #) -> r
+
+{-# DEPRECATED exportIntegerToMutableByteArray "Use integerToMutableByteArray# instead" #-}
+exportIntegerToMutableByteArray :: Integer -> MutableByteArray# RealWorld -> Word# -> Int# -> IO Word
+exportIntegerToMutableByteArray i mba off endian = IO (\s -> case I.integerToMutableByteArray# i mba off endian s of
+ (# s', r #) -> (# s', W# r #))