From d4c4ee9aa1fdd216e46d13e3a65f26d05d1d528b Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 29 Nov 2011 00:52:05 -0800 Subject: Adding memory fences to Atomic.h; won't hurt that much... --- includes/Atomic.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'includes') diff --git a/includes/Atomic.h b/includes/Atomic.h index b31c26d..d084d31 100644 --- a/includes/Atomic.h +++ b/includes/Atomic.h @@ -25,6 +25,8 @@ template T Decrement(volatile T * ptr, T delta = 1) { return __sync_fe template T CmpXChgVal(volatile T * ptr, const T xch, const T cmp) { return __sync_val_compare_and_swap(ptr, cmp, xch); } template bool CmpXChgBool(volatile T * ptr, const T xch, const T cmp) { return __sync_bool_compare_and_swap(ptr, cmp, xch); } +static inline void MemoryFence() { __sync_synchronize(); } + template T Exchange32(volatile T * ptr, const T exchange) { #if defined(i386) || defined (__x86_64) __asm__ __volatile__("lock xchgl %0, (%1)" : "+r"(exchange) : "r"(ptr)); -- cgit v1.2.3