[libcxx-commits] [libcxx] [libc++] Don't implement <stdatomic.h> before C++23 (PR #123130)

Ryan Prichard via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 15 16:01:39 PST 2025


================
@@ -592,6 +592,10 @@ template <class T>
 #else
 #  include <__config>
 
+#  if _LIBCPP_STD_VER < 23 && defined(_LIBCPP_STDATOMIC_H)
----------------
rprichard wrote:

FWIW: Android might be better served by checking for a macro like `kill_dependency` or `atomic_load` instead of `_LIBCPP_STDATOMIC_H`. (The previous version of this compatibility check looked for `kill_dependency`. https://github.com/llvm/llvm-project/pull/83351) Using `kill_dependency` or `atomic_load`, the Bionic `stdatomic.h` and the libc++ `atomic` headers could be included simultaneously.

The Android/Bionic stdatomic.h never defines `kill_dependency`. It _does_ define `atomic_load` for the C dialect, but for C++, it does not define `atomic_load`, because it delegates to `atomic` instead and has a `using std::atomic_load;` declaration. (The Bionic `stdatomic.h` has delegated to `atomic` since 2014 and was the inspiration for the current C++23 behavior.)

_Maybe_ it's possible for Bionic to drop its C++ support from its `stdatomic.h`, by switching users to C++23 instead. That seems like a good goal in the long-run. I think Android can carry a local LLVM patch, though, too, if we need to.


https://github.com/llvm/llvm-project/pull/123130


More information about the libcxx-commits mailing list