Commit Graph

170 Commits

Author SHA1 Message Date
vasilito 5995d3c4fc Add Linux/GNU C-runtime primitives for PipeWire (affinity, gettid, statfs, iface ioctls)
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.
2026-08-01 12:46:35 +03:00
Red Bear OS 1442195b84 relibc: replace all active unimplemented!() stubs with real implementations
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.
2026-07-26 23:17:32 +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 d5afd3fe81 add documentation for functions relating to controlling terminal 2026-07-09 13:23:16 +01:00
Jeremy Soller 52bb3bbfe3 Merge branch 'ptr-offset-by-literal-lint' into 'master'
add ptr_offset_by_literal clippy lint and set to deny

See merge request redox-os/relibc!1527
2026-07-06 06:04:43 -06:00
auronandace bf6dc24407 add ptr_offset_by_literal clippy lint and set to deny 2026-07-06 12:40:43 +01:00
auronandace 3683a14ab4 document termios functions 2026-07-06 11:26:04 +01:00
auronandace fe1c4e0135 add descriptions to sleep and nanosleep 2026-07-05 10:50:57 +01:00
auronandace e714c570bc make mut_from_ref deny 2026-07-02 08:28:38 +01:00
Wildan M fdcc92cd3b Add arrayvec and split PATH env logic 2026-06-20 06:38:50 +07:00
auronandace bceef31d06 add descriptions to fcntl.h functions 2026-06-19 13:46:39 +01:00
auronandace 60e301360c add descriptions to sys_uio functions and associated unistd functions 2026-06-14 14:18:25 +01:00
Wildan M 8cfe85226f Do not call getrlimit on getdtablesize in Redox 2026-06-10 05:45:21 +07:00
auronandace 94b2f29beb tackle various clippy lints 2026-06-05 14:36:06 +01:00
Jeremy Soller ffa097ccb3 Support nightly 2026-05-24 2026-05-25 17:03:17 -06:00
auronandace b57f14f14e remove sys_types from unistd header 2026-05-18 20:35:37 +01:00
Wildan M e9c3960c65 Implement nice and write test 2026-05-09 01:23:37 +07:00
Wildan M 90cb143523 Unify alarm implementation 2026-05-05 09:35:50 +07:00
auronandace 05b8ffbcb7 import timespec from time rather than bits 2026-05-03 14:33:39 +01:00
Connor-GH 7c8259dfd6 fix some lints caught by Clippy
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
2026-04-30 19:02:35 -05:00
auronandace 6a490be2c6 split out sigset_t from signal header 2026-04-29 12:29:43 +01:00
Connor-GH 960c4f3b12 move *at functions from fcntl.h to unistd.h 2026-04-21 10:02:13 -05:00
Jeremy Soller 30cc2de953 Merge branch 'faccessat-fchownat' into 'master'
add faccessat(2) and fchownat(2)

See merge request redox-os/relibc!1213
2026-04-20 16:33:30 -06:00
Connor-GH 24e250c339 add faccessat(2) and fchownat(2)
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.
2026-04-20 17:20:18 -05:00
sourceturner 4ffd337b9b add #[allow(deprecated)] annotations
allow using deprecated functions and data structures
in deprecated functions
2026-04-20 21:37:52 +00:00
sourceturner 885118ccac add missing #[deprecated] annotations
add #[deprecated] annotation to functions that are marked
as 'legacy' or 'obsolecent' (according to their comments)
2026-04-20 21:37:52 +00:00
Jeremy Soller cad9a0dfc8 Merge branch 'unlinkat-symlinkat-linkat' into 'master'
add unlinkat(2), symlinkat(2), linkat(2) and expose openat(2)

See merge request redox-os/relibc!1212
2026-04-20 11:31:10 -06:00
Connor-GH 0ff79b80a2 add unlinkat(2), symlinkat(2), linkat(2) and expose openat(2)
`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.
2026-04-20 10:58:25 -05:00
Wildan M 63f1790b41 Define syscall function for linux 2026-04-20 09:09:42 +07:00
Peter Limkilde Svendsen fbccaff46c Move setgroups() to grp.h 2026-04-13 22:56:56 +02:00
auronandace 49f96a96e6 rename bits_time to bits_timespec for consistency 2026-04-09 10:50:04 +01:00
Zero aca4df91cf feat(time): Add process_pid to timer_internal_t
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.
2026-03-31 00:19:35 +02:00
auronandace 904604020b eliminate more range loops 2026-03-16 08:26:05 +00:00
auronandace 8a2bfa2ed5 tackle some lints 2026-03-10 18:20:06 +00:00
auronandace 798e7e23ea unistd header cleanup 2026-02-27 16:25:22 +00:00
auronandace 4073242e8b signal header cleanup 2026-02-24 16:35:06 +00:00
Jeremy Soller 8cb5b0c71c Merge branch 'fix-with_argv' into 'master'
fix: adjust memory allocation for argv to include null terminator

Closes #261

See merge request redox-os/relibc!989
2026-02-24 08:13:52 -07:00
auronandace 0027ba8068 revert a cast 2026-02-15 21:57:16 +00:00
auronandace 20bdf30526 remove allow warnings and add some lints 2026-02-15 21:38:08 +00:00
auronandace 2c53eb1f6d add improper_ctypes_definitions lint 2026-02-14 16:48:39 +00:00
auronandace 955179ab6f remove code as per feedback 2026-02-13 13:22:05 +00:00
auronandace ff392a029a remove pthread_atfork from unistd and tackle some lints 2026-02-13 12:14:04 +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
Akshit Gaur 75a3d80fdb Implement pause 2026-02-10 19:17:11 +05:30
Marsman 6a7fb703c9 fix: adjust memory allocation for argv to include null terminator 2026-02-10 11:26:14 +00:00
auronandace 64f18ca89a add unused_mut lint 2026-02-08 09:00:14 +00:00
Ron Williams 2c3201eaeb move timeval to sys_select 2026-01-30 15:53:15 +00:00
Connor-GH e5997cf828 unistd/mod.rs: implement posix_close
This is a valid implementation according to POSIX,
as long as we do not support `POSIX_CLOSE_RESTART`.
2026-01-23 15:52:54 -06:00
sourceturner defd2ce7c3 Deny deny-unsafe_op_in_unsafe_fn on the crate level 2026-01-21 00:41:57 +01:00