summaryrefslogtreecommitdiff
path: root/testsuite/tests/concurrent/should_run/AtomicPrimops.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/concurrent/should_run/AtomicPrimops.hs')
-rw-r--r--testsuite/tests/concurrent/should_run/AtomicPrimops.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/testsuite/tests/concurrent/should_run/AtomicPrimops.hs b/testsuite/tests/concurrent/should_run/AtomicPrimops.hs
index b8adb3c621..05ac80dcad 100644
--- a/testsuite/tests/concurrent/should_run/AtomicPrimops.hs
+++ b/testsuite/tests/concurrent/should_run/AtomicPrimops.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
@@ -14,6 +15,8 @@ import GHC.Int
import GHC.IO
import GHC.Word
+#include "MachDeps.h"
+
-- | Iterations per worker.
iters :: Word
iters = 1000000
@@ -550,7 +553,11 @@ readInt32Array (MBA mba#) (I# ix#) = IO $ \ s# ->
readInt64Array :: MByteArray -> Int -> IO Int64
readInt64Array (MBA mba#) (I# ix#) = IO $ \ s# ->
case readInt64Array# mba# ix# s# of
+#if WORD_SIZE_IN_BITS < 64
(# s2#, n# #) -> (# s2#, I64# n# #)
+#else
+ (# s2#, n# #) -> (# s2#, I64# (int64ToInt# n#) #)
+#endif
atomicWriteIntArray :: MByteArray -> Int -> Int -> IO ()
atomicWriteIntArray (MBA mba#) (I# ix#) (I# n#) = IO $ \ s# ->
@@ -584,8 +591,13 @@ casInt32Array (MBA mba#) (I# ix#) (I32# old#) (I32# new#) = IO $ \ s# ->
casInt64Array :: MByteArray -> Int -> Int64 -> Int64 -> IO Int64
casInt64Array (MBA mba#) (I# ix#) (I64# old#) (I64# new#) = IO $ \ s# ->
+#if WORD_SIZE_IN_BITS < 64
case casInt64Array# mba# ix# old# new# s# of
(# s2#, old2# #) -> (# s2#, I64# old2# #)
+#else
+ case casInt64Array# mba# ix# (intToInt64# old#) (intToInt64# new#) s# of
+ (# s2#, old2# #) -> (# s2#, I64# (int64ToInt# old2#) #)
+#endif
------------------------------------------------------------------------
-- Wrappers around Addr#
@@ -651,5 +663,10 @@ atomicCasWord32Ptr (Ptr addr#) (W32# old#) (W32# new#) = IO $ \ s# ->
(# s2#, old2# #) -> (# s2#, W32# old2# #)
atomicCasWord64Ptr :: Ptr Word64 -> Word64 -> Word64 -> IO Word64
atomicCasWord64Ptr (Ptr addr#) (W64# old#) (W64# new#) = IO $ \ s# ->
+#if WORD_SIZE_IN_BITS < 64
case atomicCasWord64Addr# addr# old# new# s# of
(# s2#, old2# #) -> (# s2#, W64# old2# #)
+#else
+ case atomicCasWord64Addr# addr# (wordToWord64# old#) (wordToWord64# new#) s# of
+ (# s2#, old2# #) -> (# s2#, W64# (word64ToWord# old2#) #)
+#endif