Include windows.h in SDL_atomic.h by default, but don't include the atomic API in SDL.h
authorSam Lantinga <slouken@libsdl.org>
Sun, 16 Jan 2011 17:45:42 -0800
changeset 50068e8876e4aec6
parent 5005 7f0265279b68
child 5007 adf6f0c8ec35
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
include/SDL_atomic.h
src/SDL_assert.c
test/testatomic.c
     1.1 --- a/include/SDL.h	Sun Jan 16 15:31:09 2011 -0800
     1.2 +++ b/include/SDL.h	Sun Jan 16 17:45:42 2011 -0800
     1.3 @@ -76,7 +76,6 @@
     1.4  
     1.5  #include "SDL_main.h"
     1.6  #include "SDL_stdinc.h"
     1.7 -#include "SDL_atomic.h"
     1.8  #include "SDL_audio.h"
     1.9  #include "SDL_clipboard.h"
    1.10  #include "SDL_cpuinfo.h"
     2.1 --- a/include/SDL_atomic.h	Sun Jan 16 15:31:09 2011 -0800
     2.2 +++ b/include/SDL_atomic.h	Sun Jan 16 17:45:42 2011 -0800
     2.3 @@ -107,14 +107,16 @@
     2.4  
     2.5  /*@}*//*SDL AtomicLock*/
     2.6  
     2.7 -/* Platform specific optimized versions of the atomic functions */
     2.8 -#if defined(__WIN32__) && defined(_INC_WINDOWS)
     2.9 +/* Platform specific optimized versions of the atomic functions,
    2.10 + * you can disable these by defining SDL_DISABLE_ATOMIC_INLINE
    2.11 + */
    2.12 +#ifndef SDL_DISABLE_ATOMIC_INLINE
    2.13 +
    2.14 +#if defined(__WIN32__)
    2.15  /* Don't include windows.h, since it may hose code that isn't expecting it,
    2.16     but if someone has already included it, this is fair game... */
    2.17 -#if 0
    2.18  #define WIN32_LEAN_AND_MEAN
    2.19  #include <windows.h>
    2.20 -#endif
    2.21  
    2.22  #define SDL_AtomicSet(a, v)     InterlockedExchange(&(a)->value, v)
    2.23  #define SDL_AtomicGet(a)        ((a)->value)
    2.24 @@ -169,6 +171,9 @@
    2.25  
    2.26  #endif
    2.27  
    2.28 +#endif /* !SDL_DISABLE_ATOMIC_INLINE */
    2.29 +
    2.30 +
    2.31  /**
    2.32   * \brief A type representing an atomic integer value.  It is a struct
    2.33   *        so people don't accidentally use numeric operations on it.
     3.1 --- a/src/SDL_assert.c	Sun Jan 16 15:31:09 2011 -0800
     3.2 +++ b/src/SDL_assert.c	Sun Jan 16 17:45:42 2011 -0800
     3.3 @@ -21,6 +21,7 @@
     3.4  */
     3.5  
     3.6  #include "SDL.h"
     3.7 +#include "SDL_atomic.h"
     3.8  #include "SDL_assert.h"
     3.9  #include "SDL_assert_c.h"
    3.10  #include "video/SDL_sysvideo.h"
     4.1 --- a/test/testatomic.c	Sun Jan 16 15:31:09 2011 -0800
     4.2 +++ b/test/testatomic.c	Sun Jan 16 17:45:42 2011 -0800
     4.3 @@ -1,5 +1,7 @@
     4.4  #include <stdio.h>
     4.5 +
     4.6  #include "SDL.h"
     4.7 +#include "SDL_atomic.h"
     4.8  #include "SDL_assert.h"
     4.9  
    4.10  /*