X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=includes%2FSMP.h;h=af4174fca601b285d1a960ae16f5cacc34f5693f;hb=a0be7e7ccd602efd9b7d35b3e0747a2c4f155ce9;hp=515516a9824864ccb7756b65917f9321097f24b6;hpb=7adc29e83d11ced8877490f0a12fd8b751b9922a;p=ghc-hetmet.git diff --git a/includes/SMP.h b/includes/SMP.h index 515516a..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 @@ -81,6 +91,21 @@ cas(StgVolatilePtr p, StgWord o, StgWord n) :"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 @@ -102,6 +127,11 @@ write_barrier(void) { __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 @@ -117,7 +147,6 @@ write_barrier(void) { INLINE_HEADER StgInfoTable * lockClosure(StgClosure *p) { -#if i386_HOST_ARCH || x86_64_HOST_ARCH || powerpc_HOST_ARCH StgWord info; do { nat i = 0; @@ -127,21 +156,14 @@ 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(): write_barrier(); p->header.info = info; -#else - RELEASE_SM_LOCK; -#endif } #else /* !THREADED_RTS */