-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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-specific extensions for accessing Windows profileapi #70618
Conversation
r? @sfackler (rust_highfive has picked a reviewer for you, use r? to override) |
r? @RalfJung |
Sorry, but there is no way I can review this. I didn't program on Windows for more than 10 years. But I also think this is the wrong approach to get new Miri shims to work. The equivalent shims on macOS and Linux are all implemented entirely in terms of the public API of libstd, and thus work cross-platform (so on any host, you can run programs for the Linux/macOS target). |
I am currently not so sure.. |
You should be able to infer what you need from the code in libstd. Remember that Miri doesn't have to behave exactly like real Windows, it just has to be a valid implementation of the Windows API. For example, on macOS, Miri implements With a similar approach, you should be able to implement the Windows API on any host. |
See rust-lang/miri#1243 for some inspiration. |
And finally, even if we use direct host calls for the implementation in Miri (which I am inclined to reject as an implementation strategy), there is no reason to add new methods to the stable, forever-maintained backwards-compatible libstd API surface. As far as I know, there is also no precedent for directly exposing host functions like this. Instead, in that (currently entirely hypothetical) case, Miri should use So, I recommend to close this PR. |
Added new module
time
tostd::os::windows
, for accessing Windows profileapi as below.QueryPerformanceCounter
QueryPerformanceFrequency
Need for these extensions arised while working on rust-lang/miri#997, which requires implementing
3 Windows shims
GetSystemTimeAsFileTime
QueryPerformanceCounter
QueryPerformanceFrequency
(The latter two shims are not yet mentioned in the issue, but they are currently needed to pass the latest version of test case :
MIRI/tests/run-pass/time.rs
))Implementing the first shim didn't need new extensions to
std::os::windows
,but implementing the other two shims needs direct access to Windows API.
(I couldn't find any public API from
libstd
to be used inMIRI
for implementing the shims)I also tried using
winapi
library in MIRI, but I got an error saying that "MIRI doesn't support foreign functions".p.s. -
It's my first time pushing code to
libstd
, so some annotations might have to be fixed..