X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=includes%2Fstg%2FSMP.h;h=f1b04220094a146371cffdac4989c9fc9cff5d55;hb=521b792553bacbdb0eec138b150ab0626ea6f36b;hp=b302f4886bdeaa234955519eaaed18cf0c3011b8;hpb=0ee6cfbe62211121fc84a9d2e500f414f9e397f7;p=ghc-hetmet.git diff --git a/includes/stg/SMP.h b/includes/stg/SMP.h index b302f48..f1b0422 100644 --- a/includes/stg/SMP.h +++ b/includes/stg/SMP.h @@ -293,6 +293,12 @@ load_load_barrier(void) { #endif } +// Load a pointer from a memory location that might be being modified +// concurrently. This prevents the compiler from optimising away +// multiple loads of the memory location, as it might otherwise do in +// a busy wait loop for example. +#define VOLATILE_LOAD(p) (*((StgVolatilePtr)(p))) + /* ---------------------------------------------------------------------- */ #else /* !THREADED_RTS */ @@ -308,7 +314,8 @@ xchg(StgPtr p, StgWord w) return old; } -STATIC_INLINE StgWord +EXTERN_INLINE StgWord cas(StgVolatilePtr p, StgWord o, StgWord n); +EXTERN_INLINE StgWord cas(StgVolatilePtr p, StgWord o, StgWord n) { StgWord result; @@ -331,6 +338,8 @@ atomic_dec(StgVolatilePtr p) return --(*p); } +#define VOLATILE_LOAD(p) ((StgWord)*((StgWord*)(p))) + #endif /* !THREADED_RTS */ #endif /* SMP_H */