diff options
| author | bors <bors@rust-lang.org> | 2024-04-03 15:01:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-04-03 15:01:16 +0000 |
| commit | 92509847a7fe4d829c5fb73eef1b839d6b9fdbd8 (patch) | |
| tree | 077db7b1b7efa6e170bfefe9aeb97c8df951256d | |
| parent | 1981895a97c2b1172f729439f526fb7b4f0bf625 (diff) | |
| parent | f2120893c696886317e1ef66e4f1e6419a147989 (diff) | |
| download | rust-92509847a7fe4d829c5fb73eef1b839d6b9fdbd8.tar.gz rust-92509847a7fe4d829c5fb73eef1b839d6b9fdbd8.zip | |
Auto merge of #3446 - RalfJung:eventfd, r=RalfJung
eventfd: fix flag check and note a FIXME
| -rw-r--r-- | src/tools/miri/src/shims/unix/linux/epoll.rs | 2 | ||||
| -rw-r--r-- | src/tools/miri/src/shims/unix/linux/eventfd.rs | 17 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/tools/miri/src/shims/unix/linux/epoll.rs b/src/tools/miri/src/shims/unix/linux/epoll.rs index 82e0bffff77..5161d91ca36 100644 --- a/src/tools/miri/src/shims/unix/linux/epoll.rs +++ b/src/tools/miri/src/shims/unix/linux/epoll.rs @@ -35,6 +35,8 @@ impl FileDescriptor for Epoll { } fn dup(&mut self) -> io::Result<Box<dyn FileDescriptor>> { + // FIXME: this is probably wrong -- check if the `dup`ed descriptor truly uses an + // independent event set. Ok(Box::new(self.clone())) } diff --git a/src/tools/miri/src/shims/unix/linux/eventfd.rs b/src/tools/miri/src/shims/unix/linux/eventfd.rs index 4e066493d27..0f28b69ac4a 100644 --- a/src/tools/miri/src/shims/unix/linux/eventfd.rs +++ b/src/tools/miri/src/shims/unix/linux/eventfd.rs @@ -29,6 +29,7 @@ impl FileDescriptor for Event { } fn dup(&mut self) -> io::Result<Box<dyn FileDescriptor>> { + // FIXME: this is wrong, the new and old FD should refer to the same event object! Ok(Box::new(Event { val: self.val.clone() })) } @@ -91,7 +92,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { /// `EFD_SEMAPHORE` - miri does not support semaphore-like semantics. /// /// <https://linux.die.net/man/2/eventfd> - #[expect(clippy::needless_if)] fn eventfd( &mut self, val: &OpTy<'tcx, Provenance>, @@ -106,14 +106,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { 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"); + if flags & (efd_cloexec | efd_nonblock | efd_semaphore) != flags { + throw_unsup_format!("eventfd: flag {flags:#x} is unsupported"); + } + if flags & efd_cloexec == efd_cloexec { + // cloexec does nothing as we don't support `exec` + } + if flags & efd_nonblock == efd_nonblock { + // FIXME remember the nonblock flag } - // FIXME handle the cloexec and nonblock flags - if flags & efd_cloexec == efd_cloexec {} - if flags & efd_nonblock == efd_nonblock {} if flags & efd_semaphore == efd_semaphore { - throw_unsup_format!("EFD_SEMAPHORE is unsupported"); + throw_unsup_format!("eventfd: EFD_SEMAPHORE is unsupported"); } let fd = this.machine.fds.insert_fd(Box::new(Event { val: Cell::new(val.into()) })); |
