summaryrefslogtreecommitdiff
path: root/include/Atomic.h
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2009-11-11 13:40:20 -0800
committerPixel <pixel@nobis-crew.org>2009-11-11 13:40:20 -0800
commitd0110ebfd26a76d85d465b2cbc2332359dcf55e0 (patch)
tree2b1f41ce79b31cddd8a8ccb194013d20a933424c /include/Atomic.h
parenta7f5fa256d8540a3a426ad7a37dcccfe269f38af (diff)
Forgot cmpxchg.
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));