Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Use compiler intrinsics on Windows

  • Loading branch information
slouken committed Jan 17, 2011
1 parent 292cd08 commit cd5c25d249478e3f12bde49df40266f01a333b63
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/atomic/SDL_spinlock.c
@@ -25,8 +25,7 @@
#include "SDL_timer.h"

#if defined(__WIN32__)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <intrin.h>

#elif defined(__MACOSX__)
#include <libkern/OSAtomic.h>
@@ -39,7 +38,8 @@ SDL_bool
SDL_AtomicTryLock(SDL_SpinLock *lock)
{
#if defined(__WIN32__)
return (InterlockedExchange(lock, 1) == 0);
SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long));
return (_InterlockedExchange((long*)lock, 1) == 0);

#elif defined(__MACOSX__)
return OSAtomicCompareAndSwap32Barrier(0, 1, lock);

0 comments on commit cd5c25d

Please sign in to comment.