Skip to content

Commit

Permalink
TArray: Don't rely on undefined CPP behavior
Browse files Browse the repository at this point in the history
Fixes #75.
  • Loading branch information
bgamari committed Oct 6, 2023
1 parent 92b80b2 commit fe18b9b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Control/Concurrent/STM/TArray.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
{-# LANGUAGE Trustworthy #-}
#endif

#define HAS_UNLIFTED_ARRAY defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 904
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 904
#define HAS_UNLIFTED_ARRAY 1
#endif

#if HAS_UNLIFTED_ARRAY
#if defined(HAS_UNLIFTED_ARRAY)
{-# LANGUAGE MagicHash, UnboxedTuples #-}
#endif

Expand All @@ -30,7 +32,7 @@ module Control.Concurrent.STM.TArray (

import Control.Monad.STM (STM, atomically)
import Data.Typeable (Typeable)
#if HAS_UNLIFTED_ARRAY
#if defined(HAS_UNLIFTED_ARRAY)
import Control.Concurrent.STM.TVar (readTVar, readTVarIO, writeTVar)
import Data.Array.Base (safeRangeSize, MArray(..))
import Data.Ix (Ix)
Expand All @@ -47,7 +49,7 @@ import Data.Array.Base (safeRangeSize, unsafeAt, MArray(..), IArray(numElements)
-- interface for mutable arrays.
--
-- It is conceptually implemented as @Array i (TVar e)@.
#if HAS_UNLIFTED_ARRAY
#if defined(HAS_UNLIFTED_ARRAY)
data TArray i e = TArray
!i -- lower bound
!i -- upper bound
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog for [`stm` package](http://hackage.haskell.org/package/stm)

## 2.5.2.1 *September 2023*

* Eliminate reliance on undefined CPP behavior ([#75](https://github.com/haskell/stm/issues/75))

## 2.5.2.0 *September 2023*

* Fix strictness of `stateTVar` ([#30](https://github.com/haskell/stm/ssues/30))
Expand Down

0 comments on commit fe18b9b

Please sign in to comment.