Boost logo

Boost :

From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2007-09-12 08:46:32


Hi Peter,

Peter Dimov wrote:
> Do __sync_lock_test_and_set and __sync_lock_release work?

__sync_lock_test_and_set doesn't work.
__sync_lock_release compiles, but I think it's a NO-OP.

My initial thought was, "Why is Peter asking me this? I have already
said that it only has swap, so it's obviously not going to support
test-and-set!". But I was sensible and checked the gcc docs before
posting, and it has this:

   type __sync_lock_test_and_set (type *ptr, type value, ...)
       This builtin, as described by Intel, is not a traditional
test-and-set operation, but
       rather an atomic exchange operation. It writes value into *ptr,
and returns the previous
       contents of *ptr.

So "test and set" is actually an atomic swap, i.e. exactly what ARM has
- but misnamed. Aarggh. If it had the right name I would have noticed
it months ago. (I note that gcc blame Intel for the misnaming.)

Yet gcc still doesn't seem to implement it. I will go and ask on their
mailing list.

Regards,

Phil.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk