summaryrefslogtreecommitdiff
path: root/include/Atomic.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/Atomic.h')
-rw-r--r--include/Atomic.h2
1 files changed, 2 insertions, 0 deletions
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 <class T> T Increment(volatile T * ptr, T delta = 1) { __sync_fetch_and
template <class T> T Decrement(volatile T * ptr, T delta = 1) { __sync_fetch_and_sub(ptr, delta); }
};
+template <class T> T CmpXChg(volatile T * ptr, T xch, T cmp) { return __sync_val_compare_and_swap(ptr, cmp, xch); }
+
template <class T> T Exchange32(volatile T * ptr, T exchange) {
#if defined(i386) || defined (__x86_64)
__asm__ __volatile__("lock xchgl %0, (%1)" : "+r"(exchange) : "r"(ptr));