b9698beceb
Replaced P3-sys-eventfd-create.patch (constants-only stub) with: - P3-eventfd-impl.patch: full eventfd() opening /scheme/event/eventfd - P3-bits-eventfd.patch: eventfd_t type - P3-eventfd-cbindgen.patch: generates sys/eventfd.h C header - P3-bits-eventfd-mod.patch: wires bits_eventfd into header/mod.rs libwayland: removed eventfd stub from redox.patch — relibc provides it now. Only meson.build fix + wl_proxy null guards + MSG_NOSIGNAL guard remain. Documented zero-tolerance stub policy at top of local/AGENTS.md.
41 lines
1.4 KiB
Diff
41 lines
1.4 KiB
Diff
--- /dev/null 2026-05-03 20:55:05.750445686 +0100
|
|
+++ b/src/header/sys_eventfd/mod.rs
|
|
@@ -0,0 +1,37 @@
|
|
+//! `sys/eventfd.h` implementation — eventfd() with EFD_SEMAPHORE/CLOEXEC/NONBLOCK.
|
|
+
|
|
+use alloc::format;
|
|
+use crate::c_str::{CStr, CString};
|
|
+use crate::error::{Errno, ResultExt};
|
|
+use crate::header::fcntl::{O_CLOEXEC, O_NONBLOCK, O_RDWR};
|
|
+use crate::header::errno::EINVAL;
|
|
+use crate::platform::{Pal, Sys, types::{c_int, c_uint}};
|
|
+
|
|
+pub const EFD_SEMAPHORE: c_int = 1;
|
|
+pub const EFD_CLOEXEC: c_int = 0x80000;
|
|
+pub const EFD_NONBLOCK: c_int = 0x800;
|
|
+
|
|
+pub type eventfd_t = u64;
|
|
+
|
|
+#[unsafe(no_mangle)]
|
|
+pub extern "C" fn eventfd(initval: c_uint, flags: c_int) -> c_int {
|
|
+ let supported = EFD_CLOEXEC | EFD_NONBLOCK | EFD_SEMAPHORE;
|
|
+ if flags & !supported != 0 {
|
|
+ return Err::<c_int, _>(Errno(EINVAL)).or_minus_one_errno();
|
|
+ }
|
|
+ let sem = if flags & EFD_SEMAPHORE != 0 { 1 } else { 0 };
|
|
+ let path = format!("/scheme/event/eventfd/{}/{}", initval, sem);
|
|
+ let cpath = match CString::new(path) {
|
|
+ Ok(p) => p,
|
|
+ Err(_) => return Err::<c_int, _>(Errno(EINVAL)).or_minus_one_errno(),
|
|
+ };
|
|
+
|
|
+ let mut oflag = O_RDWR;
|
|
+ if flags & EFD_CLOEXEC == EFD_CLOEXEC {
|
|
+ oflag |= O_CLOEXEC;
|
|
+ }
|
|
+ if flags & EFD_NONBLOCK == EFD_NONBLOCK {
|
|
+ oflag |= O_NONBLOCK;
|
|
+ }
|
|
+ Sys::open(CStr::borrow(&cpath), oflag, 0).or_minus_one_errno()
|
|
+}
|