Skip to content

Commit

Permalink
GHC 8.6 doesn’t have UnliftedNewtypes so fall back to expensive boxed…
Browse files Browse the repository at this point in the history
… data
  • Loading branch information
sergv committed Dec 8, 2024
1 parent 628c229 commit afa4b8b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Control/Concurrent/Counter/Unlifted.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE UnliftedFFITypes #-}
{-# LANGUAGE UnliftedNewtypes #-}

#if __GLASGOW_HASKELL__ >= 810
{-# LANGUAGE UnliftedNewtypes #-}
#endif

module Control.Concurrent.Counter.Unlifted
( Counter
Expand Down Expand Up @@ -113,10 +116,18 @@ sameCounter :: Counter s -> Counter s -> Bool
sameCounter (Counter x) (Counter y) =
isTrue# (reallyUnsafePtrEquality# x y)

#else
#endif

#if !(defined(USE_CMM) && SIZEOF_HSINT == 8)

-- | Memory location that supports select few atomic operations.
#if __GLASGOW_HASKELL__ >= 810
newtype Counter s = Counter (MutableByteArray# s)
#endif

#if !(__GLASGOW_HASKELL__ >= 810)
data Counter s = Counter (MutableByteArray# s)
#endif

{-# INLINE new #-}
-- | Create new counter with initial value.
Expand Down

0 comments on commit afa4b8b

Please sign in to comment.