@@ -29,6 +29,7 @@ impl FileDescriptor for Event {
29
29
}
30
30
31
31
fn dup(&mut self) -> io::Result<Box<dyn FileDescriptor>> {
32
+ // FIXME: this is wrong, the new and old FD should refer to the same event object!
32
33
Ok(Box::new(Event { val: self.val.clone() }))
33
34
}
34
35
@@ -91,7 +92,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
91
92
/// `EFD_SEMAPHORE` - miri does not support semaphore-like semantics.
92
93
///
93
94
/// <https://linux.die.net/man/2/eventfd>
94
- #[expect(clippy::needless_if)]
95
95
fn eventfd(
96
96
&mut self,
97
97
val: &OpTy<'tcx, Provenance>,
@@ -106,14 +106,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
106
106
let efd_nonblock = this.eval_libc_i32("EFD_NONBLOCK");
107
107
let efd_semaphore = this.eval_libc_i32("EFD_SEMAPHORE");
108
108
109
- if flags & (efd_cloexec | efd_nonblock | efd_semaphore) == 0 {
110
- throw_unsup_format!("{flags} is unsupported");
109
+ if flags & (efd_cloexec | efd_nonblock | efd_semaphore) != flags {
110
+ throw_unsup_format!("eventfd: flag {flags:#x} is unsupported");
111
+ }
112
+ if flags & efd_cloexec == efd_cloexec {
113
+ // cloexec does nothing as we don't support `exec`
114
+ }
115
+ if flags & efd_nonblock == efd_nonblock {
116
+ // FIXME remember the nonblock flag
111
117
}
112
- // FIXME handle the cloexec and nonblock flags
113
- if flags & efd_cloexec == efd_cloexec {}
114
- if flags & efd_nonblock == efd_nonblock {}
115
118
if flags & efd_semaphore == efd_semaphore {
116
- throw_unsup_format!("EFD_SEMAPHORE is unsupported");
119
+ throw_unsup_format!("eventfd: EFD_SEMAPHORE is unsupported");
117
120
}
118
121
119
122
let fd = this.machine.fds.insert_fd(Box::new(Event { val: Cell::new(val.into()) }));
0 commit comments