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:
@@ -3,6 +3,35 @@
|
|||||||
This directory contains ALL custom work on top of mainline Redox. When mainline Redox
|
This directory contains ALL custom work on top of mainline Redox. When mainline Redox
|
||||||
updates (`git pull` on the build system repo), this directory is untouched.
|
updates (`git pull` on the build system repo), this directory is untouched.
|
||||||
|
|
||||||
|
## STUB AND WORKAROUND POLICY — ZERO TOLERANCE
|
||||||
|
|
||||||
|
**Red Bear OS has zero tolerance for stubs, workarounds, `#ifdef`-guarded no-ops, fake headers,
|
||||||
|
shell-script patches, sed/awk hacks, `LD_PRELOAD` tricks, rename-to-.disabled wrappers, or any
|
||||||
|
other "make it compile" shortcut.**
|
||||||
|
|
||||||
|
If something doesn't build because of a missing implementation, the ONLY acceptable response is
|
||||||
|
to implement the missing functionality in the correct component:
|
||||||
|
|
||||||
|
| Problem | Correct Fix |
|
||||||
|
|---------|-------------|
|
||||||
|
| `eventfd()` not found | Implement `eventfd()` in relibc, generate `sys/eventfd.h` via cbindgen |
|
||||||
|
| `signalfd()` not found | Implement `signalfd()` in relibc, generate `sys/signalfd.h` via cbindgen |
|
||||||
|
| Missing POSIX type | Add it to the relibc header it belongs to, with proper `stdint.h` include chain |
|
||||||
|
| Compiler can't find header | Fix the include path in the recipe's sysroot/cookbook, NOT by adding `-I` hacks |
|
||||||
|
| CMake can't find dependency | Implement the dependency or fix pkg-config, NOT with `-DFEATURE_x=OFF` |
|
||||||
|
| Qt needs `open_memstream` | Implement it in relibc — never add a static stub in Qt or libwayland source |
|
||||||
|
|
||||||
|
**Any stub found in the tree is a bug to be fixed, not a precedent to follow.**
|
||||||
|
|
||||||
|
When relibc gains a function or type that obsoletes a previously-needed local stub, the stub
|
||||||
|
MUST be removed and the dependency switched to relibc's implementation. Coexistence of stubs
|
||||||
|
with real implementations causes header conflicts, linker errors, and silent ABI mismatches.
|
||||||
|
|
||||||
|
This applies to: relibc functions, kernel syscalls, C headers, CMake modules, pkg-config `.pc`
|
||||||
|
files, Wayland protocol stubs, D-Bus service stubs, and any other layer of the stack.
|
||||||
|
|
||||||
|
**No exceptions. No "temporary." No "until we fix it properly."**
|
||||||
|
|
||||||
## DESIGN PRINCIPLE
|
## DESIGN PRINCIPLE
|
||||||
|
|
||||||
Red Bear OS is a **full fork** based on frozen Redox OS snapshots:
|
Red Bear OS is a **full fork** based on frozen Redox OS snapshots:
|
||||||
|
|||||||
@@ -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()
|
||||||
|
+}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../../local/patches/relibc/P3-bits-eventfd-mod.patch
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../../local/patches/relibc/P3-bits-eventfd.patch
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../../local/patches/relibc/P3-eventfd-cbindgen.patch
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../../local/patches/relibc/P3-eventfd-impl.patch
|
||||||
@@ -2,10 +2,15 @@
|
|||||||
git = "https://gitlab.redox-os.org/redox-os/relibc.git"
|
git = "https://gitlab.redox-os.org/redox-os/relibc.git"
|
||||||
rev = "861bbb0"
|
rev = "861bbb0"
|
||||||
patches = [
|
patches = [
|
||||||
# Module declarations (pub mod sys_eventfd/signalfd/timerfd in header/mod.rs)
|
|
||||||
"P3-eventfd-mod.patch",
|
"P3-eventfd-mod.patch",
|
||||||
# sys_eventfd module (constants only — libwayland has its own eventfd())
|
# Add pub mod bits_eventfd to header/mod.rs
|
||||||
"P3-sys-eventfd-create.patch",
|
"P3-bits-eventfd-mod.patch",
|
||||||
|
# bits_eventfd module (eventfd_t type)
|
||||||
|
"P3-bits-eventfd.patch",
|
||||||
|
# sys_eventfd module — FULL eventfd() implementation (opens /scheme/event/eventfd)
|
||||||
|
"P3-eventfd-impl.patch",
|
||||||
|
# cbindgen.toml for sys/eventfd.h C header generation
|
||||||
|
"P3-eventfd-cbindgen.patch",
|
||||||
# sys_signalfd module (cbindgen.toml + mod.rs with cbindgen exports)
|
# sys_signalfd module (cbindgen.toml + mod.rs with cbindgen exports)
|
||||||
"P3-signalfd-header.patch",
|
"P3-signalfd-header.patch",
|
||||||
# signalfd implementation (signal/signalfd.rs + signal/mod.rs wiring)
|
# signalfd implementation (signal/signalfd.rs + signal/mod.rs wiring)
|
||||||
|
|||||||
Reference in New Issue
Block a user