Atomic swap

Daniel Eischen eischen at vigrid.com
Thu Aug 7 13:21:22 PDT 2003


On Thu, 7 Aug 2003, Marcel Moolenaar wrote:

> On Thu, Aug 07, 2003 at 03:31:55PM -0400, Daniel Eischen wrote:
> > > > > 		"   stq     t0,%3\n"
> > > 		^^^^^^^^^^^^^^^^^^^^
> > > 
> > > Whoops, typo: %3 should be %2.
> > 
> > Yup, I caught that but didn't want to complain when something
> > is handed to me on a silver platter ;-)
> 
> As long as you saw it :-)

BTW, this is the only way I got it to compile.  The compiler
(or assembler) didn't seem to like having t0 and t1 hardcoded.

Grr, I just remembered.  t0, t1, etc are our names for
them.  They should probably be $1 and $2.

static __inline void
atomic_swap_long(volatile long *dst, long val, long *res)
{
        long temp1, temp2;

        __asm ( "1: ldq_l   %3, %1\n"
                "   mov     %2, %4\n"
                "   stq_c   %4, %1\n"
                "   beq     %4, 1b\n"
                "   stq     %3, %0\n"
            : "=m"(*res) : "m"(*dst), "r"(val), "r"(temp1), "r"(temp2) : "memory");    
}

-- 
Dan Eischen



More information about the freebsd-alpha mailing list