This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [libstdc++/65033] Give alignment info to libatomic
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Wed, 18 Feb 2015 12:15:12 +0000
- Subject: Re: [libstdc++/65033] Give alignment info to libatomic
- Authentication-results: sourceware.org; auth=none
- References: <54DD19B7 dot 6060401 at redhat dot com>
On 12/02/15 13:23 -0800, Richard Henderson wrote:
When we fixed PR54005, making sure that atomic_is_lock_free returns the same
value for all objects of a given type, we probably should have changed the
interface so that we would pass size and alignment rather than size and object
pointer.
Instead, we decided that passing null for the object pointer would be
sufficient. But as this PR shows, we really do need to take alignment into
account.
The following patch constructs a fake object pointer that is maximally
misaligned. This allows the interface to both the builtin and to libatomic to
remain unchanged. Which probably makes this back-portable to maintenance
releases as well.
Am I right in thinking that another option would be to ensure that
std::atomic<> objects are always suitably aligned? Would that make
std::atomic<> slightly more compatible with a C11 atomic_int, where
the _Atomic qualifier affects alignment?
https://gcc.gnu.org/PR62259 suggests we might need to enforce
alignment on std::atomic anyway, or am I barking up the wrong tree?