aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include/alMain.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-08-29 20:52:13 -0700
committerChris Robinson <[email protected]>2011-08-29 20:52:13 -0700
commitda081b81c425805eef5b3d4a07c7a213490e04b7 (patch)
tree0d122e52f4a5bfb0898940e0b077f60a53c4aeb1 /OpenAL32/Include/alMain.h
parent500ad776ea5bba13240cde84b2aa7c1caca77753 (diff)
Do a compare-exchange to set the context error
This allows for unlocked context access when getting the error
Diffstat (limited to 'OpenAL32/Include/alMain.h')
-rw-r--r--OpenAL32/Include/alMain.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 9a7c1cc4..a0c83254 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -235,6 +235,10 @@ static __inline RefCount DecrementRef(volatile RefCount *ptr)
static __inline T Exchange_##T(volatile T *ptr, T newval) \
{ \
return __sync_lock_test_and_set(ptr, newval); \
+} \
+static __inline ALboolean CompExchange_##T(volatile T *ptr, T oldval, T newval)\
+{ \
+ return __sync_bool_compare_and_swap(ptr, oldval, newval); \
}
#elif defined(_WIN32)
@@ -253,6 +257,14 @@ static __inline T Exchange_##T(volatile T *ptr, T newval) \
volatile LONG *l; \
} u = { ptr }; \
return InterlockedExchange(u.l, newval); \
+} \
+static __inline ALboolean CompExchange_##T(volatile T *ptr, T oldval, T newval)\
+{ \
+ union { \
+ volatile T *t; \
+ volatile LONG *l; \
+ } u = { ptr }; \
+ return InterlockedCompareExchange(u.l, newval, oldval) == oldval; \
}
#elif defined(__APPLE__)
@@ -278,6 +290,14 @@ static __inline T Exchange_##T(volatile T *ptr, T newval) \
oldval = *u.i; \
} while(!OSAtomicCompareAndSwap32Barrier(oldval, newval, u.i)); \
return oldval; \
+} \
+static __inline ALboolean CompExchange_##T(volatile T *ptr, T oldval, T newval)\
+{ \
+ union { \
+ volatile T *t; \
+ volatile int32_t *i; \
+ } u = { ptr }; \
+ return OSAtomicCompareAndSwap32Barrier(oldval, newval, u.i); \
}
#else