Commit Graph

130 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
vasilito 1a6d3221b2 relibc: implement error()/error_at_line() as real symbols (not header inlines)
The header-only static-inline error()/error_at_line() collided with gnulib's own
lib/error.c ('redefinition of error', building m4): autotools link-detects a
system error(), skips its replacement, then the inline in <error.h> clashes with
gnulib's definition. Implement them properly in relibc (src/header/error) with
the glibc globals (error_message_count, error_one_per_line, error_print_progname)
and make <error.h> a pure extern declaration. Fixes m4/gnulib and keeps
mesa/libelf (the original <error.h> consumers) working via the real symbol.
2026-08-01 04:30:41 +03:00
vasilito daeca3892e Add byteswap/error/libintl/ar/search headers + tsearch family, mempcpy, rawmemchr
Portable ELF tooling (elfutils/libelf, needed by Mesa's radeonsi driver) relies
on several standard headers and functions Red Bear's relibc lacked:

- <byteswap.h>: bswap_16/32/64 (compiler builtins).
- <error.h>: GNU error()/error_at_line() (inline).
- <libintl.h>: gettext family as the identity map (catalog-less system; matches
  glibc's no-catalog fallback behaviour).
- <ar.h>: Unix archive struct/magic (header-only).
- <search.h> + src/header/search: POSIX tsearch/tfind/tdelete/twalk + GNU
  tdestroy, implemented as an unbalanced BST (conforming; POSIX mandates no
  balancing).
- string: mempcpy (memcpy returning end) and rawmemchr (unbounded memchr).

All complete implementations, no stubs. Additive (no ABI break), so existing
sysroot binaries are unaffected.
2026-07-31 15:03:51 +03:00
vasilito 991d05ce2f ld_so: implement dl_iterate_phdr (link.h)
Mesa's Intel Anvil Vulkan driver requires dl_iterate_phdr, which relibc lacked
(meson cc.has_function fails). Implement it against the dynamic linker's
authoritative object list: store each object's program headers on the DSO
(new DSO.phdrs, populated in both from_raw and new), add Linker::iter_dsos, and
add a src/header/link module exporting dl_iterate_phdr that walks the loaded
objects and reports each one's base/name/phdr-table to the callback (stopping
early on non-zero return, per spec). Static binaries (no linker) report zero
objects. Hand-written include/link.h declares struct dl_phdr_info with a
correctly-typed const Elf64_Phdr* dlpi_phdr.
2026-07-31 09:55:43 +03:00
Red Bear OS e8cee8b85c header: add utmpx.h, linux/kd.h, linux/vt.h, X11/Xauth.h 2026-07-26 06:52:39 +09:00
Red Bear OS 029064baeb fix(timerfd): actually compile the sys_timerfd module (export timerfd_* symbols)
The sys_timerfd module (timerfd_create/settime/gettime) existed on disk but was
never declared in header/mod.rs, so its code was NOT compiled and the symbols
were absent from libc — timerfd was entirely non-functional. The generated
header still declared the functions, so C programs compiled but failed to LINK
with 'undefined reference to timerfd_create/timerfd_settime' (e.g. libwayland's
event-loop.c, blocking the whole Wayland stack). Declare the module so the
implementation is built and the symbols exported.
2026-07-18 02:51:31 +09:00
Red Bear OS 1a121303a3 relibc: implement eventfd() using event scheme
Creates sys_eventfd header module providing eventfd(), eventfd_read(),
and eventfd_write(). Uses the kernel event scheme (/scheme/event) on
Redox, returning ENOSYS on Linux. Required for packages like Python
that link against eventfd.
2026-07-11 18:35:03 +03:00
auronandace d7859174b7 split out pthread types for threads header 2026-07-06 16:41:09 +01:00
auronandace 185b49b73e split out pthread_attr_t 2026-07-04 17:16:08 +01:00
auronandace 93d6fc091f refactor sys_types_internal to reduce namespace pollution 2026-07-03 14:23:00 +01:00
auronandace d1633f8dba move pthread_t to bits header and move some after_includes to pthread header 2026-06-27 14:41:37 +01:00
auronandace 3cc24ddaee fix TTS_DTOR_ITERATIONS with bits file 2026-06-26 12:42:35 +01:00
auronandace 3be84f4b26 move stddef header from C to cbindgen 2026-06-24 11:52:15 +01:00
auronandace df380e5dd0 split out non-POSIX preadv and pwritev to a bits header 2026-06-23 10:48:23 +01:00
auronandace 7315ad5155 split out uint32_t for socklen_t for sys_socket header 2026-06-17 09:18:37 +01:00
Mathew John Roberts a5d07b6a84 Merge branch 'split-intptrt' into 'master'
split out intptr_t from stdint.h for sys/shm.h

Closes #289

See merge request redox-os/relibc!1470
2026-06-17 06:21:46 +01:00
Mathew John Roberts da55b3be0e Merge branch 'spawn' into 'master'
Add support for `posix_spawn` and `posix_spawnp` (Redox OS)

Closes #192

See merge request redox-os/relibc!1333
2026-06-17 06:18:59 +01:00
auronandace f2310befc3 split out intptr_t from stdint.h for sys/shm.h 2026-06-16 20:00:20 +01:00
auronandace 47b5f56d0b move stdarg header from C to cbindgen and create valist bits header 2026-06-16 11:35:40 +01:00
auronandace f5c0c1a9c9 split out ucred to a bits header 2026-06-16 08:04:26 +01:00
R Aadarsh df78820f01 Add posix_spawn_file_actions_t and posix_spawnattr_t and tests 2026-06-15 17:08:11 +05:30
Jeremy Soller a20662cc91 Move O_ constants to bits/open-flags.h for use by fcntl.h and stdlib.h 2026-06-10 08:41:29 -06:00
auronandace 3603161a6f split out stdio constants for fcntl header 2026-06-04 14:09:38 +01:00
auronandace d28a131ec5 split out wchar_t from stddef header 2026-06-04 11:17:36 +01:00
auronandace 4f5d535ebc split out NULL from stddef header 2026-06-02 16:56:12 +01:00
auronandace 3ddd4f56df split out winsize from sys_ioctl header 2026-05-25 16:57:12 +01:00
Wildan M bc6ea5ba99 Implement key_t, sys/ipc and sys/shm 2026-05-20 18:51:53 +07:00
auronandace a7b7e8dd27 move sysexits header from C to Rust 2026-05-19 15:20:49 +01:00
auronandace 430aa6f584 split out useconds_t from sys_types header 2026-05-18 08:38:10 +01:00
auronandace 4dd3c2ea70 split out reclen_t from sys_types header 2026-05-16 16:55:53 +01:00
auronandace dbe84f1503 split out nlink_t from sys_types header 2026-05-16 07:59:43 +01:00
auronandace ff923f2b9a split out dev_t from sys_types header 2026-05-15 20:26:24 +01:00
auronandace eca687759a split out blkcnt_t and blksize_t from sys_types header 2026-05-15 13:49:10 +01:00
auronandace 08b6bba666 split out timer_t from sys_types 2026-05-15 07:46:49 +01:00
auronandace dfd2dd7306 split out ino_t from sys_types header 2026-05-13 15:33:05 +01:00
auronandace fa6ef5d495 remove sys_types from sys_statvfs header 2026-05-12 16:36:25 +01:00
auronandace 7692c2776c split out mode_t type from sys_types header 2026-05-12 14:58:50 +01:00
auronandace 4f353e886e split out clockid_t type from sys_types 2026-05-12 08:30:02 +01:00
auronandace 74ca9e661a split out id_t from sys_types 2026-05-11 15:20:20 +01:00
auronandace bd505d3451 split out clock_t from sys_types 2026-05-11 14:03:16 +01:00
Connor-GH 774a9a658d implement threads.h
Most of the functions are wrappers around the pthread.h functions, but
we are not allowed to include pthread.h.
2026-05-10 19:44:34 -05:00
auronandace a365dbeda4 split out uid_t from sys_types 2026-05-10 16:28:22 +01:00
auronandace 71ab39f9e6 split out gid_t from sys_types 2026-05-09 18:30:35 +01:00
auronandace 5e922ac626 split out pid_t from sys_types 2026-05-09 14:33:10 +01:00
auronandace 8e1881c3cc split out off_t from sys_types_internal 2026-05-09 07:11:29 +01:00
auronandace dc28f2faef split out sizt_t from stddef header 2026-05-08 14:59:27 +01:00
auronandace ed488b71dc split out ssize_t from sys_types 2026-05-08 09:49:06 +01:00
auronandace 2dd36566de split out timeval to reduce namespace pollution 2026-05-04 15:05:30 +01:00
auronandace 1cd9d8769d split out suseconds_t for namespace pollution reduction preparation 2026-05-04 13:38:33 +01:00
auronandace 8d2bcee829 split out time_t to prepare for reducing namespace pollution 2026-05-03 08:30:35 +01:00