relibc: full eventfd() implementation + no-stubs policy in AGENTS.md
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.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
--- a/src/header/mod.rs
|
||||
+++ b/src/header/mod.rs
|
||||
@@ -5,6 +5,7 @@
|
||||
pub mod arpa_inet;
|
||||
pub mod assert;
|
||||
pub mod bits_arpainet;
|
||||
+pub mod bits_eventfd;
|
||||
pub mod bits_iovec;
|
||||
#[path = "bits_locale-t/mod.rs"]
|
||||
pub mod bits_locale_t;
|
||||
@@ -0,0 +1,7 @@
|
||||
--- /dev/null 2026-05-03 20:55:05.750445686 +0100
|
||||
+++ b/src/header/bits_eventfd/mod.rs
|
||||
@@ -0,0 +1,4 @@
|
||||
+//! `bits/eventfd.h` — eventfd counter type.
|
||||
+
|
||||
+use crate::platform::types::uint64_t;
|
||||
+pub type eventfd_t = uint64_t;
|
||||
@@ -0,0 +1,19 @@
|
||||
diff --git a/src/header/sys_eventfd/cbindgen.toml b/src/header/sys_eventfd/cbindgen.toml
|
||||
new file mode 100644
|
||||
index 00000000..c47f467f
|
||||
--- /dev/null
|
||||
+++ b/src/header/sys_eventfd/cbindgen.toml
|
||||
@@ -0,0 +1,13 @@
|
||||
+sys_includes = ["stdint.h"]
|
||||
+after_includes = """
|
||||
+typedef uint64_t eventfd_t;
|
||||
+int eventfd(unsigned int initval, int flags);
|
||||
+"""
|
||||
+include_guard = "_SYS_EVENTFD_H"
|
||||
+language = "C"
|
||||
+style = "Tag"
|
||||
+no_includes = true
|
||||
+cpp_compat = true
|
||||
+
|
||||
+[enum]
|
||||
+prefix_with_name = true
|
||||
@@ -0,0 +1,40 @@
|
||||
--- /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()
|
||||
+}
|
||||
Reference in New Issue
Block a user