diff options
author | Chris Robinson <[email protected]> | 2016-11-03 15:32:31 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-11-03 15:32:31 -0700 |
commit | 82e8dd0525c0379f33da84e98ff72fe878cb75e1 (patch) | |
tree | 2ee0e52e2b72f7f1b7a6a69a491fdd0e4724176c /include | |
parent | 815947492c9df58ab4872fd643b09ada5d2033ef (diff) |
Fix win32 atomic fallbacks
Diffstat (limited to 'include')
-rw-r--r-- | include/atomic.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/include/atomic.h b/include/atomic.h index 1f6ceae2..f3ee96b6 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -185,10 +185,18 @@ inline LONG AtomicAdd32(volatile LONG *dest, LONG incr) { return InterlockedExchangeAdd(dest, incr); } +inline LONGLONG AtomicAdd64(volatile LONGLONG *dest, LONGLONG incr) +{ + return InterlockedExchangeAdd64(dest, incr); +} inline LONG AtomicSub32(volatile LONG *dest, LONG decr) { return InterlockedExchangeAdd(dest, -decr); } +inline LONGLONG AtomicSub64(volatile LONGLONG *dest, LONGLONG decr) +{ + return InterlockedExchangeAdd64(dest, -decr); +} inline LONG AtomicSwap32(volatile LONG *dest, LONG newval) { @@ -212,7 +220,7 @@ inline bool CompareAndSwap64(volatile LONGLONG *dest, LONGLONG newval, LONGLONG return old == *oldval; } -#define WRAP_ADDSUB(T, _func, _ptr, _amnt) (_func((T volatile*)(_ptr), (_amnt)) +#define WRAP_ADDSUB(T, _func, _ptr, _amnt) _func((T volatile*)(_ptr), (_amnt)) #define WRAP_XCHG(T, _func, _ptr, _newval) ((T(*)(T volatile*,T))_func)((_ptr), (_newval)) #define WRAP_CMPXCHG(T, _func, _ptr, _newval, _oldval) ((bool(*)(T volatile*,T,T*))_func)((_ptr), (_newval), (_oldval)) @@ -240,9 +248,11 @@ int _al_invalid_atomic_size(); /* not defined */ #define ATOMIC_ADD(_val, _incr, ...) \ ((sizeof((_val)->value)==4) ? WRAP_ADDSUB(LONG, AtomicAdd32, &(_val)->value, (_incr)) : \ + (sizeof((_val)->value)==8) ? WRAP_ADDSUB(LONGLONG, AtomicAdd64, &(_val)->value, (_incr)) : \ _al_invalid_atomic_size()) #define ATOMIC_SUB(_val, _decr, ...) \ ((sizeof((_val)->value)==4) ? WRAP_ADDSUB(LONG, AtomicSub32, &(_val)->value, (_decr)) : \ + (sizeof((_val)->value)==8) ? WRAP_ADDSUB(LONGLONG, AtomicSub64, &(_val)->value, (_decr)) : \ _al_invalid_atomic_size()) #define ATOMIC_EXCHANGE(T, _val, _newval, ...) \ |