@@ -449,7 +449,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
449
449
let [ ptr, out, out_size] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
450
450
let ptr = this. read_pointer ( ptr) ?;
451
451
let out = this. read_pointer ( out) ?;
452
- let out_size = this. read_scalar ( out_size) ?. to_machine_usize ( this) ?;
452
+ let out_size = this. read_scalar ( out_size) ?. to_target_usize ( this) ?;
453
453
454
454
// The host affects program behavior here, so this requires isolation to be disabled.
455
455
this. check_no_isolation ( "`miri_host_to_target_path`" ) ?;
@@ -490,7 +490,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
490
490
let [ bytes] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
491
491
let ( ptr, len) = this. read_immediate ( bytes) ?. to_scalar_pair ( ) ;
492
492
let ptr = ptr. to_pointer ( this) ?;
493
- let len = len. to_machine_usize ( this) ?;
493
+ let len = len. to_target_usize ( this) ?;
494
494
let msg = this. read_bytes_ptr_strip_provenance ( ptr, Size :: from_bytes ( len) ) ?;
495
495
496
496
// Note: we're ignoring errors writing to host stdout/stderr.
@@ -504,15 +504,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
504
504
// Standard C allocation
505
505
"malloc" => {
506
506
let [ size] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
507
- let size = this. read_machine_usize ( size) ?;
507
+ let size = this. read_target_usize ( size) ?;
508
508
let res = this. malloc ( size, /*zero_init:*/ false , MiriMemoryKind :: C ) ?;
509
509
this. write_pointer ( res, dest) ?;
510
510
}
511
511
"calloc" => {
512
512
let [ items, len] =
513
513
this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
514
- let items = this. read_machine_usize ( items) ?;
515
- let len = this. read_machine_usize ( len) ?;
514
+ let items = this. read_target_usize ( items) ?;
515
+ let len = this. read_target_usize ( len) ?;
516
516
let size = items
517
517
. checked_mul ( len)
518
518
. ok_or_else ( || err_ub_format ! ( "overflow during calloc size computation" ) ) ?;
@@ -528,16 +528,16 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
528
528
let [ old_ptr, new_size] =
529
529
this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
530
530
let old_ptr = this. read_pointer ( old_ptr) ?;
531
- let new_size = this. read_machine_usize ( new_size) ?;
531
+ let new_size = this. read_target_usize ( new_size) ?;
532
532
let res = this. realloc ( old_ptr, new_size, MiriMemoryKind :: C ) ?;
533
533
this. write_pointer ( res, dest) ?;
534
534
}
535
535
536
536
// Rust allocation
537
537
"__rust_alloc" | "miri_alloc" => {
538
538
let [ size, align] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
539
- let size = this. read_machine_usize ( size) ?;
540
- let align = this. read_machine_usize ( align) ?;
539
+ let size = this. read_target_usize ( size) ?;
540
+ let align = this. read_target_usize ( align) ?;
541
541
542
542
let default = |this : & mut MiriInterpCx < ' mir , ' tcx > | {
543
543
Self :: check_alloc_request ( size, align) ?;
@@ -569,8 +569,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
569
569
}
570
570
"__rust_alloc_zeroed" => {
571
571
let [ size, align] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
572
- let size = this. read_machine_usize ( size) ?;
573
- let align = this. read_machine_usize ( align) ?;
572
+ let size = this. read_target_usize ( size) ?;
573
+ let align = this. read_target_usize ( align) ?;
574
574
575
575
return this. emulate_allocator ( Symbol :: intern ( "__rg_alloc_zeroed" ) , |this| {
576
576
Self :: check_alloc_request ( size, align) ?;
@@ -593,8 +593,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
593
593
"__rust_dealloc" | "miri_dealloc" => {
594
594
let [ ptr, old_size, align] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
595
595
let ptr = this. read_pointer ( ptr) ?;
596
- let old_size = this. read_machine_usize ( old_size) ?;
597
- let align = this. read_machine_usize ( align) ?;
596
+ let old_size = this. read_target_usize ( old_size) ?;
597
+ let align = this. read_target_usize ( align) ?;
598
598
599
599
let default = |this : & mut MiriInterpCx < ' mir , ' tcx > | {
600
600
let memory_kind = match link_name. as_str ( ) {
@@ -625,9 +625,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
625
625
let [ ptr, old_size, align, new_size] =
626
626
this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
627
627
let ptr = this. read_pointer ( ptr) ?;
628
- let old_size = this. read_machine_usize ( old_size) ?;
629
- let align = this. read_machine_usize ( align) ?;
630
- let new_size = this. read_machine_usize ( new_size) ?;
628
+ let old_size = this. read_target_usize ( old_size) ?;
629
+ let align = this. read_target_usize ( align) ?;
630
+ let new_size = this. read_target_usize ( new_size) ?;
631
631
// No need to check old_size; we anyway check that they match the allocation.
632
632
633
633
return this. emulate_allocator ( Symbol :: intern ( "__rg_realloc" ) , |this| {
@@ -651,7 +651,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
651
651
this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
652
652
let left = this. read_pointer ( left) ?;
653
653
let right = this. read_pointer ( right) ?;
654
- let n = Size :: from_bytes ( this. read_machine_usize ( n) ?) ;
654
+ let n = Size :: from_bytes ( this. read_target_usize ( n) ?) ;
655
655
656
656
let result = {
657
657
let left_bytes = this. read_bytes_ptr_strip_provenance ( left, n) ?;
@@ -672,7 +672,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
672
672
this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
673
673
let ptr = this. read_pointer ( ptr) ?;
674
674
let val = this. read_scalar ( val) ?. to_i32 ( ) ?;
675
- let num = this. read_machine_usize ( num) ?;
675
+ let num = this. read_target_usize ( num) ?;
676
676
// The docs say val is "interpreted as unsigned char".
677
677
#[ allow( clippy:: cast_sign_loss, clippy:: cast_possible_truncation) ]
678
678
let val = val as u8 ;
@@ -696,7 +696,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
696
696
this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
697
697
let ptr = this. read_pointer ( ptr) ?;
698
698
let val = this. read_scalar ( val) ?. to_i32 ( ) ?;
699
- let num = this. read_machine_usize ( num) ?;
699
+ let num = this. read_target_usize ( num) ?;
700
700
// The docs say val is "interpreted as unsigned char".
701
701
#[ allow( clippy:: cast_sign_loss, clippy:: cast_possible_truncation) ]
702
702
let val = val as u8 ;
@@ -717,7 +717,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
717
717
let ptr = this. read_pointer ( ptr) ?;
718
718
let n = this. read_c_str ( ptr) ?. len ( ) ;
719
719
this. write_scalar (
720
- Scalar :: from_machine_usize ( u64:: try_from ( n) . unwrap ( ) , this) ,
720
+ Scalar :: from_target_usize ( u64:: try_from ( n) . unwrap ( ) , this) ,
721
721
dest,
722
722
) ?;
723
723
}
0 commit comments