Skip to content

Commit 70ee96e

Browse files
committed
Tidy the shim a bit
1 parent 3ad43fd commit 70ee96e

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

src/shims/unix/mem.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
use crate::machine::Mapping;
1+
use crate::machine::{Mapping, PAGE_SIZE};
22
use crate::shims::unix::fs::EvalContextExt as _;
33
use crate::*;
44
use rustc_target::abi::{Align, Size};
55

6-
const PAGE_SIZE: u64 = 4096;
7-
86
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {}
97
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> {
108
fn mmap(
@@ -25,12 +23,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
2523
let fd = this.read_scalar(fd)?.to_i32()?;
2624
let offset = this.read_scalar(offset)?.to_machine_usize(this)?;
2725

28-
let print_args = || {
29-
eprintln!(
30-
"mmap(addr: {addr}, length: {length}, prot: {prot:x}, flags: {flags:0x}, fd: {fd}, offset: {offset})"
31-
);
32-
};
33-
3426
let prot_read = this.eval_libc_i32("PROT_READ")?;
3527
let prot_write = this.eval_libc_i32("PROT_WRITE")?;
3628
let map_private = this.eval_libc_i32("MAP_PRIVATE")?;
@@ -46,22 +38,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
4638
}
4739

4840
if prot & this.eval_libc_i32("PROT_EXEC")? > 0 {
49-
print_args();
5041
throw_unsup_format!("Miri does not support mapping executable pages");
5142
}
5243

5344
if offset != 0 {
54-
print_args();
5545
throw_unsup_format!("Miri does not support non-zero offsets to mmap (yet)");
5646
}
5747

5848
if !this.ptr_is_null(addr)? {
59-
print_args();
6049
throw_unsup_format!("Miri does not support non-null pointers to mmap");
6150
}
6251

6352
if length == 0 {
64-
print_args();
6553
this.set_last_error(Scalar::from_i32(this.eval_libc_i32("EINVAL")?))?;
6654
return Ok(Pointer::null());
6755
}

0 commit comments

Comments
 (0)