@@ -511,8 +511,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
511
511
if !this. machine . communicate {
512
512
throw_unsup_format ! ( "`clock_gettime` not available when isolation is enabled" )
513
513
} else {
514
- let tcx = & { this. tcx . tcx } ;
515
-
516
514
let clk_id = this. read_scalar ( args[ 0 ] ) ?. to_i32 ( ) ?;
517
515
518
516
if clk_id != this. eval_libc_i32 ( "CLOCK_REALTIME" ) ? {
@@ -522,14 +520,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
522
520
} else {
523
521
let tp = this. force_ptr ( this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?) ?;
524
522
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
-
531
- let allocation = this. memory_mut ( ) . get_mut ( tp. alloc_id ) ?;
532
-
533
523
let mut sign = 1 ;
534
524
535
525
let duration = std:: time:: SystemTime :: now ( )
@@ -539,20 +529,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
539
529
e. duration ( )
540
530
} ) ;
541
531
542
- allocation. write_scalar (
543
- tcx,
544
- tp,
545
- Scalar :: from_int ( sign * ( duration. as_secs ( ) as i64 ) , tv_sec_size)
546
- . into ( ) ,
547
- tv_sec_size,
548
- ) ?;
549
-
550
- allocation. write_scalar (
551
- tcx,
552
- tp. offset ( tv_sec_size, tcx) ?,
553
- Scalar :: from_int ( duration. subsec_nanos ( ) as i64 , tv_nsec_size) . into ( ) ,
554
- tv_nsec_size,
555
- ) ?;
532
+ let tv_sec = sign * ( duration. as_secs ( ) as i128 ) ;
533
+ let tv_nsec = duration. subsec_nanos ( ) as i128 ;
534
+
535
+ this. write_c_ints ( & tp, & [ tv_sec, tv_nsec] , & [ "time_t" , "c_long" ] ) ?;
556
536
557
537
this. write_scalar ( Scalar :: from_int ( 0i32 , dest. layout . size ) , dest) ?;
558
538
}
@@ -563,8 +543,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
563
543
if !this. machine . communicate {
564
544
throw_unsup_format ! ( "`gettimeofday` not available when isolation is enabled" )
565
545
} else {
566
- let tcx = & { this. tcx . tcx } ;
567
-
568
546
let tz = this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?;
569
547
// Using tz is obsolete and should always be null
570
548
if !this. is_null ( tz) ? {
@@ -574,14 +552,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
574
552
} else {
575
553
let tv = this. force_ptr ( this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?) ?;
576
554
577
- let time_t = this. resolve_path ( & [ "libc" , "time_t" ] ) ?. ty ( * tcx) ;
578
- let suseconds_t = this. resolve_path ( & [ "libc" , "suseconds_t" ] ) ?. ty ( * tcx) ;
579
-
580
- let tv_sec_size = this. layout_of ( time_t) ?. size ;
581
- let tv_usec_size = this. layout_of ( suseconds_t) ?. size ;
582
-
583
- let allocation = this. memory_mut ( ) . get_mut ( tv. alloc_id ) ?;
584
-
585
555
let mut sign = 1 ;
586
556
587
557
let duration = std:: time:: SystemTime :: now ( )
@@ -591,20 +561,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
591
561
e. duration ( )
592
562
} ) ;
593
563
594
- allocation. write_scalar (
595
- tcx,
596
- tv,
597
- Scalar :: from_int ( sign * ( duration. as_secs ( ) as i64 ) , tv_sec_size)
598
- . into ( ) ,
599
- tv_sec_size,
600
- ) ?;
601
-
602
- allocation. write_scalar (
603
- tcx,
604
- tv. offset ( tv_sec_size, tcx) ?,
605
- Scalar :: from_int ( duration. subsec_micros ( ) as i64 , tv_usec_size) . into ( ) ,
606
- tv_usec_size,
607
- ) ?;
564
+ let tv_sec = sign * ( duration. as_secs ( ) as i128 ) ;
565
+ let tv_usec = duration. subsec_micros ( ) as i128 ;
566
+
567
+ this. write_c_ints ( & tv, & [ tv_sec, tv_usec] , & [ "time_t" , "suseconds_t" ] ) ?;
608
568
609
569
this. write_scalar ( Scalar :: from_int ( 0i32 , dest. layout . size ) , dest) ?;
610
570
}
0 commit comments