src/atomic/SDL_spinlock.c
changeset 8979 1e283b7a1580
parent 8583 fb2933ca805f
child 8991 13b0df1793e8
     1.1 --- a/src/atomic/SDL_spinlock.c	Mon Jul 07 10:33:32 2014 -0700
     1.2 +++ b/src/atomic/SDL_spinlock.c	Sat Jul 05 16:11:23 2014 -0700
     1.3 @@ -28,6 +28,9 @@
     1.4  #include "SDL_mutex.h"
     1.5  #include "SDL_timer.h"
     1.6  
     1.7 +#if !defined(HAVE_GCC_ATOMICS) && defined(__SOLARIS__)
     1.8 +#include <atomic.h>
     1.9 +#endif
    1.10  
    1.11  /* This function is where all the magic happens... */
    1.12  SDL_bool
    1.13 @@ -90,6 +93,14 @@
    1.14      /* pthread instructions */
    1.15      return (pthread_spin_trylock(lock) == 0);
    1.16  
    1.17 +#elif defined(__SOLARIS__) && defined(_LP64)
    1.18 +    /* Used for Solaris with non-gcc compilers. */
    1.19 +    return (SDL_bool) ((int) atomic_cas_64((volatile uint64_t*)lock, 0, 1) == 0);
    1.20 +
    1.21 +#elif defined(__SOLARIS__) && !defined(_LP64)
    1.22 +    /* Used for Solaris with non-gcc compilers. */
    1.23 +    return (SDL_bool) ((int) atomic_cas_32((volatile uint32_t*)lock, 0, 1) == 0);
    1.24 +
    1.25  #else
    1.26  #error Please implement for your platform.
    1.27      return SDL_FALSE;
    1.28 @@ -118,6 +129,11 @@
    1.29  #elif HAVE_PTHREAD_SPINLOCK
    1.30      pthread_spin_unlock(lock);
    1.31  
    1.32 +#elif defined(__SOLARIS__)
    1.33 +    /* Used for Solaris when not using gcc. */
    1.34 +    *lock = 0;
    1.35 +    membar_producer();
    1.36 +
    1.37  #else
    1.38      *lock = 0;
    1.39  #endif