summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-11-04 18:23:31 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-11-09 10:02:46 -0500
commitbc498fdfa482dfe796e3a12ac8f9d71913930740 (patch)
tree57352d07220a402d4c785997cab39b11f2760f2f
parent2929850f0139778c579fc7144831c88e11353a9b (diff)
downloadhaskell-bc498fdfa482dfe796e3a12ac8f9d71913930740.tar.gz
Bignum: expose backendName (#20495)
-rw-r--r--libraries/ghc-bignum/changelog.md4
-rw-r--r--libraries/ghc-bignum/ghc-bignum.cabal2
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/Backend/Check.hs7
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/Backend/FFI.hs4
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs4
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs5
6 files changed, 25 insertions, 1 deletions
diff --git a/libraries/ghc-bignum/changelog.md b/libraries/ghc-bignum/changelog.md
index 68f98d3adc..015721d40b 100644
--- a/libraries/ghc-bignum/changelog.md
+++ b/libraries/ghc-bignum/changelog.md
@@ -1,5 +1,9 @@
# Changelog for `ghc-bignum` package
+## 1.3
+
+- Expose backendName
+
## 1.2
- Moved naturalToDouble# and naturalToFloat# to `base` package
diff --git a/libraries/ghc-bignum/ghc-bignum.cabal b/libraries/ghc-bignum/ghc-bignum.cabal
index 468c2a042a..59ba847272 100644
--- a/libraries/ghc-bignum/ghc-bignum.cabal
+++ b/libraries/ghc-bignum/ghc-bignum.cabal
@@ -1,6 +1,6 @@
cabal-version: 2.0
name: ghc-bignum
-version: 1.2
+version: 1.3
synopsis: GHC BigNum library
license: BSD3
license-file: LICENSE
diff --git a/libraries/ghc-bignum/src/GHC/Num/Backend/Check.hs b/libraries/ghc-bignum/src/GHC/Num/Backend/Check.hs
index b23fd1cb21..00930a62bf 100644
--- a/libraries/ghc-bignum/src/GHC/Num/Backend/Check.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/Backend/Check.hs
@@ -12,6 +12,7 @@
-- | Check Native implementation against another backend
module GHC.Num.Backend.Check where
+import GHC.CString
import GHC.Prim
import GHC.Types
import GHC.Num.WordArray
@@ -27,6 +28,12 @@ import qualified GHC.Num.Backend.Selected as Other
default ()
+-- | ghc-bignum backend name
+backendName :: [Char]
+backendName = unpackAppendCString# "check-"# Other.backendName
+ -- we don't have (++) at our disposal, so we directly use
+ -- `unpackAppendCString#`
+
bignat_compare
:: WordArray#
-> WordArray#
diff --git a/libraries/ghc-bignum/src/GHC/Num/Backend/FFI.hs b/libraries/ghc-bignum/src/GHC/Num/Backend/FFI.hs
index 21d74ee3e4..30fcc576cb 100644
--- a/libraries/ghc-bignum/src/GHC/Num/Backend/FFI.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/Backend/FFI.hs
@@ -25,6 +25,10 @@ import {-# SOURCE #-} GHC.Num.Integer
default ()
+-- | ghc-bignum backend name
+backendName :: [Char]
+backendName = "ffi"
+
-- | Compare two non-zero BigNat of the same length
--
-- Return:
diff --git a/libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs b/libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs
index 3fd4394bcf..48f5f8a90e 100644
--- a/libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs
@@ -32,6 +32,10 @@ import {-# SOURCE #-} GHC.Num.Natural
default ()
+-- | ghc-bignum backend name
+backendName :: [Char]
+backendName = "gmp"
+
----------------------------------------------------------------------------
-- type definitions
diff --git a/libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs b/libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs
index 723096544a..da08c55dd1 100644
--- a/libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs
@@ -30,6 +30,11 @@ import GHC.Types
default ()
+-- | ghc-bignum backend name
+backendName :: [Char]
+backendName = "native"
+
+
count_words_bits :: Word# -> (# Word#, Word# #)
count_words_bits n = (# nw, nb #)
where