Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Include windows.h in SDL_atomic.h by default, but don't include the a…
…tomic 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
  • Loading branch information
slouken committed Jan 17, 2011
1 parent 41baa9c commit 9719cfa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
1 change: 0 additions & 1 deletion include/SDL.h
Expand Up @@ -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"
Expand Down
13 changes: 9 additions & 4 deletions include/SDL_atomic.h
Expand Up @@ -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 <windows.h>
#endif

#define SDL_AtomicSet(a, v) InterlockedExchange(&(a)->value, v)
#define SDL_AtomicGet(a) ((a)->value)
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/SDL_assert.c
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions test/testatomic.c
@@ -1,5 +1,7 @@
#include <stdio.h>

#include "SDL.h"
#include "SDL_atomic.h"
#include "SDL_assert.h"

/*
Expand Down

0 comments on commit 9719cfa

Please sign in to comment.