comparison src/atomic/SDL_spinlock.c @ 5028:fffb33ae85e8

Whoops, good catch from Greg Jandl
author Sam Lantinga <slouken@libsdl.org>
date Tue, 18 Jan 2011 22:10:37 -0800
parents 1bf9e38431ec
children fd125217f00c
comparison
equal deleted inserted replaced
5027:8c33dd30f6a6 5028:fffb33ae85e8
22 #include "SDL_stdinc.h" 22 #include "SDL_stdinc.h"
23 23
24 #include "SDL_atomic.h" 24 #include "SDL_atomic.h"
25 #include "SDL_timer.h" 25 #include "SDL_timer.h"
26 26
27 #if defined(__WIN32__)
28 #include <intrin.h>
29
30 #elif defined(__MACOSX__)
31 #include <libkern/OSAtomic.h>
32
33 #endif
34
35 27
36 /* This function is where all the magic happens... */ 28 /* This function is where all the magic happens... */
37 SDL_bool 29 SDL_bool
38 SDL_AtomicTryLock(SDL_SpinLock *lock) 30 SDL_AtomicTryLock(SDL_SpinLock *lock)
39 { 31 {
40 #if defined(__WIN32__) 32 #if defined(_MSC_VER)
41 SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long)); 33 SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long));
42 return (_InterlockedExchange((long*)lock, 1) == 0); 34 return (_InterlockedExchange((long*)lock, 1) == 0);
43 35
44 #elif defined(__MACOSX__) 36 #elif defined(__MACOSX__)
45 return OSAtomicCompareAndSwap32Barrier(0, 1, lock); 37 return OSAtomicCompareAndSwap32Barrier(0, 1, lock);