[cxx-mem-model] use alignment when available to determine lock-free ness
Andrew MacLeod
amacleod@redhat.com
Wed Nov 2 15:25:00 GMT 2011
Lock free routines are not guaranteed to work if they are not aligned
properly. Until now, the __atmoic_is_lock_free property has simply
relied on the size of an object to determine lockfreeness. This works
when you assume a certain alignment.
The library takes generic pointers and with structure packing and such,
alignment is not guaranteed. This means its possible to have a 4 byte
object which is lock free, and another which is not. Up until now I've
simply punted on it and claimed it was undefined if not properly
aligned. By adding the address of the object to the function, it easy
enough to check alignment at runtime, as well as at compile time,
usually. The library will need this in the future so might as well take
care of it now.
Simply adds an optional parameter to __atomic_{is_always}_lock_free
which is used to check alignment against the size parameter. NULL as
the object pointer produces the same behaviour as today, lockfreeness
based on proper alignment for an integral value of the specified size.
Bootstrapped and tested on x86_64-unknown-linux-gnu.
Andrew
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: align.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20111102/db1252b7/attachment.ksh>
More information about the Gcc-patches
mailing list