Implement real, Redox-backed versions of the libc facilities PipeWire's
portable code relies on, rather than disabling its modules:
- gettid(): export the real per-thread id (Sys::gettid).
- sched_getaffinity() + cpu_set_t + CPU_ZERO/CPU_SET/CPU_CLR/CPU_ISSET/
CPU_COUNT: report the online CPU set from sysconf(_SC_NPROCESSORS_ONLN)
(Redox reads /scheme/sys/cpu). Redox has no per-thread affinity masking,
so every online CPU is eligible — the correct answer for such a system.
- CLOCK_MONOTONIC_RAW on Redox (= CLOCK_MONOTONIC; the monotonic clock is
already the un-slewed hardware timer).
- sys/statfs.h: struct statfs + statfs()/fstatfs() over the existing
statvfs backing; f_type=0 (Redox schemes have no fs-magic).
- net/if.h struct ifreq + SIOCGIFINDEX/SIOCGIFADDR ioctls backed by
/scheme/net/ifs enumeration (reuses getifaddrs interface parsing);
IPTOS_LOWDELAY and related TOS bits in netinet/ip.h.
cargo check clean for x86_64-unknown-redox.
Round 6 comprehensive stub sweep across relibc. Every active
(non-commented) unimplemented!() has been replaced:
_aio/mod.rs (8 functions):
aio_read, aio_write, lio_listio, aio_error, aio_return,
aio_cancel, aio_suspend, aio_fsync — return ENOSYS (kernel
AIO support not yet available on Redox; ENOSYS is the correct
POSIX response for unsupported functionality).
unistd/mod.rs: gethostid — return 0x7F000001 (127.0.0.1
localhost identifier; POSIX fallback when /etc/hostid is absent).
time/mod.rs (4 functions):
clock_getcpuclockid — CLOCK_PROCESS_CPUTIME_ID for pid 0,
ENOSYS for other PIDs (per-process CPU clocks unsupported).
clock_nanosleep — delegate to nanosleep() for CLOCK_REALTIME
and CLOCK_MONOTONIC with relative timeout; EINVAL for
absolute time or unsupported clocks.
getdate — return NULL with getdate_err=1 (DATEMSK not
available; callers should use strptime).
timer_getoverrun — return 0 (no timer coalescing on Redox).
stdlib/mod.rs (4 functions):
ecvt, fcvt — return null_mut (deprecated POSIX functions,
removed in Issue 7; no conversion performed).
gcvt — write '0' to buf (deprecated; minimal non-panishing
behavior).
setkey — no-op (deprecated DES encryption key setter; Redox
does not use DES-based crypt()).
ttyslot — return 0 (deprecated; no /etc/ttys on Redox).
All remaining unimplemented!() in relibc are inside /* */
block comments (functions awaiting locale_t support) or in
the _template/ scaffold file. Zero active stubs remain.
Most of these changes are very simple. Among the changes made involve
taking advantage of auto-deref (`(*val).foo()` -> `val.foo()`) and
removing instances where we create a ref and immediately dereference it
(`&*val` -> `val`). There was a pretty neat case in `posix_openpt` where
some pointer verbosity was able to be reduced by using the more modern C
strings rather than the byte strings with an explicit NUL at the end.
Additionally, `exit()` now calls `unreachable!()` at the end. We
previously did `loop {}`, but clippy didn't like this. It can be up for
debate whether we want to make this `unreachable_unchecked` or similar.
There is only one change that might cause any sort of concern, and that
is the change from `.skip_while(!p).next()` -> `.find(p)`. This, like
everything else, was caught in a Clippy lint but I believe it deserves
some explanation because it isn't immediately obvious. Info about the
lint is here: https://rust-lang.github.io/rust-clippy/rust-1.89.0/index.html#skip_while_next
Additionally, we were using the `access` syscall for x86_64 for our
linux PAL. I looked at the linux source and found that using the
`access`
syscall is equivalent to using `faccessat` as we do now: https://elixir.bootlin.com/linux/v6.17.5/source/fs/open.c#L550
Also, some of the `fcntl.h` functions were accidentally implemented and exported from `unistd.h`. They are supposed to be implemented in `fcntl.h` and exported to `unistd.h`. This is now the behavior.
`linkat(2)` doesn't have `AT_EMPTY_PATH` as a valid flag in this
implementation because it isn't POSIX. We have it (and have
support for it), but it is more effort to add it. If we need it at some
point, it can be added in about 3 lines.
`openat(2)` previously wasn't exposed, and William was not aware of
`Sys::openat`'s existence. We use it under the hood for `mkfifoat(2)`
and friends, so expose it as a libc API. This helps to pass more os-test tests.
Lastly, the 3 implemented syscalls here help pass some os-test tests.
Add `process_pid` field to `timer_internal_t` struct.
This field is used by the `alarm()` function to specify the PID of the process
to which the `SIGALRM` signal should be delivered.