From db93dcecc80a45e850b4594326fc453c950b54f5 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 17 Apr 2009 10:17:59 +0100 Subject: gallium: add #warning to mutex-based atomic implementation Some builds end up picking this up. --- src/gallium/include/pipe/p_atomic.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium/include/pipe/p_atomic.h') diff --git a/src/gallium/include/pipe/p_atomic.h b/src/gallium/include/pipe/p_atomic.h index f2fe083efa..7698ac5e03 100644 --- a/src/gallium/include/pipe/p_atomic.h +++ b/src/gallium/include/pipe/p_atomic.h @@ -299,6 +299,7 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) * Add an assembly port instead. It may abort and * doesn't destroy used mutexes. */ +#warning "using mutex-based fallback for pipe_atomic" struct pipe_atomic { pipe_mutex mutex; -- cgit v1.2.3 From 687f331a1ff0721d1a84c203eb7f721527a3f882 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 17 Apr 2009 11:01:22 +0100 Subject: gallium: simplify further the logic for selecting mutex implementation Cleaner than the previous cleanup... --- src/gallium/include/pipe/p_atomic.h | 77 ++++++++++++------------------------- 1 file changed, 24 insertions(+), 53 deletions(-) (limited to 'src/gallium/include/pipe/p_atomic.h') diff --git a/src/gallium/include/pipe/p_atomic.h b/src/gallium/include/pipe/p_atomic.h index 7698ac5e03..54dab12f89 100644 --- a/src/gallium/include/pipe/p_atomic.h +++ b/src/gallium/include/pipe/p_atomic.h @@ -18,58 +18,29 @@ extern "C" { /* Favor OS-provided implementations. + * + * Where no OS-provided implementation is available, fall back to + * locally coded assembly, compiler intrinsic or ultimately a + * mutex-based implementation. */ -#define PIPE_ATOMIC_OS_UNLOCKED \ - (defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || \ - defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)) - -#define PIPE_ATOMIC_OS_MS_INTERLOCK \ - (!defined(PIPE_CC_GCC) && \ - !PIPE_ATOMIC_OS_UNLOCKED && \ - defined(PIPE_SUBSYSTEM_WINDOWS_USER)) - -#define PIPE_ATOMIC_OS_PROVIDED \ - (PIPE_ATOMIC_OS_UNLOCKED || \ - PIPE_ATOMIC_OS_MS_INTERLOCK) - -/* Where no OS-provided implementation is available, fall back to - * either locally coded assembly or ultimately a mutex-based - * implementation: - */ -#define PIPE_ATOMIC_ASM_GCC_X86 \ - (!PIPE_ATOMIC_OS_PROVIDED && \ - defined(PIPE_CC_GCC) && \ - defined(PIPE_ARCH_X86)) - -/* KW: this was originally used when x86 asm wasn't available. - * Maintain that logic here. - */ -#define PIPE_ATOMIC_GCC_INTRINISIC \ - (!PIPE_ATOMIC_OS_PROVIDED && \ - !PIPE_ATOMIC_ASM_GCC_X86 && \ - defined(PIPE_CC_GCC)) - -#define PIPE_ATOMIC_ASM_MSVC_X86 \ - (!PIPE_ATOMIC_OS_PROVIDED && \ - defined(PIPE_CC_MSVC) && \ - defined(PIPE_ARCH_X86)) - -#define PIPE_ATOMIC_ASM \ - (PIPE_ATOMIC_ASM_GCC_X86 || \ - PIPE_ATOMIC_ASM_GCC_INTRINSIC || \ - PIPE_ATOMIC_ASM_MSVC_X86) - - -/* Where no OS-provided or locally-coded assembly implemenation is - * available, use pipe_mutex: - */ -#define PIPE_ATOMIC_MUTEX \ - (!PIPE_ATOMIC_OS_PROVIDED && \ - !PIPE_ATOMIC_ASM) +#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) && defined(PIPE_ARCH_X86)) +#define PIPE_ATOMIC_ASM_MSVC_X86 +#elif (defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86)) +#define PIPE_ATOMIC_ASM_GCC_X86 +#elif defined(PIPE_CC_GCC) +#define PIPE_ATOMIC_GCC_INTRINISIC +#else +#define PIPE_ATOMIC_MUTEX +#endif -#if (PIPE_ATOMIC_ASM_GCC_X86) +#if defined(PIPE_ATOMIC_ASM_GCC_X86) #define PIPE_ATOMIC "GCC x86 assembly" @@ -115,7 +86,7 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) /* Implementation using GCC-provided synchronization intrinsics */ -#if (PIPE_ATOMIC_ASM_GCC_INTRINSIC) +#if defined(PIPE_ATOMIC_ASM_GCC_INTRINSIC) #define PIPE_ATOMIC "GCC Sync Intrinsics" @@ -157,7 +128,7 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) /* Unlocked version for single threaded environments, such as some * windows kernel modules. */ -#if (PIPE_ATOMIC_OS_UNLOCKED) +#if defined(PIPE_ATOMIC_OS_UNLOCKED) #define PIPE_ATOMIC "Unlocked" @@ -178,7 +149,7 @@ struct pipe_atomic /* Locally coded assembly for MSVC on x86: */ -#if (PIPE_ATOMIC_ASM_MSVC_X86) +#if defined(PIPE_ATOMIC_ASM_MSVC_X86) #define PIPE_ATOMIC "MSVC x86 assembly" @@ -246,7 +217,7 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) #endif -#if (PIPE_ATOMIC_OS_MS_INTERLOCK) +#if defined(PIPE_ATOMIC_OS_MS_INTERLOCK) #define PIPE_ATOMIC "MS userspace interlocks" @@ -288,7 +259,7 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) -#if (PIPE_ATOMIC_MUTEX) +#if defined(PIPE_ATOMIC_MUTEX) #define PIPE_ATOMIC "mutex-based fallback" -- cgit v1.2.3 From dbb90436f8385a33b9938c66a0fa3eff8c36a4cc Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 17 Apr 2009 15:01:38 +0100 Subject: pipe: Fix InterlockedDecrement usage. --- src/gallium/include/pipe/p_atomic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/include/pipe/p_atomic.h') diff --git a/src/gallium/include/pipe/p_atomic.h b/src/gallium/include/pipe/p_atomic.h index 54dab12f89..a963267e26 100644 --- a/src/gallium/include/pipe/p_atomic.h +++ b/src/gallium/include/pipe/p_atomic.h @@ -234,7 +234,7 @@ struct pipe_atomic static INLINE boolean p_atomic_dec_zero(struct pipe_atomic *v) { - return InterlockedDecrement(&v->count); + return InterlockedDecrement(&v->count) != 0; } static INLINE void -- cgit v1.2.3 From 3b760729158ff39a40688980d7a823b006e0a31a Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Fri, 17 Apr 2009 17:02:34 +0200 Subject: gallium: Fix PIPE_ATOMIC_GCC_INTRINSIC build. --- src/gallium/include/pipe/p_atomic.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium/include/pipe/p_atomic.h') diff --git a/src/gallium/include/pipe/p_atomic.h b/src/gallium/include/pipe/p_atomic.h index a963267e26..ed5f665512 100644 --- a/src/gallium/include/pipe/p_atomic.h +++ b/src/gallium/include/pipe/p_atomic.h @@ -33,7 +33,7 @@ extern "C" { #elif (defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86)) #define PIPE_ATOMIC_ASM_GCC_X86 #elif defined(PIPE_CC_GCC) -#define PIPE_ATOMIC_GCC_INTRINISIC +#define PIPE_ATOMIC_GCC_INTRINSIC #else #define PIPE_ATOMIC_MUTEX #endif @@ -86,7 +86,7 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) /* Implementation using GCC-provided synchronization intrinsics */ -#if defined(PIPE_ATOMIC_ASM_GCC_INTRINSIC) +#if defined(PIPE_ATOMIC_GCC_INTRINSIC) #define PIPE_ATOMIC "GCC Sync Intrinsics" -- cgit v1.2.3 From 86ed894e47bae10d158f2b4a02065daa9dbe5194 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 17 Apr 2009 18:40:46 +0100 Subject: pipe: Get the p_atomic_dec_zero logic right this time. --- src/gallium/include/pipe/p_atomic.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/gallium/include/pipe/p_atomic.h') diff --git a/src/gallium/include/pipe/p_atomic.h b/src/gallium/include/pipe/p_atomic.h index ed5f665512..0c3fbae428 100644 --- a/src/gallium/include/pipe/p_atomic.h +++ b/src/gallium/include/pipe/p_atomic.h @@ -225,7 +225,7 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) struct pipe_atomic { - long count; + volatile long count; }; #define p_atomic_set(_v, _i) ((_v)->count = (_i)) @@ -234,7 +234,7 @@ struct pipe_atomic static INLINE boolean p_atomic_dec_zero(struct pipe_atomic *v) { - return InterlockedDecrement(&v->count) != 0; + return InterlockedDecrement(&v->count) == 0; } static INLINE void @@ -270,7 +270,6 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) * Add an assembly port instead. It may abort and * doesn't destroy used mutexes. */ -#warning "using mutex-based fallback for pipe_atomic" struct pipe_atomic { pipe_mutex mutex; -- cgit v1.2.3