@@ -25,6 +25,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
2525 this. assert_target_os ( "linux" , "clock_gettime" ) ;
2626
2727 let clk_id = this. read_scalar ( clk_id_op) ?. to_i32 ( ) ?;
28+ let tp = this. deref_operand_as ( tp_op, this. libc_ty_layout ( "timespec" ) ?) ?;
2829
2930 // Linux has two main kinds of clocks. REALTIME clocks return the actual time since the
3031 // Unix epoch, including effects which may cause time to move backwards such as NTP.
@@ -52,7 +53,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
5253 let tv_sec = duration. as_secs ( ) ;
5354 let tv_nsec = duration. subsec_nanos ( ) ;
5455
55- this. write_int_fields ( & [ tv_sec. into ( ) , tv_nsec. into ( ) ] , & this . deref_operand ( tp_op ) ? ) ?;
56+ this. write_int_fields ( & [ tv_sec. into ( ) , tv_nsec. into ( ) ] , & tp ) ?;
5657
5758 Ok ( Scalar :: from_i32 ( 0 ) )
5859 }
@@ -67,6 +68,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
6768 this. assert_target_os_is_unix ( "gettimeofday" ) ;
6869 this. check_no_isolation ( "`gettimeofday`" ) ?;
6970
71+ let tv = this. deref_operand_as ( tv_op, this. libc_ty_layout ( "timeval" ) ?) ?;
72+
7073 // Using tz is obsolete and should always be null
7174 let tz = this. read_pointer ( tz_op) ?;
7275 if !this. ptr_is_null ( tz) ? {
@@ -79,7 +82,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
7982 let tv_sec = duration. as_secs ( ) ;
8083 let tv_usec = duration. subsec_micros ( ) ;
8184
82- this. write_int_fields ( & [ tv_sec. into ( ) , tv_usec. into ( ) ] , & this . deref_operand ( tv_op ) ? ) ?;
85+ this. write_int_fields ( & [ tv_sec. into ( ) , tv_usec. into ( ) ] , & tv ) ?;
8386
8487 Ok ( 0 )
8588 }
@@ -94,6 +97,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
9497 this. assert_target_os ( "windows" , "GetSystemTimeAsFileTime" ) ;
9598 this. check_no_isolation ( "`GetSystemTimeAsFileTime`" ) ?;
9699
100+ let filetime = this. deref_operand_as ( LPFILETIME_op , this. windows_ty_layout ( "FILETIME" ) ?) ?;
101+
97102 let NANOS_PER_SEC = this. eval_windows_u64 ( "time" , "NANOS_PER_SEC" ) ?;
98103 let INTERVALS_PER_SEC = this. eval_windows_u64 ( "time" , "INTERVALS_PER_SEC" ) ?;
99104 let INTERVALS_TO_UNIX_EPOCH = this. eval_windows_u64 ( "time" , "INTERVALS_TO_UNIX_EPOCH" ) ?;
@@ -107,10 +112,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
107112
108113 let dwLowDateTime = u32:: try_from ( duration_ticks & 0x00000000FFFFFFFF ) . unwrap ( ) ;
109114 let dwHighDateTime = u32:: try_from ( ( duration_ticks & 0xFFFFFFFF00000000 ) >> 32 ) . unwrap ( ) ;
110- this. write_int_fields (
111- & [ dwLowDateTime. into ( ) , dwHighDateTime. into ( ) ] ,
112- & this. deref_operand ( LPFILETIME_op ) ?,
113- ) ?;
115+ this. write_int_fields ( & [ dwLowDateTime. into ( ) , dwHighDateTime. into ( ) ] , & filetime) ?;
114116
115117 Ok ( ( ) )
116118 }
@@ -132,7 +134,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
132134 } ) ?;
133135 this. write_scalar (
134136 Scalar :: from_i64 ( qpc) ,
135- & this. deref_operand ( lpPerformanceCount_op) ?. into ( ) ,
137+ & this. deref_operand_as ( lpPerformanceCount_op, this . machine . layouts . u64 ) ?. into ( ) ,
136138 ) ?;
137139 Ok ( Scalar :: from_i32 ( -1 ) ) // return non-zero on success
138140 }
@@ -153,7 +155,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
153155 // and thus 10^9 counts per second.
154156 this. write_scalar (
155157 Scalar :: from_i64 ( 1_000_000_000 ) ,
156- & this. deref_operand ( lpFrequency_op) ?. into ( ) ,
158+ & this. deref_operand_as ( lpFrequency_op, this . machine . layouts . u64 ) ?. into ( ) ,
157159 ) ?;
158160 Ok ( Scalar :: from_i32 ( -1 ) ) // Return non-zero on success
159161 }
@@ -180,7 +182,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
180182
181183 this. assert_target_os ( "macos" , "mach_timebase_info" ) ;
182184
183- let info = this. deref_operand ( info_op) ?;
185+ let info = this. deref_operand_as ( info_op, this . libc_ty_layout ( "mach_timebase_info" ) ? ) ?;
184186
185187 // Since our emulated ticks in `mach_absolute_time` *are* nanoseconds,
186188 // no scaling needs to happen.
@@ -199,7 +201,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
199201
200202 this. assert_target_os_is_unix ( "nanosleep" ) ;
201203
202- let duration = match this. read_timespec ( & this. deref_operand ( req_op) ?) ? {
204+ let req = this. deref_operand_as ( req_op, this. libc_ty_layout ( "timespec" ) ?) ?;
205+
206+ let duration = match this. read_timespec ( & req) ? {
203207 Some ( duration) => duration,
204208 None => {
205209 let einval = this. eval_libc ( "EINVAL" ) ?;
0 commit comments