Skip to content

Implement GetSystemTimeAsFileTime shim for Windows #997

Closed
@pvdrz

Description

@pvdrz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-shimsArea: This affects the external function shimsA-windowsArea: affects only Windows targetsC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions