X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=includes%2FSMP.h;h=af4174fca601b285d1a960ae16f5cacc34f5693f;hb=4287edeb7f329529149d8c95597d5e418388265f;hp=d985576cb4780a52bfc6edb99db1abbc8e8f06de;hpb=b1953bbb1ed3cb16497e5447db7487f0c2d9e41a;p=ghc-hetmet.git diff --git a/includes/SMP.h b/includes/SMP.h index d985576..af4174f 100644 --- a/includes/SMP.h +++ b/includes/SMP.h @@ -48,6 +48,16 @@ xchg(StgPtr p, StgWord w) :"=r" (result) :"r" (w), "r" (p) ); +#elif sparc_HOST_ARCH + result = w; + __asm__ __volatile__ ( + "swap %1,%0" + : "+r" (result), "+m" (*p) + : /* no input-only operands */ + ); +#elif !defined(WITHSMP) + result = *p; + *p = w; #else #error xchg() unimplemented on this architecture #endif @@ -76,10 +86,26 @@ cas(StgVolatilePtr p, StgWord o, StgWord n) " stwcx. %2, 0, %3\n" " bne- 1b\n" "2:" - :"=r" (result) + :"=&r" (result) :"r" (o), "r" (n), "r" (p) + :"cc", "memory" ); return result; +#elif sparc_HOST_ARCH + __asm__ __volatile__ ( + "cas [%1], %2, %0" + : "+r" (n) + : "r" (p), "r" (o) + : "memory" + ); + return n; +#elif !defined(WITHSMP) + StgWord result; + result = *p; + if (result == o) { + *p = n; + } + return result; #else #error cas() unimplemented on this architecture #endif @@ -96,11 +122,16 @@ cas(StgVolatilePtr p, StgWord o, StgWord n) * that require it (not x86 or x86_64). */ INLINE_HEADER void -wb(void) { +write_barrier(void) { #if i386_HOST_ARCH || x86_64_HOST_ARCH __asm__ __volatile__ ("" : : : "memory"); #elif powerpc_HOST_ARCH __asm__ __volatile__ ("lwsync" : : : "memory"); +#elif sparc_HOST_ARCH + /* Sparc in TSO mode does not require write/write barriers. */ + __asm__ __volatile__ ("" : : : "memory"); +#elif !defined(WITHSMP) + return; #else #error memory barriers unimplemented on this architecture #endif @@ -116,7 +147,6 @@ wb(void) { INLINE_HEADER StgInfoTable * lockClosure(StgClosure *p) { -#if i386_HOST_ARCH || x86_64_HOST_ARCH || powerpc_HOST_ARCH StgWord info; do { nat i = 0; @@ -126,26 +156,19 @@ lockClosure(StgClosure *p) } while (++i < SPIN_COUNT); yieldThread(); } while (1); -#else - ACQUIRE_SM_LOCK -#endif } INLINE_HEADER void unlockClosure(StgClosure *p, StgInfoTable *info) { -#if i386_HOST_ARCH || x86_64_HOST_ARCH || powerpc_HOST_ARCH // This is a strictly ordered write, so we need a wb(): - wb(); + write_barrier(); p->header.info = info; -#else - RELEASE_SM_LOCK; -#endif } #else /* !THREADED_RTS */ -#define wb() /* nothing */ +#define write_barrier() /* nothing */ INLINE_HEADER StgWord xchg(StgPtr p, StgWord w)