Fixed bug #1097
authorSam Lantinga <slouken@libsdl.org>
Fri, 21 Jan 2011 23:46:51 -0800
changeset 50731e94e68525d5
parent 5072 2341ecc03388
child 5074 906d7293bb47
Fixed bug #1097

There are problems with including intrin.h in C linkage in C++ compilation,
and further conflicts between intrin.h and winnt.h on Visual Studio 2005.
include/SDL_atomic.h
src/atomic/SDL_spinlock.c
     1.1 --- a/include/SDL_atomic.h	Sat Jan 22 03:57:27 2011 -0500
     1.2 +++ b/include/SDL_atomic.h	Fri Jan 21 23:46:51 2011 -0800
     1.3 @@ -56,6 +56,13 @@
     1.4  
     1.5  #include "begin_code.h"
     1.6  
     1.7 +/* Need to do this here because intrin.h has C++ code in it */
     1.8 +/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
     1.9 +#if defined(_MSC_VER) && (_MSC_VER >= 1500)
    1.10 +#include <intrin.h>
    1.11 +#define HAVE_MSC_ATOMICS
    1.12 +#endif
    1.13 +
    1.14  /* Set up for C function definitions, even when using C++ */
    1.15  #ifdef __cplusplus
    1.16  /* *INDENT-OFF* */
    1.17 @@ -112,8 +119,7 @@
    1.18   */
    1.19  #ifndef SDL_DISABLE_ATOMIC_INLINE
    1.20  
    1.21 -#if defined(_MSC_VER)
    1.22 -#include <intrin.h>
    1.23 +#if defined(HAVE_MSC_ATOMICS)
    1.24  
    1.25  #define SDL_AtomicSet(a, v)     _InterlockedExchange((long*)&(a)->value, (v))
    1.26  #define SDL_AtomicGet(a)        ((a)->value)
     2.1 --- a/src/atomic/SDL_spinlock.c	Sat Jan 22 03:57:27 2011 -0500
     2.2 +++ b/src/atomic/SDL_spinlock.c	Fri Jan 21 23:46:51 2011 -0800
     2.3 @@ -24,6 +24,10 @@
     2.4  #include "SDL_atomic.h"
     2.5  #include "SDL_timer.h"
     2.6  
     2.7 +/* Don't do the check for Visual Studio 2005, it's safe here */
     2.8 +#if defined(_MSC_VER)
     2.9 +#include <intrin.h>
    2.10 +#endif
    2.11  
    2.12  /* This function is where all the magic happens... */
    2.13  SDL_bool