add gmpSizeInBits

This commit is contained in:
Vincent Hanquez 2015-05-23 09:15:15 +01:00
parent efedb38570
commit 27dacbfb21

View File

@ -20,6 +20,7 @@ module Crypto.Number.Compat
, gmpNextPrime
, gmpTestPrimeMillerRabin
, gmpSizeInBytes
, gmpSizeInBits
, gmpExportInteger
, gmpImportInteger
) where
@ -123,6 +124,13 @@ gmpSizeInBytes n = GmpSupported (I# (word2Int# (sizeInBaseInteger n 256#)))
gmpSizeInBytes _ = GmpUnsupported
#endif
gmpSizeInBits :: Integer -> GmpSupported Int
#if MIN_VERSION_integer_gmp(0,5,1)
gmpSizeInBits n = GmpSupported (I# (word2Int# (sizeInBaseInteger n 2#)))
#else
gmpSizeInBits _ = GmpUnsupported
#endif
-- | Export an integer to a memory
gmpExportInteger :: Integer -> Ptr Word8 -> GmpSupported (IO ())
#if MIN_VERSION_integer_gmp(1,0,0)