[PATCH] D17950: Implement is_always_lock_free

Joerg Sonnenberger via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 17 23:50:47 PDT 2016

On Thu, Mar 17, 2016 at 05:56:17PM +0000, JF Bastien via cfe-commits wrote:
> C++ atomics are explicitly designed to avoid problems with touching
> adjacent bytes: if `atomic<T>` where `sizeof(T) == 1` requires a 4-byte
> `cmpxchg` then it's up to the frontend to make sure `sizeof<atomic<T>> >= 4`
> (or something equivalent such as making it non-lock-free).

That's not completely relevant for the code at hand. At least the
__sync_* builtins only ever required appropiate alignment of the base
type, not necessarily extra alignment to avoid padding for stupid
codegen. I also believe that access to extra data is completely harmless
for all but one use case. If you are directly accessing memory mapped
devices using compiler atomics, you should really know what you are
doing. That's about the only case where it matters.


More information about the cfe-commits mailing list