-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Windows: Support sub-millisecond sleep #116461
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -267,6 +267,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { | |
|
||
this.Sleep(timeout)?; | ||
} | ||
"CreateWaitableTimerExW" => { | ||
let [attributes, name, flags, access] = | ||
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally we do at least read all the arguments of a shim to make sure they are initialized -- or we mark the shim as "only run in std". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I've added the reads. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! LGTM. |
||
this.read_pointer(attributes)?; | ||
this.read_pointer(name)?; | ||
this.read_scalar(flags)?.to_u32()?; | ||
this.read_scalar(access)?.to_u32()?; | ||
// Unimplemented. Always return failure. | ||
let not_supported = this.eval_windows("c", "ERROR_NOT_SUPPORTED"); | ||
this.set_last_error(not_supported)?; | ||
this.write_null(dest)?; | ||
} | ||
|
||
// Synchronization primitives | ||
"AcquireSRWLockExclusive" => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How good is the performance of
CreateWaitableTimerExW
? If it is slow, it might be better to cache the timer in a thread local.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's around 2,000 nanoseconds on my machine (minus the time it takes to call
QueryPerformanceCounter
). That is well within noise for waiting on my machine. Granted, other hardware may be able to perform better but I'd rather avoid adding a thread local unless or until someone can show it's worth it.