Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Dec 13, 2022
1 parent 715e404 commit 3f62ab0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
13 changes: 1 addition & 12 deletions src/shims/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,17 +381,6 @@ trait EvalContextExtPrivate<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx
Ok(0)
}

/// Function used when a handle is not found inside `FileHandler`. It returns `Ok(-1)`and sets
/// the last OS error to `libc::EBADF` (invalid file descriptor). This function uses
/// `T: From<i32>` instead of `i32` directly because some fs functions return different integer
/// types (like `read`, that returns an `i64`).
fn handle_not_found<T: From<i32>>(&mut self) -> InterpResult<'tcx, T> {
let this = self.eval_context_mut();
let ebadf = this.eval_libc("EBADF");
this.set_last_error(ebadf)?;
Ok((-1).into())
}

fn file_type_to_d_type(
&mut self,
file_type: std::io::Result<FileType>,
Expand Down Expand Up @@ -737,7 +726,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
/// types (like `read`, that returns an `i64`).
fn handle_not_found<T: From<i32>>(&mut self) -> InterpResult<'tcx, T> {
let this = self.eval_context_mut();
let ebadf = this.eval_libc("EBADF")?;
let ebadf = this.eval_libc("EBADF");
this.set_last_error(ebadf)?;
Ok((-1).into())
}
Expand Down
16 changes: 8 additions & 8 deletions src/shims/unix/linux/fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {

let flags = this.read_scalar(flags)?.to_i32()?;

let epoll_cloexec = this.eval_libc_i32("EPOLL_CLOEXEC")?;
let epoll_cloexec = this.eval_libc_i32("EPOLL_CLOEXEC");
if flags == epoll_cloexec {
// Miri does not support exec, so this flag has no effect.
} else if flags != 0 {
Expand Down Expand Up @@ -64,9 +64,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let fd = this.read_scalar(fd)?.to_i32()?;
let _event = this.read_scalar(event)?.to_pointer(this)?;

let epoll_ctl_add = this.eval_libc_i32("EPOLL_CTL_ADD")?;
let epoll_ctl_mod = this.eval_libc_i32("EPOLL_CTL_MOD")?;
let epoll_ctl_del = this.eval_libc_i32("EPOLL_CTL_DEL")?;
let epoll_ctl_add = this.eval_libc_i32("EPOLL_CTL_ADD");
let epoll_ctl_mod = this.eval_libc_i32("EPOLL_CTL_MOD");
let epoll_ctl_del = this.eval_libc_i32("EPOLL_CTL_DEL");

if op == epoll_ctl_add || op == epoll_ctl_mod {
let event = this.deref_operand(event)?;
Expand Down Expand Up @@ -95,7 +95,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
Ok(Scalar::from_i32(this.handle_not_found()?))
}
} else {
let einval = this.eval_libc("EINVAL")?;
let einval = this.eval_libc("EINVAL");
this.set_last_error(einval)?;
Ok(Scalar::from_i32(-1))
}
Expand Down Expand Up @@ -127,9 +127,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let val = this.read_scalar(val)?.to_u32()?;
let flags = this.read_scalar(flags)?.to_i32()?;

let efd_cloexec = this.eval_libc_i32("EFD_CLOEXEC")?;
let efd_nonblock = this.eval_libc_i32("EFD_NONBLOCK")?;
let efd_semaphore = this.eval_libc_i32("EFD_SEMAPHORE")?;
let efd_cloexec = this.eval_libc_i32("EFD_CLOEXEC");
let efd_nonblock = this.eval_libc_i32("EFD_NONBLOCK");
let efd_semaphore = this.eval_libc_i32("EFD_SEMAPHORE");

if flags & (efd_cloexec | efd_nonblock | efd_semaphore) == 0 {
throw_unsup_format!("{flags} is unsupported");
Expand Down

0 comments on commit 3f62ab0

Please sign in to comment.