2 #ifndef __ARCH_MSVC_ORO_ATOMIC__ 3 #define __ARCH_MSVC_ORO_ATOMIC__ 11 #define ORO_ATOMIC_SETUP oro_atomic_set 12 #define ORO_ATOMIC_CLEANUP(a_int) 14 #define oro_atomic_read(a_int) (*(a_int)) 16 #define oro_atomic_set(a_int,n) (*(a_int) = (n)) 20 _InterlockedExchangeAdd((
long *)a_int, n);
30 return ((_InterlockedExchangeAdd((
long *)a_int, -n) - n) == 0);
35 _InterlockedIncrement((
long *)a_int);
40 _InterlockedDecrement((
long *)a_int);
45 return (_InterlockedDecrement((
long *)a_int) == 0);
50 return (_InterlockedIncrement((
long *)a_int) == 0);
55 return ((_InterlockedExchangeAdd((
long *)a_int, n) + n) < 0);
60 return _InterlockedExchangeAdd((
long *)a_int, n) + n;
70 return _InterlockedIncrement((
long *)a_int);
75 return _InterlockedDecrement((
long *)a_int);
80 return _InterlockedAnd((
long *)a_int, ~mask);
85 return _InterlockedOr((
long *)a_int, mask);
89 #pragma warning(disable : 4715) // Disable warning on "specified function can potentially not return a value" 91 template<
typename T>
inline T
oro_cmpxchg(
volatile void * ptr, T old, T _new)
96 return (T)(_InterlockedCompareExchange16((
short *)ptr, (
short)_new, (
short)old));
98 return (T)(_InterlockedCompareExchange((
long *)ptr, (
long)_new, (
long)old));
100 return (T)(_InterlockedCompareExchange64((__int64 *)ptr, (__int64)_new, (__int64)old));
static __forceinline int oro_atomic_inc_return(oro_atomic_t *a_int)
static __forceinline void oro_atomic_add(oro_atomic_t *a_int, int n)
static __forceinline void oro_atomic_dec(oro_atomic_t *a_int)
static __forceinline int oro_atomic_dec_and_test(oro_atomic_t *a_int)
static __forceinline void oro_atomic_sub(oro_atomic_t *a_int, int n)
static __forceinline int oro_atomic_add_negative(oro_atomic_t *a_int, int n)
volatile long oro_atomic_t
static __forceinline int oro_atomic_inc_and_test(oro_atomic_t *a_int)
static __forceinline int oro_atomic_sub_return(oro_atomic_t *a_int, int n)
static __forceinline int oro_atomic_set_mask(oro_atomic_t *a_int, int mask)
static __forceinline int oro_atomic_sub_and_test(oro_atomic_t *a_int, int n)
static __forceinline int oro_atomic_dec_return(oro_atomic_t *a_int)
static __forceinline int oro_atomic_clear_mask(oro_atomic_t *a_int, int mask)
static __forceinline int oro_atomic_add_return(oro_atomic_t *a_int, int n)
T oro_cmpxchg(volatile void *ptr, T old, T _new)
static __forceinline void oro_atomic_inc(oro_atomic_t *a_int)