Skip to content

Commit ea65024

Browse files
committed
debug windows
1 parent 310400f commit ea65024

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

libcxx/src/atomic.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <new>
1616
#include <thread>
1717
#include <type_traits>
18+
#include <iostream>
1819

1920
#include "include/apple_availability.h"
2021

@@ -163,8 +164,10 @@ static void __platform_wait_on_address(void const* __ptr, void const* __val) {
163164
static auto wait_on_address =
164165
reinterpret_cast<BOOL(WINAPI*)(void*, PVOID, SIZE_T, DWORD)>(win32_get_synch_api_function("WaitOnAddress"));
165166
if (wait_on_address != nullptr) {
166-
wait_on_address(const_cast<void*>(__ptr), &__val, _Size, INFINITE);
167+
std::cerr << "waiting with windows api of size " << _Size << std::endl;
168+
wait_on_address(const_cast<void*>(__ptr), __val, _Size, INFINITE);
167169
} else {
170+
std::cerr << "waiting with backoff of size " << _Size << std::endl;
168171
__libcpp_thread_poll_with_backoff(
169172
[=]() -> bool { return std::memcmp(const_cast<const void*>(__ptr), __val, _Size) != 0; },
170173
__libcpp_timed_backoff_policy());
@@ -179,6 +182,7 @@ static void __platform_wake_by_address(void const* __ptr, bool __notify_one) {
179182
static auto wake_by_address_single =
180183
reinterpret_cast<void(WINAPI*)(PVOID)>(win32_get_synch_api_function("WakeByAddressSingle"));
181184
if (wake_by_address_single != nullptr) {
185+
std::cerr << "wake one with windows api of size " << _Size << std::endl;
182186
wake_by_address_single(const_cast<void*>(__ptr));
183187
} else {
184188
// The fallback implementation of waking does nothing, as the fallback wait implementation just does polling, so
@@ -189,6 +193,7 @@ static void __platform_wake_by_address(void const* __ptr, bool __notify_one) {
189193
static auto wake_by_address_all =
190194
reinterpret_cast<void(WINAPI*)(PVOID)>(win32_get_synch_api_function("WakeByAddressAll"));
191195
if (wake_by_address_all != nullptr) {
196+
std::cerr << "wake all with windows api of size " << _Size << std::endl;
192197
wake_by_address_all(const_cast<void*>(__ptr));
193198
} else {
194199
// The fallback implementation of waking does nothing, as the fallback wait implementation just does polling, so

libcxx/test/std/thread/thread.semaphore/lost_wakeup.pass.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313

1414
// <semaphore>
1515

16+
#include <atomic>
1617
#include <barrier>
18+
#include <chrono>
19+
#include <cstdlib>
1720
#include <semaphore>
1821
#include <thread>
1922
#include <vector>
@@ -54,8 +57,22 @@ int main(int, char**) {
5457

5558
threads.push_back(support::make_test_thread(release));
5659

60+
std::atomic_bool finished = false;
61+
auto t = support::make_test_thread([&finished]() {
62+
auto start = std::chrono::system_clock::now();
63+
while (!finished) {
64+
auto now = std::chrono::system_clock::now();
65+
if (now - start > std::chrono::seconds(60)) {
66+
std::quick_exit(42);
67+
}
68+
}
69+
});
70+
5771
for (auto& thread : threads)
5872
thread.join();
73+
74+
finished = true;
75+
t.join();
5976
}
6077

6178
return 0;

0 commit comments

Comments
 (0)