[cfe-dev] RFC: __atomic_* support for gcc 4.7 compatibility
jyasskin at gmail.com
Tue Apr 10 23:31:20 PDT 2012
On Tue, Apr 10, 2012 at 3:20 PM, Howard Hinnant <hhinnant at apple.com> wrote:
> On Apr 10, 2012, at 6:11 PM, David Chisnall wrote:
>> On 10 Apr 2012, at 22:57, Howard Hinnant wrote:
>>> David, could you revert the initialization statements to use either plain C++, or the __atomic_init intrinsic?
>> Sorry, I thought I'd done that already when I fixed initialisation of _Atomic types in clang. I'm just about to fall asleep, but I'll do it in the morning.
> Of course. I'd much rather you be awake when you do this. :-)
>> __atomic_init() is still required for atomic_init() (in both C11 and C++11) - these are currently using __atomic_store, in libc++, so I'll fix them at the same time.
> template <class _Tp>
> inline _LIBCPP_INLINE_VISIBILITY
> atomic_init(atomic<_Tp>* __o, _Tp __d)
> __o->__a_ = __d;
> Not right?
If __o->__a_ is an _Atomic(_Tp), then C11 says "Loads and stores of
objects with atomic types are done with memory_order_seq_cst
semantics." (188.8.131.52), and the simple assignment gives you the
equivalent of atomic_store(&__o->__a_, __d, memory_order_seq_cst).
You could get the effect of atomic_init with a memcpy, but only by
knowing the _Atomic(_Tp)'s layout on the target platform.
More information about the cfe-dev