Andrew Haley writes: > Phil Endecott writes: > > 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"); > > Looks fine to me. I forgot: SWP is deprecated on ARM. Use LDREX and STREX instead. See http://lkml.org/lkml/2006/12/6/180 Andrew.