include/SDL_atomic.h
changeset 6923 d3b709232670
parent 6885 700f1b25f77f
child 6978 e851407e9294
equal deleted inserted replaced
6922:91d157d9f283 6923:d3b709232670
   124 
   124 
   125 /**
   125 /**
   126  * The compiler barrier prevents the compiler from reordering
   126  * The compiler barrier prevents the compiler from reordering
   127  * reads and writes to globally visible variables across the call.
   127  * reads and writes to globally visible variables across the call.
   128  */
   128  */
   129 #ifdef _MSC_VER
   129 #if defined(_MSC_VER) && (_MSC_VER > 1200)
   130 void _ReadWriteBarrier(void);
   130 void _ReadWriteBarrier(void);
   131 #pragma intrinsic(_ReadWriteBarrier)
   131 #pragma intrinsic(_ReadWriteBarrier)
   132 #define SDL_CompilerBarrier()   _ReadWriteBarrier()
   132 #define SDL_CompilerBarrier()   _ReadWriteBarrier()
   133 #elif defined(__GNUC__)
   133 #elif defined(__GNUC__)
   134 #define SDL_CompilerBarrier()   __asm__ __volatile__ ("" : : : "memory")
   134 #define SDL_CompilerBarrier()   __asm__ __volatile__ ("" : : : "memory")
   135 #else
   135 #else
   136 #define SDL_CompilerBarrier()   \
   136 #define SDL_CompilerBarrier()   \
   137 ({ SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); SDL_AtomicUnlock(&_tmp); })
   137 { SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); SDL_AtomicUnlock(&_tmp); }
   138 #endif
   138 #endif
   139 
   139 
   140 /* Platform specific optimized versions of the atomic functions,
   140 /* Platform specific optimized versions of the atomic functions,
   141  * you can disable these by defining SDL_DISABLE_ATOMIC_INLINE
   141  * you can disable these by defining SDL_DISABLE_ATOMIC_INLINE
   142  */
   142  */