From 57839d11ff806d172506e4a5104c1ae3d286df1c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Feb 2010 16:12:44 +0000 Subject: gallium: Use MSVC atomic intrinsics directly instead of the Windows header wrappers. --- src/gallium/include/pipe/p_atomic.h | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/gallium/include/pipe/p_atomic.h b/src/gallium/include/pipe/p_atomic.h index d50526662f..a4b769d0bf 100644 --- a/src/gallium/include/pipe/p_atomic.h +++ b/src/gallium/include/pipe/p_atomic.h @@ -26,8 +26,8 @@ extern "C" { #if (defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || \ defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)) #define PIPE_ATOMIC_OS_UNLOCKED -#elif (defined(PIPE_CC_MSVC) && defined(PIPE_SUBSYSTEM_WINDOWS_USER)) -#define PIPE_ATOMIC_OS_MS_INTERLOCK +#elif defined(PIPE_CC_MSVC) +#define PIPE_ATOMIC_MSVC_INTRINSIC #elif (defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)) #define PIPE_ATOMIC_ASM_MSVC_X86 #elif (defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86)) @@ -217,42 +217,46 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) #endif -#if defined(PIPE_ATOMIC_OS_MS_INTERLOCK) +#if defined(PIPE_ATOMIC_MSVC_INTRINSIC) -#define PIPE_ATOMIC "MS userspace interlocks" - -#include +#define PIPE_ATOMIC "MSVC Intrinsics" struct pipe_atomic { - volatile long count; + int32_t count; }; +#include + +#pragma intrinsic(_InterlockedIncrement) +#pragma intrinsic(_InterlockedDecrement) +#pragma intrinsic(_InterlockedCompareExchange) + #define p_atomic_set(_v, _i) ((_v)->count = (_i)) #define p_atomic_read(_v) ((_v)->count) static INLINE boolean p_atomic_dec_zero(struct pipe_atomic *v) { - return InterlockedDecrement(&v->count) == 0; + return _InterlockedDecrement(&v->count) == 0; } static INLINE void p_atomic_inc(struct pipe_atomic *v) { - InterlockedIncrement(&v->count); + _InterlockedIncrement(&v->count); } static INLINE void p_atomic_dec(struct pipe_atomic *v) { - InterlockedDecrement(&v->count); + _InterlockedDecrement(&v->count); } static INLINE int32_t p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) { - return InterlockedCompareExchange(&v->count, _new, old); + return _InterlockedCompareExchange(&v->count, _new, old); } #endif -- cgit v1.2.3