[RFA] Using the new atomicity builtins
Benjamin Kosnik
bkoz@redhat.com
Tue May 24 04:21:00 GMT 2005
> now that RTH kindly implemented the atomicity builtins + target bits for
> most of the most widespread targets (I remember at least x86(x86_64),
> ia64, powerpc, alpha), I think we can start migrating. Ideally, if the
> target bits were ready for *every* target we could even envisage using
> the builtins directly in the generic code. But we can't do that in the
> short term, and I'm not sure we are going to do that later, because
> builtins for i386 and old Sparcs will not (cannot, in general: we are
> talking about the complete set of ia64-type builtins) be implemented.
> My modest proposal for the 4.1 time frame would be instead using the
> builtins in the implementation of __exchange_and_add and __atomic_add,
> when available: in a nutshell, the code would become very similar to
> what we currently have for ia64.
Sounds like a good idea.
> A separate issue is about *other* atomicity primitives, that we used to
> have, open coded in inline assembly of course, for operations like CAS,
> that now would be useful again in some areas of TR1. In this case the
> idea would be, again, simply restoring the old code and using the
> builtins when available. Jonathan should be interested in this, for
> applications in shared_ptr, for instance.
I don't think we should restore the old code: we want to encourage the
builtin use, and the new builtin interface, period.
However, I do think that a __compare_and_swap
function should be added. For targets that don't have the new
builtins, then we can do something similar to what is done with the
generic code for __exchange_and_add (use a heavy weight mutex) or we
can do it non-atomically.
-benjamin
More information about the Libstdc++
mailing list