diff options
author | José Fonseca <[email protected]> | 2010-02-02 14:43:48 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2010-02-02 14:43:48 +0000 |
commit | 38f6f23fcf37247fd709d1c612d08bfa9b124e69 (patch) | |
tree | 4cb5cf4a78a1470276cacd562b3c8ecb5112e244 /src/gallium/include | |
parent | 28486880ca3ec39419ccee0cb1a3bedc9ef7117c (diff) |
gallium: Make pipe_atomic a regular int32_t.
Diffstat (limited to 'src/gallium/include')
-rw-r--r-- | src/gallium/include/pipe/p_atomic.h | 121 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_refcnt.h | 52 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_state.h | 7 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_video_state.h | 2 |
4 files changed, 53 insertions, 129 deletions
diff --git a/src/gallium/include/pipe/p_atomic.h b/src/gallium/include/pipe/p_atomic.h index a4b769d0bf5..c0a0ac0edb3 100644 --- a/src/gallium/include/pipe/p_atomic.h +++ b/src/gallium/include/pipe/p_atomic.h @@ -44,41 +44,37 @@ extern "C" { #define PIPE_ATOMIC "GCC x86 assembly" -struct pipe_atomic { - int32_t count; -}; - -#define p_atomic_set(_v, _i) ((_v)->count = (_i)) -#define p_atomic_read(_v) ((_v)->count) +#define p_atomic_set(_v, _i) (*(_v) = (_i)) +#define p_atomic_read(_v) (*(_v)) static INLINE boolean -p_atomic_dec_zero(struct pipe_atomic *v) +p_atomic_dec_zero(int32_t *v) { unsigned char c; - __asm__ __volatile__("lock; decl %0; sete %1":"+m"(v->count), "=qm"(c) + __asm__ __volatile__("lock; decl %0; sete %1":"+m"(*v), "=qm"(c) ::"memory"); return c != 0; } static INLINE void -p_atomic_inc(struct pipe_atomic *v) +p_atomic_inc(int32_t *v) { - __asm__ __volatile__("lock; incl %0":"+m"(v->count)); + __asm__ __volatile__("lock; incl %0":"+m"(*v)); } static INLINE void -p_atomic_dec(struct pipe_atomic *v) +p_atomic_dec(int32_t *v) { - __asm__ __volatile__("lock; decl %0":"+m"(v->count)); + __asm__ __volatile__("lock; decl %0":"+m"(*v)); } static INLINE int32_t -p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) +p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new) { - return __sync_val_compare_and_swap(&v->count, old, _new); + return __sync_val_compare_and_swap(v, old, _new); } #endif @@ -90,36 +86,32 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) #define PIPE_ATOMIC "GCC Sync Intrinsics" -struct pipe_atomic { - int32_t count; -}; - -#define p_atomic_set(_v, _i) ((_v)->count = (_i)) -#define p_atomic_read(_v) ((_v)->count) +#define p_atomic_set(_v, _i) (*(_v) = (_i)) +#define p_atomic_read(_v) (*(_v)) static INLINE boolean -p_atomic_dec_zero(struct pipe_atomic *v) +p_atomic_dec_zero(int32_t *v) { - return (__sync_sub_and_fetch(&v->count, 1) == 0); + return (__sync_sub_and_fetch(v, 1) == 0); } static INLINE void -p_atomic_inc(struct pipe_atomic *v) +p_atomic_inc(int32_t *v) { - (void) __sync_add_and_fetch(&v->count, 1); + (void) __sync_add_and_fetch(v, 1); } static INLINE void -p_atomic_dec(struct pipe_atomic *v) +p_atomic_dec(int32_t *v) { - (void) __sync_sub_and_fetch(&v->count, 1); + (void) __sync_sub_and_fetch(v, 1); } static INLINE int32_t -p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) +p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new) { - return __sync_val_compare_and_swap(&v->count, old, _new); + return __sync_val_compare_and_swap(v, old, _new); } #endif @@ -132,17 +124,12 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) #define PIPE_ATOMIC "Unlocked" -struct pipe_atomic -{ - int32_t count; -}; - -#define p_atomic_set(_v, _i) ((_v)->count = (_i)) -#define p_atomic_read(_v) ((_v)->count) -#define p_atomic_dec_zero(_v) ((boolean) --(_v)->count) -#define p_atomic_inc(_v) ((void) (_v)->count++) -#define p_atomic_dec(_v) ((void) (_v)->count--) -#define p_atomic_cmpxchg(_v, old, _new) ((_v)->count == old ? (_v)->count = (_new) : (_v)->count) +#define p_atomic_set(_v, _i) (*(_v) = (_i)) +#define p_atomic_read(_v) (*(_v)) +#define p_atomic_dec_zero(_v) ((boolean) --(*(_v))) +#define p_atomic_inc(_v) ((void) (*(_v))++) +#define p_atomic_dec(_v) ((void) (*(_v))--) +#define p_atomic_cmpxchg(_v, old, _new) (*(_v) == old ? *(_v) = (_new) : *(_v)) #endif @@ -153,22 +140,16 @@ struct pipe_atomic #define PIPE_ATOMIC "MSVC x86 assembly" -struct pipe_atomic -{ - int32_t count; -}; - -#define p_atomic_set(_v, _i) ((_v)->count = (_i)) -#define p_atomic_read(_v) ((_v)->count) +#define p_atomic_set(_v, _i) (*(_v) = (_i)) +#define p_atomic_read(_v) (*(_v)) static INLINE boolean -p_atomic_dec_zero(struct pipe_atomic *v) +p_atomic_dec_zero(int32_t *v) { - int32_t *pcount = &v->count; unsigned char c; __asm { - mov eax, [pcount] + mov eax, [v] lock dec dword ptr [eax] sete byte ptr [c] } @@ -177,35 +158,30 @@ p_atomic_dec_zero(struct pipe_atomic *v) } static INLINE void -p_atomic_inc(struct pipe_atomic *v) +p_atomic_inc(int32_t *v) { - int32_t *pcount = &v->count; - __asm { - mov eax, [pcount] + mov eax, [v] lock inc dword ptr [eax] } } static INLINE void -p_atomic_dec(struct pipe_atomic *v) +p_atomic_dec(int32_t *v) { - int32_t *pcount = &v->count; - __asm { - mov eax, [pcount] + mov eax, [v] lock dec dword ptr [eax] } } static INLINE int32_t -p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) +p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new) { - int32_t *pcount = &v->count; int32_t orig; __asm { - mov ecx, [pcount] + mov ecx, [v] mov eax, [old] mov edx, [_new] lock cmpxchg [ecx], edx @@ -221,42 +197,37 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) #define PIPE_ATOMIC "MSVC Intrinsics" -struct pipe_atomic -{ - int32_t count; -}; - #include <intrin.h> #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) +#define p_atomic_set(_v, _i) (*(_v) = (_i)) +#define p_atomic_read(_v) (*(_v)) static INLINE boolean -p_atomic_dec_zero(struct pipe_atomic *v) +p_atomic_dec_zero(int32_t *v) { - return _InterlockedDecrement(&v->count) == 0; + return _InterlockedDecrement(v) == 0; } static INLINE void -p_atomic_inc(struct pipe_atomic *v) +p_atomic_inc(int32_t *v) { - _InterlockedIncrement(&v->count); + _InterlockedIncrement(v); } static INLINE void -p_atomic_dec(struct pipe_atomic *v) +p_atomic_dec(int32_t *v) { - _InterlockedDecrement(&v->count); + _InterlockedDecrement(v); } static INLINE int32_t -p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new) +p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new) { - return _InterlockedCompareExchange(&v->count, _new, old); + return _InterlockedCompareExchange(v, _new, old); } #endif diff --git a/src/gallium/include/pipe/p_refcnt.h b/src/gallium/include/pipe/p_refcnt.h deleted file mode 100644 index 6609f94510a..00000000000 --- a/src/gallium/include/pipe/p_refcnt.h +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#ifndef P_REFCNT_H -#define P_REFCNT_H - - -#include "p_defines.h" -#include "p_atomic.h" -#include "util/u_debug.h" /* FIXME: remove this */ - - -#ifdef __cplusplus -extern "C" { -#endif - - -struct pipe_reference -{ - struct pipe_atomic count; -}; - - -#ifdef __cplusplus -} -#endif - -#endif /* P_REFCNT_H */ diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index f293df57334..9ae096ee3cf 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -43,7 +43,6 @@ #include "p_compiler.h" #include "p_defines.h" #include "p_format.h" -#include "p_refcnt.h" #include "p_screen.h" @@ -66,6 +65,12 @@ extern "C" { #define PIPE_MAX_TEXTURE_LEVELS 16 +struct pipe_reference +{ + int32_t count; /* atomic */ +}; + + /** * The driver will certainly subclass this to include actual memory * management information. diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h index 842860f74bd..77e22d0a566 100644 --- a/src/gallium/include/pipe/p_video_state.h +++ b/src/gallium/include/pipe/p_video_state.h @@ -33,7 +33,7 @@ #include <pipe/p_defines.h> #include <pipe/p_format.h> -#include <pipe/p_refcnt.h> +#include <pipe/p_state.h> #include <pipe/p_screen.h> #include <util/u_inlines.h> |