From d0110ebfd26a76d85d465b2cbc2332359dcf55e0 Mon Sep 17 00:00:00 2001 From: Pixel Date: Wed, 11 Nov 2009 13:40:20 -0800 Subject: Forgot cmpxchg. --- include/Atomic.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/Atomic.h b/include/Atomic.h index 0f3e8d3..35edbf1 100644 --- a/include/Atomic.h +++ b/include/Atomic.h @@ -21,6 +21,8 @@ template T Increment(volatile T * ptr, T delta = 1) { __sync_fetch_and template T Decrement(volatile T * ptr, T delta = 1) { __sync_fetch_and_sub(ptr, delta); } }; +template T CmpXChg(volatile T * ptr, T xch, T cmp) { return __sync_val_compare_and_swap(ptr, cmp, xch); } + template T Exchange32(volatile T * ptr, T exchange) { #if defined(i386) || defined (__x86_64) __asm__ __volatile__("lock xchgl %0, (%1)" : "+r"(exchange) : "r"(ptr)); -- cgit v1.2.3