[libcxx-commits] [libcxx] [libc++] Replace mutex+condvar with atomics in __call_once (PR #192433)

Shonie Caplan via libcxx-commits libcxx-commits at lists.llvm.org
Sun Apr 26 18:05:01 PDT 2026


================
@@ -25,8 +27,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 // keep in sync with:  7741191.
 
 #if _LIBCPP_HAS_THREADS
-static constinit __libcpp_mutex_t mut  = _LIBCPP_MUTEX_INITIALIZER;
-static constinit __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;
+_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*) _NOEXCEPT;
----------------
shoniecaplan wrote:

I see, thank you for the explanation. I updated it to make `__call_once` take an atomic `once_flag`, but as you can see from the CI, it is incompatible with the existing header files. I don't have any opinions on how this can be updated to go back to using the non-atomic `once_flag`. Maybe a `reinterpret_cast` inside of `__call_once`? Let me know and I will update it.

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


More information about the libcxx-commits mailing list