[commit: ghc] ghc-7.10: ghc-prim : Hide 64 bit primops when the word size is 32 bits (fixes #9886). (bd785d1)

git at git.haskell.org git at git.haskell.org
Wed Mar 11 20:09:03 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-7.10
Link       : http://ghc.haskell.org/trac/ghc/changeset/bd785d101766a1207b8d27a45b6ae0bf83cd678a/ghc

>---------------------------------------------------------------

commit bd785d101766a1207b8d27a45b6ae0bf83cd678a
Author: Erik de Castro Lopo <erikd at mega-nerd.com>
Date:   Thu Mar 5 19:39:16 2015 +1100

    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
    
    (cherry picked from commit 19440ae2bb256f75934949ae57934caee3831a80)


>---------------------------------------------------------------

bd785d101766a1207b8d27a45b6ae0bf83cd678a
 libraries/ghc-prim/cbits/atomic.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/libraries/ghc-prim/cbits/atomic.c b/libraries/ghc-prim/cbits/atomic.c
index e3d6cc1..01cc458 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
 



More information about the ghc-commits mailing list