summaryrefslogtreecommitdiff
path: root/include/SDL_atomic.h
diff options
context:
space:
mode:
authorSam Lantinga <slouken@libsdl.org>2011-01-21 23:46:51 -0800
committerSam Lantinga <slouken@libsdl.org>2011-01-21 23:46:51 -0800
commitf05d3d5c42d528391a21c1455f0fec6256a131db (patch)
tree6ebbb94d19f2f455b7160d732f280396612aab68 /include/SDL_atomic.h
parent24fc7c31eaae2718cc776d959a626997746b9c81 (diff)
downloadsdl-f05d3d5c42d528391a21c1455f0fec6256a131db.tar.gz
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.
Diffstat (limited to 'include/SDL_atomic.h')
-rw-r--r--include/SDL_atomic.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/include/SDL_atomic.h b/include/SDL_atomic.h
index de643f8d8..c2dfd045e 100644
--- a/include/SDL_atomic.h
+++ b/include/SDL_atomic.h
@@ -56,6 +56,13 @@
#include "begin_code.h"
+/* Need to do this here because intrin.h has C++ code in it */
+/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
+#if defined(_MSC_VER) && (_MSC_VER >= 1500)
+#include <intrin.h>
+#define HAVE_MSC_ATOMICS
+#endif
+
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -112,8 +119,7 @@ extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock);
*/
#ifndef SDL_DISABLE_ATOMIC_INLINE
-#if defined(_MSC_VER)
-#include <intrin.h>
+#if defined(HAVE_MSC_ATOMICS)
#define SDL_AtomicSet(a, v) _InterlockedExchange((long*)&(a)->value, (v))
#define SDL_AtomicGet(a) ((a)->value)