From 9719cfa88e6b818ddd40ed8b9f9fb63dddd111d0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 16 Jan 2011 17:45:42 -0800 Subject: [PATCH] Include windows.h in SDL_atomic.h by default, but don't include the atomic API in SDL.h This allows all SDL code to take advantage of the atomic intrinsics on Windows, but doesn't cause applications just including SDL.h to pull in windows.h --- include/SDL.h | 1 - include/SDL_atomic.h | 13 +++++++++---- src/SDL_assert.c | 1 + test/testatomic.c | 2 ++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/SDL.h b/include/SDL.h index 0f4eb35b0..9b47a281e 100644 --- a/include/SDL.h +++ b/include/SDL.h @@ -76,7 +76,6 @@ #include "SDL_main.h" #include "SDL_stdinc.h" -#include "SDL_atomic.h" #include "SDL_audio.h" #include "SDL_clipboard.h" #include "SDL_cpuinfo.h" diff --git a/include/SDL_atomic.h b/include/SDL_atomic.h index 26f66ae50..69db17c18 100644 --- a/include/SDL_atomic.h +++ b/include/SDL_atomic.h @@ -107,14 +107,16 @@ extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); /*@}*//*SDL AtomicLock*/ -/* Platform specific optimized versions of the atomic functions */ -#if defined(__WIN32__) && defined(_INC_WINDOWS) +/* Platform specific optimized versions of the atomic functions, + * you can disable these by defining SDL_DISABLE_ATOMIC_INLINE + */ +#ifndef SDL_DISABLE_ATOMIC_INLINE + +#if defined(__WIN32__) /* Don't include windows.h, since it may hose code that isn't expecting it, but if someone has already included it, this is fair game... */ -#if 0 #define WIN32_LEAN_AND_MEAN #include -#endif #define SDL_AtomicSet(a, v) InterlockedExchange(&(a)->value, v) #define SDL_AtomicGet(a) ((a)->value) @@ -169,6 +171,9 @@ extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); #endif +#endif /* !SDL_DISABLE_ATOMIC_INLINE */ + + /** * \brief A type representing an atomic integer value. It is a struct * so people don't accidentally use numeric operations on it. diff --git a/src/SDL_assert.c b/src/SDL_assert.c index 0c433d80a..167035318 100644 --- a/src/SDL_assert.c +++ b/src/SDL_assert.c @@ -21,6 +21,7 @@ */ #include "SDL.h" +#include "SDL_atomic.h" #include "SDL_assert.h" #include "SDL_assert_c.h" #include "video/SDL_sysvideo.h" diff --git a/test/testatomic.c b/test/testatomic.c index bf845d129..afa20b402 100644 --- a/test/testatomic.c +++ b/test/testatomic.c @@ -1,5 +1,7 @@ #include + #include "SDL.h" +#include "SDL_atomic.h" #include "SDL_assert.h" /*