@@ -29,6 +29,7 @@ impl FileDescriptor for Event {
2929 }
3030
3131 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!
3233 Ok ( Box :: new ( Event { val : self . val . clone ( ) } ) )
3334 }
3435
@@ -91,7 +92,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
9192 /// `EFD_SEMAPHORE` - miri does not support semaphore-like semantics.
9293 ///
9394 /// <https://linux.die.net/man/2/eventfd>
94- #[ expect( clippy:: needless_if) ]
9595 fn eventfd (
9696 & mut self ,
9797 val : & OpTy < ' tcx , Provenance > ,
@@ -106,14 +106,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
106106 let efd_nonblock = this. eval_libc_i32 ( "EFD_NONBLOCK" ) ;
107107 let efd_semaphore = this. eval_libc_i32 ( "EFD_SEMAPHORE" ) ;
108108
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
111117 }
112- // FIXME handle the cloexec and nonblock flags
113- if flags & efd_cloexec == efd_cloexec { }
114- if flags & efd_nonblock == efd_nonblock { }
115118 if flags & efd_semaphore == efd_semaphore {
116- throw_unsup_format ! ( "EFD_SEMAPHORE is unsupported" ) ;
119+ throw_unsup_format ! ( "eventfd: EFD_SEMAPHORE is unsupported" ) ;
117120 }
118121
119122 let fd = this. machine . fds . insert_fd ( Box :: new ( Event { val : Cell :: new ( val. into ( ) ) } ) ) ;
0 commit comments