[commit: ghc] master: includes/stg/SMP.h: use 'NOSMP' instead of never defined 'WITHSMP' (Trac #8789) (34bae1f)

git at git.haskell.org git at git.haskell.org
Wed Jul 2 15:12:16 UTC 2014


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/34bae1f737e1492c152ccaafd457697b621c606b/ghc

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

commit 34bae1f737e1492c152ccaafd457697b621c606b
Author: Sergei Trofimovich <slyfox at gentoo.org>
Date:   Wed Jul 2 08:54:35 2014 -0500

    includes/stg/SMP.h: use 'NOSMP' instead of never defined 'WITHSMP' (Trac #8789)
    
    Summary:
    git history does not contain state where 'WITHSMP' macro was ever defined.
    It should have always been '!NOSMP'.
    
    Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org>
    
    Test Plan: build tested
    
    Reviewers: austin, simonmar
    
    Reviewed By: austin, simonmar
    
    Subscribers: simonmar, relrod, carter
    
    Differential Revision: https://phabricator.haskell.org/D33


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

34bae1f737e1492c152ccaafd457697b621c606b
 includes/stg/SMP.h | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/includes/stg/SMP.h b/includes/stg/SMP.h
index 01663dd..00608c7 100644
--- a/includes/stg/SMP.h
+++ b/includes/stg/SMP.h
@@ -107,7 +107,10 @@ EXTERN_INLINE StgWord
 xchg(StgPtr p, StgWord w)
 {
     StgWord result;
-#if i386_HOST_ARCH || x86_64_HOST_ARCH
+#if defined(NOSMP)
+    result = *p;
+    *p = w;
+#elif i386_HOST_ARCH || x86_64_HOST_ARCH
     result = w;
     __asm__ __volatile__ (
         // NB: the xchg instruction is implicitly locked, so we do not
@@ -154,9 +157,6 @@ xchg(StgPtr p, StgWord w)
                           : "r" (w), "r" (p)
                           : "memory"
                           );
-#elif !defined(WITHSMP)
-    result = *p;
-    *p = w;
 #else
 #error xchg() unimplemented on this architecture
 #endif
@@ -170,7 +170,14 @@ xchg(StgPtr p, StgWord w)
 EXTERN_INLINE StgWord
 cas(StgVolatilePtr p, StgWord o, StgWord n)
 {
-#if i386_HOST_ARCH || x86_64_HOST_ARCH
+#if defined(NOSMP)
+    StgWord result;
+    result = *p;
+    if (result == o) {
+        *p = n;
+    }
+    return result;
+#elif i386_HOST_ARCH || x86_64_HOST_ARCH
     __asm__ __volatile__ (
  	  "lock\ncmpxchg %3,%1"
           :"=a"(o), "+m" (*(volatile unsigned int *)p)
@@ -225,13 +232,6 @@ cas(StgVolatilePtr p, StgWord o, StgWord n)
                 : "cc","memory");
 
     return result;
-#elif !defined(WITHSMP)
-    StgWord result;
-    result = *p;
-    if (result == o) {
-        *p = n;
-    }
-    return result;
 #else
 #error cas() unimplemented on this architecture
 #endif
@@ -302,7 +302,9 @@ busy_wait_nop(void)
  */
 EXTERN_INLINE void
 write_barrier(void) {
-#if i386_HOST_ARCH || x86_64_HOST_ARCH
+#if defined(NOSMP)
+    return;
+#elif i386_HOST_ARCH || x86_64_HOST_ARCH
     __asm__ __volatile__ ("" : : : "memory");
 #elif powerpc_HOST_ARCH
     __asm__ __volatile__ ("lwsync" : : : "memory");
@@ -313,8 +315,6 @@ write_barrier(void) {
     __asm__ __volatile__ ("" : : : "memory");
 #elif arm_HOST_ARCH && !defined(arm_HOST_ARCH_PRE_ARMv7)
     __asm__ __volatile__ ("dmb  st" : : : "memory");
-#elif !defined(WITHSMP)
-    return;
 #else
 #error memory barriers unimplemented on this architecture
 #endif
@@ -322,7 +322,9 @@ write_barrier(void) {
 
 EXTERN_INLINE void
 store_load_barrier(void) {
-#if i386_HOST_ARCH
+#if defined(NOSMP)
+    return;
+#elif i386_HOST_ARCH
     __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory");
 #elif x86_64_HOST_ARCH
     __asm__ __volatile__ ("lock; addq $0,0(%%rsp)" : : : "memory");
@@ -332,8 +334,6 @@ store_load_barrier(void) {
     __asm__ __volatile__ ("membar #StoreLoad" : : : "memory");
 #elif arm_HOST_ARCH && !defined(arm_HOST_ARCH_PRE_ARMv7)
     __asm__ __volatile__ ("dmb" : : : "memory");
-#elif !defined(WITHSMP)
-    return;
 #else
 #error memory barriers unimplemented on this architecture
 #endif
@@ -341,7 +341,9 @@ store_load_barrier(void) {
 
 EXTERN_INLINE void
 load_load_barrier(void) {
-#if i386_HOST_ARCH
+#if defined(NOSMP)
+    return;
+#elif i386_HOST_ARCH
     __asm__ __volatile__ ("" : : : "memory");
 #elif x86_64_HOST_ARCH
     __asm__ __volatile__ ("" : : : "memory");
@@ -352,8 +354,6 @@ load_load_barrier(void) {
     __asm__ __volatile__ ("" : : : "memory");
 #elif arm_HOST_ARCH && !defined(arm_HOST_ARCH_PRE_ARMv7)
     __asm__ __volatile__ ("dmb" : : : "memory");
-#elif !defined(WITHSMP)
-    return;
 #else
 #error memory barriers unimplemented on this architecture
 #endif



More information about the ghc-commits mailing list