This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Cleanup <atomic> and cleanup support for C++03.
AbandonedPublic

Authored by EricWF on May 26 2015, 5:48 PM.

Details

Reviewers
mclow.lists
Summary

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.

Diff Detail

Event Timeline

EricWF updated this revision to Diff 26556.May 26 2015, 5:48 PM
EricWF retitled this revision from to [libcxx] Cleanup <atomic> and cleanup support for C++03..
EricWF updated this object.
EricWF edited the test plan for this revision. (Show Details)
EricWF added a reviewer: mclow.lists.
EricWF added subscribers: Unknown Object (MLST), chandlerc.
EricWF updated this revision to Diff 26557.May 26 2015, 5:50 PM

Remove unused implementation of __c11_is_atomic_lock_free for GCC.

EricWF abandoned this revision.Jun 12 2015, 7:30 AM

Sorry for the spam. Abandoning again. I'm going to submit the critical parts of this patch separately from the C++03 stuff.

test/std/atomics/libcpp-has-no-threads.fail.cpp