Skip to content

Commit 4515628

Browse files
author
Roger Sanders
committed
[libc++] Fixed naming, added comments.
1 parent 63ee5da commit 4515628

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

libcxx/src/atomic.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo
109109

110110
static void
111111
__libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) {
112-
static auto pWaitOnAddress = reinterpret_cast<BOOL(WINAPI*)(volatile void*, PVOID, SIZE_T, DWORD)>(
112+
// WaitOnAddress was added in Windows 8 (build 9200)
113+
static auto __pWaitOnAddress = reinterpret_cast<BOOL(WINAPI*)(volatile void*, PVOID, SIZE_T, DWORD)>(
113114
GetProcAddress(GetModuleHandleW(L"api-ms-win-core-synch-l1-2-0.dll"), "WaitOnAddress"));
114-
if (pWaitOnAddress != nullptr) {
115-
pWaitOnAddress(const_cast<__cxx_atomic_contention_t*>(__ptr), &__val, sizeof(__val), INFINITE);
115+
if (__pWaitOnAddress != nullptr) {
116+
__pWaitOnAddress(const_cast<__cxx_atomic_contention_t*>(__ptr), &__val, sizeof(__val), INFINITE);
116117
} else {
117118
__libcpp_thread_poll_with_backoff(
118119
[=]() -> bool { return !__cxx_nonatomic_compare_equal(__cxx_atomic_load(__ptr, memory_order_relaxed), __val); },
@@ -122,16 +123,18 @@ __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __pt
122123

123124
static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) {
124125
if (__notify_one) {
125-
static auto pWakeByAddressSingle = reinterpret_cast<void(WINAPI*)(PVOID)>(
126+
// WakeByAddressSingle was added in Windows 8 (build 9200)
127+
static auto __pWakeByAddressSingle = reinterpret_cast<void(WINAPI*)(PVOID)>(
126128
GetProcAddress(GetModuleHandleW(L"api-ms-win-core-synch-l1-2-0.dll"), "WakeByAddressSingle"));
127-
if (pWakeByAddressSingle != nullptr) {
128-
pWakeByAddressSingle(const_cast<__cxx_atomic_contention_t*>(__ptr));
129+
if (__pWakeByAddressSingle != nullptr) {
130+
__pWakeByAddressSingle(const_cast<__cxx_atomic_contention_t*>(__ptr));
129131
}
130132
} else {
131-
static auto pWakeByAddressAll = reinterpret_cast<void(WINAPI*)(PVOID)>(
133+
// WakeByAddressAll was added in Windows 8 (build 9200)
134+
static auto __pWakeByAddressAll = reinterpret_cast<void(WINAPI*)(PVOID)>(
132135
GetProcAddress(GetModuleHandleW(L"api-ms-win-core-synch-l1-2-0.dll"), "WakeByAddressAll"));
133-
if (pWakeByAddressAll != nullptr) {
134-
pWakeByAddressAll(const_cast<__cxx_atomic_contention_t*>(__ptr));
136+
if (__pWakeByAddressAll != nullptr) {
137+
__pWakeByAddressAll(const_cast<__cxx_atomic_contention_t*>(__ptr));
135138
}
136139
}
137140
}

0 commit comments

Comments
 (0)