Skip to content

Commit

Permalink
Move mmap64's implementation under "File related shims".
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Feb 11, 2024
1 parent 7a56a76 commit d914d5e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/shims/unix/linux/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let result = this.linux_readdir64(dirp)?;
this.write_scalar(result, dest)?;
}
"mmap64" => {
let [addr, length, prot, flags, fd, offset] =
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
let offset = this.read_scalar(offset)?.to_i64()?;
let ptr = this.mmap(addr, length, prot, flags, fd, offset.into())?;
this.write_scalar(ptr, dest)?;
}

// Linux-only
"sync_file_range" => {
let [fd, offset, nbytes, flags] =
Expand Down Expand Up @@ -218,14 +226,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
this.write_null(dest)?;
}

"mmap64" => {
let [addr, length, prot, flags, fd, offset] =
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
let offset = this.read_scalar(offset)?.to_i64()?;
let ptr = this.mmap(addr, length, prot, flags, fd, offset.into())?;
this.write_scalar(ptr, dest)?;
}

_ => return Ok(EmulateForeignItemResult::NotSupported),
};

Expand Down

0 comments on commit d914d5e

Please sign in to comment.