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

Commit

Permalink
Use compiler intrinsics on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jan 17, 2011
1 parent 292cd08 commit cd5c25d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/atomic/SDL_spinlock.c
Expand Up @@ -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>
Expand All @@ -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);
Expand Down

0 comments on commit cd5c25d

Please sign in to comment.