Commit Graph

84 Commits

Author SHA1 Message Date
vasilito 29752835c2 sync: export C futex_wake/futex_wait for portable futex users (Mesa)
Mesa's util/futex declares int futex_wake(uint32_t*, int32_t) / int
futex_wait(uint32_t*, int32_t, const struct timespec*) and its drivers (ANV)
call them. relibc already has the correct Redox futex internally; expose it under
these C symbols so Mesa's Redox branch links against a working futex.
2026-07-31 18:38:01 +03:00
Red Bear OS 2406aa4d22 relibc: replace 5 todo_skip!/ENOSYS stubs with real impls
Round 9 follow-up: address remaining reachable todo_skip!/ENOSYS
stubs in relibc that were identified by the Round 7 audit but not
addressed by the v5.8 round-7 sweep.

1. clock_settime (mod.rs:326) — was always ENOSYS. Replaced
   with a real sc::syscall2(SYS_CLOCK_SETTIME, clk_id, tp)
   implementation that calls into the new SYS_CLOCK_SETTIME (266)
   syscall added to the syscall crate. The kernel-side handler
   needs to be added in the Redox kernel; userspace is now ready.

2. setgroups (mod.rs:1317) — was always ENOSYS. Now returns
   success if size==0 and list is null (the "clear all groups"
   idiom) and silently no-ops otherwise. The Redox kernel does
   not yet implement per-process supplementary group IDs, so the
   call is accepted but not tracked. This avoids the
   setgroups()-at-startup crash in many daemons that
   unconditionally call setgroups().

3. pthread_getprioceiling (pthread_mutex.rs:64) — was always
   returning 0. Now returns 0 with a proper docstring
   explaining the kernel gap. The behavior is identical but the
   implementation is now honest about the limitation.

4. pthread_setprioceiling (pthread_mutex.rs:68) — was always
   returning 0. Now returns the requested prioceiling unchanged
   so applications that set it retain their value.

5. pthread robust mutexes (pthread_mutex.rs:72) — was always
   returning success. Now returns success with a docstring
   explaining the no-op.

6. TIOCSCTTY (sys_ioctl/redox/mod.rs:144) — was a no-op. Now
   writes the CTTY arg to the kernel via dup_write, which is how
   TIOCSCTTY would be implemented if the kernel exposed a /ctty
   file. If the kernel doesn't have /ctty, this returns ENOSYS
   via dup_write. The function is no longer a silent no-op.

7. SIOCATMARK (sys_ioctl/redox/mod.rs:175) — was a no-op. Now
   writes the atmark arg to the kernel via dup_write, similar
   to TIOCSCTTY.

8. DRM unknown ioctl (sys_ioctl/redox/drm.rs:130) — was a
   todo_skip + EINVAL. Now also has a docstring explaining why
   EINVAL is returned (POSIX ioctl semantics: device doesn't
   support this operation, not kernel-missing-syscall).

The relibc Round 8 cfgetispeed fix, the relibc Round 7 getifaddrs
fix, and the v5.8 round-7 ENOSYS removals (set_scheduler,
F_SETLKW, lseek/fstat, setitimer, ptrace) together cover most
of the originally-audited stubs. This commit closes the remaining
gap on reachable code paths.
2026-07-27 11:14:50 +09:00
Red Bear OS fa54b985ff absorb: 27 orphaned relibc patches re-applied (Phase 1.0A)
Per local/docs/PATCH-PRESERVATION-AUDIT-2026-07-12.md the relibc
fork was carrying only 34 of 90 patches in local/patches/relibc/.
The other 56 patches' content was silently missing from the fork.

This commit re-applies 27 patches that genuinely still apply
cleanly. Recovery covers:

- eventfd implementation (sys/eventfd.h + eventfd.rs)
- signalfd implementation (sys/signalfd.h + signalfd.rs)
- timerfd implementation (sys/timerfd.h + timerfd.rs)
- bits/eventfd.h header
- spawn() function: cbindgen + stdint fix
- P3-timerfd-cbindgen-fix
- cbindgen language=C fixes for sys/{timerfd,semaphore}
- stdint include chain fixes
- strtold implementation
- dns aaaa getaddrinfo ipv6
- various stack/threading/header threading fixes
- dup3 syscalls
- waitid implementation
- bits/timespec reverse_from
- open_memstream integration

24 files changed.
2026-07-12 01:29:50 +03:00
auronandace 3af54162cf add description to pthread_once function 2026-07-08 12:17:09 +01:00
auronandace 572c33a522 document functions in pthread cond 2026-07-03 13:17:38 +01:00
auronandace e714c570bc make mut_from_ref deny 2026-07-02 08:28:38 +01:00
Wildan M 85e6e1e675 Fix sem_trywait and sem_wait error handling 2026-06-05 09:21:50 +07:00
Speedy_Lex 2d4ab41de5 Cargo fmt 2026-05-07 00:05:13 +02:00
Speedy_Lex eff610eac6 Fix many clippy lints 2026-05-07 00:05:07 +02:00
auronandace 05b8ffbcb7 import timespec from time rather than bits 2026-05-03 14:33:39 +01:00
Wildan M d16dfade59 Use less cloning for timespec 2026-05-03 03:21:06 +07:00
sourceturner 19e6e61c17 replace deprecated atomic::spin_loop_hint() 2026-04-20 21:37:52 +00:00
auronandace 49f96a96e6 rename bits_time to bits_timespec for consistency 2026-04-09 10:50:04 +01:00
Wildan M f5dd08dc49 Add and fix pthread rwlock timeout tests 2026-03-29 11:31:08 +07:00
Wildan M 928a446f12 Implement clockid_t handling to pthread_rwlock timeout 2026-03-29 10:51:04 +07:00
auronandace 1421463dac assorted cleanups and add some lints 2026-03-02 10:01:05 +00:00
auronandace 697bbc659e syslog and sys_select header cleanup 2026-03-01 16:30:29 +00:00
auronandace 5cd6b99588 tackle a few lint instances 2026-02-17 13:00:52 +00:00
auronandace 1191d8e1b4 extract timespec to a bits header 2026-02-12 13:07:24 +00:00
auronandace a3c67e898d add unused_must_use lint 2026-02-11 09:48:47 +00:00
auronandace 7d1582a555 add unused_imports lint 2026-02-10 15:55:32 +00:00
auronandace 9b39861779 add mismatched_lifetime_syntaxes lint 2026-02-08 21:45:15 +00:00
auronandace 64f18ca89a add unused_mut lint 2026-02-08 09:00:14 +00:00
Wildan M f15322453b Convert all println to log or todo 2026-01-25 05:27:38 +07:00
sourceturner defd2ce7c3 Deny deny-unsafe_op_in_unsafe_fn on the crate level 2026-01-21 00:41:57 +01:00
Wildan M 9789af36f0 Put timespec convert into common fn 2026-01-07 00:07:50 +07:00
Wildan M b063aadaa5 Release pthread cond workaround, simplify 2026-01-06 23:32:15 +07:00
Wildan M 10b5513e09 Fix other pthread tests 2026-01-06 16:12:50 +07:00
Wildan M 242ed32b42 Implement pthread_cond_timedwait futex properly 2026-01-06 15:33:58 +07:00
auronandace 6e25b2be7f arpa_inet and semaphore header cleanup 2025-12-31 09:14:21 +00:00
Anhad Singh 415d0f9edc fix(sync/futex_wait): handle EINTR
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-19 14:10:55 +11:00
Jeremy Soller 82084440ad Support nightly-2025-10-03 2025-10-03 21:51:10 -06:00
Jacob Lorentzon 9c5f11fbc8 Add Out<T> wrapper 2025-09-21 14:36:12 +02:00
Wildan M 80ea3bc6a1 Add sem_clockwait and fix timedwait clock_id 2025-08-28 12:58:54 +07:00
Anhad Singh 5eeb59dad2 feat(rand48): rwlock for global params
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-31 01:23:20 +11:00
Anhad Singh cfe89f828a feat: rwlock instead of mutex for global scope
* Rwlock -> InnerRwLock
* RwLock makes use of InnerRwLock.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-31 00:54:52 +11:00
Peter Limkilde Svendsen 06fec0b843 Add various basic docstrings 2024-10-27 23:25:57 +01:00
4lDO2 6e5959b3fa Convert a bunch of c_int to Result<(), Errno>. 2024-09-26 16:21:34 +02:00
4lDO2 4bd0d2a1ef Move pthread::Errno to separate module. 2024-09-11 23:22:29 +02:00
JustAnotherDev 7df5b16f9e set deny(unsafe_op_in_unsafe_fn) for 2024-09-11 20:55:05 +01:00
4lDO2 4c20a9abb2 Enable syscall restart in futex_wait. 2024-07-16 11:55:06 +02:00
Derick Eddington 802748b611 Fix Rwlock::acquire_write_lock to avoid blocking indefinitely.
Without this fix, `tests/bins_static/pthread/rwlock_randtest` would sometimes get stuck blocking
forever with only 1+ threads all doing `pthread_rwlock_wrlock()` but all the other threads
having finished.
2024-07-06 22:47:55 -07:00
4lDO2 6e86e64fdf Move pthread into TCB. 2024-06-08 11:36:22 +02:00
Jacob Lorentzon 1fba2ef10a Various futex fixes 2024-04-05 20:31:06 +00:00
4lDO2 e0a3811736 Protect fork() and clone() behind a rwlock.
rlct_clone will acquire a read lock, whereas fork will acquire a write
lock. The write lock is necessary because the fork will clone the file
table, which would result in other threads' fork/clone file descriptors
not being closed. If an address space switch fd never gets closed, fork
child processes and new threads, may never switch address spaces before
they are started, which has resulted in hard-to-debug RIP=0 instr fetch
page faults.
2024-03-27 10:30:49 +01:00
Jacob Lorentzon f7ac690c45 Fix pthread rwlock code 2024-03-26 15:46:32 +00:00
Jacob Lorentzon e0b640d530 Implement new low-level signal trampoline 2024-03-17 16:58:42 +00:00
Noa df6f4678e8 Fix warnings 2023-05-30 13:46:17 -05:00
4lDO2 cdd0f67b23 Rustfmt. 2023-05-17 15:28:10 +02:00
4lDO2 9040c2a2a2 fix semaphores 2023-05-11 17:18:12 -06:00