Shouldn't we use InterlockedIncrement ( http://msdn.microsoft.com/en-us/library/ms683614(VS.85).aspx ) and friends in Windows instead of assembly? It is implemented as a compiler intrinsic, so it probably results in more efficient generated code.
Jose On Mon, 2009-03-16 at 05:42 -0700, Micha?? Kr??l wrote: > Module: Mesa > Branch: master > Commit: c97b671d64a5f137177989a28c684a13b5cb249b > URL: > http://cgit.freedesktop.org/mesa/mesa/commit/?id=c97b671d64a5f137177989a28c684a13b5cb249b > > Author: Michal Krol <mic...@vmware.com> > Date: Mon Mar 16 13:42:22 2009 +0100 > > gallium: Implement atomic for MSVC on x86. > > --- > > src/gallium/include/pipe/p_atomic.h | 66 > ++++++++++++++++++++++++++++++++++- > 1 files changed, 65 insertions(+), 1 deletions(-) > > diff --git a/src/gallium/include/pipe/p_atomic.h > b/src/gallium/include/pipe/p_atomic.h > index 13866d2..b9bf711 100644 > --- a/src/gallium/include/pipe/p_atomic.h > +++ b/src/gallium/include/pipe/p_atomic.h > @@ -66,7 +66,71 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, > int32_t new) > return __sync_val_compare_and_swap(&v->count, old, new); > } > > -#elif (defined(PIPE_SUBSYSTEM_WINDOWS_USER)) /* (defined(PIPE_CC_GCC)) */ > +#elif (defined(PIPE_ARCH_X86) && defined(PIPE_CC_MSVC)) /* > (defined(PIPE_CC_GCC)) */ > + > +struct pipe_atomic > +{ > + int32_t count; > +}; > + > +#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) > +{ > + int32_t *pcount = &v->count; > + unsigned char c; > + > + __asm { > + mov eax, [pcount] > + lock dec dword ptr [eax] > + sete byte ptr [c] > + } > + > + return c != 0; > +} > + > +static INLINE void > +p_atomic_inc(struct pipe_atomic *v) > +{ > + int32_t *pcount = &v->count; > + > + __asm { > + mov eax, [pcount] > + lock inc dword ptr [eax] > + } > +} > + > +static INLINE void > +p_atomic_dec(struct pipe_atomic *v) > +{ > + int32_t *pcount = &v->count; > + > + __asm { > + mov eax, [pcount] > + lock dec dword ptr [eax] > + } > +} > + > +static INLINE int32_t > +p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t new) > +{ > + int32_t *pcount = &v->count; > + int32_t orig; > + > + __asm { > + mov ecx, [pcount] > + mov eax, [old] > + mov edx, [new] > + lock cmpxchg [ecx], edx > + mov [orig], eax > + } > + > + return orig; > +} > + > +#elif (defined(PIPE_SUBSYSTEM_WINDOWS_USER)) /* (defined(PIPE_ARCH_X86) && > defined(PIPE_CC_MSVC)) */ > > struct pipe_atomic > { > > _______________________________________________ > mesa-commit mailing list > mesa-com...@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-commit ------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ Mesa3d-dev mailing list Mesa3d-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mesa3d-dev