include/SDL_atomic.h
changeset 5012 2e282002bac3
parent 5006 8e8876e4aec6
child 5016 cc879bc6c4cf
     1.1 --- a/include/SDL_atomic.h	Mon Jan 17 13:52:40 2011 -0800
     1.2 +++ b/include/SDL_atomic.h	Mon Jan 17 13:53:31 2011 -0800
     1.3 @@ -113,18 +113,19 @@
     1.4  #ifndef SDL_DISABLE_ATOMIC_INLINE
     1.5  
     1.6  #if defined(__WIN32__)
     1.7 -/* Don't include windows.h, since it may hose code that isn't expecting it,
     1.8 -   but if someone has already included it, this is fair game... */
     1.9 -#define WIN32_LEAN_AND_MEAN
    1.10 -#include <windows.h>
    1.11 +#include <intrin.h>
    1.12  
    1.13 -#define SDL_AtomicSet(a, v)     InterlockedExchange(&(a)->value, v)
    1.14 +#define SDL_AtomicSet(a, v)     _InterlockedExchange(&(a)->value, (v))
    1.15  #define SDL_AtomicGet(a)        ((a)->value)
    1.16 -#define SDL_AtomicAdd(a, v)     InterlockedAdd(&(a)->value, v)
    1.17 -#define SDL_AtomicCAS(a, oldval, newval) (InterlockedCompareExchange(&(a)->value, newval, oldval) == (oldval))
    1.18 -#define SDL_AtomicSetPtr(a, v)  InterlockedExchangePointer(a, v)
    1.19 -#define SDL_AtomicGetPtr(a)     (*(a))
    1.20 -#define SDL_AtomicCASPtr(a, oldval, newval) (InterlockedCompareExchangePointer(a, newval, oldval) == (oldval))
    1.21 +#define SDL_AtomicAdd(a, v)     _InterlockedExchangeAdd(&(a)->value, (v))
    1.22 +#define SDL_AtomicCAS(a, oldval, newval) (_InterlockedCompareExchange(&(a)->value, (newval), (oldval)) == (oldval))
    1.23 +#define SDL_AtomicSetPtr(a, v)  (void)_InterlockedExchangePointer((a), (v))
    1.24 +#define SDL_AtomicGetPtr(a)     (*(a))
    1.25 +#if _M_IX86
    1.26 +#define SDL_AtomicCASPtr(a, oldval, newval) (_InterlockedCompareExchange((long*)(a), (long)(newval), (long)(oldval)) == (long)(oldval))
    1.27 +#else
    1.28 +#define SDL_AtomicCASPtr(a, oldval, newval) (_InterlockedCompareExchangePointer((a), (newval), (oldval)) == (oldval))
    1.29 +#endif
    1.30  
    1.31  #elif defined(__MACOSX__)
    1.32  #include <libkern/OSAtomic.h>