[libcxx-commits] [libcxx] [libc++] Improve performance of std::atomic_flag on Windows (PR #163524)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Nov 2 01:44:34 PDT 2025
================
@@ -101,6 +105,46 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo
_umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, nullptr, nullptr);
}
+#elif defined(_WIN32)
+
+static void
+__libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) {
+ // WaitOnAddress was added in Windows 8 (build 9200)
+ static auto wait_on_address = reinterpret_cast<BOOL(WINAPI*)(volatile void*, PVOID, SIZE_T, DWORD)>(
+ GetProcAddress(GetModuleHandleW(L"api-ms-win-core-synch-l1-2-0.dll"), "WaitOnAddress"));
+ if (wait_on_address != nullptr) {
----------------
Andarwinux wrote:
I'm unsure whether the libc++ build can depend on the existence of the LLVM toolchain. If it does, you could simply use llvm-lib /out:libc++.a libc++.a /path/to/libsynchronization.a.
Otherwise, you could simply append the libc++ object files to a local copy of libsynchronization.a and rename it to libc++.a, though I'm unsure how to do this in an elegant way within CMake. If I recall correctly, libc++ originally had some infra that made it easy to merge static libraries, but for some reason it seems to have disappeared later on.
https://github.com/llvm/llvm-project/pull/163524
More information about the libcxx-commits
mailing list