Skip to content

shims: adjust WaitOnAddress usage on Windows #759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/shims/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,13 @@ _dispatch_wait_on_address(uint32_t volatile *_address, uint32_t value,
}
return _dispatch_futex_wait(address, value, NULL, FUTEX_PRIVATE_FLAG);
#elif defined(_WIN32)
return WaitOnAddress(address, &value, sizeof(value), INFINITE) == TRUE;
// Round up to the nearest ms as `WaitOnAddress` takes a timeout in ms.
// Integral division will truncate, so make sure that we do the roundup.
DWORD dwMilliseconds =
nsecs == DISPATCH_TIME_FOREVER
? INFINITE : ((nsecs + 1000000) / 1000000);
if (dwMilliseconds == 0) return ETIMEDOUT;
return WaitOnAddress(address, &value, sizeof(value), dwMilliseconds) == TRUE;
#else
#error _dispatch_wait_on_address unimplemented for this platform
#endif
Expand Down