feat(runtime-include): support std::atomic_ref in C++ programs - #73
Open
Ignition wants to merge 1 commit into
Open
feat(runtime-include): support std::atomic_ref in C++ programs#73Ignition wants to merge 1 commit into
Ignition wants to merge 1 commit into
Conversation
The bundled <atomic> derives _LIBCPP_STD_VER from __cplusplus, nothing else supplying it: upstream libc++ has its build system set the macro, whereas this copy is included straight by the compiler driver. Unset it reads as zero, so the header's dialect checks fail and it offers its C++11 subset whatever -std it is compiled under, withholding the std::atomic<T>::is_always_lock_free it already carries. The C++20 additions here sit behind the same checks: atomic_ref, atomic_flag::test, and wait/notify on atomic, atomic_flag and atomic_ref. An atomic_ref's referent keeps the type and layout it was declared with, so it cannot go through _Atomic(T) as atomic<T> does, and uses the GCC-style atomic builtins on a plain T* instead; the interpreter models those as atomic accesses to the object. They act on whole objects, which shapes two things: a value's padding bits are zeroed before it is handed to one, so that a compare-exchange ignores them as specified, and required_alignment reports the natural alignment atomic access needs rather than the weaker figure a type may declare for itself. wait() polls, which the spin-assume transformation turns into an assume and which leaves notify_one() and notify_all() as no-ops. It compares value representations, so a wait on 0.0 does not sit on a -0.0 that has arrived. The runtime headers are installed whatever they are called, the C++ ones having no extension to match against.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bundled derives _LIBCPP_STD_VER from __cplusplus, nothing else supplying it: upstream libc++ has its build system set the macro, whereas this copy is included straight by the compiler driver. Unset it reads as zero, so the header's dialect checks fail and it offers its C++11 subset whatever -std it is compiled under, withholding the std::atomic::is_always_lock_free it already carries. The C++20 additions here sit behind the same checks: atomic_ref, atomic_flag::test, and wait/notify on atomic, atomic_flag and atomic_ref.
An atomic_ref's referent keeps the type and layout it was declared with, so it cannot go through _Atomic(T) as atomic does, and uses the GCC-style atomic builtins on a plain T* instead; the interpreter models those as atomic accesses to the object. They act on whole objects, which shapes two things: a value's padding bits are zeroed before it is handed to one, so that a compare-exchange ignores them as specified, and required_alignment reports the natural alignment atomic access needs rather than the weaker figure a type may declare for itself. wait() polls, which the spin-assume transformation turns into an assume and which leaves notify_one() and notify_all() as no-ops. It compares value representations, so a wait on 0.0 does not sit on a -0.0 that has arrived.
The runtime headers are installed whatever they are called, the C++ ones having no extension to match against.