1 /* ----------------------------------------------------------------------------
3 * (c) The GHC Team, 2005
5 * Macros for SMP support
7 * -------------------------------------------------------------------------- */
12 /* SMP is currently not compatible with the following options:
17 * and unregisterised builds.
22 #if defined(PROFILING) || defined(TICKY_TICKY)
23 #error Build options incompatible with SMP.
27 * XCHG - the atomic exchange instruction. Used for locking closures
28 * during updates (see LOCK_CLOSURE below) and the MVar primops.
31 xchg(StgPtr p, StgWord w)
35 __asm__ __volatile__ (
37 :"+r" (result), "+m" (*p)
38 : /* no input-only operands */
43 INLINE_HEADER StgInfoTable *
44 lockClosure(StgClosure *p)
49 info = xchg((P_)&p->header.info, (W_)&stg_WHITEHOLE_info);
50 if (info != (W_)&stg_WHITEHOLE_info) return (StgInfoTable *)info;
54 info = p->header.info;