Fw: [patch] Make std::tr1::shared_ptr thread-safe.

Jonathan Wakely cow@compsoc.man.ac.uk
Fri Apr 1 15:24:00 GMT 2005


On Fri, Apr 01, 2005 at 05:19:48PM +0200, Paolo Carlini wrote:

> or powerpc:
> 
>   _Atomic_word
>   __attribute__ ((__unused__))
>   __exchange_and_add(volatile _Atomic_word* __mem, int __val)
>   {
>     _Atomic_word __tmp, __res;
>     __asm__ __volatile__ (
>               "/* Inline exchange & add */\n"
>               "0:\t"
>               "lwarx    %0,0,%3 \n\t"
>               "add%I4   %1,%0,%4 \n\t"
>               _STWCX "  %1,0,%3 \n\t"
>               "bne-     0b \n\t"
>               "/* End exchange & add */"
>               : "=&b"(__res), "=&r"(__tmp), "=m" (*__mem)
>               : "r" (__mem), "Ir"(__val), "m" (*__mem)
>               : "cr0");
>     return __res;
>   }
>  
>   void
>   __attribute__ ((__unused__))
>   __atomic_add(volatile _Atomic_word* __mem, int __val)
>   {
>     _Atomic_word __tmp;
>     __asm__ __volatile__ (
>               "/* Inline atomic add */\n"
>               "0:\t"
>               "lwarx    %0,0,%2 \n\t"
>               "add%I3   %0,%0,%3 \n\t"
>               _STWCX "  %0,0,%2 \n\t"
>               "bne-     0b \n\t"
>               "/* End atomic add */"
>               : "=&b"(__tmp), "=m" (*__mem)
>               : "r" (__mem), "Ir"(__val), "m" (*__mem)
>               : "cr0");
>   }

where _STWCX is defined as:

#ifdef __PPC405__
#define _STWCX "sync \n\tstwcx. "
#else
#define _STWCX "stwcx. "
#endif



More information about the Libstdc++ mailing list