diff --git a/local/docs/RELIBC-AGAINST-GLIBC-ASSESSMENT.md b/local/docs/RELIBC-AGAINST-GLIBC-ASSESSMENT.md index 3ee5245ad..9853120ea 100644 --- a/local/docs/RELIBC-AGAINST-GLIBC-ASSESSMENT.md +++ b/local/docs/RELIBC-AGAINST-GLIBC-ASSESSMENT.md @@ -20,18 +20,16 @@ EFD_NONBLOCK = 00004000 // octal 0x800 glibc calls `INLINE_SYSCALL(eventfd2, 2, initval, flags)` — a kernel syscall. The kernel creates an anonymous file descriptor for event notification. Supports `EFD_SEMAPHORE` (semaphore-like counting), `EFD_CLOEXEC`, `EFD_NONBLOCK`. -### relibc current state +### relibc current state (updated 2026-05-05 — S1-S4 implemented) ```rust -// src/header/sys_eventfd/mod.rs — 8 lines -pub const EFD_SEMAPHORE: c_int = 1; -pub const EFD_CLOEXEC: c_int = 0x80000; -pub const EFD_NONBLOCK: c_int = 0x800; -// No eventfd() function — constants only +// src/header/sys_eventfd/mod.rs — 30 lines +// Full eventfd() implementation with EFD_SEMAPHORE/CLOEXEC/NONBLOCK. +// Opens scheme:event/eventfd/{initval}/{sem} via Sys::open. ``` -**Constants match** ✅ -**No implementation** ❌ — libwayland provides inline `eventfd()` via `/scheme/event` +**Implementation shipped** ✅ +**Kernel support**: `P0-eventfd-kernel.patch` extends event scheme with eventfd path parsing ✅ ### Gaps @@ -129,9 +127,9 @@ glibc uses a sophisticated named semaphore implementation: | Gap | Severity | Detail | |-----|----------|--------| -| **No name canonicalization** | Medium | Names go directly to `shm_open` without prefix/suffix. glibc uses `/dev/shm/sem.NAME` | -| **No existing mapping reuse** | High | Every `sem_open` creates a NEW mmap even if already open. Wasteful and races with `sem_close` on shared references | -| **No refcounting** | High | `sem_close` unconditionally munmaps. If two threads open the same semaphore, one close breaks the other | +| **No name canonicalization** | ~~Medium~~ ✅ FIXED | Names now prefixed with `sem.` before `shm_open`. glibc uses `/dev/shm/sem.NAME` equivalent. | +| **No existing mapping reuse** | ~~High~~ ✅ FIXED | Global `BTreeMap` with `AtomicUsize` refcount. `sem_open` reuses existing mappings, increments refcount. | +| **No refcounting** | ~~High~~ ✅ FIXED | `sem_close` decrements `AtomicUsize`, munmaps only when zero. | | **No cancellation safety** | Low | No `pthread_setcancelstate` around file ops | | **va_list not parsed** | Medium | `sem_open` hardcodes `value=0` when O_CREAT, ignoring mode and initial value from varargs | | **No `__sem_check_add_mapping` equivalent** | High | Opens named sem every time instead of reusing existing mapping |