106 extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); |
106 extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); |
107 |
107 |
108 /*@}*//*SDL AtomicLock*/ |
108 /*@}*//*SDL AtomicLock*/ |
109 |
109 |
110 /* Platform specific optimized versions of the atomic functions */ |
110 /* Platform specific optimized versions of the atomic functions */ |
111 #if defined(__WIN32__) |
111 #if defined(__WIN32__) && defined(_INC_WINDOWS) |
|
112 /* Don't include windows.h, since it may hose code that isn't expecting it, |
|
113 but if someone has already included it, this is fair game... */ |
|
114 #if 0 |
112 #define WIN32_LEAN_AND_MEAN |
115 #define WIN32_LEAN_AND_MEAN |
113 #include <windows.h> |
116 #include <windows.h> |
|
117 #endif |
114 |
118 |
115 #define SDL_AtomicSet(a, v) InterlockedExchange(&(a)->value, v) |
119 #define SDL_AtomicSet(a, v) InterlockedExchange(&(a)->value, v) |
116 #define SDL_AtomicGet(a) ((a)->value) |
120 #define SDL_AtomicGet(a) ((a)->value) |
117 #define SDL_AtomicAdd(a, v) InterlockedAdd(&(a)->value, v) |
121 #define SDL_AtomicAdd(a, v) InterlockedAdd(&(a)->value, v) |
118 #define SDL_AtomicCAS(a, oldval, newval) (InterlockedCompareExchange(&(a)->value, newval, oldval) == (oldval)) |
122 #define SDL_AtomicCAS(a, oldval, newval) (InterlockedCompareExchange(&(a)->value, newval, oldval) == (oldval)) |