summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik de Castro Lopo <erikd@mega-nerd.com>2015-03-05 19:39:16 +1100
committerErik de Castro Lopo <erikd@mega-nerd.com>2015-03-10 17:57:41 +1100
commit19440ae2bb256f75934949ae57934caee3831a80 (patch)
tree67703aeac268313d10b581fd67d4b1c4a8c8e0cf
parentc1db477151c2c1a330081fd0b4aab29bd85b636f (diff)
downloadhaskell-19440ae2bb256f75934949ae57934caee3831a80.tar.gz
ghc-prim : Hide 64 bit primops when the word size is 32 bits (fixes #9886).
Summary: These primops were failing to compile on PowerPC (32 bit). There is also currently no way to call into these primops from Haskell code. Currently, the *only* way to call any of these C hs_atomic_* functions is via the fetch*IntArray primops which are only defined for Int values and Int is always the native word size. When these functions can be called (and tested) from Haskell code, then it will be worth while implementing them. Test Plan: Compile and run on x86, x86_64, powerpc and arm: testsuite/tests/concurrent/should_run/AtomicPrimops.hs Reviewers: tibbe, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D702 GHC Trac Issues: #9886
-rw-r--r--libraries/ghc-prim/cbits/atomic.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libraries/ghc-prim/cbits/atomic.c b/libraries/ghc-prim/cbits/atomic.c
index e3d6cc1e95..01cc458e82 100644
--- a/libraries/ghc-prim/cbits/atomic.c
+++ b/libraries/ghc-prim/cbits/atomic.c
@@ -32,12 +32,14 @@ hs_atomic_add32(volatile StgWord32 *x, StgWord val)
return __sync_fetch_and_add(x, (StgWord32) val);
}
+#if WORD_SIZE_IN_BITS == 64
extern StgWord64 hs_atomic_add64(volatile StgWord64 *x, StgWord64 val);
StgWord64
hs_atomic_add64(volatile StgWord64 *x, StgWord64 val)
{
return __sync_fetch_and_add(x, val);
}
+#endif
// FetchSubByteArrayOp_Int
@@ -62,12 +64,14 @@ hs_atomic_sub32(volatile StgWord32 *x, StgWord val)
return __sync_fetch_and_sub(x, (StgWord32) val);
}
+#if WORD_SIZE_IN_BITS == 64
extern StgWord64 hs_atomic_sub64(volatile StgWord64 *x, StgWord64 val);
StgWord64
hs_atomic_sub64(volatile StgWord64 *x, StgWord64 val)
{
return __sync_fetch_and_sub(x, val);
}
+#endif
// FetchAndByteArrayOp_Int
@@ -92,12 +96,14 @@ hs_atomic_and32(volatile StgWord32 *x, StgWord val)
return __sync_fetch_and_and(x, (StgWord32) val);
}
+#if WORD_SIZE_IN_BITS == 64
extern StgWord64 hs_atomic_and64(volatile StgWord64 *x, StgWord64 val);
StgWord64
hs_atomic_and64(volatile StgWord64 *x, StgWord64 val)
{
return __sync_fetch_and_and(x, val);
}
+#endif
// FetchNandByteArrayOp_Int
@@ -144,6 +150,7 @@ hs_atomic_nand32(volatile StgWord32 *x, StgWord val)
#endif
}
+#if WORD_SIZE_IN_BITS == 64
extern StgWord64 hs_atomic_nand64(volatile StgWord64 *x, StgWord64 val);
StgWord64
hs_atomic_nand64(volatile StgWord64 *x, StgWord64 val)
@@ -154,6 +161,7 @@ hs_atomic_nand64(volatile StgWord64 *x, StgWord64 val)
return __sync_fetch_and_nand(x, val);
#endif
}
+#endif
// FetchOrByteArrayOp_Int
@@ -178,12 +186,14 @@ hs_atomic_or32(volatile StgWord32 *x, StgWord val)
return __sync_fetch_and_or(x, (StgWord32) val);
}
+#if WORD_SIZE_IN_BITS == 64
extern StgWord64 hs_atomic_or64(volatile StgWord64 *x, StgWord64 val);
StgWord64
hs_atomic_or64(volatile StgWord64 *x, StgWord64 val)
{
return __sync_fetch_and_or(x, val);
}
+#endif
// FetchXorByteArrayOp_Int
@@ -208,12 +218,14 @@ hs_atomic_xor32(volatile StgWord32 *x, StgWord val)
return __sync_fetch_and_xor(x, (StgWord32) val);
}
+#if WORD_SIZE_IN_BITS == 64
extern StgWord64 hs_atomic_xor64(volatile StgWord64 *x, StgWord64 val);
StgWord64
hs_atomic_xor64(volatile StgWord64 *x, StgWord64 val)
{
return __sync_fetch_and_xor(x, val);
}
+#endif
// CasByteArrayOp_Int
@@ -238,12 +250,14 @@ hs_cmpxchg32(volatile StgWord32 *x, StgWord old, StgWord new)
return __sync_val_compare_and_swap(x, (StgWord32) old, (StgWord32) new);
}
+#if WORD_SIZE_IN_BITS == 64
extern StgWord hs_cmpxchg64(volatile StgWord64 *x, StgWord64 old, StgWord64 new);
StgWord
hs_cmpxchg64(volatile StgWord64 *x, StgWord64 old, StgWord64 new)
{
return __sync_val_compare_and_swap(x, old, new);
}
+#endif
// AtomicReadByteArrayOp_Int