@@ -25,6 +25,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
25
25
this. assert_target_os_is_unix ( "clock_gettime" ) ;
26
26
27
27
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" ) ) ?;
28
29
29
30
let absolute_clocks;
30
31
let mut relative_clocks;
@@ -76,7 +77,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
76
77
let tv_sec = duration. as_secs ( ) ;
77
78
let tv_nsec = duration. subsec_nanos ( ) ;
78
79
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 ) ?;
80
81
81
82
Ok ( Scalar :: from_i32 ( 0 ) )
82
83
}
@@ -91,6 +92,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
91
92
this. assert_target_os_is_unix ( "gettimeofday" ) ;
92
93
this. check_no_isolation ( "`gettimeofday`" ) ?;
93
94
95
+ let tv = this. deref_operand_as ( tv_op, this. libc_ty_layout ( "timeval" ) ) ?;
96
+
94
97
// Using tz is obsolete and should always be null
95
98
let tz = this. read_pointer ( tz_op) ?;
96
99
if !this. ptr_is_null ( tz) ? {
@@ -103,7 +106,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
103
106
let tv_sec = duration. as_secs ( ) ;
104
107
let tv_usec = duration. subsec_micros ( ) ;
105
108
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 ) ?;
107
110
108
111
Ok ( 0 )
109
112
}
@@ -118,6 +121,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
118
121
this. assert_target_os ( "windows" , "GetSystemTimeAsFileTime" ) ;
119
122
this. check_no_isolation ( "`GetSystemTimeAsFileTime`" ) ?;
120
123
124
+ let filetime = this. deref_operand_as ( LPFILETIME_op , this. windows_ty_layout ( "FILETIME" ) ) ?;
125
+
121
126
let NANOS_PER_SEC = this. eval_windows_u64 ( "time" , "NANOS_PER_SEC" ) ;
122
127
let INTERVALS_PER_SEC = this. eval_windows_u64 ( "time" , "INTERVALS_PER_SEC" ) ;
123
128
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> {
131
136
132
137
let dwLowDateTime = u32:: try_from ( duration_ticks & 0x00000000FFFFFFFF ) . unwrap ( ) ;
133
138
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) ?;
138
140
139
141
Ok ( ( ) )
140
142
}
@@ -177,7 +179,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
177
179
// and thus 10^9 counts per second.
178
180
this. write_scalar (
179
181
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 ( ) ,
181
183
) ?;
182
184
Ok ( Scalar :: from_i32 ( -1 ) ) // Return non-zero on success
183
185
}
@@ -204,7 +206,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
204
206
205
207
this. assert_target_os ( "macos" , "mach_timebase_info" ) ;
206
208
207
- let info = this. deref_operand ( info_op) ?;
209
+ let info = this. deref_operand_as ( info_op, this . libc_ty_layout ( "mach_timebase_info" ) ) ?;
208
210
209
211
// Since our emulated ticks in `mach_absolute_time` *are* nanoseconds,
210
212
// no scaling needs to happen.
@@ -223,7 +225,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
223
225
224
226
this. assert_target_os_is_unix ( "nanosleep" ) ;
225
227
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) ? {
227
231
Some ( duration) => duration,
228
232
None => {
229
233
let einval = this. eval_libc ( "EINVAL" ) ;
0 commit comments