@@ -144,13 +144,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
144144 let ret = ret. expect ( "dest is `Some` but ret is `None`" ) ;
145145 match link_name {
146146 "malloc" => {
147- let size = this. read_scalar ( args[ 0 ] ) ?. to_usize ( this) ?;
147+ let size = this. read_scalar ( args[ 0 ] ) ?. to_machine_usize ( this) ?;
148148 let res = this. malloc ( size, /*zero_init:*/ false , MiriMemoryKind :: C ) ;
149149 this. write_scalar ( res, dest) ?;
150150 }
151151 "calloc" => {
152- let items = this. read_scalar ( args[ 0 ] ) ?. to_usize ( this) ?;
153- let len = this. read_scalar ( args[ 1 ] ) ?. to_usize ( this) ?;
152+ let items = this. read_scalar ( args[ 0 ] ) ?. to_machine_usize ( this) ?;
153+ let len = this. read_scalar ( args[ 1 ] ) ?. to_machine_usize ( this) ?;
154154 let size = items
155155 . checked_mul ( len)
156156 . ok_or_else ( || err_panic ! ( Overflow ( mir:: BinOp :: Mul ) ) ) ?;
@@ -159,8 +159,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
159159 }
160160 "posix_memalign" => {
161161 let ret = this. deref_operand ( args[ 0 ] ) ?;
162- let align = this. read_scalar ( args[ 1 ] ) ?. to_usize ( this) ?;
163- let size = this. read_scalar ( args[ 2 ] ) ?. to_usize ( this) ?;
162+ let align = this. read_scalar ( args[ 1 ] ) ?. to_machine_usize ( this) ?;
163+ let size = this. read_scalar ( args[ 2 ] ) ?. to_machine_usize ( this) ?;
164164 // Align must be power of 2, and also at least ptr-sized (POSIX rules).
165165 if !align. is_power_of_two ( ) {
166166 throw_unsup ! ( HeapAllocNonPowerOfTwoAlignment ( align) ) ;
@@ -190,14 +190,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
190190 }
191191 "realloc" => {
192192 let old_ptr = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
193- let new_size = this. read_scalar ( args[ 1 ] ) ?. to_usize ( this) ?;
193+ let new_size = this. read_scalar ( args[ 1 ] ) ?. to_machine_usize ( this) ?;
194194 let res = this. realloc ( old_ptr, new_size, MiriMemoryKind :: C ) ?;
195195 this. write_scalar ( res, dest) ?;
196196 }
197197
198198 "__rust_alloc" => {
199- let size = this. read_scalar ( args[ 0 ] ) ?. to_usize ( this) ?;
200- let align = this. read_scalar ( args[ 1 ] ) ?. to_usize ( this) ?;
199+ let size = this. read_scalar ( args[ 0 ] ) ?. to_machine_usize ( this) ?;
200+ let align = this. read_scalar ( args[ 1 ] ) ?. to_machine_usize ( this) ?;
201201 if size == 0 {
202202 throw_unsup ! ( HeapAllocZeroBytes ) ;
203203 }
@@ -212,8 +212,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
212212 this. write_scalar ( Scalar :: Ptr ( ptr) , dest) ?;
213213 }
214214 "__rust_alloc_zeroed" => {
215- let size = this. read_scalar ( args[ 0 ] ) ?. to_usize ( this) ?;
216- let align = this. read_scalar ( args[ 1 ] ) ?. to_usize ( this) ?;
215+ let size = this. read_scalar ( args[ 0 ] ) ?. to_machine_usize ( this) ?;
216+ let align = this. read_scalar ( args[ 1 ] ) ?. to_machine_usize ( this) ?;
217217 if size == 0 {
218218 throw_unsup ! ( HeapAllocZeroBytes ) ;
219219 }
@@ -233,8 +233,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
233233 }
234234 "__rust_dealloc" => {
235235 let ptr = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
236- let old_size = this. read_scalar ( args[ 1 ] ) ?. to_usize ( this) ?;
237- let align = this. read_scalar ( args[ 2 ] ) ?. to_usize ( this) ?;
236+ let old_size = this. read_scalar ( args[ 1 ] ) ?. to_machine_usize ( this) ?;
237+ let align = this. read_scalar ( args[ 2 ] ) ?. to_machine_usize ( this) ?;
238238 if old_size == 0 {
239239 throw_unsup ! ( HeapAllocZeroBytes ) ;
240240 }
@@ -253,9 +253,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
253253 }
254254 "__rust_realloc" => {
255255 let ptr = this. read_scalar ( args[ 0 ] ) ?. to_ptr ( ) ?;
256- let old_size = this. read_scalar ( args[ 1 ] ) ?. to_usize ( this) ?;
257- let align = this. read_scalar ( args[ 2 ] ) ?. to_usize ( this) ?;
258- let new_size = this. read_scalar ( args[ 3 ] ) ?. to_usize ( this) ?;
256+ let old_size = this. read_scalar ( args[ 1 ] ) ?. to_machine_usize ( this) ?;
257+ let align = this. read_scalar ( args[ 2 ] ) ?. to_machine_usize ( this) ?;
258+ let new_size = this. read_scalar ( args[ 3 ] ) ?. to_machine_usize ( this) ?;
259259 if old_size == 0 || new_size == 0 {
260260 throw_unsup ! ( HeapAllocZeroBytes ) ;
261261 }
@@ -277,11 +277,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
277277 let sys_getrandom = this
278278 . eval_path_scalar ( & [ "libc" , "SYS_getrandom" ] ) ?
279279 . expect ( "Failed to get libc::SYS_getrandom" )
280- . to_usize ( this) ?;
280+ . to_machine_usize ( this) ?;
281281
282282 // `libc::syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(), GRND_NONBLOCK)`
283283 // is called if a `HashMap` is created the regular way (e.g. HashMap<K, V>).
284- match this. read_scalar ( args[ 0 ] ) ?. to_usize ( this) ? {
284+ match this. read_scalar ( args[ 0 ] ) ?. to_machine_usize ( this) ? {
285285 id if id == sys_getrandom => {
286286 // The first argument is the syscall id,
287287 // so skip over it.
@@ -357,7 +357,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
357357 "memcmp" => {
358358 let left = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
359359 let right = this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?;
360- let n = Size :: from_bytes ( this. read_scalar ( args[ 2 ] ) ?. to_usize ( this) ?) ;
360+ let n = Size :: from_bytes ( this. read_scalar ( args[ 2 ] ) ?. to_machine_usize ( this) ?) ;
361361
362362 let result = {
363363 let left_bytes = this. memory . read_bytes ( left, n) ?;
@@ -377,7 +377,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
377377 "memrchr" => {
378378 let ptr = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
379379 let val = this. read_scalar ( args[ 1 ] ) ?. to_i32 ( ) ? as u8 ;
380- let num = this. read_scalar ( args[ 2 ] ) ?. to_usize ( this) ?;
380+ let num = this. read_scalar ( args[ 2 ] ) ?. to_machine_usize ( this) ?;
381381 if let Some ( idx) = this
382382 . memory
383383 . read_bytes ( ptr, Size :: from_bytes ( num) ) ?
@@ -395,7 +395,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
395395 "memchr" => {
396396 let ptr = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
397397 let val = this. read_scalar ( args[ 1 ] ) ?. to_i32 ( ) ? as u8 ;
398- let num = this. read_scalar ( args[ 2 ] ) ?. to_usize ( this) ?;
398+ let num = this. read_scalar ( args[ 2 ] ) ?. to_machine_usize ( this) ?;
399399 let idx = this
400400 . memory
401401 . read_bytes ( ptr, Size :: from_bytes ( num) ) ?
@@ -462,7 +462,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
462462 "write" => {
463463 let fd = this. read_scalar ( args[ 0 ] ) ?. to_i32 ( ) ?;
464464 let buf = this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?;
465- let n = this. read_scalar ( args[ 2 ] ) ?. to_usize ( tcx) ?;
465+ let n = this. read_scalar ( args[ 2 ] ) ?. to_machine_usize ( tcx) ?;
466466 trace ! ( "Called write({:?}, {:?}, {:?})" , fd, buf, n) ;
467467 let result = if fd == 1 || fd == 2 {
468468 // stdout/stderr
@@ -771,7 +771,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
771771 this. write_scalar ( this. machine . argv . expect ( "machine must be initialized" ) , dest) ?;
772772 }
773773 "SecRandomCopyBytes" => {
774- let len = this. read_scalar ( args[ 1 ] ) ?. to_usize ( this) ?;
774+ let len = this. read_scalar ( args[ 1 ] ) ?. to_machine_usize ( this) ?;
775775 let ptr = this. read_scalar ( args[ 2 ] ) ?. not_undef ( ) ?;
776776 this. gen_random ( ptr, len as usize ) ?;
777777 this. write_null ( dest) ?;
@@ -786,25 +786,25 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
786786 this. write_scalar ( Scalar :: from_int ( 1 , this. pointer_size ( ) ) , dest) ?;
787787 }
788788 "HeapAlloc" => {
789- let _handle = this. read_scalar ( args[ 0 ] ) ?. to_isize ( this) ?;
789+ let _handle = this. read_scalar ( args[ 0 ] ) ?. to_machine_isize ( this) ?;
790790 let flags = this. read_scalar ( args[ 1 ] ) ?. to_u32 ( ) ?;
791- let size = this. read_scalar ( args[ 2 ] ) ?. to_usize ( this) ?;
791+ let size = this. read_scalar ( args[ 2 ] ) ?. to_machine_usize ( this) ?;
792792 let zero_init = ( flags & 0x00000008 ) != 0 ; // HEAP_ZERO_MEMORY
793793 let res = this. malloc ( size, zero_init, MiriMemoryKind :: WinHeap ) ;
794794 this. write_scalar ( res, dest) ?;
795795 }
796796 "HeapFree" => {
797- let _handle = this. read_scalar ( args[ 0 ] ) ?. to_isize ( this) ?;
797+ let _handle = this. read_scalar ( args[ 0 ] ) ?. to_machine_isize ( this) ?;
798798 let _flags = this. read_scalar ( args[ 1 ] ) ?. to_u32 ( ) ?;
799799 let ptr = this. read_scalar ( args[ 2 ] ) ?. not_undef ( ) ?;
800800 this. free ( ptr, MiriMemoryKind :: WinHeap ) ?;
801801 this. write_scalar ( Scalar :: from_int ( 1 , Size :: from_bytes ( 4 ) ) , dest) ?;
802802 }
803803 "HeapReAlloc" => {
804- let _handle = this. read_scalar ( args[ 0 ] ) ?. to_isize ( this) ?;
804+ let _handle = this. read_scalar ( args[ 0 ] ) ?. to_machine_isize ( this) ?;
805805 let _flags = this. read_scalar ( args[ 1 ] ) ?. to_u32 ( ) ?;
806806 let ptr = this. read_scalar ( args[ 2 ] ) ?. not_undef ( ) ?;
807- let size = this. read_scalar ( args[ 3 ] ) ?. to_usize ( this) ?;
807+ let size = this. read_scalar ( args[ 3 ] ) ?. to_machine_usize ( this) ?;
808808 let res = this. realloc ( ptr, size, MiriMemoryKind :: WinHeap ) ?;
809809 this. write_scalar ( res, dest) ?;
810810 }
@@ -883,7 +883,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
883883 this. write_scalar ( Scalar :: from_int ( which, this. pointer_size ( ) ) , dest) ?;
884884 }
885885 "WriteFile" => {
886- let handle = this. read_scalar ( args[ 0 ] ) ?. to_isize ( this) ?;
886+ let handle = this. read_scalar ( args[ 0 ] ) ?. to_machine_isize ( this) ?;
887887 let buf = this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?;
888888 let n = this. read_scalar ( args[ 2 ] ) ?. to_u32 ( ) ?;
889889 let written_place = this. deref_operand ( args[ 3 ] ) ?;
@@ -973,7 +973,7 @@ fn linux_getrandom<'tcx>(
973973 dest : PlaceTy < ' tcx , Tag > ,
974974) -> InterpResult < ' tcx > {
975975 let ptr = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
976- let len = this. read_scalar ( args[ 1 ] ) ?. to_usize ( this) ?;
976+ let len = this. read_scalar ( args[ 1 ] ) ?. to_machine_usize ( this) ?;
977977
978978 // The only supported flags are GRND_RANDOM and GRND_NONBLOCK,
979979 // neither of which have any effect on our current PRNG.
0 commit comments