diff --git a/local/docs/RELIBC-AGAINST-GLIBC-ASSESSMENT.md b/local/docs/RELIBC-AGAINST-GLIBC-ASSESSMENT.md index 9853120ea..bf73e88da 100644 --- a/local/docs/RELIBC-AGAINST-GLIBC-ASSESSMENT.md +++ b/local/docs/RELIBC-AGAINST-GLIBC-ASSESSMENT.md @@ -145,22 +145,10 @@ glibc uses a sophisticated named semaphore implementation: |------|-------|--------| | errno thread-safety | TLS errno via kernel | `Cell` per platform ✅ | | errno after close | Preserved (close may overwrite) | `let _ = Sys::close(fd)` — ignores errors ✅ | -| EINTR | Handled in syscall wrappers | Not consistently handled ⚠️ | - -### Signal Safety - -| Function | glibc | relibc | -|----------|-------|--------| -| `sem_post` | AS-safe (futex) | AS-safe ✅ | -| `sem_wait` | AS-safe (futex wait, EINTR) | No EINTR handling ⚠️ | -| `eventfd` write/read | AS-safe | Not implemented | - -### Thread Safety - -| Area | glibc | relibc | -|------|-------|--------| -| sem_open refcount | Mutex-protected global list | None — race on same name ⚠️ | -| sem_close/sem_unlink | Mutex-protected | None — concurrent close races ⚠️ | +| EINTR | Handled in syscall wrappers | `Semaphore::wait` returns `Result<(), c_int>`. sem_wait/timedwait loop on EINTR ✅ | +| `sem_wait` | AS-safe (futex wait, EINTR) | EINTR retry loop ✅ | +| sem_open refcount | Mutex-protected global list | `BTreeMap` with `AtomicUsize` ✅ | +| sem_close/sem_unlink | Mutex-protected | `Mutex>>` protects registry ✅ | | signalfd mask | Per-process (kernel) | Per-call sigprocmask ✅ | --- @@ -209,11 +197,11 @@ This is a **kernel change** and should be tracked separately from relibc. | Component | relibc Status | Matches glibc | Critical Gaps | |-----------|--------------|---------------|---------------| -| eventfd | Constants only | Constants ✅ | No function ❌, no EFD_SEMAPHORE support | -| signalfd | 103-line impl | Flags ✅, struct ✅, signalfd4 ✅ | No read path ❌ (signals not delivered via fd) | -| sem_open | 176-line impl | Core works ✅, shm+mmap ✅ | No refcounting ❌, no va_list ❌, no mapping reuse | -| sem_close | Simple munmap | Semantics correct | No refcounting creates race | -| sem_wait/post | Futex-based | Works ✅ | No EINTR handling ⚠️ | +| eventfd | Full implementation | Constants ✅ | eventfd() implemented via /scheme/event/eventfd/ ✅ | +| signalfd | 103-line impl | Flags ✅, struct ✅, signalfd4 ✅ | Read path needs kernel signal delivery ⚠️ | +| sem_open | 226-line impl with refcount | Core works ✅, shm+mmap ✅ | va_list ✅, refcounting ✅, mapping reuse ✅ | +| sem_close | Refcounted munmap | Semantics correct ✅ | Atomic refcount decrement ✅ | +| sem_wait/post | Futex-based, EINTR retry | Works ✅ | EINTR loop ✅, errno returned on other errors | **Total estimated effort: 8-12 weeks for all gaps.** **Critical path: eventfd kernal + signalfd read + sem_open refcounting (Phase S1).**