@@ -25,6 +25,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
2525 this. assert_target_os_is_unix ( "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 let absolute_clocks;
3031 let mut relative_clocks;
@@ -76,7 +77,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
7677 let tv_sec = duration. as_secs ( ) ;
7778 let tv_nsec = duration. subsec_nanos ( ) ;
7879
79- this. write_int_fields ( & [ tv_sec. into ( ) , tv_nsec. into ( ) ] , & this . deref_operand ( tp_op ) ? ) ?;
80+ this. write_int_fields ( & [ tv_sec. into ( ) , tv_nsec. into ( ) ] , & tp ) ?;
8081
8182 Ok ( Scalar :: from_i32 ( 0 ) )
8283 }
@@ -91,6 +92,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
9192 this. assert_target_os_is_unix ( "gettimeofday" ) ;
9293 this. check_no_isolation ( "`gettimeofday`" ) ?;
9394
95+ let tv = this. deref_operand_as ( tv_op, this. libc_ty_layout ( "timeval" ) ) ?;
96+
9497 // Using tz is obsolete and should always be null
9598 let tz = this. read_pointer ( tz_op) ?;
9699 if !this. ptr_is_null ( tz) ? {
@@ -103,7 +106,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
103106 let tv_sec = duration. as_secs ( ) ;
104107 let tv_usec = duration. subsec_micros ( ) ;
105108
106- this. write_int_fields ( & [ tv_sec. into ( ) , tv_usec. into ( ) ] , & this . deref_operand ( tv_op ) ? ) ?;
109+ this. write_int_fields ( & [ tv_sec. into ( ) , tv_usec. into ( ) ] , & tv ) ?;
107110
108111 Ok ( 0 )
109112 }
@@ -118,6 +121,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
118121 this. assert_target_os ( "windows" , "GetSystemTimeAsFileTime" ) ;
119122 this. check_no_isolation ( "`GetSystemTimeAsFileTime`" ) ?;
120123
124+ let filetime = this. deref_operand_as ( LPFILETIME_op , this. windows_ty_layout ( "FILETIME" ) ) ?;
125+
121126 let NANOS_PER_SEC = this. eval_windows_u64 ( "time" , "NANOS_PER_SEC" ) ;
122127 let INTERVALS_PER_SEC = this. eval_windows_u64 ( "time" , "INTERVALS_PER_SEC" ) ;
123128 let INTERVALS_TO_UNIX_EPOCH = this. eval_windows_u64 ( "time" , "INTERVALS_TO_UNIX_EPOCH" ) ;
@@ -131,10 +136,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
131136
132137 let dwLowDateTime = u32:: try_from ( duration_ticks & 0x00000000FFFFFFFF ) . unwrap ( ) ;
133138 let dwHighDateTime = u32:: try_from ( ( duration_ticks & 0xFFFFFFFF00000000 ) >> 32 ) . unwrap ( ) ;
134- this. write_int_fields (
135- & [ dwLowDateTime. into ( ) , dwHighDateTime. into ( ) ] ,
136- & this. deref_operand ( LPFILETIME_op ) ?,
137- ) ?;
139+ this. write_int_fields ( & [ dwLowDateTime. into ( ) , dwHighDateTime. into ( ) ] , & filetime) ?;
138140
139141 Ok ( ( ) )
140142 }
@@ -177,7 +179,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
177179 // and thus 10^9 counts per second.
178180 this. write_scalar (
179181 Scalar :: from_i64 ( 1_000_000_000 ) ,
180- & this. deref_operand ( lpFrequency_op) ?. into ( ) ,
182+ & this. deref_operand_as ( lpFrequency_op, this . machine . layouts . u64 ) ?. into ( ) ,
181183 ) ?;
182184 Ok ( Scalar :: from_i32 ( -1 ) ) // Return non-zero on success
183185 }
@@ -204,7 +206,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
204206
205207 this. assert_target_os ( "macos" , "mach_timebase_info" ) ;
206208
207- let info = this. deref_operand ( info_op) ?;
209+ let info = this. deref_operand_as ( info_op, this . libc_ty_layout ( "mach_timebase_info" ) ) ?;
208210
209211 // Since our emulated ticks in `mach_absolute_time` *are* nanoseconds,
210212 // no scaling needs to happen.
@@ -223,7 +225,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
223225
224226 this. assert_target_os_is_unix ( "nanosleep" ) ;
225227
226- let duration = match this. read_timespec ( & this. deref_operand ( req_op) ?) ? {
228+ let req = this. deref_operand_as ( req_op, this. libc_ty_layout ( "timespec" ) ) ?;
229+
230+ let duration = match this. read_timespec ( & req) ? {
227231 Some ( duration) => duration,
228232 None => {
229233 let einval = this. eval_libc ( "EINVAL" ) ;
0 commit comments