Atomic swap
John Baldwin
jhb at FreeBSD.org
Thu Aug 7 13:37:35 PDT 2003
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 at FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!" - http://www.FreeBSD.org/
More information about the freebsd-alpha
mailing list