diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2018-03-08 13:22:22 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-03-08 16:08:04 -0500 |
commit | ed6f9fb9d5a684d2159c29633159c3254cf04deb (patch) | |
tree | 9fdb2120871ee81643c5f104cbe51fe4d3b19e5c /libraries | |
parent | bc95fedc0b1f45b62ba279f7df834c490c2e53b6 (diff) | |
download | haskell-ed6f9fb9d5a684d2159c29633159c3254cf04deb.tar.gz |
ghc-prim: Reduce scope of Clang sync_fetch_and_nand workaround
As described in https://bugs.llvm.org/show_bug.cgi?id=8842, Clang
removed the __sync_fetch_and_nand builtins due to inconsistency in GCC's
behavior in 2010. However, GCC has since clarified the behavior of
their builtins and consequently Clang re-added them in 2014.
Consequently this workaround should no longer be necessary.
Test Plan: Validate building with Clang
Subscribers: rwbarton, thomie, carter
Differential Revision: https://phabricator.haskell.org/D4480
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/ghc-prim/cbits/atomic.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libraries/ghc-prim/cbits/atomic.c b/libraries/ghc-prim/cbits/atomic.c index 2ded465fcd..722d261de8 100644 --- a/libraries/ghc-prim/cbits/atomic.c +++ b/libraries/ghc-prim/cbits/atomic.c @@ -117,11 +117,16 @@ hs_atomic_and64(StgWord x, StgWord64 val) return tmp; \ } +// This is only provided by clang +#if !defined(__has_builtin) +#define __has_builtin(x) 0 +#endif + extern StgWord hs_atomic_nand8(StgWord x, StgWord val); StgWord hs_atomic_nand8(StgWord x, StgWord val) { -#ifdef __clang__ +#if defined(__clang__) && __has_builtin(__sync_fetch_and_nand) CAS_NAND((volatile StgWord8 *) x, (StgWord8) val) #else return __sync_fetch_and_nand((volatile StgWord8 *) x, (StgWord8) val); @@ -132,7 +137,7 @@ extern StgWord hs_atomic_nand16(StgWord x, StgWord val); StgWord hs_atomic_nand16(StgWord x, StgWord val) { -#ifdef __clang__ +#if defined(__clang__) && __has_builtin(__sync_fetch_and_nand) CAS_NAND((volatile StgWord16 *) x, (StgWord16) val); #else return __sync_fetch_and_nand((volatile StgWord16 *) x, (StgWord16) val); @@ -143,7 +148,7 @@ extern StgWord hs_atomic_nand32(StgWord x, StgWord val); StgWord hs_atomic_nand32(StgWord x, StgWord val) { -#ifdef __clang__ +#if defined(__clang__) && __has_builtin(__sync_fetch_and_nand) CAS_NAND((volatile StgWord32 *) x, (StgWord32) val); #else return __sync_fetch_and_nand((volatile StgWord32 *) x, (StgWord32) val); @@ -155,7 +160,7 @@ extern StgWord64 hs_atomic_nand64(StgWord x, StgWord64 val); StgWord64 hs_atomic_nand64(StgWord x, StgWord64 val) { -#ifdef __clang__ +#if defined(__clang__) && __has_builtin(__sync_fetch_and_nand) CAS_NAND((volatile StgWord64 *) x, val); #else return __sync_fetch_and_nand((volatile StgWord64 *) x, val); |