Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 07 Aug 2003 16:37:52 -0400 (EDT)
From:      John Baldwin <jhb@FreeBSD.org>
To:        deischen@freebsd.org
Cc:        Marcel Moolenaar <marcel@xcllnt.net>
Subject:   Re: Atomic swap
Message-ID:  <XFMail.20030807163752.jhb@FreeBSD.org>
In-Reply-To: <Pine.GSO.4.10.10308071617070.14420-100000@pcnet5.pcnet.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On 07-Aug-2003 Daniel Eischen wrote:
> 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.

Yes, t0 and t1 are #define's, so they don't work in inline asm.
Also, you should clobber them if you use them directly, i.e.

        __asm("   ldq     $1, %1\n"  (suggested by Peter I think)
              "1: ldq_l   $1, %1\n"
              "   mov     %2, $2\n"
              "   stq_c   $2, %1\n"
              "   beq     $2, 1b\n"
              "   stq     $1, %0\n"
                : "+m" (*res) : "m" (*dst), "r" (val) : "memory", "$1", "$2");

-- 

John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20030807163752.jhb>