@@ -522,6 +522,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
522
522
} else {
523
523
let tp = this. force_ptr ( this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?) ?;
524
524
525
+ let long = this. resolve_path ( & [ "libc" , "c_long" ] ) ?. ty ( * tcx) ;
526
+ let time_t = this. resolve_path ( & [ "libc" , "time_t" ] ) ?. ty ( * tcx) ;
527
+
528
+ let tv_sec_size = this. layout_of ( time_t) ?. size ;
529
+ let tv_nsec_size = this. layout_of ( long) ?. size ;
530
+
525
531
let allocation = this. memory_mut ( ) . get_mut ( tp. alloc_id ) ?;
526
532
527
533
let mut sign = 1 ;
@@ -533,13 +539,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
533
539
e. duration ( )
534
540
} ) ;
535
541
536
- let tv_sec_size = Size :: from_bits ( 64 ) ;
537
- let tv_nsec_size = Size :: from_bits ( 64 ) ;
538
-
539
542
allocation. write_scalar (
540
543
tcx,
541
544
tp,
542
- Scalar :: from_int ( sign * ( duration. as_secs ( ) as i64 ) , tv_sec_size) . into ( ) ,
545
+ Scalar :: from_int ( sign * ( duration. as_secs ( ) as i64 ) , tv_sec_size)
546
+ . into ( ) ,
543
547
tv_sec_size,
544
548
) ?;
545
549
@@ -555,16 +559,16 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
555
559
}
556
560
}
557
561
558
- "strlen" => {
559
- let ptr = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
560
- let n = this. memory ( ) . read_c_str ( ptr) ?. len ( ) ;
561
- this. write_scalar ( Scalar :: from_uint ( n as u64 , dest. layout . size ) , dest) ?;
562
- }
562
+ "strlen" => {
563
+ let ptr = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
564
+ let n = this. memory ( ) . read_c_str ( ptr) ?. len ( ) ;
565
+ this. write_scalar ( Scalar :: from_uint ( n as u64 , dest. layout . size ) , dest) ?;
566
+ }
563
567
564
- // math functions
565
- "cbrtf" | "coshf" | "sinhf" | "tanf" => {
566
- // FIXME: Using host floats.
567
- let f = f32:: from_bits ( this. read_scalar ( args[ 0 ] ) ?. to_u32 ( ) ?) ;
568
+ // math functions
569
+ "cbrtf" | "coshf" | "sinhf" | "tanf" => {
570
+ // FIXME: Using host floats.
571
+ let f = f32:: from_bits ( this. read_scalar ( args[ 0 ] ) ?. to_u32 ( ) ?) ;
568
572
let f = match link_name {
569
573
"cbrtf" => f. cbrt ( ) ,
570
574
"coshf" => f. cosh ( ) ,
0 commit comments