There are many places where libc++ want to use <atomic> internally in C++03 code. Unfortunately <atomic> currently only supports C++11 and later. This patch extends <atomic> so that everything except ATOMIC_VAR_INIT and ATOMIC_FLAG_INIT can be used in c++03 code.
This patch introduces the macros:
- _LIBCPP_HAS_C11_ATOMICS: Defined if __has_extension(c_atomic) is true.
- _LIBCPP_HAS_CXX_ATOMICS: Defined if we have C11 atomics from clang or the __atomic_* builtin family from GCC and libc++ is configured for threads. If _LIBCPP_HAS_CXX_ATOMICS is defined then the <atomic> header should be safe to include.
Other Misc changes:
- __gcc_atomic_t default constructs the stored value. This make it perform the same as _Atomic.
- constexpr -> _LIBCPP_CONSTEXPR
- noexcept -> TEST_NOEXCEPT in the tests.
- re-implement std::atomic::is_lock_free() to prevent needing libatomic with GCC.