include/SDL_atomic.h
changeset 5016 cc879bc6c4cf
parent 5012 2e282002bac3
child 5024 38638d228a22
equal deleted inserted replaced
5015:1bf9e38431ec 5016:cc879bc6c4cf
   113 #ifndef SDL_DISABLE_ATOMIC_INLINE
   113 #ifndef SDL_DISABLE_ATOMIC_INLINE
   114 
   114 
   115 #if defined(__WIN32__)
   115 #if defined(__WIN32__)
   116 #include <intrin.h>
   116 #include <intrin.h>
   117 
   117 
   118 #define SDL_AtomicSet(a, v)     _InterlockedExchange(&(a)->value, (v))
   118 #define SDL_AtomicSet(a, v)     _InterlockedExchange((long*)&(a)->value, (v))
   119 #define SDL_AtomicGet(a)        ((a)->value)
   119 #define SDL_AtomicGet(a)        ((a)->value)
   120 #define SDL_AtomicAdd(a, v)     _InterlockedExchangeAdd(&(a)->value, (v))
   120 #define SDL_AtomicAdd(a, v)     _InterlockedExchangeAdd((long*)&(a)->value, (v))
   121 #define SDL_AtomicCAS(a, oldval, newval) (_InterlockedCompareExchange(&(a)->value, (newval), (oldval)) == (oldval))
   121 #define SDL_AtomicCAS(a, oldval, newval) (_InterlockedCompareExchange((long*)&(a)->value, (newval), (oldval)) == (oldval))
   122 #define SDL_AtomicSetPtr(a, v)  (void)_InterlockedExchangePointer((a), (v))
   122 #define SDL_AtomicSetPtr(a, v)  (void)_InterlockedExchangePointer((a), (v))
   123 #define SDL_AtomicGetPtr(a)     (*(a))
   123 #define SDL_AtomicGetPtr(a)     (*(a))
   124 #if _M_IX86
   124 #if _M_IX86
   125 #define SDL_AtomicCASPtr(a, oldval, newval) (_InterlockedCompareExchange((long*)(a), (long)(newval), (long)(oldval)) == (long)(oldval))
   125 #define SDL_AtomicCASPtr(a, oldval, newval) (_InterlockedCompareExchange((long*)(a), (long)(newval), (long)(oldval)) == (long)(oldval))
   126 #else
   126 #else