From: simonmar Date: Tue, 24 May 2005 15:43:32 +0000 (+0000) Subject: [project @ 2005-05-24 15:43:32 by simonmar] X-Git-Tag: Initial_conversion_from_CVS_complete~476 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=6a695ced68e4b17bfb503873126072c380b8aaf7;p=ghc-hetmet.git [project @ 2005-05-24 15:43:32 by simonmar] implement lockClosure properly --- diff --git a/ghc/includes/SMP.h b/ghc/includes/SMP.h index 86930f9..e3916bc 100644 --- a/ghc/includes/SMP.h +++ b/ghc/includes/SMP.h @@ -33,7 +33,7 @@ xchg(StgPtr p, StgWord w) StgWord result; result = w; __asm__ __volatile__ ( - "xchgl %1,%0" + "xchg %1,%0" :"+r" (result), "+m" (*p) : /* no input-only operands */ ); @@ -43,15 +43,26 @@ xchg(StgPtr p, StgWord w) INLINE_HEADER StgInfoTable * lockClosure(StgClosure *p) { +#if i386_HOST_ARCH || x86_64_HOST_ARCH StgWord info; -#if 0 do { info = xchg((P_)&p->header.info, (W_)&stg_WHITEHOLE_info); if (info != (W_)&stg_WHITEHOLE_info) return (StgInfoTable *)info; yieldThread(); } while (1); #else - info = p->header.info; + ACQUIRE_SM_LOCK +#endif +} + +INLINE_HEADER void +unlockClosure(StgClosure *p, StgInfoTable *info) +{ +#if i386_HOST_ARCH || x86_64_HOST_ARCH + // This is safe enough, because lockClosure() does the memory barrier: + p->header.info = info; +#else + RELEASE_SM_LOCK; #endif }