__sync_lock_test_and_set on ARM

Phil Endecott spam_from_gcc_help_2@chezphil.org
Wed Sep 12 16:17:00 GMT 2007


Dear Experts,

I believe that ARM's swap instruction can be used to implement the 
__sync_lock_test_and_set builtin, yet as far as I can see it is not 
implemented.  Can anyone please confirm if (a) it is implemented but 
I'm doing something wrong, or (b) there's some reason why it can't be 
done?  FWIW here is some asm that I am currently using for this:

     asm volatile ("swp\t%0, %1, [%2]"
                  :"=r" (oldval)
                  :"r"  (newval),
                   "r"  (&mem)
                  :"memory");


Regards,

Phil.






More information about the Gcc-help mailing list