@@ -275,26 +275,23 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
275275 interp_ok ( Scalar :: from_i32 ( -1 ) ) // Return non-zero on success
276276 }
277277
278- #[ allow( non_snake_case , clippy:: arithmetic_side_effects) ]
278+ #[ allow( clippy:: arithmetic_side_effects) ]
279279 fn system_time_since_windows_epoch ( & self , time : & SystemTime ) -> InterpResult < ' tcx , Duration > {
280- let this = self . eval_context_ref ( ) ;
281-
282- let INTERVALS_PER_SEC = this. eval_windows_u64 ( "time" , "INTERVALS_PER_SEC" ) ;
283- let INTERVALS_TO_UNIX_EPOCH = this. eval_windows_u64 ( "time" , "INTERVALS_TO_UNIX_EPOCH" ) ;
284- let SECONDS_TO_UNIX_EPOCH = INTERVALS_TO_UNIX_EPOCH / INTERVALS_PER_SEC ;
280+ // The amount of seconds between 1601/1/1 and 1970/1/1.
281+ // See https://learn.microsoft.com/en-us/windows/win32/sysinfo/converting-a-time-t-value-to-a-file-time
282+ // (just divide by the number of 100 ns intervals per second).
283+ const SECONDS_TO_UNIX_EPOCH : u64 = 11_644_473_600 ;
285284
286285 interp_ok ( system_time_to_duration ( time) ? + Duration :: from_secs ( SECONDS_TO_UNIX_EPOCH ) )
287286 }
288287
289288 #[ allow( non_snake_case, clippy:: arithmetic_side_effects) ]
290289 fn windows_ticks_for ( & self , duration : Duration ) -> InterpResult < ' tcx , u64 > {
291- let this = self . eval_context_ref ( ) ;
292-
293- let NANOS_PER_SEC = this. eval_windows_u64 ( "time" , "NANOS_PER_SEC" ) ;
294- let INTERVALS_PER_SEC = this. eval_windows_u64 ( "time" , "INTERVALS_PER_SEC" ) ;
295- let NANOS_PER_INTERVAL = NANOS_PER_SEC / INTERVALS_PER_SEC ;
290+ // 1 interval = 100 ns.
291+ // See https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime
292+ const NANOS_PER_INTERVAL : u128 = 100 ;
296293
297- let ticks = u64:: try_from ( duration. as_nanos ( ) / u128 :: from ( NANOS_PER_INTERVAL ) )
294+ let ticks = u64:: try_from ( duration. as_nanos ( ) / NANOS_PER_INTERVAL )
298295 . map_err ( |_| err_unsup_format ! ( "programs running more than 2^64 Windows ticks after the Windows epoch are not supported" ) ) ?;
299296 interp_ok ( ticks)
300297 }
0 commit comments