diff --git a/src/shims/foreign_items/posix/linux.rs b/src/shims/foreign_items/posix/linux.rs index d11d355eb34..f56d5b3959c 100644 --- a/src/shims/foreign_items/posix/linux.rs +++ b/src/shims/foreign_items/posix/linux.rs @@ -140,6 +140,6 @@ fn getrandom<'tcx>( let _flags = this.read_scalar(args[2])?.to_i32()?; this.gen_random(ptr, len)?; - this.write_scalar(Scalar::from_uint(len, dest.layout.size), dest)?; + this.write_scalar(Scalar::from_machine_usize(len, this), dest)?; Ok(()) } diff --git a/src/shims/mod.rs b/src/shims/mod.rs index 588f496d1f3..58972731fb1 100644 --- a/src/shims/mod.rs +++ b/src/shims/mod.rs @@ -75,7 +75,7 @@ fn align_offset( let ptr_scalar = this.read_scalar(ptr_op)?.not_undef()?; // Default: no result. - let mut result = this.truncate(u128::MAX, dest.layout); + let mut result = this.usize_max(); if let Ok(ptr) = this.force_ptr(ptr_scalar) { // Only do anything if we can identify the allocation this goes to. let cur_align = @@ -84,7 +84,7 @@ fn align_offset( // If the allocation alignment is at least the required alignment we use the // libcore implementation. // FIXME: is this correct in case of truncation? - result = u128::try_from( + result = u64::try_from( (this.force_bits(ptr_scalar, this.pointer_size())? as *const i8) .align_offset(usize::try_from(req_align).unwrap()) ).unwrap(); @@ -92,7 +92,7 @@ fn align_offset( } // Return result, and jump to caller. - this.write_scalar(Scalar::from_uint(result, this.pointer_size()), dest)?; + this.write_scalar(Scalar::from_machine_usize(result, this), dest)?; this.go_to_block(ret); Ok(()) }