[commit: packages/containers] ghc-head: Use finiteBitSize with base >= 4.7... (501fa5b)

git at git.haskell.org git at git.haskell.org
Thu Jan 16 07:50:50 UTC 2014


Repository : ssh://git@git.haskell.org/containers

On branch  : ghc-head
Link       : http://git.haskell.org/packages/containers.git/commitdiff/501fa5b32c0e654e42a7107c87ebcab67292970e

>---------------------------------------------------------------

commit 501fa5b32c0e654e42a7107c87ebcab67292970e
Author: Milan Straka <fox at ucw.cz>
Date:   Mon Oct 7 15:14:44 2013 +0200

    Use finiteBitSize with base >= 4.7...
    
    ... and silence warning in GHC 7.8.


>---------------------------------------------------------------

501fa5b32c0e654e42a7107c87ebcab67292970e
 Data/IntSet/Base.hs |   36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/Data/IntSet/Base.hs b/Data/IntSet/Base.hs
index 5b726fe..9315b08 100644
--- a/Data/IntSet/Base.hs
+++ b/Data/IntSet/Base.hs
@@ -158,6 +158,26 @@ module Data.IntSet.Base (
     , bitmapOf
     ) where
 
+-- We want to be able to compile without cabal. Nevertheless
+-- #if defined(MIN_VERSION_base) && MIN_VERSION_base(4,5,0)
+-- does not work, because if MIN_VERSION_base is undefined,
+-- the last condition is syntactically wrong.
+#define MIN_VERSION_base_4_5_0 0
+#ifdef MIN_VERSION_base
+#if MIN_VERSION_base(4,5,0)
+#undef MIN_VERSION_base_4_5_0
+#define MIN_VERSION_base_4_5_0 1
+#endif
+#endif
+
+#define MIN_VERSION_base_4_7_0 0
+#ifdef MIN_VERSION_base
+#if MIN_VERSION_base(4,7,0)
+#undef MIN_VERSION_base_4_7_0
+#define MIN_VERSION_base_4_7_0 1
+#endif
+#endif
+
 import Control.DeepSeq (NFData)
 import Data.Bits
 import qualified Data.List as List
@@ -1193,7 +1213,11 @@ tip kx bm = Tip kx bm
 ----------------------------------------------------------------------}
 
 suffixBitMask :: Int
+#if MIN_VERSION_base_4_7_0
+suffixBitMask = finiteBitSize (undefined::Word) - 1
+#else
 suffixBitMask = bitSize (undefined::Word) - 1
+#endif
 {-# INLINE suffixBitMask #-}
 
 prefixBitMask :: Int
@@ -1439,18 +1463,6 @@ foldr'Bits prefix f z bm = let lb = lowestBitSet bm
     Derrick Lehmer and published in 1964 in a book edited by Beckenbach.)"
 ----------------------------------------------------------------------}
 
--- We want to be able to compile without cabal. Nevertheless
--- #if defined(MIN_VERSION_base) && MIN_VERSION_base(4,5,0)
--- does not work, because if MIN_VERSION_base is undefined,
--- the last condition is syntactically wrong.
-#define MIN_VERSION_base_4_5_0 0
-#ifdef MIN_VERSION_base
-#if MIN_VERSION_base(4,5,0)
-#undef MIN_VERSION_base_4_5_0
-#define MIN_VERSION_base_4_5_0 1
-#endif
-#endif
-
 bitcount :: Int -> Word -> Int
 #if MIN_VERSION_base_4_5_0
 bitcount a x = a + popCount x



More information about the ghc-commits mailing list