Skip to content

Commit

Permalink
Fix for indexInt8OffAddr# returning sized type in next GHC
Browse files Browse the repository at this point in the history
Here's how we fix this without CPP:

In old GHC:

  I8# :: Int# -> Int8
  indexInt8OffAddr# :: Addr# -> Int# -> Int#

In upcoming GHC 9.2:

  I8# :: Int8# -> Int8
  indexInt8OffAddr# :: Addr# -> Int# -> Int8#

So the "GLB" interface is:

  exists alpha.
  I8# :: alpha -> Int8
  indexInt8OffAddr# :: Addr# -> Int# -> alpha

We we write a program against that, eliminating the black-box `alpha`
with `I8#` and then converting to `Int`.
  • Loading branch information
Ericson2314 committed Jan 26, 2021
1 parent e3253fc commit 7f9d92a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion containers/src/Data/IntSet/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ import Text.Read

#if __GLASGOW_HASKELL__
import qualified GHC.Exts
import qualified GHC.Int
#endif

import qualified Data.Foldable as Foldable
Expand Down Expand Up @@ -1642,7 +1643,7 @@ highestBitSet x = WORD_SIZE_IN_BITS - 1 - countLeadingZeros x
----------------------------------------------------------------------}

indexOfTheOnlyBit bitmask =
GHC.Exts.I# (lsbArray `GHC.Exts.indexInt8OffAddr#` unboxInt (intFromNat ((bitmask * magic) `shiftRL` offset)))
fromIntegral (GHC.Int.I8# (lsbArray `GHC.Exts.indexInt8OffAddr#` unboxInt (intFromNat ((bitmask * magic) `shiftRL` offset))))
where unboxInt (GHC.Exts.I# i) = i
#if WORD_SIZE_IN_BITS==32
magic = 0x077CB531
Expand Down

0 comments on commit 7f9d92a

Please sign in to comment.