Skip to content
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

Implement GetSystemTimeAsFileTime shim for Windows #997

Closed
pvdrz opened this issue Oct 14, 2019 · 1 comment · Fixed by #1286
Closed

Implement GetSystemTimeAsFileTime shim for Windows #997

pvdrz opened this issue Oct 14, 2019 · 1 comment · Fixed by #1286
Labels
A-shims Area: This affects the external function shims A-windows Area: affects only Windows targets C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement

Comments

@pvdrz
Copy link
Contributor

pvdrz commented Oct 14, 2019

SystemTime::now is implemented in windows using the GetSystemTimeAsFileTime foreign function, which currently doesn't have a shim in miri.

Some instructions:

Implementing the shim for GetSystemTimeAsFileTime its pretty similar to the linux (clock_gettime) and macOS (gettimeofday) shims (those can already be found in src/shims/time.rs). Its functionality is described in detail here.

The main difference is that this shim only has one argument: a pointer to a FILETIME structure, which has two integer fields dwLowDateTime and dwHighDateTime. These fields correspond to the first and last 32 bits of the 64 bits number counting the 100-nanosecond intervals (so its basically an u64 represented as two u32).

It is also important to take into account that windows counts time since January 1, 1601 instead of January 1, 1970.

The testcase for this issue is:

use std::time::SystemTime;

fn main() {
   let _now = SystemTime::now();
}

Which can be found in miri/tests/run-pass/time.rs.

@RalfJung RalfJung added A-shims Area: This affects the external function shims A-windows Area: affects only Windows targets C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement labels Oct 16, 2019
@JOE1994
Copy link
Contributor

JOE1994 commented Mar 31, 2020

I'm currently working on this issue, and will try to make a PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-shims Area: This affects the external function shims A-windows Area: affects only Windows targets C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants