@@ -449,7 +449,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
449449 let [ ptr, out, out_size] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
450450 let ptr = this. read_pointer ( ptr) ?;
451451 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) ?;
453453
454454 // The host affects program behavior here, so this requires isolation to be disabled.
455455 this. check_no_isolation ( "`miri_host_to_target_path`" ) ?;
@@ -490,7 +490,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
490490 let [ bytes] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
491491 let ( ptr, len) = this. read_immediate ( bytes) ?. to_scalar_pair ( ) ;
492492 let ptr = ptr. to_pointer ( this) ?;
493- let len = len. to_machine_usize ( this) ?;
493+ let len = len. to_target_usize ( this) ?;
494494 let msg = this. read_bytes_ptr_strip_provenance ( ptr, Size :: from_bytes ( len) ) ?;
495495
496496 // Note: we're ignoring errors writing to host stdout/stderr.
@@ -504,15 +504,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
504504 // Standard C allocation
505505 "malloc" => {
506506 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) ?;
508508 let res = this. malloc ( size, /*zero_init:*/ false , MiriMemoryKind :: C ) ?;
509509 this. write_pointer ( res, dest) ?;
510510 }
511511 "calloc" => {
512512 let [ items, len] =
513513 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) ?;
516516 let size = items
517517 . checked_mul ( len)
518518 . 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> {
528528 let [ old_ptr, new_size] =
529529 this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
530530 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) ?;
532532 let res = this. realloc ( old_ptr, new_size, MiriMemoryKind :: C ) ?;
533533 this. write_pointer ( res, dest) ?;
534534 }
535535
536536 // Rust allocation
537537 "__rust_alloc" | "miri_alloc" => {
538538 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) ?;
541541
542542 let default = |this : & mut MiriInterpCx < ' mir , ' tcx > | {
543543 Self :: check_alloc_request ( size, align) ?;
@@ -569,8 +569,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
569569 }
570570 "__rust_alloc_zeroed" => {
571571 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) ?;
574574
575575 return this. emulate_allocator ( Symbol :: intern ( "__rg_alloc_zeroed" ) , |this| {
576576 Self :: check_alloc_request ( size, align) ?;
@@ -593,8 +593,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
593593 "__rust_dealloc" | "miri_dealloc" => {
594594 let [ ptr, old_size, align] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
595595 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) ?;
598598
599599 let default = |this : & mut MiriInterpCx < ' mir , ' tcx > | {
600600 let memory_kind = match link_name. as_str ( ) {
@@ -625,9 +625,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
625625 let [ ptr, old_size, align, new_size] =
626626 this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
627627 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) ?;
631631 // No need to check old_size; we anyway check that they match the allocation.
632632
633633 return this. emulate_allocator ( Symbol :: intern ( "__rg_realloc" ) , |this| {
@@ -651,7 +651,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
651651 this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
652652 let left = this. read_pointer ( left) ?;
653653 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) ?) ;
655655
656656 let result = {
657657 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> {
672672 this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
673673 let ptr = this. read_pointer ( ptr) ?;
674674 let val = this. read_scalar ( val) ?. to_i32 ( ) ?;
675- let num = this. read_machine_usize ( num) ?;
675+ let num = this. read_target_usize ( num) ?;
676676 // The docs say val is "interpreted as unsigned char".
677677 #[ allow( clippy:: cast_sign_loss, clippy:: cast_possible_truncation) ]
678678 let val = val as u8 ;
@@ -696,7 +696,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
696696 this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
697697 let ptr = this. read_pointer ( ptr) ?;
698698 let val = this. read_scalar ( val) ?. to_i32 ( ) ?;
699- let num = this. read_machine_usize ( num) ?;
699+ let num = this. read_target_usize ( num) ?;
700700 // The docs say val is "interpreted as unsigned char".
701701 #[ allow( clippy:: cast_sign_loss, clippy:: cast_possible_truncation) ]
702702 let val = val as u8 ;
@@ -717,7 +717,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
717717 let ptr = this. read_pointer ( ptr) ?;
718718 let n = this. read_c_str ( ptr) ?. len ( ) ;
719719 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) ,
721721 dest,
722722 ) ?;
723723 }
0 commit comments