src/atomic/SDL_spinlock.c
changeset 5090 327f181542f1
parent 5086 c2539ff054c8
child 5091 2164a79b5ca9
equal deleted inserted replaced
5089:79bd1e289005 5090:327f181542f1
    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 /* Don't do the check for Visual Studio 2005, it's safe here */
    27 /* Don't do the check for Visual Studio 2005, it's safe here */
    28 #if defined(_MSC_VER)
    28 #include "../core/windows/SDL_windows.h"
    29 #ifdef _WIN32_WCE
       
    30 #define WIN32_LEAN_AND_MEAN
       
    31 #include <windows.h>
       
    32 #else
       
    33 #include <intrin.h>
       
    34 #endif
       
    35 #endif /* _MSC_VER */
       
    36 
    29 
    37 /* This function is where all the magic happens... */
    30 /* This function is where all the magic happens... */
    38 SDL_bool
    31 SDL_bool
    39 SDL_AtomicTryLock(SDL_SpinLock *lock)
    32 SDL_AtomicTryLock(SDL_SpinLock *lock)
    40 {
    33 {
    41 #if defined(_MSC_VER)
    34 #if defined(_MSC_VER)
    42     SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long));
    35     SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long));
    43     return (_InterlockedExchange((long*)lock, 1) == 0);
    36     return (InterlockedExchange((long*)lock, 1) == 0);
    44 
    37 
    45 #elif defined(__MACOSX__)
    38 #elif defined(__MACOSX__)
    46     return OSAtomicCompareAndSwap32Barrier(0, 1, lock);
    39     return OSAtomicCompareAndSwap32Barrier(0, 1, lock);
    47 
    40 
    48 #elif defined(HAVE_GCC_ATOMICS) || defined(HAVE_GCC_SYNC_LOCK_TEST_AND_SET)
    41 #elif defined(HAVE_GCC_ATOMICS) || defined(HAVE_GCC_SYNC_LOCK_TEST_AND_SET)