5005 Commits

Author SHA1 Message Date
Red Bear OS aa219c6509 rb: add cbindgen config for bits_eventfd (eventfd_t type)
bits/eventfd.h defines the eventfd_t 64-bit counter type used by
sys/eventfd.h. Without this config, cbindgen skipped the directory
and the type wasn't generated.
2026-07-12 19:35:50 +03:00
Red Bear OS e47a604197 rb: add cbindgen config for sys_timerfd
sys_timerfd was fully implemented in Rust (timerfd_create,
timerfd_settime, timerfd_gettime, itimerspec support) but lacked
the cbindgen.toml needed to generate the <sys/timerfd.h> C header.
Qt6's QSocketNotifier and many other C programs depend on this header.
Without it, cbindgen skips the directory entirely.

This adds the cbindgen config + trailer with all function prototypes,
matching the pattern used by sys_signalfd.
2026-07-12 19:19:35 +03:00
vasilito d8ced461fa Add __fseterr and __freadahead to stdio ext (P3-stdio-fseterr patch) 2026-07-12 16:05:57 +03:00
Red Bear OS bb20fe9c76 Remove FEXEC_STEP diagnostic from proc.rs 2026-07-12 15:17:50 +03:00
Red Bear OS 5049c25a79 diag: print ns_fd in pipe2 on failure 2026-07-12 12:15:24 +03:00
Red Bear OS 5ee906eee3 fix: add MAP_SHARED to map_mut_anywhere flags
validate_kfmap_flags in kernel proc scheme requires exactly one of
MAP_SHARED or MAP_PRIVATE. Without it, shared == private == false,
and the check fails with EINVAL. This was the root cause of the
fexec_impl crash at step 62 (first PT_LOAD segment mapping).
2026-07-12 11:31:34 +03:00
Red Bear OS f643e1b58b fix: register external fds with userspace FILETABLE
redox-scheme Socket and RawEventQueue create fds via libredox raw
syscalls (SYS_DUP, openat) that bypass the redox-rt userspace
FILETABLE. When FdGuard::dup later reserves a POSIX fd slot via
FILETABLE.add_posix, it can reserve a position occupied by the
untracked socket fd. SYS_DUP_INTO then closes the socket and
replaces it, corrupting the procmgr's fd table.

Add register_external_fd() to redox-rt::sys that marks an
existing kernel fd as occupied in the userspace FILETABLE.
Call it from procmgr::run() for the socket fd and event queue
fd.
2026-07-12 11:17:57 +03:00
Red Bear OS 58dfd26452 diag: remove 31 FK: debug prints from redox-rt fork implementation
Removes all syscall::write(1, b'FK:...') debug trace lines from
fork_impl/fork_inner in redox-rt/src/proc.rs that were polluting
serial output during every fork() call.
2026-07-12 05:32:20 +03:00
Red Bear OS 0ce58a8c0d fix: add stdint.h to signal.h sys_includes
Generated signal.h uses uint32_t, int32_t, uint64_t, uintptr_t etc.
without including stdint.h, causing compilation failures in C packages
that include signal.h (diffutils, etc).
2026-07-12 03:19:44 +03:00
Red Bear OS f222c3464b fix: resolve 6 compilation errors from patch absorption
- fcntl/mod.rs: Remove misplaced F_DUPFD_CLOEXEC fallback code from
  inside the flock struct definition (bad patch merge artifact)
- fcntl/mod.rs: Remove unused 'close' import
- signal/mod.rs: Remove duplicate 'mod signalfd' declaration
- pthread/mod.rs: Add Pal+Sys imports for sched_yield() in pthread_yield
- time/mod.rs: Remove duplicate From<&TimeSpec> impl (already in
  bits_timespec/mod.rs)
- pthread/mod.rs: Add FINISHED flag to PthreadFlags and set it on
  thread exit (referenced by pthread_kill in signal/mod.rs)
2026-07-12 02:12:54 +03: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
Red Bear OS d60ba8730d Add granular FK: progress markers throughout fork_inner to pinpoint EOPNOTSUPP 2026-07-11 21:58:08 +03:00
Red Bear OS 64527aae68 debug: add FK:ENTER and FK:INNER markers to trace fork EOPNOTSUPP 2026-07-11 20:14:02 +03:00
Red Bear OS 11195dac6d relibc: fix unsafe block for from_bytes_with_nul_unchecked in eventfd 2026-07-11 18:46:16 +03:00
Red Bear OS 4b9f90c2b9 relibc: fix eventfd EventFlags constants (EVENT_READ/WRITE not FLAG_) 2026-07-11 18:43:54 +03: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
Red Bear OS 353c43ce13 relibc: add missing IPV6_{RECVPKTINFO,PKTINFO,RECVTCLASS,TCLASS} socket option constants 2026-07-11 18:02:43 +03:00
Red Bear OS 2576fe453e redox-rt: add fork debug tracing to identify EOPNOTSUPP source 2026-07-11 17:40:31 +03:00
Red Bear OS af769016b4 relibc: add LDBL_DIG, DECIMAL_DIG, LDBL_MIN/MAX_10_EXP to float.h cbindgen
C11 <float.h> requires these macros. Without them, gnulib-based
packages (diffutils, coreutils, etc.) fail with 'LDBL_DIG undeclared'.
2026-07-11 13:57:03 +03:00
Red Bear OS 48b3490ad6 relibc: fix unsafe block for mutable static access (Rust 2024) 2026-07-11 13:48:02 +03:00
Red Bear OS 03e71cd749 relibc: implement getprogname() in stdlib
BSD extension used by diffutils, coreutils, and other GNU software.
Returns the basename of program_invocation_name.
2026-07-11 13:42:06 +03:00
Red Bear OS 45ecf48235 relibc: regenerate Cargo.lock with [patch.crates-io] properly applied 2026-07-11 12:01:00 +03:00
Red Bear OS 0be7dec907 relibc: start from latest upstream master (cbc14a31) + RB path deps
Upstream precedence: upstream provides eventfd, signalfd, timerfd, POSIX
stubs, cbindgen fixes, Rust 2024 edition, fenv, scheduler, and many more
that RB had previously patched. All RB patches for already-upstreamed
functionality have been dropped per the golden rule.

RB additions on top of upstream:
- Version suffix +rb0.3.1
- Path deps for redox_syscall and libredox (local fork policy)
- [patch.crates-io] for local fork resolution
- Author attribution
2026-07-11 11:45:31 +03:00
Jeremy Soller cbc14a3176 Merge branch 'redoxioctl-lints' into 'master'
tackle clippy lints in redox-ioctl

See merge request redox-os/relibc!1543
2026-07-10 17:33:47 -06:00
auronandace 6f75b90451 remove expect and wrapping 2026-07-10 19:06:40 +01:00
auronandace 433eb0dce7 tackle clippy lints in redox-ioctl 2026-07-10 07:22:32 +01:00
Jeremy Soller d58990030e Fix inverted pointer alignment checks 2026-07-09 13:28:42 -06:00
Jeremy Soller cfc63f23ec Merge branch 'ct-related-docs' into 'master'
add documentation for functions relating to controlling terminal

See merge request redox-os/relibc!1541
2026-07-09 08:48:57 -06:00
Jeremy Soller 36944c4049 Merge branch 'redoxrt-lint-improvements' into 'master'
tackle some clippy lints in redox-rt

See merge request redox-os/relibc!1540
2026-07-09 08:48:46 -06:00
Jeremy Soller dfa26984cf Merge branch 'clippy-check' into 'master'
CI: Add clippy check

See merge request redox-os/relibc!1539
2026-07-09 08:48:24 -06:00
auronandace d5afd3fe81 add documentation for functions relating to controlling terminal 2026-07-09 13:23:16 +01:00
auronandace 8f3ac79670 tackle some clippy lints in redox-rt 2026-07-09 08:35:50 +01:00
Jeremy Soller 88483b96fe Merge branch 'fix-pthread-null' into 'master'
correct definition for PTHREAD_NULL

See merge request redox-os/relibc!1538
2026-07-08 09:21:25 -06:00
auronandace 60d98aebf2 correct definition for PTHREAD_NULL 2026-07-08 14:38:51 +01:00
Jeremy Soller e16f2a4e0d Merge branch 'manual-let-else' into 'master'
apply manual_let_else clippy lint

See merge request redox-os/relibc!1536
2026-07-08 06:01:40 -06:00
Jeremy Soller 649d5f87c0 Merge branch 'pthread-once-doc' into 'master'
add description to pthread_once function

See merge request redox-os/relibc!1537
2026-07-08 06:01:25 -06:00
auronandace 3af54162cf add description to pthread_once function 2026-07-08 12:17:09 +01:00
auronandace 7840bfcdd1 apply manual_let_else clippy lint 2026-07-08 10:07:15 +01:00
Jeremy Soller 2594d92dd3 Merge branch 'master' into 'master'
sys_ioctl: add Redox implementations for `tcdrain`, `tcflow`, and `tcsendbreak`

See merge request redox-os/relibc!1535
2026-07-07 16:55:25 -06:00
Connor-GH d465f3d34d sys_ioctl: add Redox implementations for tcdrain, tcflow, and tcsendbreak
Strangely enough, the `dup_write` was already done for `tcflush`, but wasn't implemented in ptyd.
2026-07-07 16:51:18 -05:00
Wildan M d6bb922a76 CI: Add clippy check 2026-07-08 04:21:33 +07:00
Jeremy Soller 3a44b63a9a Merge branch 'termios-oflag-doc' into 'master'
share some more termios constants

See merge request redox-os/relibc!1534
2026-07-07 06:47:11 -06:00
Jeremy Soller 939180a769 Merge branch 'log-ldso' into 'master'
Enable logging for ld_so

See merge request redox-os/relibc!1533
2026-07-07 06:46:04 -06:00
Jeremy Soller ba0ac174df Merge branch 'no-tcb' into 'master'
Handle panic without TCB

See merge request redox-os/relibc!1530
2026-07-07 06:45:42 -06:00
auronandace bcbd9bb69c share some more termios constants 2026-07-07 08:57:07 +01:00
Jeremy Soller 82d444324e Explicitly include features.h in sys/types.h 2026-07-06 17:37:20 -06:00
Jeremy Soller 85625f86dd Define _GNU_SOURCE or _BSD_SOURCE the way musl does 2026-07-06 17:19:03 -06:00
Jeremy Soller 77f87530c1 Merge branch 'threads-bits' into 'master'
split out pthread types for threads header

See merge request redox-os/relibc!1532
2026-07-06 12:19:20 -06:00
Jeremy Soller 0948df3432 Merge branch 'race-tcb' into 'master'
Fix exit_current_thread racing with pthread_join

See merge request redox-os/relibc!1531
2026-07-06 12:18:58 -06:00
Jeremy Soller c699b37cc0 Merge branch 'ftok-doc' into 'master'
add descriptions to the ftok function and ipc_perm struct members

See merge request redox-os/relibc!1529
2026-07-06 12:18:34 -06:00
Jeremy Soller 4910ce92b7 Merge branch 'termios-iflag-docs' into 'master'
add descriptions to termios iflags

See merge request redox-os/relibc!1528
2026-07-06 12:16:41 -06:00
auronandace d7859174b7 split out pthread types for threads header 2026-07-06 16:41:09 +01:00
Wildan M 30f50abbfa Enable logging for ld_so 2026-07-06 22:00:53 +07:00
auronandace 5acc81cc97 add descriptions to the ftok function and ipc_perm struct members 2026-07-06 14:46:07 +01:00
auronandace ff37890ea2 add descriptions to termios iflags 2026-07-06 14:06:53 +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
Jeremy Soller c8d99d6481 Merge branch 'termios-func-doc' into 'master'
document termios functions

See merge request redox-os/relibc!1526
2026-07-06 05:45:24 -06:00
Jeremy Soller 103b040f86 Merge branch 'rename-def-source' into 'master'
Add _GNU_SOURCE to get bits/uio.h

See merge request redox-os/relibc!1524
2026-07-06 05:44:33 -06:00
Jeremy Soller 66dcae87bf Merge branch 'open-log' into 'master'
Parse flags when logging openat

See merge request redox-os/relibc!1523
2026-07-06 05:44:05 -06:00
auronandace bf6dc24407 add ptr_offset_by_literal clippy lint and set to deny 2026-07-06 12:40:43 +01:00
Jeremy Soller b8948a1d03 Merge branch 'cast-const' into 'master'
Set ByteLiteral::cast_cchar as const fn

See merge request redox-os/relibc!1522
2026-07-06 05:40:32 -06:00
auronandace 3683a14ab4 document termios functions 2026-07-06 11:26:04 +01:00
Wildan M 9a03f5f9c4 Remove ExpectTlsFree 2026-07-06 16:31:47 +07:00
Wildan M fbb56200ab Handle panic without TCB 2026-07-06 16:08:59 +07:00
Wildan M be3e38ed65 Fix exit_current_thread racing with pthread_join 2026-07-06 11:01:41 +07:00
Wildan M 4a327141d5 Add _GNU_SOURCE to get bits/uio.h 2026-07-06 07:13:43 +07:00
Wildan M 812982556a Parse flags when logging openat 2026-07-06 05:35:13 +07:00
Wildan M 7b9768ae23 Set ByteLiteral::cast_cchar as const fn 2026-07-06 00:17:55 +07:00
Jeremy Soller 9930a90de0 Merge branch 'all-path' into 'master'
Adapt with new redox-path

See merge request redox-os/relibc!1504
2026-07-05 10:53:21 -06:00
Wildan M 2e8ee25139 Add open trace logging 2026-07-05 19:28:23 +07:00
Wildan M c0cdc017d3 Adapt with new redox-path 2026-07-05 19:27:57 +07:00
Jeremy Soller 97e59311db Merge branch 'unistd-sleep' into 'master'
add descriptions to sleep and nanosleep

See merge request redox-os/relibc!1521
2026-07-05 05:46:50 -06:00
Jeremy Soller 8e9864bcd9 Merge branch 'nosignal-fix' into 'master'
Fix curl EOPNOSUPP due to MSG_NOSIGNAL

See merge request redox-os/relibc!1520
2026-07-05 05:46:07 -06:00
Jeremy Soller 2374154231 Merge branch 'fix-override-at' into 'master'
fix: Always increment active_count in override_at to ensure synchronization

See merge request redox-os/relibc!1519
2026-07-05 05:43:40 -06:00
Jeremy Soller 649a194bf8 Merge branch 'runner-dyn' into 'master'
Set the test runner dynamically linked

See merge request redox-os/relibc!1518
2026-07-05 05:42:57 -06:00
auronandace fe1c4e0135 add descriptions to sleep and nanosleep 2026-07-05 10:50:57 +01:00
Wildan M 7f4c3803bc Fix curl EOPNOSUPP due to MSG_NOSIGNAL 2026-07-05 15:33:40 +07:00
Ibuki.O d84be7571f fix: Always increment active_count in override_at to ensure synchronization 2026-07-05 11:23:00 +09:00
Jeremy Soller fef4343580 Merge branch 'detach-crash' into 'master'
Fix crash when exiting from detached thread

See merge request redox-os/relibc!1517
2026-07-04 19:19:50 -06:00
Jeremy Soller 7c9141db30 Merge branch 'clean-test' into 'master'
Fix clean tests

See merge request redox-os/relibc!1516
2026-07-04 17:41:35 -06:00
Wildan M dc3461f3e9 Set the test runner dynamically linked 2026-07-05 05:17:18 +07:00
Wildan M 1c194990f8 Fix crash when exiting from detached thread 2026-07-05 04:05:30 +07:00
Wildan M 001062e20c Fix clean tests 2026-07-05 02:51:17 +07:00
Jeremy Soller 13394f9251 Merge branch 'split-pthreadattrt' into 'master'
split out pthread_attr_t

See merge request redox-os/relibc!1515
2026-07-04 11:09:18 -06:00
Jeremy Soller 0b8c549d2d Merge branch 'exit-eagain' into 'master'
Fix panic at posix_exit due to EAGAIN

See merge request redox-os/relibc!1514
2026-07-04 11:08:34 -06:00
auronandace 185b49b73e split out pthread_attr_t 2026-07-04 17:16:08 +01:00
Jeremy Soller fe20b68a95 Merge branch 'fix_join_pf' into 'master'
Dealloc TCB on detach/join rather than exit.

See merge request redox-os/relibc!1513
2026-07-04 07:03:09 -06:00
Wildan M 3cbcc916cd Fix panic at posix_exit due to EAGAIN 2026-07-04 19:55:58 +07:00
4lDO2 0434043c44 Dealloc TCB on detach/join rather than exit. 2026-07-04 13:48:31 +02:00
Jeremy Soller 1ef6fb94e2 Merge branch 'systypes-guard' into 'master'
refactor sys_types_internal to reduce namespace pollution

See merge request redox-os/relibc!1511
2026-07-03 11:36:06 -06:00
Jeremy Soller f9e04a67a0 Merge branch 'pthread-cond-docs' into 'master'
document functions in pthread cond

See merge request redox-os/relibc!1510
2026-07-03 11:35:44 -06:00
auronandace 93d6fc091f refactor sys_types_internal to reduce namespace pollution 2026-07-03 14:23:00 +01:00
auronandace 572c33a522 document functions in pthread cond 2026-07-03 13:17:38 +01:00
Jeremy Soller 984ce223e5 Merge branch 'pthread-attr-docs' into 'master'
document pthread attr functions

See merge request redox-os/relibc!1509
2026-07-02 08:30:00 -06:00
Jeremy Soller 893dbfa261 Merge branch 'mut-from-ref-tackle' into 'master'
make mut_from_ref deny

See merge request redox-os/relibc!1507
2026-07-02 08:27:52 -06:00
auronandace bc228c3d91 document pthread attr functions 2026-07-02 13:08:16 +01:00
auronandace e714c570bc make mut_from_ref deny 2026-07-02 08:28:38 +01:00
Jeremy Soller e8d4ce4822 Merge branch 'avoid-blocking-nsmgr' into 'master'
refactor: Move fd allocation logic into userspace

See merge request redox-os/relibc!1479
2026-07-01 08:08:23 -06:00
Ibuki Omatsu fba233467a refactor: Move fd allocation logic into userspace 2026-07-01 08:08:23 -06:00
Jeremy Soller 15a4a27a46 Merge branch 'openat-test' into 'master'
Add basic test for openat

See merge request redox-os/relibc!1501
2026-06-30 15:29:11 -06:00
Mathew John Roberts 9bd2b595f9 Merge branch 'doc-termios-flags' into 'master'
add descriptions to cc constants for termios

See merge request redox-os/relibc!1506
2026-06-30 07:27:39 +01:00
Mathew John Roberts 61046e2af8 Merge branch 'doc-string-func' into 'master'
add descriptions to some string header functions

See merge request redox-os/relibc!1505
2026-06-30 07:27:22 +01:00
Mathew John Roberts ddd94ce4c0 Merge branch 'utime-doc' into 'master'
add descriptions to utime header

See merge request redox-os/relibc!1503
2026-06-30 07:27:01 +01:00
Mathew John Roberts b3b60d7943 Merge branch 'pthread-spin-doc' into 'master'
add descriptions to pthread spin lock functions

See merge request redox-os/relibc!1502
2026-06-30 07:26:36 +01:00
Mathew John Roberts 7d38536e5d Merge branch 'pthread-afterincludes' into 'master'
move pthread_t to bits header and move some after_includes to pthread header

See merge request redox-os/relibc!1499
2026-06-30 07:26:14 +01:00
auronandace 759bdb06b2 add descriptions to cc constants for termios 2026-06-29 13:38:49 +01:00
auronandace 6ab0d57510 add descriptions to some string header functions 2026-06-29 11:51:47 +01:00
auronandace e5f4f3d179 add descriptions to utime header 2026-06-29 09:12:11 +01:00
auronandace 68c7361a34 add descriptions to pthread spin lock functions 2026-06-29 08:13:20 +01:00
Wildan M ead8ca0043 Add basic test for openat 2026-06-28 15:34:01 +07: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
Jeremy Soller e9963128a8 Merge branch 'signal-func-doc2' into 'master'
add more descriptions to signal header functions

See merge request redox-os/relibc!1498
2026-06-27 06:21:41 -06:00
auronandace 3fff28e44a add more descriptions to signal header functions 2026-06-26 17:51:57 +01:00
Jeremy Soller eeea60c1d1 Merge branch 'bits-limits-ptdi' into 'master'
fix TTS_DTOR_ITERATIONS with bits file

See merge request redox-os/relibc!1497
2026-06-26 06:31:18 -06:00
Jeremy Soller 35e51551b9 Merge branch 'pthread-panic' into 'master'
Return ENOSYS to pthread_getschedparam instead of panic

See merge request redox-os/relibc!1496
2026-06-26 06:29:57 -06:00
auronandace 3cc24ddaee fix TTS_DTOR_ITERATIONS with bits file 2026-06-26 12:42:35 +01:00
Wildan M ec78de0abf Return ENOSYS to pthread_getschedparam instead of panic 2026-06-26 07:58:15 +07:00
Jeremy Soller fec9d49c18 Merge branch 'signal-func-doc' into 'master'
add some descriptions to some of the signal header functions

See merge request redox-os/relibc!1495
2026-06-25 12:16:52 -06:00
auronandace 27de2f4795 add some descriptions to some of the signal header functions 2026-06-25 14:28:26 +01:00
Jeremy Soller b174c8d7c2 Merge branch 'sysepoll-func-doc' into 'master'
add descriptions to sys_epoll functions

See merge request redox-os/relibc!1494
2026-06-25 06:43:05 -06:00
auronandace bbac94480b add descriptions to sys_epoll functions 2026-06-25 11:26:36 +01:00
Jeremy Soller 5e4591aff1 Merge branch 'stddef-rust' into 'master'
move stddef header from C to cbindgen

See merge request redox-os/relibc!1492
2026-06-24 14:39:54 -06:00
Jeremy Soller 1fb72c6dbe Merge branch 'spawn-flag' into 'master'
add missing flag to spawn

See merge request redox-os/relibc!1491
2026-06-24 13:50:39 -06:00
auronandace 3be84f4b26 move stddef header from C to cbindgen 2026-06-24 11:52:15 +01:00
auronandace a80dda35eb add missing flag to spawn 2026-06-24 10:30:19 +01:00
Mathew John Roberts 08fb0c193d Merge branch 'bits-uio' into 'master'
split out non-POSIX preadv and pwritev to a bits header

See merge request redox-os/relibc!1490
2026-06-24 06:35:37 +01:00
auronandace 281b6fcd44 correct the include guard 2026-06-23 10:53:40 +01:00
auronandace df380e5dd0 split out non-POSIX preadv and pwritev to a bits header 2026-06-23 10:48:23 +01:00
Mathew John Roberts 777c1103d6 Merge branch 'sysselect-func-doc' into 'master'
add descriptions to sys_select functions

See merge request redox-os/relibc!1486
2026-06-23 06:40:19 +01:00
Mathew John Roberts 3b1be86ed6 Merge branch 'sig-const-doc' into 'master'
add descriptions to remaining signals constants and structs

See merge request redox-os/relibc!1485
2026-06-23 06:40:05 +01:00
Mathew John Roberts d0fdf6d026 Merge branch 'spawn-sh' into 'master'
Fix posix_spawn launching sh script

See merge request redox-os/relibc!1489
2026-06-23 06:39:38 +01:00
Mathew John Roberts a2ec2838d8 Merge branch 'eintr-exit' into 'master'
Handle EINTR in posix_exit

See merge request redox-os/relibc!1488
2026-06-23 06:38:43 +01:00
Wildan M b5e764d967 Fix posix_spawn launching sh script 2026-06-23 12:22:31 +07:00
Wildan Mubarok aa16f69fed Merge branch 'arr-cwd' into 'master'
Use ArrayString for Cwd

See merge request redox-os/relibc!1487
2026-06-23 03:19:39 +00:00
Wildan M 0880176578 Handle EINTR in posix_exit 2026-06-23 01:53:29 +07:00
Wildan M c234ace91d Use ArrayString for Cwd 2026-06-22 22:13:24 +07:00
auronandace 1cff1ab1d5 add descriptions to sys_select functions 2026-06-22 14:57:46 +01:00
auronandace 24f93c0b08 add descriptions to remaining signals constants and structs 2026-06-22 13:55:28 +01:00
Mathew John Roberts 4e4ed8b8c7 Merge branch 'dis-spawn-test' into 'master'
Disable spawn test temporarily

See merge request redox-os/relibc!1484
2026-06-21 19:37:51 +01:00
Mathew John Roberts e197b07e70 Merge branch 'relpath-spawn' into 'master'
Fix relative program path handling in posix_spawn

See merge request redox-os/relibc!1483
2026-06-21 19:10:57 +01:00
Wildan M c47b492717 Disable spawn test temporarily 2026-06-21 14:54:58 +07:00
Wildan M 73a8c843a8 Fix relative program path handling in posix_spawn 2026-06-21 14:12:05 +07:00
Mathew John Roberts 0c63874856 Merge branch 'path-spawn' into 'master'
Add arrayvec and split PATH env logic, Fix posix_spawn various issues

See merge request redox-os/relibc!1482
2026-06-20 07:00:33 +01:00
Wildan M 5779743a9a Remove posix_spawn string allocation 2026-06-20 12:31:32 +07:00
Wildan M 56d5fe6bce Fix posix_spawn various issues 2026-06-20 07:05:28 +07:00
Wildan M fdcc92cd3b Add arrayvec and split PATH env logic 2026-06-20 06:38:50 +07:00
Mathew John Roberts dd8394865d Merge branch 'fcntl-func-doc' into 'master'
add descriptions to fcntl.h functions

See merge request redox-os/relibc!1481
2026-06-19 14:10:30 +01:00
auronandace bceef31d06 add descriptions to fcntl.h functions 2026-06-19 13:46:39 +01:00
Mathew John Roberts 59ce5ee527 Merge branch 'unify-signal-constants' into 'master'
unify and document most of the signal constants

See merge request redox-os/relibc!1480
2026-06-19 12:35:10 +01:00
auronandace 3d996626d2 cargo fmt 2026-06-19 12:07:32 +01:00
auronandace e0225f1b15 unify and document most of the signal constants 2026-06-19 12:03:38 +01:00
Mathew John Roberts 99675e2b80 Merge branch 'spawn-doc' into 'master'
add descriptions to the spawn header functions

See merge request redox-os/relibc!1473
2026-06-18 17:05:02 +01:00
Mathew John Roberts e66360e22d Merge branch 'syswait-doc' into 'master'
add descriptions of sys_wait constants, macros and functions

See merge request redox-os/relibc!1478
2026-06-18 16:24:28 +01:00
auronandace ae4a71dc1e add descriptions of sys_wait constants, macros and functions 2026-06-18 14:19:16 +01:00
Mathew John Roberts f638679a51 Merge branch 'use-symloopmax' into 'master'
use SYMLOOP_MAX in resolve_sym_links in redox path

See merge request redox-os/relibc!1477
2026-06-18 13:18:47 +01:00
Mathew John Roberts 09ae605623 Apply 1 suggestion(s) to 1 file(s)
Co-authored-by: Wildan Mubarok <willnode@wellosoft.net>
2026-06-18 13:02:25 +01:00
Mathew John Roberts 1426003c61 Merge branch 'pthread-barrier-doc' into 'master'
add descriptions to the pthread barrier functions

See merge request redox-os/relibc!1476
2026-06-18 12:27:34 +01:00
Mathew John Roberts de29dcfa6c Merge branch 'signal-doc' into 'master'
add documentation for some signal constants and structs

See merge request redox-os/relibc!1475
2026-06-18 12:26:39 +01:00
auronandace d0760c2b90 fix amount 2026-06-18 12:25:40 +01:00
auronandace c84f1f41fb use SYMLOOP_MAX in resolve_sym_links in redox path 2026-06-18 12:06:56 +01:00
auronandace 3759fd8867 add descriptions to the pthread barrier functions 2026-06-18 11:20:51 +01:00
auronandace ceb500364c add documentation for some signal constants and structs 2026-06-18 09:10:31 +01:00
Mathew John Roberts 29e86bcf63 Merge branch 'function-casts-as-integer' into 'master'
apply function_casts_as_integer lint to other arches

See merge request redox-os/relibc!1474
2026-06-18 06:25:19 +01:00
auronandace 4674c47f2b apply function_casts_as_integer lint to other arches 2026-06-17 14:28:39 +01:00
auronandace 35425db05e add descriptions to the spawn header functions 2026-06-17 13:07:08 +01:00
Mathew John Roberts 349e7e72a3 Merge branch 'split-uint32t' into 'master'
split out uint32_t for socklen_t for sys_socket header

See merge request redox-os/relibc!1472
2026-06-17 10:08:42 +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 6c49b9acac Merge branch 'spawn-cleanup' into 'master'
spawn header cleanup

See merge request redox-os/relibc!1471
2026-06-17 08:31:24 +01:00
auronandace 40f22b62ab set style to Type instead of Tag 2026-06-17 08:08:34 +01:00
auronandace e69aba445e spawn header cleanup 2026-06-17 07:43:35 +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
Mathew John Roberts 6be61dd09e Merge branch 'stdarg-rust' into 'master'
move stdarg header from C to cbindgen and create valist bits header

See merge request redox-os/relibc!1469
2026-06-16 17:23:37 +01:00
auronandace 16c3a316c6 remove ifdef from wscanf test file 2026-06-16 11:49:13 +01:00
auronandace 47b5f56d0b move stdarg header from C to cbindgen and create valist bits header 2026-06-16 11:35:40 +01:00
Mathew John Roberts 038bae3cd6 Merge branch 'libgen-doc' into 'master'
add descriptions to libgen functions

See merge request redox-os/relibc!1468
2026-06-16 10:49:03 +01:00
Mathew John Roberts 16c824d99b Merge branch 'split-ucred' into 'master'
split out ucred to a bits header

See merge request redox-os/relibc!1467
2026-06-16 10:47:50 +01:00
auronandace eee0634175 add descriptions to libgen functions 2026-06-16 09:45:43 +01:00
auronandace f5c0c1a9c9 split out ucred to a bits header 2026-06-16 08:04:26 +01:00
Mathew John Roberts 65e0136466 Merge branch 'inttypes' into 'master'
Fix inttypes macros for i586

See merge request redox-os/relibc!1466
2026-06-16 06:33:49 +01:00
Wildan M 812870bf6e Fix inttypes macros for i586 2026-06-16 07:22:54 +07:00
Mathew John Roberts 39cbed50d7 Merge branch 'inttypes-doc' into 'master'
add descriptions to inttypes header and related functions

See merge request redox-os/relibc!1465
2026-06-15 15:49:30 +01:00
Mathew John Roberts f2d8dac37c Merge branch 'sys-un-utsname-doc' into 'master'
add descriptions to sys_un and sys_utsname

See merge request redox-os/relibc!1464
2026-06-15 15:30:25 +01:00
auronandace c953dff5dd cargo fmt 2026-06-15 15:13:37 +01:00
auronandace 68758f3f90 add descriptions to inttypes header and related functions 2026-06-15 15:09:18 +01:00
Mathew John Roberts 527a268a7a Merge branch 'implicit-clone' into 'master'
add implicit_clone clippy lint and tackle a few others

See merge request redox-os/relibc!1463
2026-06-15 13:50:03 +01:00
auronandace 3e06b6d5d0 add descriptions to sys_un and sys_utsname 2026-06-15 13:32:06 +01:00
R Aadarsh 789be35518 Add comments to cbindgen.toml 2026-06-15 17:08:11 +05:30
R Aadarsh 1ff7d7bba0 * Fix pgroup inheritance
* Remove unnecessary nesting

* Make the child process explicitly inherit parent's u/g id
2026-06-15 17:08:11 +05:30
R Aadarsh 5891ae023e Change number of characters 2026-06-15 17:08:11 +05:30
R Aadarsh 58fefac9f5 Enable sched params change 2026-06-15 17:08:11 +05:30
R Aadarsh 484fe42c0e * Add docs
* Change safety signatures

* Change tests

* Correctly set u/g id
2026-06-15 17:08:11 +05:30
R Aadarsh 6d14437f34 Implement u/g id change based on executable's s(u/g)id mode bit 2026-06-15 17:08:11 +05:30
R Aadarsh 0d127d3652 Add more tests 2026-06-15 17:08:11 +05:30
R Aadarsh ad151e0de8 * Correctly determine argv[0]
- If the function called is `posix_spawnp`, and the passed program name **does not** contain a slash, the path is used unmodified, and the path to the directory containing the program on $PATH is prepended to the program's path and assigned to `argv[0]. If the program name **does** contain a slash, the path is absolutised relative to CWD, and assigned to argv[0]

    - If the function called is `posix_spawn`, the behaviour is as described above in the case where path contains a slash

* Add initial tests
2026-06-15 17:08:11 +05:30
R Aadarsh f59e292744 Change spawn to use CString. String not-being null-terminated prevented files on PATH from being opened. 2026-06-15 17:08:11 +05:30
R Aadarsh 4ea8f329b6 Remove unused constants 2026-06-15 17:08:11 +05:30
R Aadarsh 72ee48df3f Change file_actions implementation to mirror other pthread 2026-06-15 17:08:11 +05:30
R Aadarsh 632c8302a4 Change assertions and panics to display ERRNO 2026-06-15 17:08:11 +05:30
R Aadarsh a941458ba0 Remove the use of platform::redox::path 2026-06-15 17:08:11 +05:30
R Aadarsh fefea0f0a9 Make code safer by disallowing NULL argv, empty argv and NULL values for pointer arguments to functions 2026-06-15 17:08:11 +05:30
R Aadarsh 8c65ed481a Make path to be owned 2026-06-15 17:08:11 +05:30
R Aadarsh 91933b4165 * Change Operation to Action
* Change the linked list to a `Vec<Action>`

* Make functions unsafe
2026-06-15 17:08:11 +05:30
R Aadarsh 2df7484e6c * Make posix_spawnp consider the program argument as a path if it contains a slash
* Remove existence and file type check

* Make envp optional

* Ensure that the CWD of the calling process is same before and after spawning
2026-06-15 17:08:11 +05:30
R Aadarsh 38af072426 Implement chdir and fchdir operations 2026-06-15 17:08:11 +05:30
R Aadarsh db5eeb7c20 Remove call to close, instead make the kernel remove the file 2026-06-15 17:08:11 +05:30
R Aadarsh a6e1b269af * Make dup2 work
* Use `CloseCloExec` for closing O_CLOEXEC files
2026-06-15 17:08:11 +05:30
R Aadarsh 4df38b6f0d * Implement open operation
* Comment out the code for dup2
2026-06-15 17:08:11 +05:30
R Aadarsh 0810991d7d Do the requested sigmask changes and u/g id changes 2026-06-15 17:08:11 +05:30
R Aadarsh 0e5210cb4d Make close operation work 2026-06-15 17:08:11 +05:30
R Aadarsh e3d2257f64 * Make posix_spawn_file_actions_t an iterator
* Fix bug that caused the spawned process to not start

* Make the spawned process inherit the parent's file descriptos
2026-06-15 17:08:11 +05:30
R Aadarsh ad83227225 Change the posix_spawn_file_actions_t struct to use a linked list instead of an array 2026-06-15 17:08:11 +05:30
R Aadarsh 88185cbd8d Make posix_spawnp work 2026-06-15 17:08:11 +05:30
R Aadarsh 119f078216 * Fix bug that caused pid of the child process to be returned instead of 0 or errorno
* Add `same_process` field to not change the address space when `fexec_impl` is called on a different process
2026-06-15 17:08:11 +05:30
R Aadarsh 1bc472e7e1 Add posix_spawn and posix_spawnp for RedoxOS 2026-06-15 17:08:11 +05:30
R Aadarsh df78820f01 Add posix_spawn_file_actions_t and posix_spawnattr_t and tests 2026-06-15 17:08:11 +05:30
Mathew John Roberts 0dd5cf597a Merge branch 'remove-redundant-includes' into 'master'
remove redundant includes

See merge request redox-os/relibc!1462
2026-06-15 12:33:33 +01:00
auronandace c4509c9684 add implicit_clone clippy lint and tackle a few others 2026-06-15 12:14:07 +01:00
auronandace 507264f5bb remove redundant includes 2026-06-15 07:49:47 +01:00
Mathew John Roberts 19fd9d70ff Merge branch 'sysuio-doc' into 'master'
add descriptions to sys_uio functions and associated unistd functions

See merge request redox-os/relibc!1460
2026-06-15 07:16:39 +01:00
auronandace 297bc7bd62 add TODO notes for Non-POSIX functions and include 2026-06-14 14:29:32 +01:00
auronandace 60e301360c add descriptions to sys_uio functions and associated unistd functions 2026-06-14 14:18:25 +01:00
Jeremy Soller 51819dac36 Merge branch 'crypt-questionmark' into 'master'
replace an explicit return with question mark

See merge request redox-os/relibc!1458
2026-06-12 15:29:14 -06:00
Jeremy Soller 71d29a94b7 Merge branch 'xopen-namepath-max' into 'master'
move and document some constants

See merge request redox-os/relibc!1459
2026-06-12 15:29:09 -06:00
auronandace 999001db98 move and document some constants 2026-06-12 18:22:29 +01:00
auronandace 0816e07a5d replace an explicit return with question mark 2026-06-12 17:25:53 +01:00
Jeremy Soller 5f7a1a5c14 Merge branch 'casting-ascii' into 'master'
avoid as casting ascii bytes to c_char

See merge request redox-os/relibc!1457
2026-06-12 06:02:47 -06:00
auronandace ecb081d8bd add descriptions and pick a better function name 2026-06-12 11:13:06 +01:00
auronandace 0dc5247ff6 revert const for now 2026-06-11 18:10:28 +01:00
auronandace 4882c450d8 apply ByteLiteral abstraction 2026-06-11 18:01:25 +01:00
auronandace 40d2512728 test with into 2026-06-11 17:34:32 +01:00
auronandace e27345d93a cargo fmt 2026-06-11 17:22:53 +01:00
auronandace 2e72022a26 add and test ByteLiteral abstraction 2026-06-11 17:19:33 +01:00
Jeremy Soller 1ff9fd392b Merge branch 'ignored-unit-patterns' into 'master'
apply ignored_unit_patterns clippy lint

See merge request redox-os/relibc!1456
2026-06-11 09:25:03 -06:00
auronandace 40767a44fa avoid as casting ascii bytes to c_char 2026-06-11 15:06:06 +01:00
auronandace fd09491c4a apply ignored_unit_patterns clippy lint 2026-06-11 14:00:24 +01:00
Jeremy Soller c645cfc9ac Merge branch 'iov-max' into 'master'
move IOV_MAX to limits header

See merge request redox-os/relibc!1455
2026-06-11 06:54:24 -06:00
Jeremy Soller 8f28f07359 Merge branch 'sysresource-descriptions' into 'master'
add descriptions to the functions in the sys_resource header

See merge request redox-os/relibc!1454
2026-06-11 06:38:33 -06:00
Jeremy Soller 2727bb2c03 Merge branch 'macro-lints' into 'master'
silence cast_lossless clippy lint from triggering inside macros

See merge request redox-os/relibc!1453
2026-06-11 06:36:03 -06:00
Jeremy Soller 78b05d3297 Merge branch 'arpainet-followup' into 'master'
apply some clippy lints to arpa_inet header

See merge request redox-os/relibc!1452
2026-06-11 06:35:26 -06:00
Jeremy Soller 8173c9cdec Merge branch 'openflags-followup' into 'master'
update comments in open flags bits cbindgen file

See merge request redox-os/relibc!1451
2026-06-11 06:34:25 -06:00
auronandace 08a01d62d8 move IOV_MAX to limits header 2026-06-11 13:27:13 +01:00
auronandace 5f9e82f067 add descriptions to the functions in the sys_resource header 2026-06-11 12:06:14 +01:00
auronandace 965941564d silence cast_lossless clippy lint from triggering inside macros 2026-06-11 09:42:47 +01:00
auronandace 805b920bd8 apply some clippy lints to arpa_inet header 2026-06-11 08:11:23 +01:00
auronandace e215033b4d update comments in open flags bits cbindgen file 2026-06-11 07:35:47 +01:00
Jeremy Soller c7c5ab649d Merge branch 'implement-AF_INET6-for-inet_pton' into 'master'
fix: implement IPv6 for arpa_inet/inet_pton()

See merge request redox-os/relibc!1450
2026-06-10 16:27:07 -06:00
sourceturner 16abb5d342 fix: implement IPv6 for arpa_inet/inet_pton() 2026-06-11 00:05:58 +02:00
Jeremy Soller b390ee651b Merge branch 'bits-open-flags' into 'master'
Move O_ constants to bits/open-flags.h for use by fcntl.h and stdlib.h

See merge request redox-os/relibc!1449
2026-06-10 08:56:04 -06:00
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
Jeremy Soller 50251287ce Merge branch 'ctype-doc' into 'master'
add documentation to ctype header

See merge request redox-os/relibc!1448
2026-06-10 07:18:43 -06:00
auronandace 2488e523cb add documentation to ctype header 2026-06-10 13:49:28 +01:00
Jeremy Soller 5478334138 Merge branch 'unify-sysconf-constants' into 'master'
unify the remaining sysconf constants

See merge request redox-os/relibc!1447
2026-06-10 05:51:14 -06:00
Jeremy Soller 638befdffa Merge branch 'bits-cleanup' into 'master'
cleanup the bits headers

See merge request redox-os/relibc!1446
2026-06-10 05:50:48 -06:00
Jeremy Soller 9bfeaa4cff Merge branch 'fix-crypt_md5' into 'master'
fix: crypt_md5: clamp salt slice to string length

See merge request redox-os/relibc!1445
2026-06-10 05:50:25 -06:00
Jeremy Soller 6627ebfba1 Merge branch 'assert-doc' into 'master'
add documentation to the assert header

See merge request redox-os/relibc!1444
2026-06-10 05:49:27 -06:00
auronandace aedcb6820e unify the remaining sysconf constants 2026-06-10 12:03:15 +01:00
auronandace 73a111b67e cleanup the bits headers 2026-06-10 11:16:22 +01:00
Marsman1996 9408cef1c6 fix: crypt_md5: clamp salt slice to string length 2026-06-10 16:38:27 +08:00
auronandace 17b27ba9dd add documentation to the assert header 2026-06-10 08:47:00 +01:00
Jeremy Soller da1baa9e4a Merge branch 'no-getrlimit' into 'master'
Do not call getrlimit on getdtablesize in Redox

See merge request redox-os/relibc!1443
2026-06-09 17:05:42 -06:00
Wildan M 8cfe85226f Do not call getrlimit on getdtablesize in Redox 2026-06-10 05:45:21 +07:00
Jeremy Soller c52bb696a6 Merge branch 'fix-crypt_r-utf8' into 'master'
fix: crypt: treat key as raw bytes instead of requiring UTF-8

See merge request redox-os/relibc!1442
2026-06-09 06:20:42 -06:00
lyw458372 38d9c05e39 fix: crypt_r: treat key as raw bytes instead of requiring UTF-8 2026-06-09 15:23:50 +08:00
Jeremy Soller c586fea290 Merge branch 'posix-includes-sweep' into 'master'
verify POSIX header includes

Closes #244

See merge request redox-os/relibc!1441
2026-06-08 17:27:43 -06:00
auronandace 9ea36a0c6c verify POSIX header includes 2026-06-08 18:27:53 +01:00
Jeremy Soller 227e736836 Merge branch 'fix-sha' into 'master'
fix: crypt_sha: bounds-check before slicing setting

See merge request redox-os/relibc!1440
2026-06-08 07:28:16 -06:00
lyw458372 5a3322ba97 fix: crypt_sha: bounds-check before slicing setting 2026-06-08 21:07:53 +08:00
Jeremy Soller 4a521f06e1 Merge branch 'fix-shm' into 'master'
fix: shmget: return EINVAL on size overflow

See merge request redox-os/relibc!1439
2026-06-08 06:46:12 -06:00
Jeremy Soller 944bd18772 Merge branch 'fix-glob-utf8' into 'master'
fix: glob: handle non-UTF-8 paths without panicking

See merge request redox-os/relibc!1438
2026-06-08 06:45:12 -06:00
Jeremy Soller 11557957e0 Merge branch 'verify-wctype-includes' into 'master'
verify wctype header includes

See merge request redox-os/relibc!1437
2026-06-08 06:44:47 -06:00
Jeremy Soller d56f1cdb64 Merge branch 'verify-wchar-includes' into 'master'
Verify wchar includes

See merge request redox-os/relibc!1436
2026-06-08 06:44:30 -06:00
Jeremy Soller 7aa4278b08 Merge branch 'verify-stdlib-includes' into 'master'
verify stdlib header includes

See merge request redox-os/relibc!1434
2026-06-08 06:44:11 -06:00
Jeremy Soller d6d2c00e16 Merge branch 'verify-stdio-includes' into 'master'
verify stdio header includes

See merge request redox-os/relibc!1433
2026-06-08 06:43:47 -06:00
Jeremy Soller 6479ad6031 Merge branch 'verify-pthread-includes' into 'master'
verify pthread header includes

See merge request redox-os/relibc!1432
2026-06-08 06:43:21 -06:00
Jeremy Soller f1856908a8 Merge branch 'verify-fenv-includes' into 'master'
verify fenv header includes

See merge request redox-os/relibc!1431
2026-06-08 06:42:49 -06:00
Jeremy Soller 2896c94932 Merge branch 'fix-mktime' into 'master'
fix: mktime: stop using tm_gmtoff, use system timezone per POSIX

See merge request redox-os/relibc!1435
2026-06-08 06:37:09 -06:00
lyw458372 163c44e523 fix: shmget: return EINVAL on size overflow 2026-06-08 20:27:54 +08:00
lyw458372 7d8cd46131 chore: delete dead code 2026-06-08 19:41:49 +08:00
lyw458372 5a545a1e26 test: add tm_gmtoff 2026-06-08 19:39:55 +08:00
lyw458372 8e11d7af70 fix: mktime: stop using tm_gmtoff, use system timezone per POSIX 2026-06-08 19:39:06 +08:00
auronandace 498eaf9a34 verify wctype header includes 2026-06-08 12:20:46 +01:00
lyw458372 18c1977f20 fix: glob: handle non-UTF-8 paths without panicking 2026-06-08 19:18:59 +08:00
auronandace 163c2ee663 remove stdarg as it is brought in by stdio 2026-06-08 11:32:38 +01:00
auronandace e7bda42123 verify wchar header includes 2026-06-08 11:26:17 +01:00
auronandace 359f9b26ef verify stdlib header includes 2026-06-08 10:32:22 +01:00
auronandace db06516303 verify stdio header includes 2026-06-08 09:08:21 +01:00
auronandace ba3bd139ad verify pthread header includes 2026-06-08 08:09:48 +01:00
auronandace 44e2301dbc verify fenv header includes 2026-06-08 07:43:11 +01:00
Jeremy Soller e4617b4ba3 Merge branch 'sysconf-constants' into 'master'
deduplicate unistd sysconf constants

See merge request redox-os/relibc!1430
2026-06-07 16:31:29 -06:00
auronandace 9cc73da0cf deduplicate unistd sysconf constants 2026-06-07 16:55:29 +01:00
Jeremy Soller 0cffe8c826 Merge branch 'arpainet-doc' into 'master'
add descriptions to arpa_inet functions

See merge request redox-os/relibc!1429
2026-06-07 08:35:49 -06:00
auronandace eca333f18e add descriptions to arpa_inet functions 2026-06-07 14:40:05 +01:00
Jeremy Soller c9ba9d2937 Merge branch 'flycast' into 'master'
Fix elf.h typedef and ELFMAG, add IPPROTO_ICMPV6 and MSG_NOSIGNAL

See merge request redox-os/relibc!1428
2026-06-07 05:52:28 -06:00
Wildan Mubarok 216ec9f5bf Apply 1 suggestion(s) to 1 file(s)
Co-authored-by: Mathew John Roberts <auronandace@duck.com>
2026-06-07 06:49:36 +00:00
Wildan M f484e108cc Fix elf.h typedef and ELFMAG, add IPPROTO_ICMPV6 and MSG_NOSIGNAL 2026-06-07 00:17:04 +07:00
Jeremy Soller bcc1a0d43c Merge branch 'revert-ipv6-checks-in-unittests' into 'master'
revert checks for presence of IPv6 related symbols

See merge request redox-os/relibc!1427
2026-06-06 08:50:38 -06:00
Jeremy Soller 10e8ce6f06 Merge branch 'fix-inttypes' into 'master'
fix inttypes/wcstoumax os-test unit test

See merge request redox-os/relibc!1426
2026-06-06 08:50:27 -06:00
sourceturner f035178b00 revert checks for presence of IPv6 related symbols 2026-06-06 16:18:01 +02:00
sourceturner 61eb978f8e fix inttypes/wcstoumax os-test unit test 2026-06-06 16:02:01 +02:00
Jeremy Soller 7df28779b9 Merge branch 'ip6' into 'master'
Revert ip6 flag in constants, Add placeholders for ip6 feature

See merge request redox-os/relibc!1425
2026-06-06 06:04:21 -06:00
Wildan M 77bba18a4b Revert ip6 flag 2026-06-06 13:31:42 +07:00
Jeremy Soller 3c6861d72c Merge branch 'fix-glob' into 'master'
fix os-test for glob()

See merge request redox-os/relibc!1423
2026-06-05 20:32:52 -06:00
Jeremy Soller 646687f138 Merge branch 'sem' into 'master'
Fix sem_trywait and sem_wait error handling

See merge request redox-os/relibc!1424
2026-06-05 20:31:58 -06:00
sourceturner 364569366b fix os-test for glob() 2026-06-05 21:57:23 +02:00
Jeremy Soller 0fb862a177 Merge branch 'clippy-lints' into 'master'
tackle various clippy lints

See merge request redox-os/relibc!1422
2026-06-05 10:05:23 -06:00
auronandace 94b2f29beb tackle various clippy lints 2026-06-05 14:36:06 +01:00
Wildan M 85e6e1e675 Fix sem_trywait and sem_wait error handling 2026-06-05 09:21:50 +07:00
Jeremy Soller 15c415072f Merge branch 'fix-os-test-basic-arpa_inet' into 'master'
Fix os test basic arpa inet, fix compiler warnings

See merge request redox-os/relibc!1391
2026-06-04 19:56:32 -06:00
sourceturner 20d89d166c use ip6 feature flag for IPv6 related definitions
as a consequence, some unit tests have to be fixed, too
2026-06-04 17:48:14 +02:00
sourceturner 125d48e9cd restrict octal prefix to leading zero
the '0o' prefix is only allowed by C2Y, not by C17
POSIX spec defers to C17
2026-06-04 17:33:37 +02:00
sourceturner b2da042f79 fix sys_socket/getpeername unit test 2026-06-04 17:33:37 +02:00
sourceturner fddf16c8b1 fix netdb/getaddrinfo unit test 2026-06-04 17:33:37 +02:00
sourceturner e39106835a fix compiler warnings 2026-06-04 17:33:37 +02:00
sourceturner 538db929cf fix arpa_inet/inet_addr 2026-06-04 17:33:37 +02:00
sourceturner ef7b690626 add arpa_inet/inet_addr unit test 2026-06-04 17:33:37 +02:00
sourceturner 17b2866d7e fix the inet_pton test of the os-test test suite 2026-06-04 17:33:37 +02:00
Jeremy Soller 3cdd418f53 Merge branch 'verify-aio-includes' into 'master'
verify aio header includes

See merge request redox-os/relibc!1420
2026-06-04 09:27:31 -06:00
Jeremy Soller ef29aa0ef3 Merge branch 'verify-systimes-includes' into 'master'
verify sys_times header includes

See merge request redox-os/relibc!1419
2026-06-04 09:27:21 -06:00
Jeremy Soller 7829bc80cf Merge branch 'fcntl-bits' into 'master'
split out stdio constants for fcntl header

See merge request redox-os/relibc!1417
2026-06-04 09:27:02 -06:00
Jeremy Soller e4cc04c9bf Merge branch 'ptsname-test-fix' into 'master'
tests/stdlib/ptsname: fix test for Linux due to pty changes

See merge request redox-os/relibc!1418
2026-06-04 09:26:25 -06:00
Jeremy Soller 4cfefaf97e Merge branch 'err-unsafe' into 'master'
make unsafe usage explicit in err header

See merge request redox-os/relibc!1416
2026-06-04 09:25:16 -06:00
auronandace a8036d6477 verify aio header includes 2026-06-04 15:25:16 +01:00
auronandace 1e22e149a4 verify sys_times header includes 2026-06-04 14:52:04 +01:00
Connor-GH 6da03f457c tests/stdlib/ptsname: fix test for Linux due to pty changes 2026-06-04 08:17:17 -05:00
auronandace 3603161a6f split out stdio constants for fcntl header 2026-06-04 14:09:38 +01:00
Jeremy Soller fca1a59849 Merge branch 'verify-unistd-includes' into 'master'
verify unistd header includes

See merge request redox-os/relibc!1415
2026-06-04 06:28:08 -06:00
Jeremy Soller c4db1fae05 Merge branch 'wchart_split' into 'master'
split out wchar_t from stddef header

See merge request redox-os/relibc!1414
2026-06-04 06:27:34 -06:00
Jeremy Soller 747a7d322b Merge branch 'sysresource-doc' into 'master'
verify sys_resource includes and add some documentation

See merge request redox-os/relibc!1413
2026-06-04 06:26:33 -06:00
Jeremy Soller 3cc23c4f2d Merge branch 'systypes-stddef' into 'master'
remove stddef from sys_types header

See merge request redox-os/relibc!1412
2026-06-04 06:22:55 -06:00
Jeremy Soller 0305f7d52a Merge branch 'tiocgptn-comment' into 'master'
update TIOCGPTN comment

See merge request redox-os/relibc!1411
2026-06-04 06:22:28 -06:00
Jeremy Soller ef9cfed7e0 Merge branch 'old-cpp' into 'master'
Fix lack of nullptr for older C++

See merge request redox-os/relibc!1410
2026-06-04 06:21:13 -06:00
auronandace ced5ff1df9 make unsafe usage explicit in err header 2026-06-04 13:21:10 +01:00
auronandace 2719e007e2 verify unistd header includes 2026-06-04 12:09:59 +01:00
auronandace d28a131ec5 split out wchar_t from stddef header 2026-06-04 11:17:36 +01:00
auronandace 172e5cb55b verify sys_resource includes and add some documentation 2026-06-04 10:35:47 +01:00
auronandace d51674078f remove stddef from sys_types header 2026-06-04 08:42:31 +01:00
auronandace 7b588b57b3 update TIOCGPTN comment 2026-06-04 08:12:40 +01:00
Jeremy Soller fafc4c2c00 Merge branch 'epoll-del-test' into 'master'
Add test for EPOLL_CTL_DEL

See merge request redox-os/relibc!1309
2026-06-03 19:27:58 -06:00
Jeremy Soller 1bc08e8664 Merge branch 'ptyd-changes' into 'master'
pty: update libc functions for ptyd changes

See merge request redox-os/relibc!1409
2026-06-03 19:24:58 -06:00
Connor-GH ee6b7137e7 pty: remove some duplicated code
The Linux and Redox implementations can be combined to reduce code
duplication.
2026-06-03 19:59:53 -05:00
Jeremy Soller 7680bbe6d7 Merge branch 'pthread-def' into 'master'
Fix pthread init and null for C++

See merge request redox-os/relibc!1408
2026-06-03 18:57:24 -06:00
Connor-GH 38737af78d pty: update libc functions for ptyd changes
Of note is that `unlockpt` is required, both by the standard, and our
implementation. This has been taken care of inside of `openpty`, which
is the only non-libc way we are acquiring ptys. Additionally, it has
been modified such that it is POSIX compliant, so any outside future
changes to ptyd will not affect it.

This is part of my ptyd changes (#100). This can be safely merged once
the changes from base/ and userutils/ are merged alongside it.
2026-06-03 19:41:38 -05:00
Wildan M 864f629d3f Fix lack of nullptr for older C++ 2026-06-04 06:17:36 +07:00
Wildan M 6acf560ed0 Fix pthread init and null for C++ 2026-06-04 00:38:58 +07:00
Jeremy Soller cef4ba679c Merge branch 'grp-doc' into 'master'
add descriptions to grp header

See merge request redox-os/relibc!1407
2026-06-03 08:53:34 -06:00
auronandace f82397f228 add descriptions to grp header 2026-06-03 15:13:31 +01:00
Jeremy Soller e2218c53d3 Merge branch 'timeb-doc' into 'master'
add descriptions to timeb struct and ftime function

See merge request redox-os/relibc!1405
2026-06-03 07:09:20 -06:00
Jeremy Soller 7323cec50b Merge branch 'nulldef' into 'master'
Fix NULL definition

See merge request redox-os/relibc!1406
2026-06-03 07:08:53 -06:00
Jeremy Soller 85354e2afd Merge branch 'syssocket-doc' into 'master'
add descriptions to sys_socket constants and structs

See merge request redox-os/relibc!1404
2026-06-03 07:08:24 -06:00
Jeremy Soller a1a81ad958 Merge branch 'ifaddrs-doc' into 'master'
add descriptions to the ifaddrs header

See merge request redox-os/relibc!1403
2026-06-03 07:07:45 -06:00
Wildan M 4a027c9f2b Fix NULL definition 2026-06-03 19:59:06 +07:00
auronandace ad0f500823 add descriptions to timeb struct and ftime function 2026-06-03 13:49:08 +01:00
auronandace 11769408e5 add descriptions to sys_socket constants and structs 2026-06-03 12:32:28 +01:00
auronandace 2e29bbe86a add descriptions to the ifaddrs header 2026-06-03 09:36:42 +01:00
Jeremy Soller 6ed85ce9c8 Merge branch 'stddef-null' into 'master'
split out NULL from stddef header

See merge request redox-os/relibc!1402
2026-06-02 19:55:19 -06:00
auronandace 4f5d535ebc split out NULL from stddef header 2026-06-02 16:56:12 +01:00
Jeremy Soller 7e546be11a Merge branch 'strings-include' into 'master'
remove stddef include from strings header

See merge request redox-os/relibc!1401
2026-06-02 05:41:40 -06:00
Jeremy Soller 11acec879b Merge branch 'wchart-type' into 'master'
change wchar_t type to int

See merge request redox-os/relibc!1400
2026-06-02 05:41:17 -06:00
auronandace 5860d65514 remove stddef include from strings header 2026-06-02 12:29:58 +01:00
auronandace 5795eac276 change wchar_t type to int 2026-06-02 12:13:17 +01:00
Jeremy Soller d4f680a319 Merge branch 'termios-doc' into 'master'
document some termios constants and the termios struct

See merge request redox-os/relibc!1399
2026-06-01 05:51:40 -06:00
Jeremy Soller 84a03f008f Merge branch 'verify-systime-includes' into 'master'
verify sys_time header includes

See merge request redox-os/relibc!1398
2026-06-01 05:51:19 -06:00
Jeremy Soller 056f2c8470 Merge branch 'verify-semaphore-includes' into 'master'
verify semaphore header includes

See merge request redox-os/relibc!1397
2026-06-01 05:50:52 -06:00
Jeremy Soller 2b4a363d23 Merge branch 'verify-langinfo-includes' into 'master'
verify langinfo header includes

See merge request redox-os/relibc!1396
2026-06-01 05:50:32 -06:00
Jeremy Soller 729cc3b90b Merge branch 'verify-netdb-includes' into 'master'
verify netdb header includes

See merge request redox-os/relibc!1395
2026-06-01 05:49:59 -06:00
Jeremy Soller bc6af64d06 Merge branch 'syssocket-includes' into 'master'
verify sys_socket header includes

See merge request redox-os/relibc!1394
2026-06-01 05:49:43 -06:00
auronandace 5b4ddd4732 document some termios constants and the termios struct 2026-06-01 12:05:01 +01:00
auronandace 27f65e1b22 verify sys_time header includes 2026-06-01 10:34:39 +01:00
auronandace 784b34f236 verify semaphore header includes 2026-06-01 10:04:03 +01:00
auronandace 4fd346c9d6 verify langinfo header includes 2026-06-01 09:27:09 +01:00
auronandace 0d8b8175c5 verify netdb header includes 2026-06-01 08:20:53 +01:00
auronandace d2df4c9d69 verify sys_socket header includes 2026-06-01 07:42:51 +01:00
Jeremy Soller 664fab3763 Merge branch 'timeout' into 'master'
Implement event timeout

See merge request redox-os/relibc!1382
2026-05-30 13:43:28 -06:00
4lDO2 21253a4be4 Fix unused_warnings error. 2026-05-30 17:00:30 +02:00
Jeremy Soller fa0b529796 Merge branch 'sysioctl-cleanup' into 'master'
deduplicate part of sys_ioctl

See merge request redox-os/relibc!1393
2026-05-30 08:37:33 -06:00
Jeremy Soller 3325795eb3 Merge branch 'dlfcn-doc' into 'master'
add descriptions to constants and struct members in dlfcn header

See merge request redox-os/relibc!1392
2026-05-30 08:34:28 -06:00
Wildan M 959e7d6cca Implement event timeout with EVENT_TIMEOUT_ID 2026-05-30 01:03:37 +07:00
auronandace 5abdcdf346 cargo fmt 2026-05-28 12:33:34 +01:00
auronandace 670288ef0c update ioctl function body 2026-05-28 12:28:22 +01:00
auronandace abba75fd62 deduplicate part of sys_ioctl 2026-05-28 12:17:11 +01:00
auronandace e6d4994c90 add descriptions to constants and struct members in dlfcn header 2026-05-28 08:36:12 +01:00
Jacob Lorentzon 0813a23294 Merge branch 'relpathat' into 'master'
feat: Implement relpathat

See merge request redox-os/relibc!1360
2026-05-27 16:36:45 +02:00
Ibuki Omatsu c2bcf91339 feat: Implement relpathat 2026-05-27 16:36:44 +02:00
Jeremy Soller 265111562a Merge branch 'sysstat-doc' into 'master'
add descriptions for stat struct and some constants

See merge request redox-os/relibc!1390
2026-05-27 06:32:19 -06:00
auronandace 5a696f87d0 add descriptions for stat struct and some constants 2026-05-27 13:17:38 +01:00
Jeremy Soller a6b0a8deca Merge branch 'fenv-systypes' into 'master'
remove sys_types from _fenv header

See merge request redox-os/relibc!1388
2026-05-27 05:27:33 -06:00
Jeremy Soller 1014fe2781 Merge branch 'split-winsize' into 'master'
split out winsize from sys_ioctl header

See merge request redox-os/relibc!1386
2026-05-27 05:22:39 -06:00
auronandace ea3c2b1791 remove sys_types from _fenv header 2026-05-27 07:18:45 +01:00
Jeremy Soller dfbe3e41d6 Merge branch 'redox-2026-05-24' into 'master'
Support nightly 2026-05-24

See merge request redox-os/relibc!1387
2026-05-26 07:20:23 -06:00
Wildan M 3e0971603d Fix long double printf for updated Rust 2026-05-26 20:05:38 +07:00
Jeremy Soller ffa097ccb3 Support nightly 2026-05-24 2026-05-25 17:03:17 -06:00
auronandace 3ddd4f56df split out winsize from sys_ioctl header 2026-05-25 16:57:12 +01:00
Jeremy Soller 7b3371848c Merge branch 'aio-cleanup' into 'master'
cleanup _aio header

See merge request redox-os/relibc!1385
2026-05-25 08:08:35 -06:00
auronandace 0920fefe3b cleanup _aio header 2026-05-25 14:36:56 +01:00
Jeremy Soller c0383a9465 Merge branch 'shadow-systypes' into 'master'
remove sys_types from the shadow header

See merge request redox-os/relibc!1384
2026-05-25 06:50:13 -06:00
Jeremy Soller b63901099f Merge branch 'utime-systypes' into 'master'
remove sys_types header from utime header includes

See merge request redox-os/relibc!1383
2026-05-25 06:49:56 -06:00
Jeremy Soller 47c5a08466 Merge branch 'ftime-out-ptr' into 'master'
Use Out for out-pointer in ftime()

See merge request redox-os/relibc!1181
2026-05-25 06:48:15 -06:00
Peter Limkilde Svendsen 9eddd8a73e Use Out for out-pointer in ftime() 2026-05-25 06:48:14 -06:00
auronandace 33dbe1aab8 remove sys_types from the shadow header 2026-05-25 07:58:33 +01:00
auronandace 441d9ebfc6 remove sys_types header from utime header includes 2026-05-25 07:22:01 +01:00
Jeremy Soller 6ec441d72f Merge branch 'fix-posix-timers' into 'master'
fix posix timers

See merge request redox-os/relibc!1270
2026-05-24 18:44:13 -06:00
sourceturner c96fd58a07 increase values for timer
CI runner needs more time to be able to run timer_gettime() after timer_settime()
2026-05-24 19:14:08 +02:00
sourceturner 4b4dc2ce94 implement housekeeping for posix timers 2026-05-24 19:14:02 +02:00
sourceturner d16183732c use raw borrow operator instead of pointer cast
clippy dislikes the pointer cast - let's make clippy happy
2026-05-24 19:12:05 +02:00
sourceturner 843449130a fix wrong null checks
while it is true that timer_t is implemented as a pointer,
this does not mean that timer_t cannot be 0.
actually, on linux, the first timer created seems to have
a timer_t value of 0 by default
2026-05-24 19:12:05 +02:00
sourceturner abbae3dce6 add basic unit test for posix timers (time/timer) 2026-05-24 19:12:05 +02:00
Jeremy Soller b6ff0f89f7 Merge branch 'netif-doc' into 'master'
add descriptions to items in net_if header

See merge request redox-os/relibc!1381
2026-05-24 06:28:34 -06:00
Jeremy Soller 341df4f404 Merge branch 'sysrandom-doc' into 'master'
add descriptions to constants and function in sys_random

See merge request redox-os/relibc!1380
2026-05-24 06:23:51 -06:00
Jeremy Soller b3c64f02b8 Merge branch 'sysfile-doc' into 'master'
document some constants in sys_file

See merge request redox-os/relibc!1379
2026-05-24 06:23:34 -06:00
Jeremy Soller 678096cfc8 Merge branch 'sysepoll-doc' into 'master'
move sys_epoll constants and add some descriptions

See merge request redox-os/relibc!1378
2026-05-24 06:22:53 -06:00
Jeremy Soller a7297c76f3 Merge branch 'sysptrace-doc' into 'master'
add documentation to sys_ptrace

See merge request redox-os/relibc!1377
2026-05-24 06:22:34 -06:00
auronandace 027536f0fa add descriptions to items in net_if header 2026-05-24 07:39:01 +01:00
auronandace 0b6bf4ef96 add descriptions to constants and function in sys_random 2026-05-23 14:51:31 +01:00
auronandace 8f1d6fe65c document some constants in sys_file 2026-05-23 14:15:42 +01:00
auronandace f6ef35da61 move sys_epoll constants and add some descriptions 2026-05-23 13:48:37 +01:00
auronandace cc14b6a69a add documentation to sys_ptrace 2026-05-23 08:02:25 +01:00
Jeremy Soller b72c825149 Merge branch 'pselect' into 'master'
Implement pselect and write test

See merge request redox-os/relibc!1376
2026-05-22 08:59:00 -06:00
Wildan M 0f03bff838 Implement pselect and write test 2026-05-22 03:29:57 +07:00
Jeremy Soller 0f216b2fa0 Merge branch 'systimeb-cleanup' into 'master'
remove sys_types from sys_timeb header includes

See merge request redox-os/relibc!1375
2026-05-21 06:49:37 -06:00
Jeremy Soller c0109a258c Merge branch 'syssyscall-cleanup' into 'master'
clean up sys_syscall header

See merge request redox-os/relibc!1374
2026-05-21 06:49:21 -06:00
Jeremy Soller 7f8bb29540 Merge branch 'verify-threads-includes' into 'master'
verify threads header includes

See merge request redox-os/relibc!1373
2026-05-21 06:48:44 -06:00
Jeremy Soller 4e13ac44f6 Merge branch 'verify-fmtmsg-includes' into 'master'
verify fmtmsg header includes

See merge request redox-os/relibc!1372
2026-05-21 06:48:01 -06:00
Jeremy Soller 01affff361 Merge branch 'verify-float-includes' into 'master'
verify float header includes

See merge request redox-os/relibc!1371
2026-05-21 06:47:45 -06:00
Jeremy Soller afb190e630 Merge branch 'glib-strftime' into 'master'
Add %x support to strftime

See merge request redox-os/relibc!1370
2026-05-21 06:46:12 -06:00
Jeremy Soller ab841f060d Merge branch 'systypes-keyt' into 'master'
add key_t to sys_types, cleanup sys_ipc and sys_shm

See merge request redox-os/relibc!1369
2026-05-21 06:45:12 -06:00
Jeremy Soller fca9c62654 Merge branch 'ebadf-epoll' into 'master'
Workaround epoll edge cases

See merge request redox-os/relibc!1368
2026-05-21 06:43:39 -06:00
auronandace 301c57d465 remove sys_types from sys_timeb header includes 2026-05-21 13:29:46 +01:00
auronandace 4341a11f51 clean up sys_syscall header 2026-05-21 12:30:13 +01:00
auronandace ab3538e259 verify threads header includes 2026-05-21 11:51:35 +01:00
auronandace 22ee588ead verify fmtmsg header includes 2026-05-21 11:28:05 +01:00
auronandace d14051e550 verify float header includes 2026-05-21 10:11:27 +01:00
auronandace 402ceb1c95 cargo fmt 2026-05-21 08:56:18 +01:00
auronandace 613ff4b860 add key_t to sys_types, cleanup sys_ipc and sys_shm 2026-05-21 08:50:15 +01:00
Wildan M c4924fba79 Workaround epoll edge cases 2026-05-21 11:06:54 +07:00
Wildan M 90676dcf04 Add %x support to strftime 2026-05-21 06:52:01 +07:00
Jeremy Soller e3514fa329 Merge branch 'shm' into 'master'
Implement key_t, sys/ipc and sys/shm

See merge request redox-os/relibc!1367
2026-05-20 10:11:58 -06:00
Wildan M 49c2eac09b Add cpp concat to sys/shm 2026-05-20 17:58:49 +02:00
Jeremy Soller 402de99e9f Merge branch 'fcntl-doc' into 'master'
add descriptions to fcntl constants

See merge request redox-os/relibc!1366
2026-05-20 07:29:03 -06:00
Jeremy Soller 647de7467b Merge branch 'endian-docs' into 'master'
add descriptions to endian functions

See merge request redox-os/relibc!1365
2026-05-20 07:28:58 -06:00
Jeremy Soller 49489023e5 Merge branch 'aarch64user-struct' into 'master'
remove function struct export workaround for aarch64_user header

See merge request redox-os/relibc!1364
2026-05-20 07:28:25 -06:00
Jeremy Soller 1313829e86 Merge branch 'archriscvuser-struct' into 'master'
remove function struct export from arch_riscv64_user header

See merge request redox-os/relibc!1363
2026-05-20 07:28:08 -06:00
Jeremy Soller 6ef45672d1 Merge branch 'fix-fstatat' into 'master'
fix: Fix fstatat by passing O_PATH when calling openat2

See merge request redox-os/relibc!1362
2026-05-20 06:29:10 -06:00
Jeremy Soller 0e51021c56 Merge branch 'no-cast' into 'master'
Avoid StringWriter cast and string format

See merge request redox-os/relibc!1361
2026-05-20 06:28:45 -06:00
Wildan M ad443944f3 Add sys/types to sys_shm, fix guard names 2026-05-20 19:22:54 +07:00
Wildan M bc6ea5ba99 Implement key_t, sys/ipc and sys/shm 2026-05-20 18:51:53 +07:00
auronandace 1bd574eb80 add descriptions to fcntl constants 2026-05-20 11:30:15 +01:00
auronandace cdf4fd1d71 add descriptions to endian functions 2026-05-20 09:35:35 +01:00
auronandace f232f33329 remove function struct export workaround for aarch64_user header 2026-05-20 08:07:29 +01:00
auronandace d70761cbfb remove function struct export from arch_riscv64_user header 2026-05-20 07:44:58 +01:00
Ibuki.O 0e2f24125a fix: Fix fstatat by passing O_PATH when calling openat2 2026-05-20 12:11:11 +09:00
Wildan M 4a7f2d80ff Avoid StringWriter cast and string format 2026-05-20 09:10:25 +07:00
Jeremy Soller b07babc03c Merge branch 'sysexits-rust' into 'master'
move sysexits header from C to Rust

See merge request redox-os/relibc!1359
2026-05-19 14:51:35 -06:00
auronandace a7b7e8dd27 move sysexits header from C to Rust 2026-05-19 15:20:49 +01:00
Jeremy Soller d2f9e53caa Merge branch 'x64user-struct' into 'master'
remove function struct export workaround for arch_x64_user header

See merge request redox-os/relibc!1358
2026-05-19 07:54:03 -06:00
auronandace fd0792aa93 remove function struct export workaround for arch_x64_user header 2026-05-19 14:24:25 +01:00
Jeremy Soller b11453423d Merge branch 'fcntl-fix' into 'master'
add stdio to fcntl includes for constants

See merge request redox-os/relibc!1357
2026-05-19 07:14:27 -06:00
Jeremy Soller 9bfc1a4867 Merge branch 'semaphore-fix' into 'master'
add bits_clockid_t to after_includes

See merge request redox-os/relibc!1356
2026-05-19 07:00:35 -06:00
auronandace 437528a10c add stdio to fcntl includes for constants 2026-05-19 13:54:03 +01:00
auronandace 33408eddb0 add bits_clockid_t to after_includes 2026-05-19 13:35:25 +01:00
Jeremy Soller 87e9cb656d Merge branch 'elfh' into 'master'
Fix elf.h by including stdint.h

See merge request redox-os/relibc!1354
2026-05-19 06:03:32 -06:00
Jeremy Soller e6fceb9dd1 Merge branch 'static-assert' into 'master'
Implement static_assert

See merge request redox-os/relibc!1355
2026-05-19 06:03:05 -06:00
Jeremy Soller 34984cf3d9 Merge branch 'setjmp' into 'master'
Move sigsetjmp and siglongjmp to setjmp.h

See merge request redox-os/relibc!1353
2026-05-19 06:02:09 -06:00
Jeremy Soller 05d4015b81 Merge branch 'ssize-limits' into 'master'
Include ssize_t for limits.h

See merge request redox-os/relibc!1352
2026-05-18 18:57:47 -06:00
Jeremy Soller d9075b9392 Merge branch 'resource-h' into 'master'
Fix sys/resource.h by avoiding stdint

See merge request redox-os/relibc!1351
2026-05-18 17:02:24 -06:00
Jeremy Soller 96f63879c7 Merge branch 'unistd-systypes' into 'master'
remove sys_types from unistd header

See merge request redox-os/relibc!1350
2026-05-18 16:52:50 -06:00
Jeremy Soller 190c8f077d Merge branch 'alarm_fix' into 'master'
Alarm fix

See merge request redox-os/relibc!1349
2026-05-18 16:52:05 -06:00
David Finder 1dbc61932a Alarm fix 2026-05-18 16:52:04 -06:00
auronandace b57f14f14e remove sys_types from unistd header 2026-05-18 20:35:37 +01:00
Jeremy Soller b2cbdf98f8 Merge branch 'docs_spelling' into 'master'
docs: fixed minor grammatical errors

See merge request redox-os/relibc!1348
2026-05-18 12:32:16 -06:00
Jeremy Soller c05d2f8c6b Merge branch 'split-usecondst' into 'master'
split out useconds_t from sys_types header

See merge request redox-os/relibc!1343
2026-05-18 12:30:55 -06:00
Jeremy Soller bf303ecfdc Merge branch 'sysprocfs-structs' into 'master'
remove function struct export workaround for sys_procfs header

See merge request redox-os/relibc!1347
2026-05-18 12:30:22 -06:00
Jeremy Soller 8c1512b9c6 Merge branch 'netinettcp-doc' into 'master'
add descriptions to netinet_tcp constants

See merge request redox-os/relibc!1346
2026-05-18 12:30:19 -06:00
Jeremy Soller 119aa9eec5 Merge branch 'sysmman-systypes' into 'master'
remove sys_types from sys_mman header

See merge request redox-os/relibc!1345
2026-05-18 12:30:15 -06:00
Jeremy Soller cfbfbb6507 Merge branch 'verify-fcntl-includes' into 'master'
verify fcntl header includes

See merge request redox-os/relibc!1344
2026-05-18 12:30:13 -06:00
Jeremy Soller b045e73d79 Merge branch 'dirent-systypes' into 'master'
remove sys_types from dirent header

See merge request redox-os/relibc!1342
2026-05-18 12:30:12 -06:00
Wildan M ff56dc9b74 Implement static_assert 2026-05-18 21:56:54 +07:00
Wildan M 36af0d41a0 Fix elf.h by including stdint.h 2026-05-18 21:55:46 +07:00
Vera 00662ebaa0 docs: fixed minor grammatical errors 2026-05-18 08:29:50 -04:00
Wildan M f731a20e02 Move sigsetjmp and siglongjmp to setjmp.h 2026-05-18 19:03:11 +07:00
auronandace 6f88ad9b80 remove function struct export workaround for sys_procfs header 2026-05-18 11:25:39 +01:00
Wildan M aaf2e492cc Include ssize_t for limits.h 2026-05-18 17:11:40 +07:00
auronandace 6d3dea6a1d add descriptions to netinet_tcp constants 2026-05-18 10:48:15 +01:00
auronandace a12baf3858 remove sys_types from sys_mman header 2026-05-18 10:21:00 +01:00
auronandace cd84da629c verify fcntl header includes 2026-05-18 09:51:23 +01:00
Wildan M a222fe84bf Fix sys/resource.h by avoiding stdint 2026-05-18 15:29:44 +07:00
auronandace 9862397f7c cargo fmt 2026-05-18 08:44:14 +01:00
auronandace 430aa6f584 split out useconds_t from sys_types header 2026-05-18 08:38:10 +01:00
auronandace 151cb35a3f remove sys_types from dirent header 2026-05-18 07:38:36 +01:00
Jeremy Soller 6dc57272a7 Merge branch 'rpath' into 'master'
Fix rpath not loaded

See merge request redox-os/relibc!1341
2026-05-17 06:17:12 -06:00
Jeremy Soller b16aebd794 Merge branch 'sysstat-systypes' into 'master'
remove sys_types from sys_stat header

See merge request redox-os/relibc!1340
2026-05-17 06:16:21 -06:00
Jeremy Soller dd5e6f8e0d Merge branch 'split-reclent' into 'master'
split out reclen_t from sys_types header

See merge request redox-os/relibc!1339
2026-05-17 06:15:14 -06:00
Wildan M 0b430660b7 Fix rpath not loaded 2026-05-17 08:09:53 +07:00
auronandace 9dd41b283c remove sys_types from sys_stat header 2026-05-16 17:24:51 +01:00
auronandace 4dd3c2ea70 split out reclen_t from sys_types header 2026-05-16 16:55:53 +01:00
Jeremy Soller 291b6991ce Merge branch 'split-nlinkt' into 'master'
split out nlink_t from sys_types header

See merge request redox-os/relibc!1338
2026-05-16 09:34:58 -06:00
auronandace dbe84f1503 split out nlink_t from sys_types header 2026-05-16 07:59:43 +01:00
Jeremy Soller 086f4c9a47 Merge branch 'split-devt' into 'master'
split out dev_t from sys_types header

See merge request redox-os/relibc!1337
2026-05-15 14:25:30 -06:00
auronandace ff923f2b9a split out dev_t from sys_types header 2026-05-15 20:26:24 +01:00
Jeremy Soller 3a5b482db1 Merge branch 'time-systypes' into 'master'
remove sys_types from time header includes

See merge request redox-os/relibc!1336
2026-05-15 08:33:13 -06:00
Jeremy Soller 8751cbc35e Merge branch 'syswait-systypes' into 'master'
remove sys_types from the sys_wait header includes

See merge request redox-os/relibc!1335
2026-05-15 08:33:09 -06:00
Jeremy Soller 48aa0241f3 Merge branch 'sysstat-bits' into 'master'
split out blkcnt_t and blksize_t from sys_types header

See merge request redox-os/relibc!1334
2026-05-15 08:33:09 -06:00
auronandace 933190e37c remove sys_types from time header includes 2026-05-15 14:58:20 +01:00
auronandace 3eb7d8b7f5 remove sys_types from the sys_wait header includes 2026-05-15 14:23:17 +01:00
auronandace eca687759a split out blkcnt_t and blksize_t from sys_types header 2026-05-15 13:49:10 +01:00
Jeremy Soller f7594af753 Merge branch 'systimes-systypes' into 'master'
remove sys_types from sys_times includes

See merge request redox-os/relibc!1332
2026-05-15 06:27:08 -06:00
Jeremy Soller a339431940 Merge branch 'elf-structs' into 'master'
eliminate struct export function workaround for elf header

See merge request redox-os/relibc!1331
2026-05-15 06:26:49 -06:00
Jeremy Soller d89bd7f143 Merge branch 'signal-systypes' into 'master'
remove sys_types header from signal header includes

See merge request redox-os/relibc!1330
2026-05-15 06:26:34 -06:00
Jeremy Soller 16284c7165 Merge branch 'split-timert' into 'master'
split out timer_t from sys_types

See merge request redox-os/relibc!1329
2026-05-15 06:26:02 -06:00
auronandace 927f912f58 remove export rename 2026-05-15 11:33:31 +01:00
auronandace f91ca7c0d2 remove sys_types from sys_times includes 2026-05-15 11:27:07 +01:00
auronandace 4e24bab4dd eliminate struct export function workaround for elf header 2026-05-15 09:35:30 +01:00
auronandace a9bb695f2f add features.h to includes 2026-05-15 08:57:32 +01:00
auronandace ece3044fe8 include types in correct order 2026-05-15 08:51:33 +01:00
auronandace b74eec62d4 remove sys_types header from signal header includes 2026-05-15 08:42:31 +01:00
auronandace 08b6bba666 split out timer_t from sys_types 2026-05-15 07:46:49 +01:00
bjorn3 5e0867eae0 Merge branch 'drm15' into 'master'
Fix DRM_IOCTL_MODE_SETPLANE and add DRM_IOCTL_MODE_CLOSEFB

See merge request redox-os/relibc!1328
2026-05-14 19:20:57 +00:00
bjorn3 0ae5d24a62 Add DRM_IOCTL_MODE_CLOSEFB 2026-05-14 20:55:51 +02:00
bjorn3 1d7820beac Add missing mapping for DRM_IOCTL_MODE_SETPLANE 2026-05-14 20:55:12 +02:00
Jeremy Soller 546bc6fb21 Merge branch 'drm14' into 'master'
Add support for DRM_IOCTL_MODE_ADDFB2

See merge request redox-os/relibc!1327
2026-05-14 06:10:57 -06:00
bjorn3 d0975d28bb Add support for DRM_IOCTL_MODE_ADDFB2 2026-05-14 12:01:15 +02:00
Jeremy Soller 83d89ab294 Merge branch 'drm13' into 'master'
Handle DRM_IOCTL_GET_UNIQUE and DRM_IOCTL_SET_VERSION

See merge request redox-os/relibc!1326
2026-05-13 15:02:54 -06:00
bjorn3 d047295496 Handle DRM_IOCTL_GET_UNIQUE and DRM_IOCTL_SET_VERSION 2026-05-13 22:56:15 +02:00
Jeremy Soller 578fd3c4a6 Merge branch 'split-inot' into 'master'
split out ino_t from sys_types header

See merge request redox-os/relibc!1325
2026-05-13 08:52:31 -06:00
auronandace dfd2dd7306 split out ino_t from sys_types header 2026-05-13 15:33:05 +01:00
Jeremy Soller a832420e76 Merge branch 'threads-features' into 'master'
Fix threads includes and gnu-binutils compilation

See merge request redox-os/relibc!1324
2026-05-13 08:20:31 -06:00
auronandace 14daa9b6d6 threads should include time header according to spec 2026-05-13 15:01:32 +01:00
auronandace fdfab223c5 fix threads header and gnu-binutils compilation 2026-05-13 14:56:46 +01:00
Jeremy Soller 668702ad08 Merge branch 'inode-cache' into 'master'
Remove ld.so cache

See merge request redox-os/relibc!1323
2026-05-13 07:43:17 -06:00
Wildan M 519bc8ebc8 Remove ld.so cache 2026-05-13 07:11:36 +07:00
Jeremy Soller b3f9587a99 Merge branch 'dlfcn-struct' into 'master'
eliminate function struct export in dlfcn header

See merge request redox-os/relibc!1321
2026-05-12 14:08:34 -06:00
auronandace 3c5d474000 eliminate function struct export in dlfcn header 2026-05-12 17:22:53 +01:00
Jeremy Soller f0f46540db Merge branch 'statvfs-bits' into 'master'
remove sys_types from sys_statvfs header

See merge request redox-os/relibc!1320
2026-05-12 10:15:34 -06:00
auronandace 2e6db7fb87 fix typo 2026-05-12 16:45:02 +01:00
auronandace fa6ef5d495 remove sys_types from sys_statvfs header 2026-05-12 16:36:25 +01:00
Jeremy Soller 6b307d2cd5 Merge branch 'inttypes-includes' into 'master'
remove wchar header from inttypes includes

See merge request redox-os/relibc!1319
2026-05-12 09:10:52 -06:00
Jeremy Soller 8fb8a134ec Parse last 0 as number instead of radix 2026-05-12 08:54:02 -06:00
auronandace 7df33d647c remove wchar header from inttypes includes 2026-05-12 15:46:26 +01:00
Jeremy Soller fd376c45fe Merge branch 'split-modet' into 'master'
split out mode_t type from sys_types header

See merge request redox-os/relibc!1318
2026-05-12 08:36:06 -06:00
auronandace 7692c2776c split out mode_t type from sys_types header 2026-05-12 14:58:50 +01:00
Jeremy Soller ed2704185f Merge branch 'syssocket-systypes' into 'master'
remove sys_types from sys_socket header

See merge request redox-os/relibc!1317
2026-05-12 07:33:18 -06:00
Jeremy Soller 5dd09a1b70 Merge branch 'wchar-to-stddef' into 'master'
move wchar_t to stddef header

See merge request redox-os/relibc!1316
2026-05-12 07:33:11 -06:00
Jeremy Soller e4eb6e36d4 Merge branch 'signal-structs' into 'master'
remove function struct export workarounds for signal header

See merge request redox-os/relibc!1315
2026-05-12 06:27:05 -06:00
Jeremy Soller 6727d93fab Merge branch 'stdio-systypes' into 'master'
remove sys_types from stdio header

See merge request redox-os/relibc!1314
2026-05-12 06:26:44 -06:00
Jeremy Soller c3a364dea6 Merge branch 'split-clockidt' into 'master'
split out clockid_t type from sys_types

See merge request redox-os/relibc!1313
2026-05-12 06:26:27 -06:00
Jeremy Soller 04a5cc222a Merge branch 'sysresource-systypes' into 'master'
remove sys_types from sys_resource header

See merge request redox-os/relibc!1312
2026-05-12 06:26:10 -06:00
Jeremy Soller a44884b498 Merge branch 'pwd-systypes' into 'master'
remove sys_types from pwd header

See merge request redox-os/relibc!1311
2026-05-12 06:25:53 -06:00
auronandace 84c2bd5ae2 remove sys_types from sys_socket header 2026-05-12 12:03:55 +01:00
auronandace 3d16b8a1b8 move wchar_t to stddef header 2026-05-12 11:09:23 +01:00
auronandace 86c870a274 remove function struct export workarounds for signal header 2026-05-12 10:22:08 +01:00
auronandace a9cd9986e6 remove sys_types from stdio header 2026-05-12 09:33:56 +01:00
auronandace a93aab03a5 cargo fmt 2026-05-12 08:51:36 +01:00
auronandace 9cf02d7a83 correct use statement for mode_t 2026-05-12 08:45:39 +01:00
auronandace 4f353e886e split out clockid_t type from sys_types 2026-05-12 08:30:02 +01:00
auronandace d3f1b588b7 remove sys_types from sys_resource header 2026-05-12 08:02:41 +01:00
auronandace c0f0fb3c94 remove sys_types from pwd header 2026-05-12 07:13:25 +01:00
Jeremy Soller aaaabaded3 Merge branch 'split-idt' into 'master'
split out id_t from sys_types

See merge request redox-os/relibc!1308
2026-05-11 10:30:37 -06:00
auronandace 74ca9e661a split out id_t from sys_types 2026-05-11 15:20:20 +01:00
Jeremy Soller 76225b5e71 Merge branch 'systime-systypes' into 'master'
remove sys_types from sys_time header

See merge request redox-os/relibc!1307
2026-05-11 07:56:04 -06:00
Jeremy Soller ac410f0ee0 Merge branch 'split-clockt' into 'master'
split out clock_t from sys_types

See merge request redox-os/relibc!1306
2026-05-11 07:43:35 -06:00
auronandace c75654bcae remove sys_types from sys_time header 2026-05-11 14:38:51 +01:00
auronandace bd505d3451 split out clock_t from sys_types 2026-05-11 14:03:16 +01:00
Jeremy Soller 1b6bd3700b Merge branch 'pthread-docs' into 'master'
Document all pthread functions

See merge request redox-os/relibc!1305
2026-05-11 06:15:24 -06:00
Jeremy Soller ad3922bc57 Merge branch 'threads.h-impl' into 'master'
implement threads.h

See merge request redox-os/relibc!1301
2026-05-11 06:13:43 -06:00
Jeremy Soller 0178452e11 Merge branch 'pkey-del' into 'master'
Fix EINVAL at pthread_key_delete

See merge request redox-os/relibc!1304
2026-05-11 06:12:21 -06:00
Jeremy Soller 11d6067ba2 Merge branch 'heapless-nproc' into 'master'
Make get_cpu_count heapless

See merge request redox-os/relibc!1302
2026-05-11 06:08:06 -06:00
Jeremy Soller c249f9a5ac Merge branch 'utimes-ub' into 'master'
Fix UB in utimes and write test

See merge request redox-os/relibc!1303
2026-05-11 06:01:39 -06: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
Jeremy Soller 456636dce1 Merge branch 'split-uidt' into 'master'
split out uid_t from sys_types

See merge request redox-os/relibc!1299
2026-05-10 13:48:49 -06:00
Jeremy Soller ddf9dd6c94 Merge branch 'grp-systypes' into 'master'
remove sys_types from grp header

See merge request redox-os/relibc!1298
2026-05-10 13:48:28 -06:00
Jeremy Soller 87048c3b9a Merge branch 'sched-systypes' into 'master'
remove sys_types from sched header

See merge request redox-os/relibc!1297
2026-05-10 13:48:11 -06:00
Jeremy Soller 4adbc77f2f Merge branch 'llvm-memalign' into 'master'
Revert 292fd9e to fix LLVM allocation issue

See merge request redox-os/relibc!1300
2026-05-10 13:47:21 -06:00
auronandace a365dbeda4 split out uid_t from sys_types 2026-05-10 16:28:22 +01:00
auronandace 4f2059cae7 remove sys_types from grp header 2026-05-10 15:51:37 +01:00
auronandace 3d0a7aad4d remove sys_types from sched header 2026-05-10 15:21:19 +01:00
Jeremy Soller 8d9da76434 Merge branch 'syssocket-structs' into 'master'
remove struct export workaround from sys_socket

See merge request redox-os/relibc!1296
2026-05-10 06:53:29 -06:00
Wildan M 74d34ca6e0 Add test for EPOLL_CTL_DEL 2026-05-10 18:02:57 +07:00
auronandace b6ba69febb remove struct export workaround from sys_socket 2026-05-10 08:33:38 +01:00
Wildan M 58537615bf Document all pthread functions 2026-05-10 14:08:41 +07:00
Wildan M d9e1c69f5b Fix EINVAL at pthread_key_delete 2026-05-10 13:45:04 +07:00
Wildan M 19da3a5551 Fix UB in utimes and write test 2026-05-10 08:05:05 +07:00
Wildan M d1e33f1386 Make get_cpu_count heapless 2026-05-10 06:43:26 +07:00
Wildan M 799cca048f Revert 292fd9e to fix LLVM allocation issue 2026-05-10 03:45:59 +07:00
Jeremy Soller d51e7c817b Merge branch 'termios-systypes' into 'master'
replace sys_types with bits for termios

See merge request redox-os/relibc!1295
2026-05-09 13:23:27 -06:00
Jeremy Soller 64e5ddf978 Merge branch 'split-gidt' into 'master'
split out gid_t from sys_types

See merge request redox-os/relibc!1294
2026-05-09 13:23:11 -06:00
auronandace 366215347a replace sys_types with bits for termios 2026-05-09 19:14:20 +01:00
auronandace 71ab39f9e6 split out gid_t from sys_types 2026-05-09 18:30:35 +01:00
Jeremy Soller 25cbce4098 Merge branch 'test-race' into 'master'
Fix possible signal race in tests

See merge request redox-os/relibc!1293
2026-05-09 09:01:08 -06:00
Jeremy Soller 1df573f017 Merge branch 'split-pidt' into 'master'
split out pid_t from sys_types

See merge request redox-os/relibc!1292
2026-05-09 08:00:22 -06:00
Jeremy Soller fde7321945 Merge branch 'libm-rel' into 'master'
Fix libm rust feature not emitted

See merge request redox-os/relibc!1291
2026-05-09 07:59:55 -06:00
Jeremy Soller 852eac9ac5 Merge branch 'sysuio-systypes' into 'master'
remove sys_types from sys_uio and bits_iovec

See merge request redox-os/relibc!1290
2026-05-09 07:58:05 -06:00
auronandace 5e922ac626 split out pid_t from sys_types 2026-05-09 14:33:10 +01:00
Jeremy Soller e8e9aa61f7 Merge branch 'glob-sizet' into 'master'
remove stddef header from glob

See merge request redox-os/relibc!1289
2026-05-09 07:12:06 -06:00
auronandace b60f77d7a0 remove sys_types from sys_uio and bits_iovec 2026-05-09 14:03:48 +01:00
Jeremy Soller a0a8629f17 Merge branch 'sysresource-constants' into 'master'
move sys_resource constants from cbindgen to rust

See merge request redox-os/relibc!1288
2026-05-09 06:21:52 -06:00
Jeremy Soller 45749ad101 Merge branch 'posix-dent-export' into 'master'
eliminate function export struct workaround for posix_dent

See merge request redox-os/relibc!1287
2026-05-09 06:21:35 -06:00
Jeremy Soller 1c7faca624 Merge branch 'regex-systypes' into 'master'
replace sys_types include in regex header with bits

See merge request redox-os/relibc!1286
2026-05-09 06:20:31 -06:00
Jeremy Soller c9ab8f8676 Merge branch 'monetary-systypes' into 'master'
replace sys_types include in monetary header with bits

See merge request redox-os/relibc!1285
2026-05-09 06:20:10 -06:00
Jeremy Soller 2c2bab1955 Merge branch 'split-offt' into 'master'
split out off_t from sys_types_internal

See merge request redox-os/relibc!1284
2026-05-09 06:18:51 -06:00
auronandace da8de4b034 remove stddef header from glob 2026-05-09 13:15:34 +01:00
Jeremy Soller 501394aa42 Merge branch 'nice' into 'master'
Implement nice and write test

See merge request redox-os/relibc!1283
2026-05-09 06:15:34 -06:00
auronandace 5b29140b29 move sys_resource constants from cbindgen to rust 2026-05-09 12:40:39 +01:00
auronandace 1b7a84633e eliminate function export struct workaround for posix_dent 2026-05-09 12:09:33 +01:00
auronandace aa52ed1bcc replace sys_types include in regex header with bits 2026-05-09 08:30:02 +01:00
auronandace 8e9b2837cc replace sys_types include in monetary header with bits 2026-05-09 07:45:22 +01:00
auronandace 8e1881c3cc split out off_t from sys_types_internal 2026-05-09 07:11:29 +01:00
Wildan M 2c23024245 Fix possible signal race in tests 2026-05-09 11:14:19 +07:00
Wildan M 27727d28a8 Fix libm rust feature not emitted 2026-05-09 09:47:14 +07:00
Wildan M c15059e205 Workaround nice test hit the ceiling 2026-05-09 05:48:45 +07:00
Wildan M e9c3960c65 Implement nice and write test 2026-05-09 01:23:37 +07:00
Jeremy Soller 3caae5a009 Merge branch 'split-sizet' into 'master'
split out size_t from stddef header

See merge request redox-os/relibc!1282
2026-05-08 08:35:35 -06:00
auronandace dc28f2faef split out sizt_t from stddef header 2026-05-08 14:59:27 +01:00
Jeremy Soller 4596d71bf5 Merge branch 'eliminate-flock-workaround' into 'master'
eliminate function export workaround for flock struct

See merge request redox-os/relibc!1281
2026-05-08 06:58:00 -06:00
Jeremy Soller 00a90eab57 Merge branch 'expect-simplify' into 'master'
Simplify expect files

See merge request redox-os/relibc!1280
2026-05-08 06:30:21 -06:00
Jeremy Soller 90fc985806 Merge branch 'eliminate-timeval-function' into 'master'
eliminate cbindgen export function workaround for timeval struct

See merge request redox-os/relibc!1279
2026-05-08 06:29:41 -06:00
Jeremy Soller a4b536fdcb Merge branch 'netinet-in-systypes' into 'master'
remove sys_types from netinet_in

See merge request redox-os/relibc!1278
2026-05-08 06:29:24 -06:00
Jeremy Soller 45f9484fd2 Merge branch 'split-ssizet' into 'master'
split out ssize_t from sys_types

See merge request redox-os/relibc!1277
2026-05-08 06:27:21 -06:00
Jeremy Soller dbb4a1efa4 Merge branch 'include-guards' into 'master'
disamiguate include guards for arpa_inet and sys_time

See merge request redox-os/relibc!1276
2026-05-08 06:26:45 -06:00
auronandace 71427e3594 eliminate function export workaround for flock struct 2026-05-08 13:21:20 +01:00
auronandace 5c131dc037 eliminate cbindgen export function workaround for timeval struct 2026-05-08 12:30:55 +01:00
Wildan M e9f8b0c697 Merge expect files 2026-05-08 17:57:18 +07:00
Wildan M 796b1d8ef5 Remove empty stderr expect 2026-05-08 17:48:25 +07:00
auronandace 4ef52218f1 remove sys_types from netinet_in 2026-05-08 11:47:56 +01:00
auronandace 4cb1ab3a2e acutally include ssize_t in sys_types_internal 2026-05-08 09:58:13 +01:00
auronandace ed488b71dc split out ssize_t from sys_types 2026-05-08 09:49:06 +01:00
auronandace c75c13da91 disamiguate include guards for arpa_inet and sys_time 2026-05-08 07:54:05 +01:00
Jeremy Soller f35df25195 Merge branch 'master' into 'master'
Fix many clippy lints

See merge request redox-os/relibc!1226
2026-05-07 06:06:20 -06: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
Jeremy Soller eebd41a187 Merge branch 'smp-ci' into 'master'
Enable SMP for testing

See merge request redox-os/relibc!1273
2026-05-06 13:01:07 -06:00
Jeremy Soller fc8947006b Merge branch 'verify-syswait-includes' into 'master'
verify sys_wait header includes

See merge request redox-os/relibc!1275
2026-05-06 06:18:15 -06:00
Jeremy Soller 4be86efdfa Merge branch 'fnmatch-doc' into 'master'
add documentation for fnmatch

See merge request redox-os/relibc!1274
2026-05-06 06:16:33 -06:00
Jeremy Soller 519fea47cc Merge branch 'iovec-cleanup' into 'master'
eliminate export function for struct iovec

See merge request redox-os/relibc!1272
2026-05-06 06:15:48 -06:00
Jeremy Soller 3c90d97a2a Merge branch 'timespec-cleanup' into 'master'
eliminate export function struct workaround for timespec

See merge request redox-os/relibc!1271
2026-05-06 06:14:35 -06:00
auronandace d1ff2d0a0a verify sys_wait header includes 2026-05-06 12:26:40 +01:00
auronandace b09b1fb0c7 add documentation for fnmatch 2026-05-06 11:42:12 +01:00
auronandace e1d26137b4 eliminate export function for struct iovec 2026-05-06 08:57:33 +01:00
auronandace b8a767fced eliminate export function struct workaround for timespec 2026-05-06 08:17:26 +01:00
Jeremy Soller a5f0d0c918 Merge branch 'redundant-syscall-removal' into 'master'
Remove redundant code and impl them in terms of *at functions

See merge request redox-os/relibc!1269
2026-05-05 14:52:24 -06:00
Connor-GH e2486379b1 Remove redundant code and impl them in terms of *at functions
The following functions were replaced with their *at variants or
similar:
- lstat -> lstat -> fstatat
- stat -> stat -> fstatat
- fstat -> fstatat
- fchmod -> fchmodat
- fchown -> fchownat
- lchown -> fchownat
- mkfifo -> mkfifoat
- open -> openat
- renameat -> renameat2
- rmdir -> unlinkat
- unlink -> unlinkat
- symlink-> symlinkat

The `open_flags` logic for fstatat was redundant, as this is already
handled (and better so) in `openat2`.

Additionally, the fstatat test succeeds in os-test, and no longer
returns EINVAL. This is because `O_SYMLINK` is no longer
unconditionally passed like it was before. This is a problem because
redoxfs returns EINVAL if a node isn't a symlink but set `O_SYMLINK`.
2026-05-05 15:30:46 -05:00
Jeremy Soller 5312b86ee5 Merge branch 'fix-semaphore' into 'master'
include fcntl in semaphore header to fix includes

See merge request redox-os/relibc!1267
2026-05-05 11:49:13 -06:00
Jeremy Soller f500e637c3 Merge branch 'utimensat' into 'master'
add utimensat

See merge request redox-os/relibc!1268
2026-05-05 11:49:05 -06:00
Wildan M fd9faac62d Enable SMP for testing 2026-05-05 23:00:21 +07:00
Connor-GH 03103893ef add utimensat
This addition removes duplicated code and also passes an os-test.

The `AT_EMPTY_PATH` duplicated code will be taken care of in the future.
2026-05-05 10:42:32 -05:00
auronandace aae576b4a0 include fcntl in semaphore header to fix includes 2026-05-05 16:00:24 +01:00
Jeremy Soller ad4fa52f96 Merge branch 'unified-alarm' into 'master'
Unify alarm implementation

See merge request redox-os/relibc!1266
2026-05-05 07:07:08 -06:00
Jeremy Soller 518b597082 Merge branch 'preaslr' into 'master'
Link Scrt1 to crt0 for linux relibc

See merge request redox-os/relibc!1265
2026-05-05 06:44:10 -06:00
Jeremy Soller 4137ac1d8a Merge branch 'qsort_r' into 'master'
Implement qsort_r

See merge request redox-os/relibc!1264
2026-05-05 06:42:28 -06:00
Jeremy Soller 2e7d1bdb60 Merge branch 'utimensat' into 'master'
Implement utimensat

See merge request redox-os/relibc!1263
2026-05-05 06:40:37 -06:00
Wildan M 90cb143523 Unify alarm implementation 2026-05-05 09:35:50 +07:00
Wildan M 39a1f7b223 Link Scrt1 to crt0 for linux relibc 2026-05-05 06:56:00 +07:00
Wildan M 5c253e3cc8 Implement qsort_r 2026-05-05 02:54:17 +07:00
Jeremy Soller 6b3ba5b2d9 Merge branch 'fix-chmod-regression' into 'master'
fix test regression caused by !1250

See merge request redox-os/relibc!1262
2026-05-04 13:40:22 -06:00
Connor-GH 1016fdf01e fix test regression caused by !1250
MR https://gitlab.redox-os.org/redox-os/relibc/-/merge_requests/1250 was
done in order to try and patch out an `EINVAL` error, and it was
successful in doing so. Unfortunately, fixing one failure caused
another.

I will continue to do what I can to make relibc's FS layer and redoxFS
smaller, as they have way too much duplicated code.
2026-05-04 14:20:02 -05:00
Wildan M 7aba041004 Implement utimensat 2026-05-05 02:02:43 +07:00
Jeremy Soller 36d2efa334 Merge branch 'more-redox-pal-cleanups' into 'master'
platform/redox: migrate more functions to use their *at variants

See merge request redox-os/relibc!1261
2026-05-04 11:48:45 -06:00
Connor-GH cf65eedbaf platform/redox: migrate more functions to use their *at variants
Additionally, this adds the `SYMLOOP_MAX` constant in `limits.h` to
replace the `MAX_LEVEL` magic number used during symlink resolution.

`fstat` was kept because it is more difficult than the others to do a
drop-in replacement in terms of `fstatat` for since a naive approach
would cause mutual recursion.
2026-05-04 11:44:53 -05:00
Jeremy Soller 5b6b2a3f17 Merge branch 'split-timeval' into 'master'
split out timeval to reduce namespace pollution

See merge request redox-os/relibc!1260
2026-05-04 09:14:32 -06:00
auronandace f6f4d8f71d export struct via function 2026-05-04 15:22:19 +01:00
auronandace 2dd36566de split out timeval to reduce namespace pollution 2026-05-04 15:05:30 +01:00
Jeremy Soller 4bff41fe78 Merge branch 'epoll-event-needless-update' into 'master'
address needless_update clippy lint for epoll_event

See merge request redox-os/relibc!1259
2026-05-04 07:32:44 -06:00
Jeremy Soller a93268f247 Merge branch 'split-susecondst' into 'master'
split out suseconds_t for namespace pollution reduction preparation

See merge request redox-os/relibc!1258
2026-05-04 07:07:24 -06:00
Jeremy Soller 17a4f143b4 Merge branch 'verify-time-includes' into 'master'
verify time header includes

See merge request redox-os/relibc!1257
2026-05-04 07:06:52 -06:00
auronandace 400448b011 address needless_update clippy lint for epoll_event 2026-05-04 14:05:41 +01:00
auronandace 1cd9d8769d split out suseconds_t for namespace pollution reduction preparation 2026-05-04 13:38:33 +01:00
auronandace 1edd7a63d7 verify time header includes 2026-05-04 09:05:32 +01:00
Jeremy Soller 76f5c6a882 Merge branch 'socklent-cleanup' into 'master'
import socklen_t from sys_socket instead of bits

See merge request redox-os/relibc!1256
2026-05-03 10:09:48 -06:00
auronandace 8cec0c2280 import socklen_t from sys_socket instead of bits 2026-05-03 16:54:46 +01:00
Jeremy Soller 9fd1da5d92 Merge branch 'linux' into 'master'
Add linux-relibc target support

See merge request redox-os/relibc!1255
2026-05-03 09:00:22 -06:00
Jeremy Soller 6c5435fcf8 Merge branch 'timespec-cleanup' into 'master'
import timespec from time rather than bits

See merge request redox-os/relibc!1254
2026-05-03 08:57:03 -06:00
auronandace 5ad5058324 fix typo 2026-05-03 14:43:34 +01:00
auronandace 05b8ffbcb7 import timespec from time rather than bits 2026-05-03 14:33:39 +01:00
Jeremy Soller 135753d0e6 Merge branch 'split-timet' into 'master'
Split timet

See merge request redox-os/relibc!1253
2026-05-03 06:20:16 -06:00
Jeremy Soller b16a00f7dd Merge branch 'type-write' into 'master'
Refactor internal timer to fix alarm test

See merge request redox-os/relibc!1236
2026-05-03 06:17:03 -06:00
auronandace 356d2e18d2 cargo fmt and fix clippy lints in fmtmsg 2026-05-03 08:35:29 +01:00
auronandace 8d2bcee829 split out time_t to prepare for reducing namespace pollution 2026-05-03 08:30:35 +01:00
Wildan M c72a9c276b Add linux-relibc target support 2026-05-03 07:07:44 +07:00
Wildan M ea667cdca1 Support disarming timer 2026-05-03 05:06:25 +07:00
Jeremy Soller fc0aa8471a Merge branch 'sigset-t' into 'master'
FIx sigjmp_buf and add tests

See merge request redox-os/relibc!1252
2026-05-02 16:06:21 -06:00
Wildan M 9188a9e354 Make timer_internal_t atomic 2026-05-03 05:02:29 +07:00
Wildan M d16dfade59 Use less cloning for timespec 2026-05-03 03:21:06 +07:00
Wildan M 7b0354ca3d Use type casts for timespec conversion 2026-05-03 03:09:52 +07:00
Jeremy Soller 08fc95fce2 Merge branch 'epoll-types' into 'master'
Fix types for sys/epoll

See merge request redox-os/relibc!1251
2026-05-02 07:55:32 -06:00
Wildan M 043ec22076 FIx sigjmp_buf and add tests 2026-05-02 16:59:48 +07:00
Wildan M 64911d582f Fix types for sys/epoll 2026-05-02 15:02:41 +07:00
Jeremy Soller 397eb503ed Merge branch 'fchownat-openat2-fix' into 'master'
openat2: fix internal assumption causing EINVAL

See merge request redox-os/relibc!1250
2026-05-01 16:39:02 -06:00
Connor-GH 76d801f7cd openat2: fix internal assumption causing EINVAL
Inside of `openat2`, we are assuming that if we are passed
`AT_SYMLINK_NOFOLLOW` that we are also passed a symlink. This is simply
not the case, as POSIX defines the flag to only have a noticable effect
if the resolved path is a symlink. Therefore, we cannot assume that we
have a symlink if we see `AT_SYMLINK_NOFOLLOW`. The previous behavior
caused an `EINVAL` in redoxfs because we do a consistency check to
error out if we are passed `O_SYMLINK` (which was added because
`AT_SYMLINK_NOFOLLOW` was observed) and aren't a symlink.

Hmm, maybe a special errno like `ENOTLNK` should be deployed for this? It's
specific enough that it could possibly be added to a future POSIX.
2026-05-01 17:01:39 -05:00
Jeremy Soller 19d380f198 Merge branch 'misc-clippy-fixes' into 'master'
fix some lints caught by Clippy

See merge request redox-os/relibc!1248
2026-05-01 07:04:57 -06:00
Jeremy Soller 49a72d73c8 Merge branch 'fmtmsg-constants' into 'master'
add and document missing constants in fmtmsg

See merge request redox-os/relibc!1249
2026-05-01 07:04:32 -06:00
auronandace d057fdd40a add and document missing constants in fmtmsg 2026-05-01 13:39:45 +01:00
Mathew John Roberts 1ddc5e0da6 Merge branch 'fmtmsg' into 'master'
Add fmtmsg

See merge request redox-os/relibc!1125
2026-05-01 06:00:12 +01:00
Mustafa öz 03d56f4887 Add fmtmsg 2026-05-01 06:00:11 +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
Jeremy Soller c1912066a1 Merge branch 'poll-descriptions' into 'master'
add some descriptions for items in the poll header

See merge request redox-os/relibc!1247
2026-04-30 11:11:43 -06:00
Jeremy Soller 9629d50c89 Merge branch 'open-fix' into 'master'
Fix open permission and add umask test

See merge request redox-os/relibc!1246
2026-04-30 11:11:05 -06:00
Jeremy Soller 55d5d6048c Merge branch 'verify-sysselect-includes' into 'master'
verify sys_select header includes

See merge request redox-os/relibc!1245
2026-04-30 11:10:47 -06:00
Jeremy Soller 17736470c2 Merge branch 'verify-poll-includes' into 'master'
verify poll header includes

See merge request redox-os/relibc!1244
2026-04-30 11:10:37 -06:00
auronandace 524a9fb634 add some descriptions for items in the poll header 2026-04-30 10:29:28 +01:00
Wildan M 598d34d8a0 Fix open permission and add umask test 2026-04-30 16:08:05 +07:00
auronandace 6fafb81f02 verify sys_select header includes 2026-04-30 08:56:19 +01:00
auronandace e1b39d786f verify poll header includes 2026-04-30 08:23:05 +01:00
Jeremy Soller 702b9b9d82 Merge branch 'fchownat-uid-gid-negative-1' into 'master'
fchownat: fix behavior for uid == -1 && gid == -1

See merge request redox-os/relibc!1243
2026-04-29 14:28:27 -06:00
Connor-GH 22faf6b615 fchownat: fix behavior for uid == -1 && gid == -1
Previously, this would error with EINVAL since the conversion to
unsigned int would fail on -1. Now, we do a bitwise conversion via
an `as` cast.
2026-04-29 15:23:56 -05:00
Jeremy Soller 861bbb024a Merge branch 'split-sigset-t' into 'master'
split out sigset_t from signal header

See merge request redox-os/relibc!1242
2026-04-29 06:51:47 -06:00
Jeremy Soller 7747064459 Merge branch 'sys-utsname-tar' into 'master'
disambiguate include guards and export C strings

See merge request redox-os/relibc!1241
2026-04-29 06:51:06 -06:00
Jeremy Soller ad36f13c9a Merge branch 'mesa-strings' into 'master'
import strings header in string for mesa

See merge request redox-os/relibc!1240
2026-04-29 06:50:45 -06:00
Jeremy Soller 250d42880f Merge branch 'sys-stat-statvfs' into 'master'
disambiguate include guards for sys_stat and sys_statvfs

See merge request redox-os/relibc!1239
2026-04-29 06:46:41 -06:00
Jeremy Soller bb496ce10a Merge branch 'unistd-trailer' into 'master'
change unistd cbindgen trailer to after_includes

See merge request redox-os/relibc!1238
2026-04-29 06:40:59 -06:00
Jeremy Soller 70e49f0830 Merge branch 'getopt-cleanup' into 'master'
remove unused C header

See merge request redox-os/relibc!1237
2026-04-29 06:39:20 -06:00
auronandace 6a490be2c6 split out sigset_t from signal header 2026-04-29 12:29:43 +01:00
auronandace 323061f51c disambiguate include guards and export C strings 2026-04-29 10:36:13 +01:00
auronandace 4dfbb97a69 import strings header in string for mesa 2026-04-29 09:57:11 +01:00
auronandace d86583c1f5 disambiguate include guards for sys_stat and sys_statvfs 2026-04-29 09:01:50 +01:00
auronandace 88ac8e3f30 change unistd cbindgen trailer to after_includes 2026-04-29 08:30:55 +01:00
auronandace 798d929254 remove unused C header 2026-04-29 08:09:37 +01:00
Jeremy Soller a7961e69d7 Merge branch 'linking_cleanups' into 'master'
Couple of linking related cleanups

Closes #211

See merge request redox-os/relibc!1235
2026-04-28 10:15:21 -06:00
bjorn3 79b469f29d Remove support for _init and _fini in statically linked executables
These are legacy predecessors of .init_array/.fini_array. They were
already not supported by the dynamic linker.
2026-04-28 17:59:45 +02:00
bjorn3 e34b259822 Cleanup building of libc.so and ld.so 2026-04-28 17:16:30 +02:00
bjorn3 e1bdb98cf0 Simplify build.rs
Cargo always sets TARGET.
2026-04-28 16:49:28 +02:00
Jeremy Soller 6c2edd8efd Merge branch 'verify-sysmman-includes' into 'master'
verify sys_mman header includes

See merge request redox-os/relibc!1234
2026-04-27 12:27:28 -06:00
Jeremy Soller a224e92183 Merge branch 'correct-netent' into 'master'
use uint32_t for n_net in netent

See merge request redox-os/relibc!1233
2026-04-27 12:27:24 -06:00
auronandace 31052b5ef5 verify sys_mman header includes 2026-04-27 16:06:17 +01:00
auronandace df5deb2b59 use uint32_t for n_net in netent 2026-04-27 15:09:53 +01:00
Jeremy Soller a6df5229f4 Merge branch 'sysuio-include-guard' into 'master'
disambiguate sys_uio include guard

See merge request redox-os/relibc!1232
2026-04-27 06:56:05 -06:00
Jeremy Soller 0de8734ff4 Merge branch 'verify-string-includes' into 'master'
verify string header includes

See merge request redox-os/relibc!1231
2026-04-27 06:56:02 -06:00
Jeremy Soller 9cfa1e50eb Merge branch 'sysresource-trailer' into 'master'
change trailer to after_includes for sys_resource

See merge request redox-os/relibc!1230
2026-04-27 06:55:57 -06:00
Jeremy Soller 97cdf7da2e Merge branch 'netinetin-trailer' into 'master'
add include guard to cbindgen trailer for netinet_in

See merge request redox-os/relibc!1229
2026-04-27 06:55:33 -06:00
Jeremy Soller 4f4e535e18 Merge branch 'netdb-trailer' into 'master'
add include guard to netdb cbindgen trailer

See merge request redox-os/relibc!1228
2026-04-27 06:55:16 -06:00
Jeremy Soller dd16d3e413 Merge branch 'dirent-cleanup' into 'master'
move some constants from cbindgen to Rust in dirent

See merge request redox-os/relibc!1227
2026-04-27 06:54:42 -06:00
auronandace bed9717f6a disambiguate sys_uio include guard 2026-04-27 12:21:32 +01:00
auronandace b50262b76a verify string header includes 2026-04-27 11:20:59 +01:00
auronandace fad0f5b751 change trailer to after_includes for sys_resource 2026-04-27 10:40:49 +01:00
auronandace 522d88a587 add include guard to cbindgen trailer for netinet_in 2026-04-27 09:15:17 +01:00
auronandace 1544554ceb add include guard to netdb cbindgen trailer 2026-04-27 08:51:26 +01:00
auronandace 16e85bab8b move some constants from cbindgen to Rust in dirent 2026-04-27 08:06:45 +01:00
Jeremy Soller 9fdb120b2c Merge branch 'sys-wait' into 'master'
fix sys_wait trailer and include guard

See merge request redox-os/relibc!1225
2026-04-25 09:47:11 -06:00
auronandace 8dc8c05e4d fix sys_wait trailer and include guard 2026-04-25 08:39:53 +01:00
Jeremy Soller 02229def9b Merge branch 'add-file-back' into 'master'
fix libiconv compilation

See merge request redox-os/relibc!1224
2026-04-24 07:00:53 -06:00
Jeremy Soller 54d16f7a65 Merge branch 'remove-allowed-unused-imports' into 'master'
remove unused imports and #[allow(unused_imports)] annotations

See merge request redox-os/relibc!1223
2026-04-24 07:00:04 -06:00
Jeremy Soller 908763a6c9 Merge branch 'pal-cleanup' into 'master'
Pal: Add default method impls and remove duplicated code

See merge request redox-os/relibc!1222
2026-04-24 06:59:19 -06:00
auronandace e5451510fc fix libiconv compilation 2026-04-24 12:06:43 +01:00
sourceturner 8daf17e4f7 remove unused imports and #[allow(unused_imports)] annotations 2026-04-23 21:41:24 +02:00
Connor-GH 313f2be0f8 Pal: Add default method impls and remove duplicated code
I noticed that the Linux and Redox PALs both do very similar things for
a given FS function and its *at variant. For example, `mkdir()` is just
a call to `mkdirat()`. POSIX requires these to be equivalent.
Additionally, we use AT_EMPTY_PATH in some places but note that this is
not POSIX and is instead an extension that Linux (and Redox) implement.
That doesn't really matter though, since this is an implementation
detail. Implementations can choose to implement these functions anyway
and ignore the default impl. Such a case is `fstat`, because the current
Redox impl of `fstatat` relies on `fstat`, and this would cause infinite
recursion.

Future work:

POSIX says that `fcntl(fd, F_DUPFD, 0);` shall be equivalent to
`dup(fd);`. `dup2` might have cases where it can be implemented using
`dup3`. `dup` seemingly cannot be implemented in terms of `dup2`, so the
`fcntl` default implementation is sufficient. `pipe(fds)` is equivalent to
`pipe2(fds, 0);`.
2026-04-23 14:18:04 -05:00
Jeremy Soller 4ec5b2c37b Merge branch 'systypes-internals' into 'master'
move internal types from C to rust

See merge request redox-os/relibc!1221
2026-04-23 09:10:51 -06:00
Jeremy Soller 810b0d85b4 Merge branch 'deny-non_camel_case_types' into 'master'
Deny non camel case types

See merge request redox-os/relibc!1220
2026-04-23 09:10:12 -06:00
auronandace e15e7cafdb cargo fmt 2026-04-23 11:21:45 +01:00
auronandace e7f311c2c4 move internal types from C to rust 2026-04-23 11:18:14 +01:00
sourceturner 4c32e3ca72 add comment that 'non_camel_case_types' should be allowed 2026-04-22 23:18:43 +02:00
sourceturner ef46ff8746 rename RTLDState enum members 2026-04-22 21:58:02 +02:00
sourceturner 110646a9da rename bitset type to FdBitSet 2026-04-22 21:58:02 +02:00
Jeremy Soller 084d69af14 Merge branch 'verify-strings-includes' into 'master'
verify strings header includes

See merge request redox-os/relibc!1218
2026-04-22 06:36:07 -06:00
Jeremy Soller 02a494268b Merge branch 'inttypes-bits' into 'master'
move inttypes bits to cbindgen

See merge request redox-os/relibc!1216
2026-04-22 06:35:36 -06:00
Jeremy Soller ea0db54ae5 Merge branch 'sysmman-fix' into 'master'
correct placement of MAP_FAILED

See merge request redox-os/relibc!1219
2026-04-22 06:34:34 -06:00
Jeremy Soller 85d14dd90f Merge branch 'stdio-guards' into 'master'
add include guards for stdio bits in cbindgen

See merge request redox-os/relibc!1217
2026-04-22 06:33:40 -06:00
auronandace 312ce6200f correct placement of MAP_FAILED 2026-04-22 13:12:46 +01:00
auronandace 5596471e9d remove duplicate typedef, silence cbindgen warning 2026-04-22 12:33:07 +01:00
auronandace bf7e77b836 verify strings header includes 2026-04-22 11:40:16 +01:00
auronandace bbb3e08647 add include guards for stdio bits in cbindgen 2026-04-22 09:56:16 +01:00
auronandace f7ab0e579f move inttypes bits to cbindgen 2026-04-22 08:08:24 +01:00
Jeremy Soller b7989acb58 Merge branch 'unused-imports-fix' into 'master'
Remove some unused imports that caused CI to fail

See merge request redox-os/relibc!1215
2026-04-21 15:15:23 -06:00
Connor-GH c170acaaba Remove some unused imports that caused CI to fail 2026-04-21 13:36:29 -05:00
Jeremy Soller 73823c64ca Merge branch 'at-functions-to-unistd.h' into 'master'
move *at functions from fcntl.h to unistd.h

See merge request redox-os/relibc!1214
2026-04-21 12:26:59 -06: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
Jeremy Soller 3b41e24051 Merge branch 'deny-deprecated' into 'master'
set 'deprecated' lint to 'deny'

See merge request redox-os/relibc!1208
2026-04-20 16:27:58 -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 a886faff59 remove obsolete comment
thanks to Wildan Mubarok for the hint
2026-04-20 21:37:52 +00:00
sourceturner 8b10cbfa1a set 'deprecated' flag to 'deny' 2026-04-20 21:37:52 +00:00
sourceturner 2873086f39 replace deprecated setitimer() in alarm() implementation 2026-04-20 21:37:52 +00:00
sourceturner 138520d1c5 replace deprecated useconds_t type 2026-04-20 21:37:52 +00:00
sourceturner 19e6e61c17 replace deprecated atomic::spin_loop_hint() 2026-04-20 21:37:52 +00:00
sourceturner 1f584a3943 replace deprecated NaiveDateTime::from_timestamp 2026-04-20 21:37:52 +00:00
sourceturner 292fd9e50b replace deprecated memalign() with posix_memalign() 2026-04-20 21:37:52 +00: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
Jeremy Soller 7236cab8db Merge branch 'get-kern-ver' into 'master'
Print kernel version on test

See merge request redox-os/relibc!1211
2026-04-20 11:29:33 -06:00
Jeremy Soller 61703694a5 Merge branch 'float-bits' into 'master'
move float bits from C to cbindgen

See merge request redox-os/relibc!1210
2026-04-20 11:27:47 -06:00
Jeremy Soller 2c2bec65ae Merge branch 'syscall-h' into 'master'
Define syscall function for linux

See merge request redox-os/relibc!1209
2026-04-20 11:26:56 -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
auronandace abd64422c8 move float bits from C to cbindgen 2026-04-20 08:34:51 +01:00
Wildan M b5d7e79f4a Print kernel version on test 2026-04-20 10:28:19 +07:00
Wildan M 63f1790b41 Define syscall function for linux 2026-04-20 09:09:42 +07:00
Jeremy Soller aa8d1386a9 Merge branch 'fix-test-install' into 'master'
Fix relibc-tests-bins

See merge request redox-os/relibc!1207
2026-04-19 08:45:39 -06:00
Wildan M e6b44e6c6a Fix relibc-tests-bins 2026-04-19 17:04:26 +07:00
Jeremy Soller 807b963d53 Merge branch 'Sv39' into 'master'
RISCV64: Change VA scheme to Sv39 for real hardware support

See merge request redox-os/relibc!1174
2026-04-18 09:46:57 -06:00
aarch 20014bc121 RISCV64: Change VA scheme to Sv39 for real hardware support 2026-04-18 09:46:57 -06:00
Jeremy Soller c21041d0c7 Merge branch 'strtold-conflict' into 'master'
Fix include conflict in strtold

See merge request redox-os/relibc!1206
2026-04-18 07:02:49 -06:00
Wildan M 30ccb7d337 Fix include conflict in strtold 2026-04-18 12:49:02 +07:00
Jeremy Soller 2b69838a48 Merge branch 'sig_atomic_t' into 'master'
Move sig_atomic_t from stdint

See merge request redox-os/relibc!1205
2026-04-17 18:48:29 -06:00
Jeremy Soller a3f12568af Merge branch 'priority-sched' into 'master'
Priority Scheduler

See merge request redox-os/relibc!1068
2026-04-17 18:45:46 -06:00
Akshit Gaur 87b16e6d12 Priority Scheduler 2026-04-17 18:45:46 -06:00
Wildan M f59dfab490 Move sig_atomic_t from stdint 2026-04-18 02:31:35 +07:00
Jeremy Soller c35c291bea Merge branch 'susecond-t' into 'master'
Fix linux suseconds_t to fix alarm test

See merge request redox-os/relibc!1203
2026-04-16 06:49:46 -06:00
Jeremy Soller e87e3b8dc1 Merge branch 'fix-sigalrm' into 'master'
Disable SIGARLM timer delivery

See merge request redox-os/relibc!1202
2026-04-16 06:49:06 -06:00
Jeremy Soller 8f8c918822 Merge branch 'safamilyt-stdint' into 'master'
use c_ushort instead of u16 for sa_family_t

See merge request redox-os/relibc!1199
2026-04-16 06:48:20 -06:00
Jeremy Soller a549399ac3 Merge branch 'fix_wscanf_regressions' into 'master'
Fix wscanf regressions

See merge request redox-os/relibc!1201
2026-04-16 06:47:09 -06:00
Jeremy Soller 3d13964fd8 Merge branch 'termios-types-fix' into 'master'
fix types used in termios

See merge request redox-os/relibc!1200
2026-04-16 06:46:15 -06:00
Jeremy Soller c6390fc17f Merge branch 'monetary-type-fix' into 'master'
correct types in monetary

See merge request redox-os/relibc!1198
2026-04-16 06:45:24 -06:00
Jeremy Soller 48c4445c08 Merge branch 'no-libc-check-fix' into 'master'
Fix unable to compile without libc check

See merge request redox-os/relibc!1038
2026-04-16 06:44:58 -06:00
Jeremy Soller 2969569a16 Merge branch 'no-redoxer' into 'master'
Allow not installing redoxer for check.sh

See merge request redox-os/relibc!1003
2026-04-16 06:44:04 -06:00
Jeremy Soller ea9f1625c1 Merge branch 'native-types-signal' into 'master'
Use native types for signal.h

See merge request redox-os/relibc!1197
2026-04-16 06:43:26 -06:00
auronandace 752ac8f49d use c_ushort instead of u16 for sa_family_t 2026-04-15 22:09:43 +01:00
nicoan abc05e8c0b handling better the case 2026-04-15 17:10:31 -03:00
nicoan 495779a21b format 2026-04-15 15:40:45 -03:00
nicoan 2c4a20e71b added tests to scanf and wscanf 2026-04-15 15:38:40 -03:00
nicoan da3ff538d6 WIP: fixing regressions 2026-04-15 14:18:20 -03:00
Wildan M 9ef2789287 Fix linux suseconds_t to fix alarm test 2026-04-16 00:11:44 +07:00
Wildan M b73dd22020 Disable SIGARLM timer delivery 2026-04-15 21:03:36 +07:00
auronandace 8f62fed364 fix types used in termios 2026-04-15 14:09:42 +01:00
auronandace f0aaef6336 add stdint to safamily-t bits for uint16_t 2026-04-15 13:47:17 +01:00
auronandace 3e30fc9091 correct types in monetary 2026-04-15 13:16:38 +01:00
Wildan M 3b5acbdb40 Fix type for jump 2026-04-15 11:16:31 +07:00
Jeremy Soller 24a481364f Merge branch 'more-maths' into 'master'
Add more definition to rust math.h

See merge request redox-os/relibc!1196
2026-04-14 21:16:49 -06:00
Wildan M ff43be1be0 Use native types for signal.h 2026-04-15 10:05:35 +07:00
Wildan M 1689055c0d Add more definition to rust math.h 2026-04-15 05:50:21 +07:00
Jeremy Soller e30ccf83e3 Merge branch 'lookaheadreader_in_format_iterator' into 'master'
Using Reader (formerly LookAheadReader) in scanf/wscanf format string

See merge request redox-os/relibc!620
2026-04-14 14:11:58 -06:00
Nicolás Antinori 89f53e7640 Using Reader (formerly LookAheadReader) in scanf/wscanf format string 2026-04-14 14:11:57 -06:00
Wildan M f26bc31c2b Fix unable to compile without libc check 2026-04-14 23:43:09 +07:00
Wildan M 4d5eed6587 Allow not installing redoxer for check.sh 2026-04-14 23:40:33 +07:00
Jeremy Soller 93082f93cd Merge branch 'verify-sysun-includes' into 'master'
verify sys_un header includes

See merge request redox-os/relibc!1195
2026-04-14 08:22:38 -06:00
auronandace 78040e75ba verify sys_un header includes 2026-04-14 14:32:45 +01:00
Jeremy Soller 746d025957 Merge branch 'verify-termios-includes' into 'master'
verify termios header includes

See merge request redox-os/relibc!1194
2026-04-14 07:13:38 -06:00
Jeremy Soller 9b766ca8de Merge branch 'verify-monetary-includes' into 'master'
verify monetary header includes

See merge request redox-os/relibc!1193
2026-04-14 07:13:18 -06:00
Jeremy Soller f148ec216a Merge branch 'rust-cpio' into 'master'
move cpio header from C to Rust

See merge request redox-os/relibc!1192
2026-04-14 07:12:58 -06:00
Jeremy Soller 9efe255fdc Merge branch 'bits-safamilyt' into 'master'
split out sa_family_t to a bits header

See merge request redox-os/relibc!1191
2026-04-14 07:12:43 -06:00
auronandace a0d1e5648b verify termios header includes 2026-04-14 12:59:14 +01:00
auronandace 09fe8e29c3 verify monetary header includes 2026-04-14 11:00:25 +01:00
auronandace 1a6659ada1 move cpio header from C to Rust 2026-04-14 10:21:26 +01:00
auronandace 8c41979aba fix redox compilation for sa_family_t 2026-04-14 08:52:31 +01:00
auronandace b0c66cf470 split out sa_family_t to a bits header 2026-04-14 08:44:13 +01:00
Jeremy Soller 022f040f05 Merge branch 'signal-h' into 'master'
Fix signal.h include headers

See merge request redox-os/relibc!1190
2026-04-13 19:25:26 -06:00
Jeremy Soller 5d6dc38b71 Merge branch 'rust-math' into 'master'
Expose rust math with a feature flag

See merge request redox-os/relibc!1189
2026-04-13 19:24:51 -06:00
Jeremy Soller 3e6193ac47 Merge branch 'limits.h-more-limits' into 'master'
limits.h: add more constants

See merge request redox-os/relibc!1188
2026-04-13 19:23:53 -06:00
Connor-GH 7ade6fc0ca limits.h: add more constants
This helps us to pass several tests in Sortie's os-test suite. I forget
the exact number, but it was something like 8 or so tests:
https://doc.redox-os.org/test-results/os-test/os-test-20260410/html/limits/index.html#limits
2026-04-13 19:59:38 -05:00
Wildan M a3d2429dec Fix signal.h include headers 2026-04-14 06:22:26 +07:00
Wildan M 8f7879fc47 Expose rust math with a feature flag 2026-04-14 06:19:41 +07:00
Jeremy Soller f3a5152cb2 Merge branch 'setgroups-to-grp' into 'master'
Move setgroups() to grp.h

See merge request redox-os/relibc!1187
2026-04-13 17:03:02 -06:00
Jeremy Soller 14039049a1 Merge branch 'verify-glob-includes' into 'master'
verify glob header includes

See merge request redox-os/relibc!1186
2026-04-13 16:58:36 -06:00
Peter Limkilde Svendsen fbccaff46c Move setgroups() to grp.h 2026-04-13 22:56:56 +02:00
auronandace 95f897b62e verify glob header includes 2026-04-13 15:19:48 +01:00
Jeremy Soller 539d04009a Merge branch 'syssocket-bits' into 'master'
move sys_socket bits from C to cbindgen

See merge request redox-os/relibc!1185
2026-04-13 06:47:59 -06:00
Jeremy Soller c22d4afd54 Merge branch 'verify-signal-includes' into 'master'
verify signal header includes

See merge request redox-os/relibc!1184
2026-04-13 06:47:36 -06:00
Jeremy Soller 2c88d5abb1 Merge branch 'gmtime-localtime-safety' into 'master'
Describe safety requirements for gmtime(_r) and localtime(_r)

See merge request redox-os/relibc!1182
2026-04-13 06:43:08 -06:00
Peter Limkilde Svendsen 31a703144d Describe safety requirements for gmtime(_r) and localtime(_r) 2026-04-13 06:43:07 -06:00
auronandace 8945b07415 add include guard for the moved bits 2026-04-13 11:29:13 +01:00
auronandace 7cf6933f81 remove sys_socket include from netdb tests 2026-04-13 11:14:11 +01:00
auronandace f0e3574f30 remove sys_socket include from ifaddrs and netdb 2026-04-13 10:59:23 +01:00
auronandace e8429cdc5e move sys_socket bits from C to cbindgen 2026-04-13 10:18:40 +01:00
auronandace 1eed88923a verify signal header includes 2026-04-13 08:52:53 +01:00
Jeremy Soller de0f2f5329 Merge branch 'assert-bits' into 'master'
move assert bits from C to cbindgen

See merge request redox-os/relibc!1183
2026-04-12 06:50:45 -06:00
auronandace 17ff347332 move assert bits from C to cbindgen 2026-04-12 08:37:54 +01:00
Jeremy Soller 483d435d9c Merge branch 'verify-sysstatvfs-includes' into 'master'
verify header includes for sys_statvfs

See merge request redox-os/relibc!1179
2026-04-11 11:33:03 -06:00
auronandace b4fe14a15b verify header includes for sys_statvfs 2026-04-11 15:21:54 +01:00
Jeremy Soller 53bd8b48ec Merge branch 'seed48-no-static-mut' into 'master'
Replace static mut in seed48()

See merge request redox-os/relibc!1178
2026-04-11 08:13:02 -06:00
Peter Limkilde Svendsen f28cb80507 Replace static mut in seed48() 2026-04-11 16:07:48 +02:00
Jeremy Soller a820dd4d25 Merge branch 'printf-float-alternate-fix' into 'master'
printf: fix '%#.0e' to always print the radix character

See merge request redox-os/relibc!1177
2026-04-10 18:53:22 -06:00
Jeremy Soller b75492bdd2 Merge branch 'printf-precision-zero-fix' into 'master'
printf: ignore zero flag on some conversions if precision is specified.

See merge request redox-os/relibc!1176
2026-04-10 18:52:30 -06:00
Connor-GH 4a497bb263 printf: fix '%#.0e' to always print the radix character
Before, we were printing `'-4e+01'` from `printf("'%#.0e'\n", -42.0);`
Now we print `'-4.e+01'` as POSIX requires, and to pass a test in
os-test: https://doc.redox-os.org/test-results/os-test/os-test-20260410/html/stdio/printf-e-alt.c
2026-04-10 13:53:31 -05:00
Mathew John Roberts 9b82e54e5a Merge branch 'disconnected_udp' into 'master'
Move to separate 0.0.0.0:0 and disconnected states for udp AF_UNSPEC

See merge request redox-os/relibc!1166
2026-04-10 18:55:26 +01:00
Benton60 7bf209dc8e Move to separate 0.0.0.0:0 and disconnected states for udp AF_UNSPEC 2026-04-10 18:55:26 +01:00
Connor-GH 7ec3e239b5 printf: ignore zero flag on some conversions if precision is specified. 2026-04-10 11:19:55 -05:00
Jeremy Soller da40ffa9ec Merge branch 'fix-malloc-conflict' into 'master'
Fix malloc conflict

See merge request redox-os/relibc!1175
2026-04-10 07:11:25 -06:00
Wildan M 87e1739a85 Fix malloc conflict 2026-04-10 16:38:32 +07:00
Jeremy Soller 62b0f0c198 Merge branch 'timespec' into 'master'
rename bits_time to bits_timespec for consistency

See merge request redox-os/relibc!1173
2026-04-09 15:25:49 -06:00
Jeremy Soller c8ba916e7e Merge branch 'ucred' into 'master'
remove ucred from sys_socket bits

See merge request redox-os/relibc!1172
2026-04-09 15:25:35 -06:00
auronandace 49f96a96e6 rename bits_time to bits_timespec for consistency 2026-04-09 10:50:04 +01:00
auronandace 121ee8edb0 remove ucred from sys_socket bits 2026-04-09 09:59:24 +01:00
Mathew John Roberts 6530de76b9 Merge branch 'sys-epoll-docs' into 'master'
Add more sys/epoll.h docs

See merge request redox-os/relibc!1171
2026-04-09 07:59:59 +01:00
Mathew John Roberts e599c37a40 Merge branch 'pal-socket-docs' into 'master'
Add docs for PalSocket

See merge request redox-os/relibc!1170
2026-04-09 07:55:53 +01:00
Mathew John Roberts 6af45691f6 Merge branch 'pal-signal-docs' into 'master'
Add docs for PalSignal

See merge request redox-os/relibc!1169
2026-04-09 07:52:50 +01:00
Mathew John Roberts ddeb282648 Merge branch 'ptrace-docs' into 'master'
Improve ptrace docs

See merge request redox-os/relibc!1168
2026-04-09 07:49:54 +01:00
Mathew John Roberts b5fecf9ef2 Merge branch 'pal-epoll-docs' into 'master'
Add docs for PalEpoll

See merge request redox-os/relibc!1167
2026-04-09 07:47:16 +01:00
Peter Limkilde Svendsen 711d342227 Add more sys/epoll.h docs 2026-04-08 23:41:04 +02:00
Peter Limkilde Svendsen abb1c62ff7 Add docs for PalSocket 2026-04-08 23:24:50 +02:00
Peter Limkilde Svendsen 2c2d968455 Add docs for PalSignal 2026-04-08 23:08:03 +02:00
Peter Limkilde Svendsen 74c6e48a8f Improve ptrace docs 2026-04-08 22:36:19 +02:00
Peter Limkilde Svendsen ac1467fb2f Add docs for PalEpoll 2026-04-08 22:27:01 +02:00
Mathew John Roberts d6261d3868 Merge branch 'pal-docs' into 'master'
Document Pal methods

See merge request redox-os/relibc!1165
2026-04-08 19:48:47 +01:00
Mathew John Roberts 0b802afc7f Merge branch 'platform-rw-docs' into 'master'
Document platform readers and writers

See merge request redox-os/relibc!1164
2026-04-08 19:46:58 +01:00
Mathew John Roberts 83022746f9 Merge branch 'aio-docs' into 'master'
Add aio.h docs

See merge request redox-os/relibc!1163
2026-04-08 19:45:06 +01:00
Mathew John Roberts 4a05586a2f Merge branch 'format-mr-1159' into 'master'
Formatting

See merge request redox-os/relibc!1162
2026-04-08 19:43:22 +01:00
Mathew John Roberts 67fd089c90 Merge branch 'pthread-types-docs' into 'master'
Document pthread types

See merge request redox-os/relibc!1160
2026-04-08 19:42:29 +01:00
Peter Limkilde Svendsen 2d2aa5592b Document Pal methods 2026-04-06 20:12:04 +02:00
Peter Limkilde Svendsen bbb9426e6a Document platform readers and writers 2026-04-06 01:02:42 +02:00
Peter Limkilde Svendsen 68a49acace Add aio.h docs 2026-04-05 17:30:06 +02:00
Peter Limkilde Svendsen 8757c0facf Formatting 2026-04-05 16:44:09 +02:00
Jeremy Soller 43a8cbadec Merge branch 'fix-comp' into 'master'
Fix compilation

See merge request redox-os/relibc!1161
2026-04-05 08:38:20 -06:00
Peter Limkilde Svendsen 5151e58b47 Document pthread types 2026-04-05 16:33:06 +02:00
Jeremy Soller 1ccbd6d23f Merge branch 'connect' into 'master'
Add AF_UNSPEC support to the netstack

See merge request redox-os/relibc!1159
2026-04-05 07:51:41 -06:00
Jeremy Soller 933a53bfc0 Apply 1 suggestion(s) to 1 file(s)
Co-authored-by: Mathew John Roberts <auronandace@duck.com>
2026-04-05 07:51:20 -06:00
Wildan M f348d880e7 Fix compilation 2026-04-05 20:03:40 +07:00
Benton60 2b63e37410 fix behavior to always nullify the address regardless of what is passed in. 2026-04-05 01:26:45 -04:00
Benton60 7c733fc3b3 adding support for disconnecting via AF_UNSPEC 2026-04-04 18:27:01 -04:00
Jeremy Soller 7a10e071c2 Merge branch 'minor-cleanups' into 'master'
minor code cleanups

See merge request redox-os/relibc!1158
2026-04-04 07:39:30 -06:00
auronandace b4009544a8 minor code cleanups 2026-04-03 14:39:56 +01:00
Jeremy Soller 19b0b44eb9 Merge branch 'elf-bits' into 'master'
move elf bits to cbindgen

See merge request redox-os/relibc!1157
2026-04-03 07:01:10 -06:00
Jeremy Soller 02a6fedd32 Merge branch 'unistd-bits' into 'master'
move unistd bits to cbindgen

See merge request redox-os/relibc!1156
2026-04-03 07:00:35 -06:00
auronandace 700cf642e5 move elf bits to cbindgen 2026-04-03 09:15:08 +01:00
auronandace a0dd75a011 move unistd bits to cbindgen 2026-04-03 08:58:37 +01:00
Jeremy Soller 79232aecb8 Merge branch 'sigsetjmp-asm-fix' into 'master'
Fix regression caused in e553e9e4

See merge request redox-os/relibc!1155
2026-04-02 18:42:27 -06:00
Connor-GH aecec88fb6 Fix regression caused in e553e9e4
In the process of converting the assembly from AT&T syntax to Intel
syntax, bjorn3 made some mistakes. Firstly, `A+B(%reg)` is translated to
`[reg + A + B]`, and not `[reg * B + A]`. I can see how this was
confused because x86 also has an addressing mode that takes up to 4
arguments, where `A(%r1,%r2,B)` is translated to `[r1 + A + r2 * B]`
with the constraints that `B` must be a power of two <= 8, and `A` (if
present), must be an immediate. In this case, the `72+8` and such is
constfolded by the assembler into `80`.

This commit and the previous AT&T syntax version produce the exact same
assembly output now.
2026-04-02 19:14:42 -05:00
Jeremy Soller 8f9dde924b Merge branch 'fix-grp' into 'master'
make usize as size_t as per spec

See merge request redox-os/relibc!1154
2026-04-02 08:47:10 -06:00
Jeremy Soller 44efa11673 Merge branch 'platform-types-docs' into 'master'
Platform types docs

See merge request redox-os/relibc!1153
2026-04-02 08:47:08 -06:00
Peter Limkilde Svendsen 1f3cfcafb2 Platform types docs 2026-04-02 08:47:07 -06:00
Jeremy Soller 3ec44cf18c Merge branch 'cbindgen-iovec' into 'master'
export iovec via cbindgen function

See merge request redox-os/relibc!1152
2026-04-02 08:46:54 -06:00
auronandace 6d0030b765 make usize as size_t as per spec 2026-04-02 13:59:14 +01:00
auronandace 18ce904d7e export iovec via cbindgen function 2026-04-02 08:03:19 +01:00
Jeremy Soller 616f380856 Merge branch 'fix-rustdoc-warnings' into 'master'
Fix most rustdoc warnings

See merge request redox-os/relibc!1151
2026-04-01 18:47:12 -06:00
Jeremy Soller 369b45fceb Merge branch 'getopt-docs' into 'master'
Improve getopt.h docs

See merge request redox-os/relibc!1150
2026-04-01 18:46:38 -06:00
Peter Limkilde Svendsen 55f9c611b2 Fix most rustdoc warnings 2026-04-02 00:43:20 +02:00
Peter Limkilde Svendsen ce26bdc8b6 Improve getopt.h docs 2026-04-01 23:43:32 +02:00
Jeremy Soller 594381aaff Merge branch 'timeval-move-doc' into 'master'
Document moved spec of timeval struct

See merge request redox-os/relibc!1149
2026-04-01 15:35:42 -06:00
Jeremy Soller 0696a09005 Merge branch 'shadow-docs' into 'master'
Add docs for shadow.h

See merge request redox-os/relibc!1148
2026-04-01 15:35:35 -06:00
Peter Limkilde Svendsen 6f458cf1f3 Document moved spec of timeval struct 2026-04-01 23:20:05 +02:00
Peter Limkilde Svendsen b057e5078c Add docs for shadow.h 2026-04-01 22:54:30 +02:00
Jeremy Soller 0b880eb17d Merge branch 'split-iovec' into 'master'
split out iovec from sys_uio header

See merge request redox-os/relibc!1147
2026-04-01 08:41:26 -06:00
Jeremy Soller a64cebf296 Merge branch 'verify-grp-includes' into 'master'
verify grp header includes

See merge request redox-os/relibc!1146
2026-04-01 08:41:07 -06:00
Jeremy Soller 0630fa12f2 Merge branch 'stdio-bits' into 'master'
move stdio bits to cbindgen

See merge request redox-os/relibc!1145
2026-04-01 08:40:50 -06:00
Jeremy Soller d4c14e721e Merge branch 'stdlib-bits' into 'master'
move stdlib bits to cbindgen

See merge request redox-os/relibc!1144
2026-04-01 08:40:37 -06:00
Jeremy Soller a1c52aeae8 Merge branch 'feat/thread-based-alarm' into 'master'
feat: implement alarm(2) using thread-based POSIX timer machinery

See merge request redox-os/relibc!1109
2026-04-01 08:40:24 -06:00
auronandace 005b322c7c actually export iovec 2026-03-31 11:13:16 +01:00
auronandace 5d22f7096b split out iovec from sys_uio header 2026-03-31 11:03:41 +01:00
auronandace 83eb95a496 verify grp header includes 2026-03-31 09:15:51 +01:00
auronandace 1764004b80 move stdio bits to cbindgen 2026-03-31 08:53:10 +01:00
auronandace afd9cad0c3 move stdlib bits to cbindgen 2026-03-31 08:31:26 +01:00
Zero caa5ef8afb chore(signal): Move alarm function and adding the todo 2026-03-31 00:19:35 +02: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
Zero 5cbb4ba0cc test(unistd): Add alarm(2) test
Introduce a new test for the alarm(2) system call.
This test verifies the behavior of setting, cancelling,
and re-arming alarms, ensuring correct signal delivery
and return values.
2026-03-31 00:09:07 +02:00
Zero e0c9b0ed03 feat(signal): Implement alarm() and timer_settime logic
Adds the implementation for the `alarm()` function and its underlying
`alarm_timespec` helper. This involves managing a process-global POSIX timer
to deliver SIGALRM signals.
2026-03-31 00:09:07 +02:00
Jeremy Soller d34872cb35 Merge branch 'fgetws-fix' into 'master'
fgetws: don't always return NULL on EOF

See merge request redox-os/relibc!1126
2026-03-30 07:12:06 -06:00
Connor-GH e721d3d7c8 fgetws: don't always return NULL on EOF
This was a bug that prevented a lot of tests from passing. We only
need to return NULL if the file had an error. `fgetws` "stops when end
of stream is reached". Also, it only returns an error if "end of stream
was *already* reached or if an error occurred" (emphasis mine). Compare
this to the musl implementation:
https://git.musl-libc.org/cgit/musl/tree/src/stdio/fgetws.c
2026-03-29 21:10:59 -05:00
Jeremy Soller a1337a8fc0 Merge branch 'sysconf-heads' into 'master'
Add sysconf posix constants

See merge request redox-os/relibc!1143
2026-03-29 16:21:12 -06:00
Jeremy Soller 9b38ea8b55 Merge branch 'wchar-bits' into 'master'
move wchar bits to cbindgen

See merge request redox-os/relibc!1142
2026-03-29 15:32:18 -06:00
Jeremy Soller c9f6befae8 Merge branch 'exec-cache' into 'master'
Implement exec cache from ld_so cache

See merge request redox-os/relibc!1140
2026-03-29 15:31:56 -06:00
auronandace 4130dbce23 readd trailer for inttypes bits 2026-03-29 16:07:58 +01:00
auronandace 61eb827bc4 fix inttypes after moving wchar bits 2026-03-29 16:05:33 +01:00
auronandace 3b69b617a2 move wchar bits to cbindgen 2026-03-29 15:49:01 +01:00
Jeremy Soller e553e9e46d Merge branch 'fix_arm64' into 'master'
Move setjmp and sigsetjmp together

See merge request redox-os/relibc!1141
2026-03-29 08:36:20 -06:00
bjorn3 f8626fd9d0 Move setjmp and sigsetjmp together
This fixes compilation of relibc on arm64. On arm64 the reference from
sigsetjmp to setjmp has a limited range.
2026-03-29 16:18:21 +02:00
Jeremy Soller 18e47cdf5a Merge branch 'malloc-bits' into 'master'
move malloc bits to cbindgen

See merge request redox-os/relibc!1138
2026-03-29 07:10:14 -06:00
Jeremy Soller 078bfe81f1 Merge branch 'dirent-bits' into 'master'
move dirent bits to cbindgen

See merge request redox-os/relibc!1137
2026-03-29 07:09:58 -06:00
Jeremy Soller 299ee7da12 Merge branch 'errno-bits' into 'master'
move errno bits from C to cbindgen

See merge request redox-os/relibc!1136
2026-03-29 07:09:41 -06:00
Jeremy Soller 182b2daebe Merge branch 'rwlock-timeout' into 'master'
Implement clockid_t handling to pthread_rwlock timeout

See merge request redox-os/relibc!1139
2026-03-29 07:08:24 -06:00
Wildan M 6e1199448c Add sysconf posix constants 2026-03-29 17:39:13 +07:00
auronandace d84c8bf8f3 move malloc bits to cbindgen 2026-03-29 08:40:37 +01:00
Wildan M 464c840697 Fix linux compilation 2026-03-29 14:39:43 +07:00
auronandace 42d555b043 move dirent bits to cbindgen 2026-03-29 08:10:13 +01:00
auronandace 80db4127fd move errno bits from C to cbindgen 2026-03-29 07:44:55 +01:00
Wildan M b2de3d6e2e Implement exec cache from ld_so cache 2026-03-29 13:11:36 +07: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
Jeremy Soller a78c1f5cfd Merge branch 'init-ld-so' into 'master'
Minor ld_so init improvement

See merge request redox-os/relibc!1135
2026-03-28 20:25:05 -06:00
Wildan M e41052d307 Minor ld_so init improvement 2026-03-29 07:48:37 +07:00
Jeremy Soller e589a94c6d Merge branch 'ldso-cache' into 'master'
Implement ld_so cache backed by shm

See merge request redox-os/relibc!1134
2026-03-28 18:28:03 -06:00
Jeremy Soller 9d148e21f0 Merge branch 'fnmatch-collapsing' into 'master'
Fix fnmatch caused oom

See merge request redox-os/relibc!1133
2026-03-28 18:26:07 -06:00
Wildan M 459b8da27b Implement ld_so cache backed by shm 2026-03-29 05:34:14 +07:00
Wildan M ef922979ac Fix fmt 2026-03-29 02:29:31 +07:00
Wildan M 38650d994e Fix fnmatch caused oom 2026-03-29 02:20:16 +07:00
Jeremy Soller 5f97cc4178 Merge branch 'netdb-bits' into 'master'
move netdb bits to cbindgen

See merge request redox-os/relibc!1132
2026-03-28 11:56:14 -06:00
auronandace 306cd8b68f move netdb bits to cbindgen 2026-03-28 17:44:18 +00:00
Jeremy Soller 47acf75398 Merge branch 'sys-wait-bits' into 'master'
move sys_wait bits from C to cbindgen

See merge request redox-os/relibc!1130
2026-03-28 09:59:27 -06:00
auronandace 254e81ef74 move sys_wait bits from C to cbindgen 2026-03-28 15:12:54 +00:00
Jeremy Soller d3197c1006 Merge branch 'sys-time-bits' into 'master'
move sys_time bits from C to cbindgen

See merge request redox-os/relibc!1129
2026-03-28 09:07:49 -06:00
auronandace dbc6507c79 move sys_time bits from C to cbindgen 2026-03-28 14:57:11 +00:00
Jeremy Soller b732b50dac Merge branch 'tests-install' into 'master'
Update paths for install-tests

See merge request redox-os/relibc!1128
2026-03-28 07:24:14 -06:00
Jeremy Soller 310d7efac0 Merge branch 'netinetin-bits' into 'master'
move netinet_in bits to cbindgen

See merge request redox-os/relibc!1127
2026-03-28 07:23:52 -06:00
auronandace 93a8b4b7c6 cargo fmt 2026-03-28 08:21:13 +00:00
auronandace 516729bd83 move netinet_in bits to cbindgen 2026-03-28 08:15:24 +00:00
Wildan M cd698603c9 Update paths for install-tests 2026-03-28 06:12:32 +07:00
Jeremy Soller 216dd35a0a Merge branch 'recvmsg' into 'master'
reserve extra space for scheme path to fix os-test/sys_socket/recvfrom

See merge request redox-os/relibc!1124
2026-03-27 10:07:15 -06:00
Benton60 5de398c6a9 reserve extra space for scheme path to fix os-test/sys_socket/recvfrom 2026-03-27 09:49:47 -04:00
Jeremy Soller 1d7e95b9d1 Merge branch 'ctype-bits' into 'master'
move ctype bits from C to cbindgen

See merge request redox-os/relibc!1122
2026-03-27 07:34:45 -06:00
auronandace 71560ce9ca move ctype bits from C to cbindgen 2026-03-27 08:07:18 +00:00
Jeremy Soller 3bdca6200e Merge branch 'sys-stat-bits' into 'master'
move sys stat bits from C file to cbindgen

See merge request redox-os/relibc!1120
2026-03-26 09:07:19 -06:00
auronandace bc5ee99856 move sys stat bits from C file to cbindgen 2026-03-26 13:58:09 +00:00
Jeremy Soller 8dec9f36ff Merge branch 'sys-mman-bits' into 'master'
move sys mman bits to cbindgen

See merge request redox-os/relibc!1119
2026-03-26 06:30:51 -06:00
Jeremy Soller 6c34d491f8 Merge branch 'sys-ioctl-bits' into 'master'
move sys ioctl bits to cbindgen

See merge request redox-os/relibc!1118
2026-03-26 06:30:28 -06:00
auronandace db8021d4c8 move sys mman bits to cbindgen 2026-03-26 11:33:11 +00:00
auronandace bdceda8665 move sys ioctl bits to cbindgen 2026-03-26 11:09:52 +00:00
Jeremy Soller 88de0babd3 Merge branch 'sys-select-bits' into 'master'
move sys select bits to cbindgen

See merge request redox-os/relibc!1117
2026-03-25 20:00:40 -06:00
auronandace 23996c4fd7 move sys select bits to cbindgen 2026-03-25 14:28:00 +00:00
Jeremy Soller 467895ab5f Merge branch 'resource-bits' into 'master'
move sys resource bits file to cbindgen

See merge request redox-os/relibc!1116
2026-03-25 08:05:41 -06:00
auronandace 44bb9d8d63 cargo fmt 2026-03-25 13:38:12 +00:00
auronandace 6f48e1c954 move sys resource bits file to cbindgen 2026-03-25 13:34:03 +00:00
Jeremy Soller ab654db071 Merge branch 'remove-c-ptrace' into 'master'
remove empty C ptrace bits header

See merge request redox-os/relibc!1115
2026-03-25 07:04:05 -06:00
Jeremy Soller 7de94d974f Merge branch 'verify-netinetin-includes' into 'master'
verify netinet_in header includes

See merge request redox-os/relibc!1114
2026-03-25 07:03:47 -06:00
Jeremy Soller 1978c1aa4c Merge branch 'impl_recvmsg' into 'master'
update recvfrom to route calls through recvmsg

See merge request redox-os/relibc!1113
2026-03-25 07:02:06 -06:00
Jeremy Soller a50f21cc30 Merge branch 'glibc-build' into 'master'
Make test files buildable for glibc

See merge request redox-os/relibc!1112
2026-03-25 07:01:28 -06:00
Jeremy Soller dc50b5ea1a Merge branch 'wrap-test' into 'master'
Wrap tests in a separate build directory

See merge request redox-os/relibc!1111
2026-03-25 07:01:08 -06:00
auronandace 7ce47e0cad remove empty C ptrace bits header 2026-03-25 12:26:24 +00:00
auronandace d826d1fdc2 verify netinet_in header includes 2026-03-25 10:50:01 +00:00
Wildan M 00bcc90f98 Fix epoll 2026-03-25 04:19:44 +07:00
Wildan M 000cd996f3 Add more support test files 2026-03-25 04:16:16 +07:00
Wildan M 46379d7001 Make test files buildable for glibc 2026-03-25 03:11:33 +07:00
Wildan M d7c14e94af Wrap tests in a separate build directory 2026-03-25 03:05:47 +07:00
Jeremy Soller 186dc66818 Merge branch 'move-conversion-functions' into 'master'
move 4 conversion functions from netinet_in to arpa_inet

See merge request redox-os/relibc!1110
2026-03-24 07:04:45 -06:00
auronandace 88e0a4381e fix include in sys_socket recvfrom test 2026-03-24 11:34:41 +00:00
auronandace 9b76fce0cc move 4 conversion functions from netinet_in to arpa_inet 2026-03-24 11:22:14 +00:00
Benton60 0addd84414 update recvfrom to route calls through recvmsg 2026-03-23 23:37:15 -04:00
Jeremy Soller ab3e0bc94a Merge branch 'consolidate-deps' into 'master'
specify workspace dependencies

See merge request redox-os/relibc!1108
2026-03-23 17:54:50 -06:00
auronandace 1bc532848f specify workspace dependencies 2026-03-23 08:32:25 +00:00
Jeremy Soller 2083559d7f Merge branch 'cleanup' into 'master'
minor cleanup

See merge request redox-os/relibc!1107
2026-03-19 08:26:18 -06:00
Jeremy Soller d28752a931 Merge branch 'start-math' into 'master'
start of rust math header

See merge request redox-os/relibc!1106
2026-03-19 08:25:36 -06:00
auronandace b516113722 minor cleanup 2026-03-19 13:03:16 +00:00
auronandace c5187d18d6 start of rust math header 2026-03-19 10:43:20 +00:00
Jeremy Soller ecb0d3f33c Merge branch 'remove-fdset' into 'master'
remove duplicate fd_set struct from sys_time

See merge request redox-os/relibc!1105
2026-03-18 10:58:52 -06:00
Jeremy Soller ccbc09c694 Merge branch 'bump-goblin' into 'master'
update goblin dependency

See merge request redox-os/relibc!1104
2026-03-18 10:58:36 -06:00
Jeremy Soller c565a3181d Merge branch 'fix-gitmodules' into 'master'
remove unused compiler-builtins submodule

See merge request redox-os/relibc!1103
2026-03-18 10:58:20 -06:00
Jeremy Soller 9ffe37de96 Merge branch 'disable-fail-tests' into 'master'
Disable fail tests, make aarch64 test optional

See merge request redox-os/relibc!1102
2026-03-18 10:57:11 -06:00
auronandace ed2931fc60 remove duplicate fd_set struct from sys_time 2026-03-18 12:00:01 +00:00
auronandace 0918f5bcb6 update goblin dependency 2026-03-18 11:00:33 +00:00
auronandace 032207cd70 remove unused compiler-builtins submodule 2026-03-18 09:43:12 +00:00
Jeremy Soller 2d607b2fc8 Merge branch 'fix-fchmodat' into 'master'
Fix fchmodat with AT_EMPTY_PATH

See merge request redox-os/relibc!1101
2026-03-17 16:03:46 -06:00
Jeremy Soller 18e6c9f5c1 Merge branch 'verify-inttypes-includes' into 'master'
Verify inttypes includes

See merge request redox-os/relibc!1100
2026-03-17 11:44:43 -06:00
auronandace c79315ed06 cargo fmt 2026-03-17 17:13:19 +00:00
auronandace b252a794e0 verify inttypes header includes 2026-03-17 17:11:42 +00:00
auronandace 84c9038a11 move wcstoimax and wcstoumax from wchar to inttypes 2026-03-17 16:53:48 +00:00
auronandace 70f9dad334 move macros from wchar to macros 2026-03-17 16:46:09 +00:00
Jeremy Soller c758acb31a Merge branch 'verify-regex-includes' into 'master'
verify regex header includes

See merge request redox-os/relibc!1099
2026-03-17 05:51:32 -06:00
Jeremy Soller 4c17ebab49 Merge branch 'inaddr-nocopy' into 'master'
do not derive Copy on in_addr struct

See merge request redox-os/relibc!1098
2026-03-17 05:51:05 -06:00
Jeremy Soller d68ebe2149 Merge branch 'transmute' into 'master'
silence transmute warning lints

See merge request redox-os/relibc!1097
2026-03-17 05:48:59 -06:00
auronandace a6337706e1 verify regex header includes 2026-03-17 09:42:29 +00:00
auronandace 8a6e085121 do not derive Copy on in_addr struct 2026-03-17 09:18:45 +00:00
Wildan M bda6ca582a Ignore malloc/usable_size, add tls test 2026-03-17 16:13:41 +07:00
auronandace 01ea72ecc7 silence transmute warning lints 2026-03-17 08:11:42 +00:00
Wildan M 733821e279 Fix makefile commences 2026-03-17 07:31:42 +07:00
Wildan M bc705a1c7c Make aarch64 test optional 2026-03-17 07:31:09 +07:00
Wildan M 96a09e6dc4 Disable failed tests 2026-03-17 07:09:54 +07:00
Jeremy Soller e6f6e7078d Merge branch 'drm12' into 'master'
drm: Support MODE_PAGE_FLIP and MODE_DIRTYFB

See merge request redox-os/relibc!1096
2026-03-16 17:11:38 -06:00
bjorn3 6fc6831f67 drm: Support MODE_PAGE_FLIP and MODE_DIRTYFB 2026-03-16 21:47:23 +01:00
Wildan M 0db44c3f72 Fix fchmodat with AT_EMPTY_PATH 2026-03-17 03:12:34 +07:00
Jeremy Soller 3a956fe758 Merge branch 'needless-range-loops' into 'master'
eliminate more range loops

See merge request redox-os/relibc!1095
2026-03-16 08:39:18 -06:00
auronandace 904604020b eliminate more range loops 2026-03-16 08:26:05 +00:00
Jeremy Soller 9fd49d41e2 Merge branch 'iterate-dont-index' into 'master'
iterate instead of indexing using a range

See merge request redox-os/relibc!1094
2026-03-15 16:29:04 -06:00
auronandace 25f059bf67 iterate instead of indexing using a range 2026-03-15 21:39:10 +00:00
Jeremy Soller 936fe93447 Merge branch 'uname-version-info' into 'master'
uname: update to reflect version info given from scheme

See merge request redox-os/relibc!1093
2026-03-15 15:08:06 -06:00
Connor-GH a60b7cefc1 uname: update to reflect version info given from scheme
We recently updated the kernel to give the "version" info in the
uname scheme. Now, we also put this info in the `utsname` struct for the
`uname` function.
2026-03-15 15:49:10 -05:00
Jeremy Soller cfdad8646e Merge branch 'drm/update_plane' into 'master'
redox_ioctl: drm_mode_set_plane realisation

See merge request redox-os/relibc!1092
2026-03-14 11:16:19 -06:00
Jeremy Soller 3ddedbde18 Merge branch 'rand-update' into 'master'
update rand dependencies to latest

See merge request redox-os/relibc!1091
2026-03-14 10:38:23 -06:00
Meijlen d54f05a53b redox_ioctl: drm_mode_set_plane realisation 2026-03-14 23:08:41 +07:00
auronandace 2b52312227 update rand dependencies to latest 2026-03-14 15:38:45 +00:00
Jeremy Soller a57e55c458 Merge branch 'ldso-cleanup' into 'master'
tackle some clippy lints in ld_so

See merge request redox-os/relibc!1090
2026-03-14 08:50:04 -06:00
auronandace 5c646e78a1 add as conversion back in for i586 2026-03-14 14:30:06 +00:00
auronandace a01313467e tackle some clippy lints in ld_so 2026-03-14 14:20:22 +00:00
Jeremy Soller 693cf03519 Merge branch 'migrate-to-stdfscall' into 'master'
refactor: Migrate fstat*/fchmod/getdents/ftruncate/futimens to stdfscall

See merge request redox-os/relibc!1088
2026-03-14 07:17:03 -06:00
Jeremy Soller 266bf56554 Merge branch 'drm11' into 'master'
drm: Support MODE_SET_CRTC, MODE_CURSOR and MODE_CURSOR2

See merge request redox-os/relibc!1089
2026-03-14 07:13:25 -06:00
Jeremy Soller 5b3ce0105d Merge branch 't' into 'master'
refactor: remove outdated TODO

See merge request redox-os/relibc!1087
2026-03-14 07:00:59 -06:00
bjorn3 6c340e8c57 drm: Support MODE_SET_CRTC, MODE_CURSOR and MODE_CURSOR2 2026-03-14 13:48:22 +01:00
Ibuki.O ac88c8f670 refactor: Migrate fstat*/fchmod/getdents/ftruncate/futimens to stdfscall 2026-03-14 13:35:39 +09:00
Mustafa öz 8f847bde66 refactor: remove outdated TODO 2026-03-14 03:57:26 +00:00
Jeremy Soller df97789fb9 Merge branch 'time' into 'master'
fix: handle integer overflow

See merge request redox-os/relibc!1086
2026-03-13 19:03:12 -06:00
Mustafa öz d97f93a36b fix: handle integer overflow 2026-03-13 19:03:12 -06:00
Jeremy Soller 301b0d5943 Merge branch 'unistd-def' into 'master'
Define feature macros in unistd

See merge request redox-os/relibc!1085
2026-03-13 15:04:11 -06:00
Wildan M c119eba845 Define feature macros in unistd 2026-03-13 21:19:35 +07:00
Jeremy Soller 4d785e3a99 Merge branch 'getgrnam_r-fix' into 'master'
correct the strncmp check in getgrnam_r

See merge request redox-os/relibc!1084
2026-03-13 07:25:10 -06:00
Jeremy Soller e7af953089 Merge branch 'inet-pton-fix' into 'master'
Inet pton fix

See merge request redox-os/relibc!1083
2026-03-13 06:57:22 -06:00
auronandace 2f90dcd08e correct the strncmp check in getgrnam_r 2026-03-13 12:44:46 +00:00
auronandace 0a5f8429a3 negate filter predicate 2026-03-13 08:41:41 +00:00
auronandace 29d0cc67ee cargo fmt 2026-03-13 08:23:49 +00:00
auronandace 0d0afac2c8 fix parsing octets with leading zeros in inet_pton 2026-03-13 08:18:01 +00:00
Jeremy Soller f278abbb20 Merge branch 'timespec-noncopy' into 'master'
do not derive Copy for timespec

See merge request redox-os/relibc!1082
2026-03-11 09:41:52 -06:00
auronandace 3ea60eeb72 timespec clone followup for redox 2026-03-11 14:51:06 +00:00
auronandace 293a2e991d do not derive Copy for timespec 2026-03-11 14:37:16 +00:00
Jeremy Soller 06f94de968 Merge branch 'socklen-t-dedup' into 'master'
remove duplicate socklen_t definition

See merge request redox-os/relibc!1081
2026-03-11 07:22:24 -06:00
Jeremy Soller 36892976bf Merge branch 'wchar-lossless' into 'master'
make some cast lossless in macro in wchar

See merge request redox-os/relibc!1080
2026-03-11 07:20:55 -06:00
Jeremy Soller 07947f96dc Merge branch 'rand48' into 'master'
remove unneeded casts and conversions in rand48

See merge request redox-os/relibc!1079
2026-03-11 07:19:40 -06:00
Jeremy Soller 7a143003e3 Merge branch 'lossless-casts' into 'master'
tackle some lints

See merge request redox-os/relibc!1078
2026-03-11 07:17:18 -06:00
auronandace e9b9e1e28b fix trailer 2026-03-11 13:02:18 +00:00
auronandace ae91f48fae remove duplicate socklen_t definition 2026-03-11 12:42:53 +00:00
auronandace c4d667c6bf make some cast lossless in macro in wchar 2026-03-11 11:02:53 +00:00
auronandace 367bb2ee11 remove unneeded casts and conversions in rand48 2026-03-11 08:53:10 +00:00
auronandace 8a2bfa2ed5 tackle some lints 2026-03-10 18:20:06 +00:00
Jeremy Soller 1bed273ad0 Merge branch 'verify-sysuio-includes' into 'master'
verify header includes for sys_uio

See merge request redox-os/relibc!1077
2026-03-10 07:50:01 -06:00
Jeremy Soller 8dc281e1f2 Merge branch 'lint-fixes' into 'master'
fix a rust lint and a clippy lint

See merge request redox-os/relibc!1076
2026-03-10 07:49:40 -06:00
Jeremy Soller 582adf5822 Merge branch 'verify-pwd-includes' into 'master'
verify pwd header includes

See merge request redox-os/relibc!1075
2026-03-10 07:49:08 -06:00
Jeremy Soller 36fcca3d35 Merge branch 'verify-systypes-includes' into 'master'
Verify systypes includes

See merge request redox-os/relibc!1074
2026-03-10 07:48:51 -06:00
Jeremy Soller ce8df81275 Merge branch 'verify-sysstat-includes' into 'master'
verify header includes for sys_stat

See merge request redox-os/relibc!1073
2026-03-10 07:47:47 -06:00
auronandace 9b5d411feb verify header includes for sys_uio 2026-03-10 12:36:26 +00:00
auronandace bd4fb1f660 fix a rust lint and a clippy lint 2026-03-10 12:11:03 +00:00
auronandace 23b31bb65c verify pwd header includes 2026-03-10 11:43:30 +00:00
auronandace d8dc04d335 only import the needed types in bits_pthread 2026-03-10 11:24:51 +00:00
auronandace de516b22e5 verify header includes for sys_types 2026-03-10 11:20:47 +00:00
auronandace 28ab34921c verify header includes for sys_stat 2026-03-10 10:04:56 +00:00
Jeremy Soller 9340d76a92 Merge branch 'non-exhaustive-enum' into 'master'
mark enum as non-exhaustive

See merge request redox-os/relibc!1071
2026-03-08 09:15:27 -06:00
auronandace 5c77e5723a mark enum as non-exhaustive 2026-03-08 14:50:31 +00:00
Jeremy Soller 115a43a075 Merge branch 'unneeded-comparison' into 'master'
eliminate a useless comparison on aarch64 and riscv64

See merge request redox-os/relibc!1070
2026-03-07 09:16:14 -07:00
auronandace 003615a382 specify the correct arches 2026-03-07 16:03:14 +00:00
auronandace 38ff0b79bd eliminate a useless comparison on aarch64 and riscv64 2026-03-07 15:51:24 +00:00
Jeremy Soller d82c4531ab Merge branch 'getgroups' into 'master'
Implement getgroups

See merge request redox-os/relibc!1069
2026-03-06 21:08:47 -07:00
Wildan M fb07b5f982 Implement getgroups 2026-03-07 11:02:50 +07:00
Jeremy Soller ecfeceab6d Merge branch 'cyclic-unload' into 'master'
Fix dynamic linker hitting unwrap

See merge request redox-os/relibc!1067
2026-03-05 09:17:03 -07:00
Wildan M e45ec784b7 Fix dynamic linker hitting unwrap 2026-03-05 13:02:52 +07:00
Jeremy Soller 5964f60bd6 Merge branch 'inet-aton' into 'master'
partially improve inet_aton

See merge request redox-os/relibc!1066
2026-03-04 09:51:38 -07:00
Jeremy Soller e6b86267fa Merge branch 'long-double' into 'master'
Implement long double in printf

Closes #273

See merge request redox-os/relibc!1065
2026-03-04 09:51:24 -07:00
auronandace 63366e98ef correct the count 2026-03-04 16:35:07 +00:00
auronandace 5ce797af52 partially improve inet_aton 2026-03-04 15:38:15 +00:00
Wildan M b93e24b1d6 Implement long double in printf 2026-03-04 22:03:31 +07:00
Jeremy Soller 99dc1e97ae Merge branch 'fix-comp-2' into 'master'
Fix compile error

See merge request redox-os/relibc!1064
2026-03-03 09:56:21 -07:00
Jeremy Soller b81f58ff94 Merge branch 'static-sigjmp' into 'master'
Fix static linker error caused by setjmp aarch64

See merge request redox-os/relibc!1063
2026-03-03 09:48:33 -07:00
Jeremy Soller 760f67a8f2 Merge branch 'verify-dirent-includes' into 'master'
verify dirent header includes

See merge request redox-os/relibc!1062
2026-03-03 08:39:06 -07:00
auronandace 5c17aff8eb verify dirent header includes 2026-03-03 15:20:31 +00:00
Wildan M 3232273183 Fix compile error 2026-03-03 10:43:43 +07:00
Wildan M 31c8d87a7c Fix static linker error caused by setjmp aarch64 2026-03-03 10:37:07 +07:00
Jeremy Soller f073bedf3f Merge branch 'minor-cleanup' into 'master'
assorted cleanups and add some lints

See merge request redox-os/relibc!1061
2026-03-02 17:11:09 -07:00
auronandace 1421463dac assorted cleanups and add some lints 2026-03-02 10:01:05 +00:00
Jeremy Soller 59cce6304f Merge branch 'borrow-as-ptr' into 'master'
enforce borrow-as-ptr clippy lint

See merge request redox-os/relibc!1060
2026-03-01 13:18:31 -07:00
auronandace 6933287a94 enforce borrow-as-ptr clippy lint 2026-03-01 19:54:31 +00:00
Jeremy Soller 55dbb35a8a Merge branch 'syslog-sysselect-cleanup' into 'master'
syslog and sys_select header cleanup

See merge request redox-os/relibc!1059
2026-03-01 11:00:11 -07:00
auronandace 31489ab401 make exception for needless_update lint 2026-03-01 16:48:18 +00:00
auronandace 697bbc659e syslog and sys_select header cleanup 2026-03-01 16:30:29 +00:00
Jeremy Soller aeffcc1257 Merge branch 'reimpl-at_fdcwd' into 'master'
refactor: Reimplement the *at functions using openat and CWD fd

See merge request redox-os/relibc!1058
2026-03-01 07:08:31 -07:00
Ibuki Omatsu 3385c66c6c refactor: Reimplement the *at functions using openat and CWD fd 2026-03-01 07:08:31 -07:00
Jeremy Soller 364a1f0b03 Merge branch 'auxv_const_usage' into 'master'
Use consts for AT_* in static_init

See merge request redox-os/relibc!1057
2026-03-01 07:05:52 -07:00
Jeremy Soller 2bb9a8aed1 Merge branch 'fix-chdir' into 'master'
fix: Use cwd_guard directly to prevent deadlock in chdir

See merge request redox-os/relibc!1056
2026-03-01 07:04:01 -07:00
Ibuki Omatsu 9cde64a321 fix: Use cwd_guard directly to prevent deadlock in chdir 2026-03-01 07:04:01 -07:00
Jeremy Soller 3acebe2b87 Merge branch 'stdlib-stdio-cleanup' into 'master'
stdlib and stdio header cleanup

See merge request redox-os/relibc!1055
2026-02-28 12:21:29 -07:00
auronandace b44bf78793 stdlib and stdio header cleanup 2026-02-28 19:01:06 +00:00
Jeremy Soller fa04b004c6 Merge branch 'termios-syssocket-cleanup' into 'master'
sys_socket and termios header cleanup

See merge request redox-os/relibc!1054
2026-02-28 10:31:05 -07:00
auronandace 6f1e16c0a6 sys_socket and termios header cleanup 2026-02-28 17:19:29 +00:00
Jeremy Soller 5f56e868c4 Merge branch 'getopt-wchar-cleanup' into 'master'
getopt and wchar cleanup

See merge request redox-os/relibc!1053
2026-02-28 09:06:36 -07:00
auronandace 4b9a15ce7d getopt and wchar cleanup 2026-02-28 15:50:10 +00:00
bjorn3 599e53db89 Use consts for AT_* in static_init 2026-02-28 16:49:17 +01:00
Jeremy Soller 0f52382daa Merge branch 'pty-signal-cleanup' into 'master'
pty and signal header cleanup

See merge request redox-os/relibc!1052
2026-02-28 08:14:19 -07:00
Jeremy Soller 02ac27bf4b Merge branch 'stdfscall' into 'master'
refactor: Move protocols into libredox

See merge request redox-os/relibc!1042
2026-02-28 08:04:47 -07:00
Ibuki Omatsu cab0021461 refactor: Move protocols into libredox 2026-02-28 08:04:47 -07:00
auronandace d76417587c pty and signal header cleanup 2026-02-28 14:36:46 +00:00
Jeremy Soller fccd849d22 Merge branch 'pthread-platform-cleanup' into 'master'
platform and pthread cleanup

See merge request redox-os/relibc!1051
2026-02-27 14:50:06 -07:00
auronandace 2d3ee10aef platform and pthread cleanup 2026-02-27 21:38:16 +00:00
Jeremy Soller 94325a10c9 Merge branch 'sysuio-sysun-tar-cleanup' into 'master'
tar sys_uio and sys_un header cleanup

See merge request redox-os/relibc!1050
2026-02-27 14:21:23 -07:00
auronandace 1195ea9b9f tar sys_uio and sys_un header cleanup 2026-02-27 21:10:56 +00:00
Jeremy Soller bd6719931c Merge branch 'time-cleanup' into 'master'
time header cleanup

See merge request redox-os/relibc!1049
2026-02-27 11:31:38 -07:00
auronandace 1db7abb2d3 time header cleanup 2026-02-27 18:14:51 +00:00
Jeremy Soller 6fd923adec Merge branch 'unistd-cleanup' into 'master'
unistd header cleanup

See merge request redox-os/relibc!1048
2026-02-27 09:52:18 -07:00
auronandace 798e7e23ea unistd header cleanup 2026-02-27 16:25:22 +00:00
Jeremy Soller 04f82d7855 Merge branch 'string-cleanup' into 'master'
string and strings header cleanup

See merge request redox-os/relibc!1047
2026-02-27 08:37:06 -07:00
auronandace 55534b9af1 string and strings header cleanup 2026-02-27 14:18:58 +00:00
Jeremy Soller 6a08c53d1e Merge branch 'fix-dso' into 'master'
fix: improve error handling in DSO methods

Closes #263

See merge request redox-os/relibc!1046
2026-02-27 06:26:31 -07:00
Jeremy Soller 0b20d0a614 Merge branch 'shebang' into 'master'
fix(redox/exec): shebang

See merge request redox-os/relibc!1045
2026-02-27 06:22:46 -07:00
Jeremy Soller 1040413944 Merge branch 'stdlib-cleanup' into 'master'
stdlib header cleanup

See merge request redox-os/relibc!1044
2026-02-27 06:19:55 -07:00
Jeremy Soller 5f8ae0ea5b Merge branch 'flock' into 'master'
feat(copy_string_array): make strings contiguous

See merge request redox-os/relibc!1043
2026-02-27 06:16:34 -07:00
Anhad Singh c469792043 feat(exec/shebang): handle multiple whitespaces
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-28 00:14:28 +11:00
Anhad Singh 79c3674c10 feat(redox/exec): replace argv[0] with script
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-28 00:14:21 +11:00
Marsman 26dea09563 fix: improve error handling in DSO methods 2026-02-27 13:02:11 +00:00
auronandace 1c1ec91167 take into account x86 c_long 2026-02-27 12:21:54 +00:00
auronandace ebc1410fa5 stdlib header cleanup 2026-02-27 11:56:45 +00:00
Anhad Singh 4b6789dec5 feat(copy_string_array): make strings contiguous
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-27 15:45:04 +11:00
Jeremy Soller d0593f5480 Merge branch 'cwd-fd' into 'master'
refactor: Make processes have cwd as a capability

See merge request redox-os/relibc!1026
2026-02-26 06:09:27 -07:00
Ibuki Omatsu bd9c6f1440 refactor: Make processes have cwd as a capability 2026-02-26 06:09:27 -07:00
Jeremy Soller 98e8716f48 Merge branch 'upper-case-acronyms' into 'master'
add upper_case_acronyms clippy lint and minor cleanups

See merge request redox-os/relibc!1041
2026-02-25 08:32:01 -07:00
Jeremy Soller 1ff26de318 Merge branch 'flock' into 'master'
feat(redox): flocking

See merge request redox-os/relibc!1037
2026-02-25 08:20:46 -07:00
Anhad Singh fe89f12da6 chore: bump redox_syscall
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-26 02:17:53 +11:00
auronandace e1e9753c65 add upper_case_acronyms clippy lint and minor cleanups 2026-02-25 13:55:01 +00:00
Jeremy Soller ac9c4e6601 Merge branch 'stdio-cleanup' into 'master'
stdio header cleanup

See merge request redox-os/relibc!1040
2026-02-24 13:03:12 -07:00
auronandace cefb9cccb9 stdio header cleanup 2026-02-24 19:45:09 +00:00
Jeremy Soller 812f132eb8 Merge branch 'signal-cleanup' into 'master'
signal header cleanup

See merge request redox-os/relibc!1039
2026-02-24 10:03:30 -07:00
auronandace 4073242e8b signal header cleanup 2026-02-24 16:35:06 +00:00
Jeremy Soller acc32bb019 Merge branch 'fix-parse_xxx' into 'master'
fix: handle char boundary in `parse_weekday` and `parse_month`

Closes #265

See merge request redox-os/relibc!990
2026-02-24 08:14:10 -07: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
Jeremy Soller af2e4a72c6 Merge branch 'fix-pthread_rwlockattr_setpshared' into 'master'
fix: handle invalid `pshared` in `pthread_rwlockattr_setpshared`

Closes #264

See merge request redox-os/relibc!987
2026-02-24 08:13:30 -07:00
Jeremy Soller f69aac0899 Merge branch 'fix-assert' into 'master'
fix: `to_string_lossy` for safer string conversion in `__assert_fail`

Closes #262

See merge request redox-os/relibc!986
2026-02-24 08:13:07 -07:00
Jeremy Soller 4e9b64a177 Merge branch 'fix-seekdir' into 'master'
fix: handle negative offset in `seekdir`

Closes #260

See merge request redox-os/relibc!980
2026-02-24 08:11:11 -07:00
Jeremy Soller e8fb4604fb Merge branch 'fix-mprotect' into 'master'
fix: return EINVAL for invalid `prot` of `mprotect`

Closes #259

See merge request redox-os/relibc!976
2026-02-24 08:10:46 -07:00
Jeremy Soller 24ea34a03e Merge branch 'fix-aligned_alloc' into 'master'
fix: return EINVAL when `alignment` of `aligned_alloc` is 0

Closes #258

See merge request redox-os/relibc!968
2026-02-24 08:10:24 -07:00
Anhad Singh d1c031f1b5 feat(redox): F_{OFD}_{GETLK,SETLK}
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-25 01:43:45 +11:00
Jeremy Soller 93cce3bc63 Merge branch 'blkcnt' into 'master'
Fix blkcnt_t type

See merge request redox-os/relibc!1036
2026-02-24 06:30:47 -07:00
Anhad Singh 73ef851d59 feat(redox): F_OFD_SETLK
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-24 22:36:19 +11:00
Jeremy Soller 4d61651620 Merge branch 'shadow-pthread-cleanup' into 'master'
pthread and shadow cleanup

See merge request redox-os/relibc!1035
2026-02-23 18:54:21 -07:00
Wildan M 8810e143ec Fix blkcnt_t type 2026-02-24 07:47:35 +07:00
auronandace c879035288 pthread and shadow cleanup 2026-02-23 16:28:26 +00:00
Jeremy Soller 27f64a268e Merge branch 'monetary-regex-cleanup' into 'master'
monetary net_if and regex cleanup

See merge request redox-os/relibc!1034
2026-02-23 08:36:51 -07:00
auronandace 52049592d5 monetary net_if and regex cleanup 2026-02-23 15:11:37 +00:00
Jeremy Soller b2b37b53dd Merge branch 'eliding-lifetimes' into 'master'
elide some lifetimes

See merge request redox-os/relibc!1033
2026-02-23 07:05:28 -07:00
auronandace 92f9b0d4c8 elide some lifetimes 2026-02-23 13:48:56 +00:00
Jeremy Soller f65ddc8224 Merge branch 'pwd-pty-cleanup' into 'master'
pty and pwd cleanup

See merge request redox-os/relibc!1032
2026-02-23 06:25:06 -07:00
Anhad Singh aa79ec49ad misc(Makefile): cleanup
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-23 23:55:11 +11:00
Anhad Singh aa317238f1 feat(redox/fcntl): F_SETLK
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-23 23:55:11 +11:00
Anhad Singh 79987da821 misc(tests/Makefile): add pthread/tls
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-23 23:55:11 +11:00
auronandace 53912fa029 pty and pwd cleanup 2026-02-23 08:51:05 +00:00
Jeremy Soller 6f00355741 Merge branch 'langinfo-libgen-cleanup' into 'master'
langinfo and libgen cleanup

See merge request redox-os/relibc!1031
2026-02-22 17:18:41 -07:00
auronandace 4ecce16dc4 langinfo and libgen cleanup 2026-02-22 22:18:03 +00:00
Jeremy Soller 0430eb7426 Merge branch 'netdb-cleanup' into 'master'
netdb header cleanup

See merge request redox-os/relibc!1030
2026-02-22 11:58:48 -07:00
auronandace 533cdd8c39 netdb header cleanup 2026-02-22 18:48:17 +00:00
Jeremy Soller f045f948c6 Merge branch 'dirent-fnmatch-cleanup' into 'master'
dirent and fnmatch cleanup

See merge request redox-os/relibc!1029
2026-02-22 08:16:00 -07:00
auronandace ec100d5af8 dirent and fnmatch cleanup 2026-02-22 14:14:58 +00:00
Jeremy Soller 6cbba4d1f8 Merge branch 'allocator-signal-cleanup' into 'master'
allocator and linux signal cleanup in platform

See merge request redox-os/relibc!1028
2026-02-22 06:47:14 -07:00
auronandace dc4542e81c allocator and linux signal cleanup in platform 2026-02-22 08:43:20 +00:00
Jeremy Soller 53cc0e5aed Merge branch 'stdio-cvec-cleanup' into 'master'
stdio and c_vec cleanup

See merge request redox-os/relibc!1027
2026-02-20 08:15:46 -07:00
auronandace 768e28cb4e stdio and c_vec cleanup 2026-02-20 14:10:34 +00:00
Jeremy Soller dbe7fb0b18 Merge branch 'bitstime-crypt-ctype-cleanup' into 'master'
cleanup bits_time, crypt and ctype headers

See merge request redox-os/relibc!1025
2026-02-20 05:50:58 -07:00
Jeremy Soller 0bac773992 Merge branch 'precedence' into 'master'
apply precedence clippy lint

See merge request redox-os/relibc!1024
2026-02-20 05:49:54 -07:00
Jeremy Soller dcaeb8c63a Merge branch 'wchar-cleanup' into 'master'
wchar cleanup

See merge request redox-os/relibc!1023
2026-02-20 05:49:16 -07:00
Jeremy Soller 896140bea7 Merge branch 'master' into 'master'
fix(redox-rt): ET_EXEC

See merge request redox-os/relibc!1022
2026-02-20 05:43:33 -07:00
auronandace cfb16cd888 cleanup bits_time, crypt and ctype headers 2026-02-20 12:06:16 +00:00
auronandace 47b23ae546 apply precedence clippy lint 2026-02-20 11:27:43 +00:00
auronandace c8a1bff78a wchar cleanup 2026-02-20 09:51:15 +00:00
Anhad Singh 1c5668acd4 feat(dso): do not zero memory
The region is mapped with the `MAP_ANONYMOUS` and thus already
initialised with zeros.

According to POSIX Issue 8:

> Anonymous memory objects shall be initialized to all bits zero.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-20 16:30:49 +11:00
Anhad Singh 09f52fd163 fix(redox-rt): FIXED_NOREPLACE for ET_EXEC
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-20 12:00:29 +11:00
Anhad Singh 4c0d4c7963 fix(redox-rt): update min mmap address for ET_EXEC
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-20 11:58:28 +11:00
Anhad Singh 4fbb8ec338 fix(redox-rt): add base address to e_entry
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-20 11:56:28 +11:00
Jeremy Soller 27b4c3ed90 Merge branch 'grp-inttypes-cleanup' into 'master'
grp and inttypes cleanup

See merge request redox-os/relibc!1021
2026-02-19 09:59:23 -07:00
auronandace 874e11b147 grp and inttypes cleanup 2026-02-19 15:51:33 +00:00
Jeremy Soller 976ed3c276 Merge branch 'locale-cleanup' into 'master'
clean up some as casts in locale

See merge request redox-os/relibc!1020
2026-02-19 08:18:23 -07:00
auronandace c8747c97c3 clean up some as casts in locale 2026-02-19 14:45:18 +00:00
Jeremy Soller 940352affe Merge branch 'master' into 'master'
Revert "fix(ld.so): temporary rollback"

See merge request redox-os/relibc!1019
2026-02-19 07:22:35 -07:00
Jeremy Soller 28ffabebf6 Merge branch 'remove-redox-platform-clone' into 'master'
remove unneeded file

See merge request redox-os/relibc!1018
2026-02-19 06:36:59 -07:00
Jeremy Soller ee6a6062cd Merge branch 'glob-cleanup' into 'master'
casting and clarity cleanups in glob

See merge request redox-os/relibc!1017
2026-02-19 06:35:11 -07:00
Jeremy Soller f743570926 Merge branch 'fix-sigaction' into 'master'
change sa_flags in sigaction to int to match spec

See merge request redox-os/relibc!1016
2026-02-19 06:32:42 -07:00
auronandace c8d9b4deca remove unused import 2026-02-19 12:51:12 +00:00
auronandace 2d647590a7 remove reference to clone 2026-02-19 12:20:54 +00:00
auronandace dcca06f80e add imports 2026-02-19 12:09:46 +00:00
auronandace 406b889c1f remove unneeded file 2026-02-19 11:55:31 +00:00
auronandace 723586e754 casting and clarity cleanups in glob 2026-02-19 11:05:30 +00:00
auronandace 92503ed298 missed redox specific fix 2026-02-19 09:56:13 +00:00
auronandace 4b3d1aa5ca change sa_flags in sigaction to int to match spec 2026-02-19 09:46:56 +00:00
Jeremy Soller 9e0f04133c Merge branch 'getopt-cleanup' into 'master'
cleanup getopt casting

See merge request redox-os/relibc!1015
2026-02-18 05:58:12 -07:00
auronandace 0f1124ae25 cleanup getopt casting 2026-02-18 09:26:39 +00:00
Anhad Singh 5568bb5a8a Revert "fix(ld.so): temporary rollback"
This reverts commit 5cf865189d.
2026-02-18 10:57:08 +11:00
Jeremy Soller 13f84e9d62 Merge branch 'arpainet-cleanup' into 'master'
refactor some as casts in arpa_inet

See merge request redox-os/relibc!1014
2026-02-17 15:20:36 -07:00
auronandace 5d753b7f48 refactor some as casts in arpa_inet 2026-02-17 17:35:13 +00:00
Jeremy Soller 6c6232ad70 Merge branch 'correct-unused-imports' into 'master'
remove allowed unused imports

See merge request redox-os/relibc!1012
2026-02-17 09:42:44 -07:00
Jeremy Soller 35d25cafa9 Merge branch 'master' into 'master'
fix(ld.so): temporary rollback

See merge request redox-os/relibc!1013
2026-02-17 09:42:33 -07:00
Anhad Singh 5cf865189d fix(ld.so): temporary rollback
See the "Redox OS/Support" channel. This commit temporarily fixes the
issue by rolling back the changes to preload the executable.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-18 02:36:03 +11:00
auronandace 53273c35c4 remove allowed unused imports 2026-02-17 15:35:58 +00:00
Jeremy Soller 928d3176b9 Merge branch 'replace-transmute' into 'master'
avoid unneeded transmute on aarch64 and riscv

See merge request redox-os/relibc!1011
2026-02-17 07:50:11 -07:00
auronandace 8a656d7727 avoid unneeded transmute on aarch64 and riscv 2026-02-17 14:35:08 +00:00
Jeremy Soller 8ff18965de Merge branch 'little-cleanup' into 'master'
tackle a few lint instances

See merge request redox-os/relibc!1010
2026-02-17 06:42:02 -07:00
auronandace 5cd6b99588 tackle a few lint instances 2026-02-17 13:00:52 +00:00
Jeremy Soller ba75b5c9db Merge branch 'correct-timespec-includes' into 'master'
add sys_types to time bits include for time_t

See merge request redox-os/relibc!1009
2026-02-16 11:36:16 -07:00
auronandace 58120ee007 add sys_types to time bits include for time_t 2026-02-16 17:50:59 +00:00
Jeremy Soller df3229958e Merge branch 'ld_preload_program' into 'master'
feat(ld.so): position independent

See merge request redox-os/relibc!1007
2026-02-16 07:00:08 -07:00
Jeremy Soller 14c0cebaee Merge branch 'remove-allow-warnings' into 'master'
remove allow warnings and add some lints

See merge request redox-os/relibc!1008
2026-02-16 06:57:32 -07:00
Anhad Singh e3abf808f3 misc(ld.so): remove no_mangle for stage2
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-17 00:47:36 +11:00
Anhad Singh d234e81fc9 fix(ld.so): debug build
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-17 00:15:10 +11:00
Anhad Singh f5ebd7882d misc(ld.so): minor cleanup
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-16 22:51:14 +11:00
Anhad Singh 0c3f88f462 misc(ld.so): fix logging
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-16 22:46:45 +11:00
Anhad Singh 371540d2ae fix(ld.so/i586): build
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-16 17:04:01 +11:00
Anhad Singh 0430081f4a feat(redox-rt): preload the executable
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-16 12:29:19 +11: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
Anhad Singh 8cb41ed4e2 feat(ld.so): shared library
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-15 19:14:07 +11:00
Anhad Singh f9487321c0 fix(ld.so): base_addr
Not guaranteed that the program headers immediately follow the ELF
header.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-15 15:47:02 +11:00
Jeremy Soller b926190b19 Merge branch 'improper-ctypes-definitions' into 'master'
add improper_ctypes_definitions lint

See merge request redox-os/relibc!1006
2026-02-14 10:43:35 -07:00
auronandace 6ed46304c0 add annotation to redox function as exception 2026-02-14 16:57:53 +00:00
auronandace 2c53eb1f6d add improper_ctypes_definitions lint 2026-02-14 16:48:39 +00:00
Jeremy Soller 0cf3f8af92 Merge branch 'several-lints' into 'master'
remove pthread_atfork from unistd and tackle some lints

See merge request redox-os/relibc!1004
2026-02-14 06:39:07 -07:00
auronandace 0da732be98 remove Copy from utsname 2026-02-14 08:40:15 +00:00
Jeremy Soller 87bd0ad8df Merge branch 'log-proc-name' into 'master'
Append program name in log

See merge request redox-os/relibc!1005
2026-02-13 11:15:22 -07:00
Wildan Mubarok 51f997b28f Apply 1 suggestion(s) to 1 file(s) 2026-02-13 13:32:37 +00:00
Wildan M 83a1680beb Append program name in log 2026-02-13 20:23:29 +07:00
auronandace 955179ab6f remove code as per feedback 2026-02-13 13:22:05 +00:00
auronandace 5d6ae8fd3f add pthread.h to unistd fork test 2026-02-13 12:31:59 +00:00
auronandace ff392a029a remove pthread_atfork from unistd and tackle some lints 2026-02-13 12:14:04 +00:00
Anhad Singh b69672cf80 misc(.gitignore): add .vscode
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-13 22:00:20 +11:00
Jeremy Soller 31b674d6a6 Merge branch 'verify-sched-includes' into 'master'
verify sched header includes

See merge request redox-os/relibc!1002
2026-02-12 15:33:26 -07:00
auronandace ed80ef1b26 remove bits sched from tests includes 2026-02-12 17:27:03 +00:00
auronandace 70f2e28c37 remove sched bits from pthread bits 2026-02-12 17:16:58 +00:00
auronandace a4079f13f0 verify sched header includes 2026-02-12 17:05:02 +00:00
Jeremy Soller fca7117842 Merge branch 'disentangle-timespec' into 'master'
extract timespec to a bits header

See merge request redox-os/relibc!1001
2026-02-12 07:52:43 -07:00
auronandace f1ec5a4856 add cbindgen struct to bits file 2026-02-12 14:28:47 +00:00
auronandace 0e1af0503e remove export rename from the bits cbindgen file 2026-02-12 13:59:23 +00:00
auronandace bc25b5a7ed add export renames to cbindgen files 2026-02-12 13:33:54 +00:00
auronandace bb48f68968 redox import fixes for timespec 2026-02-12 13:16:23 +00:00
auronandace 1191d8e1b4 extract timespec to a bits header 2026-02-12 13:07:24 +00:00
Jeremy Soller 0bbaadf2ce Merge branch 'remove-duplicate-locale-bits' into 'master'
removed the C locale bits header

See merge request redox-os/relibc!1000
2026-02-11 09:55:04 -07:00
Jeremy Soller 5a45e844d4 Merge branch 'unexpected-cfgs' into 'master'
add unexpected_cfgs lint

See merge request redox-os/relibc!999
2026-02-11 09:54:43 -07:00
auronandace e8118dc293 removed the C locale bits header 2026-02-11 15:38:42 +00:00
auronandace 924189992f add unexpected_cfgs lint 2026-02-11 14:13:57 +00:00
Jeremy Soller 9da9422995 Merge branch 'sched_param-export' into 'master'
Fix exporting sched_param

See merge request redox-os/relibc!998
2026-02-11 06:49:44 -07:00
Jeremy Soller f6b7c8bce3 Merge branch 'unused-must-use' into 'master'
add unused_must_use lint

See merge request redox-os/relibc!996
2026-02-11 06:49:24 -07:00
Jeremy Soller 0cd60481ce Merge branch 'epollet-test' into 'master'
Add failed epollet test

See merge request redox-os/relibc!997
2026-02-11 06:48:08 -07:00
Jeremy Soller 5db35733f8 Merge branch 'fix-ub-sys_call' into 'master'
fix: Avoid UB by passing raw pointers to syscall5

See merge request redox-os/relibc!995
2026-02-11 06:46:49 -07:00
Wildan M ff3b2b3ca0 Fix exporting sched_param 2026-02-11 17:29:17 +07:00
Wildan M d18a4da715 Add failed epollet test 2026-02-11 17:00:17 +07:00
Wildan M dd577957ec Fix compilation for linux ARM 2026-02-11 16:59:17 +07:00
auronandace aa13343b2e redox native fixes for unused_must_use 2026-02-11 09:58:50 +00:00
auronandace a3c67e898d add unused_must_use lint 2026-02-11 09:48:47 +00:00
Ibuki.O 29f8219d5d fix: Avoid UB by passing raw pointers to syscall5 2026-02-11 13:34:22 +09:00
Jeremy Soller 395c6ba33b Merge branch 'usused-imports' into 'master'
add unused_imports lint

See merge request redox-os/relibc!993
2026-02-10 15:01:21 -07:00
auronandace 1c98e7b273 last riscv64 unused_imports fix 2026-02-10 18:14:15 +00:00
auronandace b9d956bacb try again with allow 2026-02-10 18:04:40 +00:00
auronandace 8307ba25b3 missed some 2026-02-10 17:30:29 +00:00
auronandace 932defff20 follow up fixes for i586, aarch64 and riscv64gc 2026-02-10 16:53:10 +00:00
auronandace 6792e49563 missed 2 more 2026-02-10 16:33:52 +00:00
auronandace 11f28342f9 unused_imports redox follow-up 2026-02-10 16:29:37 +00:00
auronandace 7d1582a555 add unused_imports lint 2026-02-10 15:55:32 +00:00
Jeremy Soller 8c81e34ab8 Merge branch 'really-apply-workspace-lints' into 'master'
inherit lints in the workspace crates

See merge request redox-os/relibc!992
2026-02-10 07:53:54 -07:00
auronandace c950340aca inherit lints in the workspace crates 2026-02-10 14:38:58 +00:00
Jeremy Soller 0e5db98e35 Merge branch 'implement-pause' into 'master'
Implement pause

See merge request redox-os/relibc!991
2026-02-10 06:49:23 -07:00
Akshit Gaur 75a3d80fdb Implement pause 2026-02-10 19:17:11 +05:30
Marsman 7de04a217b fix: handle char boundary in parse_weekday and parse_month 2026-02-10 13:17:40 +00:00
Jeremy Soller 55380d119d Merge branch 'fix-schedparam' into 'master'
make struct repr C

See merge request redox-os/relibc!988
2026-02-10 06:04:30 -07:00
Jeremy Soller 89ab7a8fa2 Merge branch 'mismatched-lifetime-syntaxes' into 'master'
add mismatched_lifetime_syntaxes lint

See merge request redox-os/relibc!979
2026-02-10 06:02:01 -07:00
Marsman 6a7fb703c9 fix: adjust memory allocation for argv to include null terminator 2026-02-10 11:26:14 +00:00
auronandace deb3abf522 make struct repr C 2026-02-10 11:24:08 +00:00
auronandace ee729c20d6 deduplicate clippy lints in Cargo.toml 2026-02-10 07:25:55 +00:00
Marsman ca84f5b795 fix: handle invalid pshared in pthread_rwlockattr_setpshared 2026-02-10 02:45:24 +00:00
Marsman ba90edb97b fix: to_string_lossy for safer string conversion in __assert_fail 2026-02-10 02:29:33 +00:00
Jeremy Soller 950ec367ca Merge branch 'fmap-test' into 'master'
Add failed fmap test

See merge request redox-os/relibc!985
2026-02-09 17:39:08 -07:00
Jeremy Soller 6685e972c6 Merge branch 'verify-tar-includes' into 'master'
verify tar header includes

See merge request redox-os/relibc!984
2026-02-09 14:26:32 -07:00
Jeremy Soller 82cca1ef04 Merge branch 'verify-syslog-includes' into 'master'
verify syslog header includes

See merge request redox-os/relibc!983
2026-02-09 14:26:29 -07:00
Jeremy Soller c48559892a Merge branch 'verify-sysutsname-includes' into 'master'
verify sys_utsname header includes

See merge request redox-os/relibc!982
2026-02-09 14:26:26 -07:00
auronandace 743b9c2478 verify tar header includes 2026-02-09 19:17:29 +00:00
auronandace e951f0de76 verify syslog header includes 2026-02-09 19:09:24 +00:00
auronandace 306d03a036 verify sys_utsname header includes 2026-02-09 18:55:08 +00:00
Jeremy Soller f18b11465c Merge branch 'verify-netinettcp-includes' into 'master'
verify netinet_tcp header includes

See merge request redox-os/relibc!981
2026-02-09 11:04:12 -07:00
auronandace 1c42bc4c64 verify netinet_tcp header includes 2026-02-09 16:30:51 +00:00
Marsman d29016c98c fix: handle negative offset in seekdir 2026-02-09 16:10:42 +00:00
Wildan M da2fc2ee5f Add failed fmap test 2026-02-09 21:53:18 +07:00
auronandace bb6931cd87 readd ExpectTlsFree 2026-02-08 22:03:34 +00:00
auronandace 9b39861779 add mismatched_lifetime_syntaxes lint 2026-02-08 21:45:15 +00:00
Jeremy Soller ab6a2e7322 Merge branch 'unused-unsafe' into 'master'
add unused-unsafe lint

See merge request redox-os/relibc!978
2026-02-08 12:47:28 -07:00
auronandace 9ce9b3bfb3 unused_unsafe ptrace exception 2026-02-08 16:12:07 +00:00
auronandace 8c0ec4193c unused_unsafe fix for riscv 2026-02-08 16:02:05 +00:00
auronandace df37258ed2 usused_unsafe follow-up for redox 2026-02-08 15:52:55 +00:00
auronandace c3f3e051e1 add unused-unsafe lint 2026-02-08 15:39:48 +00:00
Jeremy Soller 1ec204d702 Merge branch 'unused-mut' into 'master'
add unused_mut lint

See merge request redox-os/relibc!977
2026-02-08 07:28:44 -07:00
Jeremy Soller 19d2b65e47 Merge branch 'msg_cmsg_cloexec' into 'master'
feat: Implement MSG_CMSG_CLOEXEC handling to recvmsg

See merge request redox-os/relibc!975
2026-02-08 07:19:22 -07:00
auronandace 48224dc5ff redox unused_mut follow-up 2026-02-08 09:14:05 +00:00
auronandace 64f18ca89a add unused_mut lint 2026-02-08 09:00:14 +00:00
Marsman deb4a529be fix: return EINVAL for invalid prot of mprotect 2026-02-08 08:18:36 +00:00
Ibuki.O 5e61f17a3a feat: Implement MSG_CMSG_CLOEXEC handling to recvmsg 2026-02-08 12:09:08 +09:00
Jeremy Soller a935094d2d Merge branch 'bulk-fd-passing' into 'master'
refactor: Reimplement recvmsg and sendmsg using bulk fd passing.

See merge request redox-os/relibc!970
2026-02-07 19:48:59 -07:00
Ibuki Omatsu 94b0cfc682 refactor: Reimplement recvmsg and sendmsg using bulk fd passing. 2026-02-07 19:48:59 -07:00
Jeremy Soller 3724e7892d Merge branch 'pointer-comparisons' into 'master'
add unpredictable_function_pointer_comparisons lint

See merge request redox-os/relibc!974
2026-02-07 12:54:46 -07:00
auronandace 50cd1ce1b0 add unpredictable_function_pointer_comparisons lint 2026-02-07 19:38:07 +00:00
Jeremy Soller a3d479acb6 Merge branch 'dangling-pointers' into 'master'
add dangling_pointers_from_temporaries lint

See merge request redox-os/relibc!973
2026-02-07 11:20:17 -07:00
Jeremy Soller ce9a163f01 Merge branch 'reduce_unsafe_usage' into 'master'
redox-rt: Use Option rather than MaybeUninit + bool

See merge request redox-os/relibc!972
2026-02-07 10:47:56 -07:00
auronandace b1e0e861cc add dangling_pointers_from_temporaries lint 2026-02-07 17:46:26 +00:00
bjorn3 24aaf8fac9 redox-rt: Use Option rather than MaybeUninit + bool 2026-02-07 18:37:37 +01:00
Jeremy Soller 02d2597292 Merge branch 'irrefutable_let_patterns' into 'master'
add irrefutable_let_patterns lint

See merge request redox-os/relibc!971
2026-02-07 10:06:11 -07:00
auronandace 130231d6b4 add irrefutable_let_patterns lint 2026-02-07 16:50:19 +00:00
Jeremy Soller 57b8bfb579 Merge branch 'zero-ptr' into 'master'
tidy up lints and add zero_ptr

See merge request redox-os/relibc!969
2026-02-07 08:26:51 -07:00
auronandace 4a84b2f04c tidy up lints and add zero_ptr 2026-02-07 14:58:02 +00:00
Marsman 2e4db0d130 fix: return EINVAL when alignment is 0 2026-02-07 10:55:39 +00:00
Jeremy Soller 12dc6766de Merge branch 'ref-as-ptr' into 'master'
add clippy lint ref_as_ptr

See merge request redox-os/relibc!966
2026-02-06 14:50:10 -07:00
auronandace be0bc8ca11 add clippy lint ref_as_ptr 2026-02-06 21:05:29 +00:00
Jeremy Soller 0929574f37 Merge branch 'ptr-as-ptr' into 'master'
add clippy lint ptr_as_ptr

See merge request redox-os/relibc!965
2026-02-06 10:32:15 -07:00
auronandace 028061ca0f add clippy lint ptr_as_ptr 2026-02-06 17:17:07 +00:00
Jeremy Soller fe41ef6273 Merge branch 'add-clippy' into 'master'
start adding some clippy lints to Cargo.toml

See merge request redox-os/relibc!963
2026-02-06 08:40:11 -07:00
Jeremy Soller eb2a5e68e0 Merge branch 'uds-preaccept' into 'master'
Add test for data transfer before accept for UDS

See merge request redox-os/relibc!964
2026-02-06 08:39:34 -07:00
auronandace 473bf0389a start adding some clippy lints to Cargo.toml 2026-02-06 14:53:59 +00:00
Jeremy Soller cee50ab8c7 Merge branch 'clippy-lint' into 'master'
silence a clippy error

See merge request redox-os/relibc!962
2026-02-06 06:42:18 -07:00
4lDO2 61f42d6b93 Fix panic in sigtimedwait with per-thread rt sig. 2026-02-06 12:16:10 +01:00
auronandace a275a047ce silence a clippy error 2026-02-06 08:18:06 +00:00
Wildan M e2b8acb05d Add test for data transfer before accept for UDS 2026-02-06 14:17:45 +07:00
Jeremy Soller 67e9cf25c7 Merge branch 'fix-tests' into 'master'
remove rust platform tests

See merge request redox-os/relibc!961
2026-02-05 08:28:49 -07:00
auronandace b7742efe5e remove rust platform tests 2026-02-05 15:11:42 +00:00
4lDO2 bc6784d5ed Replace EINTR with ERESTART in posix_sigqueue. 2026-02-05 15:15:41 +01:00
Jeremy Soller 199a09329d Merge branch 'poll-epoll-unsafe' into 'master'
mark poll_epoll as unsafe

See merge request redox-os/relibc!960
2026-02-05 06:31:57 -07:00
Jeremy Soller 1398c2b0fb Merge branch 'fix_raise_sigrtmax' into 'master'
Remove incorrect sig number check in raise.

Closes #255

See merge request redox-os/relibc!959
2026-02-05 06:31:29 -07:00
Jeremy Soller d6b4203001 Merge branch 'verify-netif-includes' into 'master'
verify net_if header includes

See merge request redox-os/relibc!958
2026-02-05 06:30:58 -07:00
Jeremy Soller d24b630a5b Merge branch 'verify-locale-includes' into 'master'
verify locale header includes

See merge request redox-os/relibc!957
2026-02-05 06:30:38 -07:00
Jeremy Soller 453ef0ab90 Merge branch 'verify-limits-includes' into 'master'
verify limits header includes

See merge request redox-os/relibc!956
2026-02-05 06:30:12 -07:00
Jeremy Soller 1a4c77f6df Merge branch 'sigqueue-nonrealtime' into 'master'
Use posix_kill instead of posix_sigqueue for non-realtime signals

See merge request redox-os/relibc!955
2026-02-05 06:22:42 -07:00
auronandace c12605642f mark poll_epoll as unsafe 2026-02-05 11:59:41 +00:00
4lDO2 7004484ac1 Avoid redundant sig trampoline jump in sigprocmask. 2026-02-05 12:10:00 +01:00
4lDO2 0b8bae2092 Fix RLCT_SIGNAL_MASK off-by-one. 2026-02-05 12:09:40 +01:00
4lDO2 4b2637aea0 Remove incorrect sig number check in raise. 2026-02-05 11:52:08 +01:00
auronandace cffa3cd21c verify net_if header includes 2026-02-05 10:41:24 +00:00
auronandace a10d84a271 verify locale header includes 2026-02-05 10:21:11 +00:00
auronandace dccb22d55f verify limits header includes 2026-02-05 09:42:21 +00:00
Ron Williams 05bc77d7be Use posix_kill instead of posix_sigqueue for non-realtime signals 2026-02-05 04:31:49 +00:00
Jeremy Soller c64af90940 Merge branch 'uds-write-test' into 'master'
Add UDS write test

See merge request redox-os/relibc!953
2026-02-04 09:55:15 -07:00
Jeremy Soller a690988350 Merge branch 'verify-libgen-includes' into 'master'
verify libgen header includes

See merge request redox-os/relibc!952
2026-02-04 09:45:00 -07:00
Jeremy Soller a9822d2a18 Merge branch 'verify-fnmatch-includes' into 'master'
verify fnmatch header includes

See merge request redox-os/relibc!951
2026-02-04 09:44:55 -07:00
Wildan M 3027826be2 Add uds write test 2026-02-04 23:43:01 +07:00
auronandace 30e87290ec verify libgen header includes 2026-02-04 14:57:44 +00:00
auronandace d6eda227d4 verify fnmatch header includes 2026-02-04 13:54:57 +00:00
Jeremy Soller e500560736 Merge branch 'document-localet' into 'master'
document headers that require locale_t

See merge request redox-os/relibc!950
2026-02-04 06:20:00 -07:00
Jeremy Soller ac2fcbc42f Merge branch 'unistd-cleanup' into 'master'
unistd header cleanup

See merge request redox-os/relibc!949
2026-02-04 06:19:35 -07:00
Jeremy Soller f19a286350 Merge branch 'verify-errno-includes' into 'master'
verify errno header includes

See merge request redox-os/relibc!948
2026-02-04 06:18:29 -07:00
Jeremy Soller d580134b8e Merge branch 'verify-endian-includes' into 'master'
verify endian header includes

See merge request redox-os/relibc!947
2026-02-04 06:18:10 -07:00
Jeremy Soller 285211c5de Merge branch 'verify-dlfcn-includes' into 'master'
verify dlfcn header includes

See merge request redox-os/relibc!946
2026-02-04 06:17:50 -07:00
auronandace 6ad81bb77a document headers that require locale_t 2026-02-04 12:12:50 +00:00
auronandace 804bb83c34 unistd header cleanup 2026-02-04 10:13:57 +00:00
auronandace b560c88452 verify errno header includes 2026-02-04 08:49:12 +00:00
auronandace 5b4e8154bf verify endian header includes 2026-02-04 08:32:14 +00:00
auronandace ce0cb927e0 verify dlfcn header includes 2026-02-04 08:11:30 +00:00
Jeremy Soller 2f4cdc87d9 Merge branch 'stdio-cleanup' into 'master'
stdio header cleanup

See merge request redox-os/relibc!945
2026-02-03 16:52:17 -07:00
auronandace f8d9ef6e43 stdio header cleanup 2026-02-03 21:11:47 +00:00
Jeremy Soller 0e4911f82b Merge branch 'verify-ctype-includes' into 'master'
verify ctype header includes

See merge request redox-os/relibc!944
2026-02-03 08:03:31 -07:00
Jeremy Soller b4cf8ff7b9 Merge branch 'verify-assert-includes' into 'master'
verify assert header includes

See merge request redox-os/relibc!943
2026-02-03 08:03:15 -07:00
auronandace ea61d11e92 verify ctype header includes 2026-02-03 14:35:24 +00:00
auronandace 7b9e4801a4 verify assert header includes 2026-02-03 14:06:06 +00:00
Jeremy Soller c5a795a46b Merge branch 'borrow-as-ptr' into 'master'
apply clippy::borrow-as-ptr lint

See merge request redox-os/relibc!942
2026-02-03 06:04:30 -07:00
Jeremy Soller 27b80cd603 Merge branch 'signal-wchar-cleanup' into 'master'
signal and wchar header cleanup

See merge request redox-os/relibc!941
2026-02-03 06:04:04 -07:00
Jeremy Soller cce227a30f Merge branch 'verify-arpainet-includes' into 'master'
verify arpa_inet includes

See merge request redox-os/relibc!940
2026-02-03 06:02:14 -07:00
auronandace ac0a7e71f4 apply clippy::borrow-as-ptr lint 2026-02-03 12:02:26 +00:00
auronandace d2d45f0c75 cargo fmt 2026-02-03 11:14:01 +00:00
auronandace 506df9a175 signal and wchar header cleanup 2026-02-03 11:11:41 +00:00
auronandace 38a6cd5359 verify arpa_inet includes 2026-02-03 09:11:29 +00:00
Jeremy Soller 38e1aeddb8 Merge branch 'syssocket-netdb-cleanup' into 'master'
sys_socket and netdb header cleanup

See merge request redox-os/relibc!938
2026-02-02 06:39:53 -07:00
Jeremy Soller df7492f5d5 Merge branch 'fcntl-syslog-cleanup' into 'master'
fcntl and sys_syslog header cleanup

See merge request redox-os/relibc!937
2026-02-02 06:39:26 -07:00
auronandace 46edf9ba65 sys_socket and netdb header cleanup 2026-02-02 09:43:33 +00:00
auronandace 4927301713 fcntl and sys_syslog header cleanup 2026-02-02 08:53:28 +00:00
Jeremy Soller 3f71ace6ab Merge branch 'add-pthreadstackmin' into 'master'
define PTHREAD_STACK_MIN

See merge request redox-os/relibc!936
2026-02-01 08:14:43 -07:00
auronandace e492dd29ba define PTHREAD_STACK_MIN 2026-02-01 14:59:48 +00:00
Jeremy Soller 84de07395c Merge branch 'linux-time-fix' into 'master'
remove duplicate constant

Closes #247

See merge request redox-os/relibc!935
2026-02-01 07:00:54 -07:00
Jeremy Soller fdf7135373 Merge branch 'sigismember' into 'master'
include realtime signals in sigismember range

See merge request redox-os/relibc!934
2026-02-01 06:59:22 -07:00
Ron Williams c7a262ac9d include realtime signals in sigismember range 2026-02-01 06:59:22 -07:00
auronandace e69d399654 remove duplicate constant 2026-02-01 08:37:48 +00:00
Jeremy Soller 303b4b404e Merge branch 'SI_QUEUE' into 'master'
Remove SI_QUEUE and SI_USER from signal mod.rs

See merge request redox-os/relibc!933
2026-01-31 17:47:12 -07:00
Ron Williams 810d5a7330 Remove SI_QUEUE and SI_USER from signal mod.rs 2026-01-31 22:58:49 +00:00
Jeremy Soller a202a5a42e Merge branch 'sigwaitinfo_ret' into 'master'
Return awaited signal number in sigtimedwait

Closes #245

See merge request redox-os/relibc!932
2026-01-31 12:28:55 -07:00
4lDO2 7f27471746 return awaited signal number in sigtimedwait 2026-01-31 18:50:14 +01:00
Jeremy Soller 2798dd118c Merge branch 'include-test' into 'master'
Add include test

See merge request redox-os/relibc!931
2026-01-30 11:58:15 -07:00
Wildan M 185265397d Add include test 2026-01-30 23:46:10 +07:00
Jeremy Soller 485187cb76 Merge branch 'fix-types-h' into 'master'
move timeval to sys_select

See merge request redox-os/relibc!930
2026-01-30 09:45:07 -07:00
Ron Williams 69c2e6cbba fix linux types.h 2026-01-30 16:31:54 +00:00
Ron Williams 2c3201eaeb move timeval to sys_select 2026-01-30 15:53:15 +00:00
Jeremy Soller edf7f6951f Merge branch 'master' into 'master'
fix(poll): handle overflow in ppoll timeout

See merge request redox-os/relibc!929
2026-01-30 06:05:40 -07:00
nekluu 908b132f04 fix(poll): handle overflow in ppoll timeout 2026-01-30 06:41:13 +03:00
Jeremy Soller a32fd56e61 Merge branch 'fcntl-test' into 'master'
Adjust fnctl/open test assert

See merge request redox-os/relibc!927
2026-01-29 06:27:55 -07:00
Jeremy Soller deaef805bc Merge branch 'rlctattr-not-copy' into 'master'
remove Copy from RcltAttr

See merge request redox-os/relibc!928
2026-01-29 06:21:50 -07:00
auronandace 8d7b86ffb3 remove Copy from RcltAttr 2026-01-29 13:07:54 +00:00
Wildan M d4546dbce0 Adjust fnctl/open test assert 2026-01-29 17:24:06 +07:00
Jeremy Soller a6f51aa428 Merge branch 'pthread-barrier-test-fix' into 'master'
widen unsafe block for pthread barrier test

See merge request redox-os/relibc!924
2026-01-28 15:20:13 -07:00
auronandace 17cc166fff widen unsafe block for pthread barrier test 2026-01-28 22:10:48 +00:00
Jeremy Soller 807e66cab6 Merge branch 'tzset-test-fix' into 'master'
widen unsafe blocks to fix tzset test

See merge request redox-os/relibc!923
2026-01-28 14:10:07 -07:00
auronandace b027b77dbf widen unsafe blocks to fix tzset test 2026-01-28 20:56:29 +00:00
Jeremy Soller 8d68023059 Merge branch 'disable-o_noatime-test' into 'master'
Disable O_NOATIME test

See merge request redox-os/relibc!922
2026-01-28 13:09:03 -07:00
Josh Megnauth b29b49bdf4 Disable O_NOATIME test
Redox doesn't have it.
2026-01-28 14:23:00 -05:00
Jeremy Soller 9ab384440c Merge branch 'sysptrace-ifaddrs-cleanup' into 'master'
sys_ptrace and ifaddrs header cleanup

See merge request redox-os/relibc!921
2026-01-28 11:46:46 -07:00
auronandace a9d64bd3d4 sys_ptrace and ifaddrs header cleanup 2026-01-28 18:24:32 +00:00
Jeremy Soller eb0fc58155 Merge branch 'master' into 'master'
fix(Makefile): coloured messages

See merge request redox-os/relibc!920
2026-01-28 08:48:34 -07:00
Anhad Singh b6a955be0e fix(Makefile): coloured messages
From `man 1 echo`:
> -e     Enable interpretation of backslash escapes.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-01-29 02:20:51 +11:00
Jeremy Soller 0bb9632884 Merge branch 'sysepoll-dltls-cleanup' into 'master'
sys_epoll and dl-tls header cleanup

See merge request redox-os/relibc!919
2026-01-28 07:00:39 -07:00
auronandace 714a1b6766 sys_epoll and dl-tls header cleanup 2026-01-28 11:21:43 +00:00
Jeremy Soller dff1e17baa Merge branch 'master' into 'master'
misc(pthread/mutex): cleanup

See merge request redox-os/relibc!918
2026-01-27 09:18:29 -07:00
Anhad Singh 2f8f12e3c7 misc(pthread/mutex): cleanup
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-01-28 01:05:11 +11:00
Jeremy Soller 30097af0cd Merge branch 'wchar-cpp' into 'master'
Fixes to enable wide character in C++

See merge request redox-os/relibc!916
2026-01-27 06:04:01 -07:00
Jeremy Soller 199d635c84 Merge branch 'master' into 'master'
fix(pthread/mutex): broken `pthread_mutexattr_*`

See merge request redox-os/relibc!917
2026-01-27 04:11:49 -07:00
Anhad Singh d82240f228 fix(pthread/mutex): broken pthread_mutexattr_*
Regression of https://gitlab.redox-os.org/redox-os/relibc/-/merge_requests/890

* The unsafe block needs to be moved *outside* to make sure the `attr`
  is mutated.
* `RlctMutexAttr` was `Copy` which is not required.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-01-27 19:31:14 +11:00
Wildan M 1acf1d83cc Temporarily enable wcsftime and wcsxfrm 2026-01-27 15:27:45 +07:00
Wildan M 2c522c355f Fix wchar_t redefinition in C++ 2026-01-27 14:40:23 +07:00
Jeremy Soller 5cadc9ebbd Merge branch 'trace-log-crate' into 'master'
Implement configurable log from env

Closes redox#1770

See merge request redox-os/relibc!913
2026-01-25 07:08:47 -07:00
Jeremy Soller 7ecba809b5 Merge branch 'size-max-i586' into 'master'
Fix SIZE_MAX for i586

See merge request redox-os/relibc!915
2026-01-24 18:16:27 -07:00
Wildan M 59bd6a62db Fix changing log level 2026-01-25 05:56:27 +07:00
Jeremy Soller f6b1f78766 Merge branch 'more-open-tests' into 'master'
Add more 'open' tests

See merge request redox-os/relibc!914
2026-01-24 15:34:25 -07:00
Josh Megnauth 02f766b8df Add more 'open' tests 2026-01-24 15:34:24 -07:00
Wildan M f15322453b Convert all println to log or todo 2026-01-25 05:27:38 +07:00
Wildan M 9711dcca51 Implement logger and todo macros 2026-01-25 04:55:18 +07:00
Wildan M 632b3a9a4f Fix SIZE_MAX for i586 2026-01-25 01:09:39 +07:00
Wildan M 7b9402783d Add log crate, use it to all trace cmd 2026-01-24 22:39:05 +07:00
Jeremy Soller 954c806d80 Merge branch 'posix_close-impl' into 'master'
unistd/mod.rs: implement posix_close

See merge request redox-os/relibc!912
2026-01-23 15:10:36 -07: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
Jeremy Soller ee648a4e57 Merge branch 'stdio.h-regex.h-add-macros' into 'master'
stdio.h: add std{in,out,err} macros; regex.h: add REG_MINIMAL macro

See merge request redox-os/relibc!911
2026-01-23 08:46:11 -07:00
Connor-GH 6356142c79 stdio.h: add std{in,out,err} macros; regex.h: add REG_MINIMAL macro 2026-01-23 09:41:19 -06:00
Jeremy Soller 599d60e404 Merge branch 'unixpeername' into 'master'
Fix unixpeername expected stdout

See merge request redox-os/relibc!910
2026-01-23 06:49:55 -07:00
Jeremy Soller 538fed80a0 Merge branch 'getaddrinfo-hang' into 'master'
Fix getaddrinfo hang due to infinite loop

See merge request redox-os/relibc!909
2026-01-23 00:25:10 -07:00
Jeremy Soller 1445c2385d Merge branch 'p12' into 'master'
fix(pthread/tls): destructors

See merge request redox-os/relibc!908
2026-01-22 23:49:22 -07:00
Anhad Singh f3d16d3fbd fix(pthread/tls): nit
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-01-23 14:29:35 +11:00
Anhad Singh b6914ef239 feat(pthread/tls): more tests
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-01-23 14:27:47 +11:00
Anhad Singh 0f4a82b5e8 fix(pthread/tls): destructors
Also added tests for it.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-01-23 14:24:43 +11:00
Jeremy Soller ba99b7940c Merge branch 'langinfo.h-posix-2024' into 'master'
langinfo.h: add macros and a function for POSIX 2024

See merge request redox-os/relibc!907
2026-01-22 17:19:35 -07:00
Connor-GH 0baee310eb langinfo.h: add macros and a function for POSIX 2024
Additionally, the `CRNCYSTR` string was in the wrong place in
the string table. This has been fixed.

This completes all requirements for Sortie's os-test for the "include"
section of langinfo.
2026-01-22 18:11:32 -06:00
Jeremy Soller c2d759bfd1 Merge branch 'multiple_sigs' into 'master'
misc signal fixes

See merge request redox-os/relibc!873
2026-01-22 07:35:04 -07:00
Jacob Lorentzon eeba32b3a2 misc signal fixes 2026-01-22 07:35:04 -07:00
Jeremy Soller 1cba18f299 Merge branch 'ctype.h-locale-functions-impl' into 'master'
ctype/mod.rs: add locale_t type definition

See merge request redox-os/relibc!906
2026-01-22 07:29:56 -07:00
Connor-GH 7beaba6bce ctype/mod.rs: add locale_t type definition 2026-01-22 08:26:56 -06:00
Jeremy Soller a65c9282e6 Merge branch 'ctype.h-locale-functions-impl' into 'master'
ctype.h: add *_l family of functions

See merge request redox-os/relibc!905
2026-01-22 06:52:31 -07:00
Connor-GH 71d192fa4c ctype.h: add *_l family of functions
This commit adds all of the locale-based versions of the ctype
functions, like `isalpha_l`. This allows 14 more tests to pass for
os-test.
2026-01-22 07:39:24 -06:00
Wildan M 675a60bd9a Fix unixpeername expected stdout 2026-01-22 19:06:29 +07:00
Wildan M 6a455159ae Fix getaddrinfo hang due to infinite loop 2026-01-22 16:48:13 +07:00
Jeremy Soller 576fd5fe01 Merge branch 'ctype.h-locale_t-fix' into 'master'
ctype.h: add locale_t type

See merge request redox-os/relibc!904
2026-01-21 18:23:54 -07:00
Connor-GH cfd291f698 ctype.h: add locale_t type 2026-01-21 19:20:10 -06:00
Jeremy Soller a1a97069f6 Merge branch 'psignal-psiginfo-todo-completion' into 'master'
psignal/psiginfo: complete TODOs and remove allocations

See merge request redox-os/relibc!903
2026-01-21 17:10:34 -07:00
Connor-GH 89c0ff6570 psignal/psiginfo: complete TODOs and remove allocations
These implementations already passed the os-test test suite (and still
do after these changes), but I saw that they had some TODOs and some
overcomplicated code. If we want to be a fast libc, removing use of
`format!` where we can is likely a good first step because it
allocates memory.
2026-01-21 17:41:33 -06:00
Jeremy Soller 8548517784 Merge branch 'feature/deny-unsafe_op_in_unsafe_fn' into 'master'
Feature/deny unsafe op in unsafe fn

See merge request redox-os/relibc!902
2026-01-21 15:04:26 -07:00
sourceturner 1a04c02b06 Deny unsafe_op_in_unsafe_fn in generic-rt, ld_so, redox-ioctl 2026-01-21 22:43:00 +01:00
sourceturner e6ce5628da Use unsafe blocks in redox-rt 2026-01-21 22:41:46 +01:00
Jeremy Soller ac7b3c2b74 Merge branch 'shadow-sysprocfs-cleanup' into 'master'
shadow and sys_procfs header cleanup

See merge request redox-os/relibc!901
2026-01-21 06:15:39 -07:00
Jeremy Soller b44e3c2e31 Merge branch 'sgtty-sysioctl-cleanup' into 'master'
sgtty and sys_ioctl header cleanup

See merge request redox-os/relibc!900
2026-01-21 06:15:12 -07:00
auronandace f45bc46bfc shadow and sys_procfs header cleanup 2026-01-21 11:26:08 +00:00
auronandace cea71ae627 sgtty and sys_ioctl header cleanup 2026-01-21 10:50:36 +00:00
Jeremy Soller 3a8f64aa14 Merge branch 'namespace-improvement' into 'master'
Introduce namespace fd and related features

See merge request redox-os/relibc!797
2026-01-20 20:43:06 -07:00
Ibuki Omatsu 1bcb6dff78 Introduce namespace fd and related features 2026-01-20 20:43:05 -07:00
Jeremy Soller 4a50c8f313 Merge branch 'p12' into 'master'
fix(libc): use `ld.so`'s allocator

See merge request redox-os/relibc!882
2026-01-20 20:35:12 -07:00
Jeremy Soller 896c40507f Merge branch 'feature/deny-unsafe_op_in_unsafe_fn' into 'master'
Use unsafe blocks in some more unsafe functions, deny unsafe_op_in_unsafe_fn on crate level

See merge request redox-os/relibc!899
2026-01-20 16:48:35 -07:00
sourceturner defd2ce7c3 Deny deny-unsafe_op_in_unsafe_fn on the crate level 2026-01-21 00:41:57 +01:00
sourceturner 582e6eba69 Use unsafe blocks in some more unsafe functions
Building with redoxer showed some more places
that have to use unsafe blocks
2026-01-21 00:41:43 +01:00
Jeremy Soller 55aba2825e Merge branch 'locale.h-string.h-namespace-pollution-fix' into 'master'
string.h: don't pollute the namespace with locale.h

See merge request redox-os/relibc!898
2026-01-20 13:35:47 -07:00
Connor-GH cedd1686ba string.h: don't pollute the namespace with locale.h
Previously, we included all of `<locale.h>` in order to get `locale_t`.
This commit separates it into a `<bits/locale-t.h>` header (generated by
cbindgen) to better deal with this.
2026-01-20 14:29:08 -06:00
Jeremy Soller 3362ca356a Merge branch 'stdlib-cleanup' into 'master'
stdlib header cleanup

See merge request redox-os/relibc!897
2026-01-20 10:18:09 -07:00
auronandace 06971ff4bf stdlib header cleanup 2026-01-20 16:43:51 +00:00
Jeremy Soller 5d378c1460 Merge branch 'strings-endian-elf-cleanup' into 'master'
cleanup strings endian and elf headers

See merge request redox-os/relibc!896
2026-01-20 09:01:31 -07:00
auronandace c7e45afd23 cleanup strings endian and elf headers 2026-01-20 15:43:35 +00:00
Anhad Singh bbc86d8027 fix(libc): use ld.so's allocator
Previously, this was implemented incorrectly because `tcb.mspace` was
set just *before* jumping to the program's entry point. However,
`alloc_init` is called when the init functions are run for `libc.so`, so
`tcb.mspace` must be initialized *before* the init functions are
run.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-01-20 14:00:29 +11:00
Jeremy Soller ca46905fa9 Merge branch 'i586-guard-fix' into 'master'
Fix cbindgen 32 bit definition

See merge request redox-os/relibc!895
2026-01-19 17:54:06 -07:00
Wildan M 18b7b5456a Fix cbindgen 32 bit definition 2026-01-20 07:32:31 +07:00
Jeremy Soller e63c891af4 Merge branch 'string-locale' into 'master'
Fix CI regression caused by 0934bcf1

See merge request redox-os/relibc!894
2026-01-19 17:23:35 -07:00
Connor-GH 8544c078eb Fix CI regression caused by 0934bcf1
Previously, the CI was failing to build because it didn't
see `locale_t` inside of `<string.h>`. This commit adds
a hacky fix to this so that CI stops failing.

For now, this pollutes the C namespace by including locale
functions and definitions inside of `<string.h>`. In the
future, we will come up with a mechanism to export `locale_t`
by itself.
2026-01-19 18:19:20 -06:00
Jeremy Soller 79a636f853 Merge branch 'string-locale' into 'master'
Implement strxfrm_l, strcoll_l, and strerror_l

See merge request redox-os/relibc!893
2026-01-19 16:01:56 -07:00
Connor-GH 0934bcf13e Implement strxfrm_l, strcoll_l, and strerror_l
These implementations are effectively the same as the ones in musl.
2026-01-19 16:58:54 -06:00
Jeremy Soller b17df4daf5 Merge branch 'shutdown' into 'master'
netstack: Add shutdown syscall

See merge request redox-os/relibc!892
2026-01-19 09:34:46 -07:00
Akshit Gaur 3754effab8 Add shutdown syscall 2026-01-19 21:58:06 +05:30
Jeremy Soller 31e0766eb6 Merge branch 'master' into 'master'
fix(redox/build): missing unsafe blocks

See merge request redox-os/relibc!891
2026-01-19 03:55:38 -07:00
Anhad Singh c05e2da5b3 misc(all): formatting
Signed-off-by: Anhad Singh andypython@protonmail.com
2026-01-19 09:03:44 +00:00
Anhad Singh 81e6d4116a fix(redox/build): missing unsafe blocks
This change was made, commited, pushed and tested entirely on Redox :^)
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-01-19 08:42:41 +00:00
Jeremy Soller bfbbfb756c Merge branch 'feature/deny-unsafe_op_in_unsafe_fn' into 'master'
Use unsafe blocks in headers and modules

See merge request redox-os/relibc!890
2026-01-18 18:56:50 -07:00
sourceturner df5d7b2adb Use unsafe blocks in start.rs 2026-01-18 21:57:21 +01:00
sourceturner 86ca639b14 Use unsafe blocks in raw_cell.rs 2026-01-18 21:56:53 +01:00
sourceturner 0107a29e00 Use unsafe blocks in out.rs 2026-01-18 21:56:20 +01:00
sourceturner b5291171d3 Use unsafe blocks in macros.rs 2026-01-18 21:55:50 +01:00
sourceturner 1af4be27c0 Use unsafe blocks in c_vec.rs 2026-01-18 21:54:40 +01:00
sourceturner f6b0b3fde0 Use unsafe blocks in c_str.rs 2026-01-18 21:53:43 +01:00
sourceturner de27858da2 Use unsafe blocks in pthread module 2026-01-18 21:51:49 +01:00
sourceturner 2d5ac47214 Use unsafe blocks in platform module 2026-01-18 21:51:33 +01:00
sourceturner 0f23c03ba4 Use unsafe blocks in io module 2026-01-18 21:51:08 +01:00
sourceturner 718dc53b87 Use unsafe blocks in wchar.h implementation 2026-01-18 21:25:10 +01:00
sourceturner 83815c7433 Use unsafe blocks in utmp.h implementation 2026-01-18 21:23:50 +01:00
sourceturner 61e098eb2c Use unsafe blocks in unistd.h implementation 2026-01-18 21:23:24 +01:00
sourceturner 2cf1a2d16a Use unsafe blocks in time.h implementation 2026-01-18 21:22:57 +01:00
sourceturner 3873cf9a28 Use unsafe blocks in termios.h implementation 2026-01-18 21:21:03 +01:00
sourceturner 1a7136e6c4 Use unsafe blocks in sys/wait.h implementation 2026-01-18 21:20:33 +01:00
sourceturner 560360cb08 Use unsafe blocks in sys/utsname.h implementation 2026-01-18 21:20:14 +01:00
sourceturner 3ccfc170ad Use unsafe blocks in sys/uio.h implementation 2026-01-18 21:19:40 +01:00
sourceturner 3bfd14fcab Use unsafe blocks in sys/time.h implementation 2026-01-18 21:19:08 +01:00
sourceturner 093b830148 Use unsafe blocks in syslog.h implementation 2026-01-18 21:18:45 +01:00
sourceturner 263567f2cc Use unsafe blocks in sys/statvfs.h implementation 2026-01-18 21:18:06 +01:00
sourceturner 95c8e6ddb5 Use unsafe blocks in sys/stat.h implementation 2026-01-18 21:17:21 +01:00
sourceturner ee765594a3 Use unsafe blocks in sys/socket.h implementation 2026-01-18 21:16:57 +01:00
sourceturner 3326fafa90 Use unsafe blocks in sys/select.h implementation 2026-01-18 21:16:37 +01:00
sourceturner e076024268 Use unsafe blocks in sys/resource.h implementation 2026-01-18 21:16:02 +01:00
sourceturner 6aed86d282 Use unsafe blocks in sys/random.h implementation 2026-01-18 21:15:32 +01:00
sourceturner 3bace40832 Use unsafe blocks in ptrace compatibility layer 2026-01-18 21:14:56 +01:00
sourceturner 2720f41032 Use unsafe blocks in sys/mman.h implementation 2026-01-18 21:14:10 +01:00
sourceturner 3879cb641d Use unsafe blocks in ioctl implementation 2026-01-18 21:13:34 +01:00
sourceturner bb3ff6e068 Use unsafe blocks in sys/epoll.h implementation 2026-01-18 21:11:13 +01:00
sourceturner 59fb13ee2c Use unsafe blocks in stdlib.h implementation 2026-01-18 21:10:34 +01:00
sourceturner 891eb61239 Use unsafe blocks in pty.h implementation 2026-01-18 21:10:03 +01:00
sourceturner ac449a4338 Use unsafe blocks in pthread.h implementation 2026-01-18 21:09:17 +01:00
sourceturner e57ef36d3c Use unsafe blocks in netdb.h implementation 2026-01-18 21:01:15 +01:00
Jeremy Soller 2d149b51ae Merge branch 'limits-max' into 'master'
Define max limits in rust

See merge request redox-os/relibc!889
2026-01-17 06:59:05 -07:00
Jeremy Soller 1f61e80bef Merge branch 'printf-g-hash' into 'master'
stdio: Fix printf-g-hash test

See merge request redox-os/relibc!888
2026-01-17 06:53:18 -07:00
Wildan M 5476770359 Define max limits in rust 2026-01-17 18:17:35 +07:00
Akshit Gaur 1273868a3c stdio: Fix printf-g-hash test 2026-01-17 12:18:22 +05:30
Jeremy Soller ecd3a55797 Merge branch 'feature/deny-unsafe_op_in_unsafe_fn' into 'master'
Unsafe blocks: float ifaddrs locale malloc net_if pwd regex semaphore signal stdio string

See merge request redox-os/relibc!887
2026-01-16 15:22:23 -07:00
sourceturner f72ecfd8dc Use unsafe blocks in string.h implementation 2026-01-16 21:49:01 +00:00
sourceturner b3f7db83cf Use unsafe blocks in stdio.h implementation 2026-01-16 21:49:01 +00:00
sourceturner b3add24654 Use unsafe blocks in signal.h implementation 2026-01-16 21:49:01 +00:00
sourceturner a426887528 Use unsafe blocks in semaphore.h implementation 2026-01-16 21:49:01 +00:00
sourceturner 2e055a6d98 Use unsafe blocks in regex.h implementation 2026-01-16 21:49:01 +00:00
sourceturner 23fb2dd042 Use unsafe blocks in pwd.h implementation 2026-01-16 21:49:01 +00:00
sourceturner c22fa8af96 Use unsafe blocks in net_if.h implementation 2026-01-16 21:49:01 +00:00
sourceturner a27518ef2f Use unsafe blocks in malloc.h implementation 2026-01-16 21:49:01 +00:00
sourceturner 827df02158 Use unsafe blocks in locale.h implementation 2026-01-16 21:49:01 +00:00
sourceturner 12807920b6 Use unsafe blocks in ifaddrs.h implementation 2026-01-16 21:49:01 +00:00
sourceturner d539b134ef Use unsafe blocks in float.h implementation 2026-01-16 21:49:01 +00:00
Jeremy Soller 375061a69c Add sys/sysmacros.h from musl (fixes last commit) 2026-01-16 12:47:06 -07:00
Jeremy Soller 03c370d7f3 Fix dev_t type and add sys/sysmacros.h include from musl 2026-01-16 12:42:58 -07:00
Jeremy Soller 391baf41f2 Merge branch 'mutex-fork-test' into 'master'
Add fork inside thread test

See merge request redox-os/relibc!886
2026-01-16 05:31:14 -07:00
Wildan M d33bf64e5f Remove the mutex, just fork and threads 2026-01-16 13:26:16 +07:00
Wildan M fd616a9704 Add mutex inside fork test 2026-01-16 13:21:51 +07:00
Jeremy Soller b833e44293 Revert "Remove bits/stdlib"
This reverts commit 8867ba80df.
2026-01-15 18:40:23 -07:00
Jeremy Soller 40c9c14ea8 Revert "Convert strtold to Rust"
This reverts commit 08485648f6.
2026-01-15 18:31:47 -07:00
Jeremy Soller c8b4a03b45 Merge branch 'sys-socket-tests-2' into 'master'
Add more sys_socket tests, fix linux ARM compilation

See merge request redox-os/relibc!885
2026-01-15 17:57:43 -07:00
Wildan M 3bf35abeae Add more sys_socket tests 2026-01-16 07:18:13 +07:00
Wildan M fe6ad62ed8 Allow missing stderr file in expected tests 2026-01-16 07:10:28 +07:00
Wildan M e69e0b937e Fix linux aarch64 compilation 2026-01-16 07:09:57 +07:00
Jeremy Soller 8f0bdf95cc Merge branch 'recvfrom-uds' into 'master'
Append inner_af_unix with null, workaround unix dgram getpeername

See merge request redox-os/relibc!884
2026-01-15 14:26:07 -07:00
Wildan M e14a03fea4 Handle getpeername other error 2026-01-15 07:31:30 +07:00
Wildan M af7636daba Enable unix tests 2026-01-15 05:34:53 +07:00
Wildan M aa4572b613 Append inner_af_unix with null, workaround unix dgram getpeername 2026-01-15 05:26:44 +07:00
Jeremy Soller 57d300ce63 Merge branch 'add-mkdirat' into 'master'
Implement mkfifoat(2)

See merge request redox-os/relibc!881
2026-01-12 19:25:27 -07:00
Connor-GH da140913bc Implement mkfifoat(2) 2026-01-13 01:40:25 +00:00
Jeremy Soller 5265b732cc strtok_r: return the end of s in lasts when finished and only reference musl 2026-01-12 14:56:40 -07:00
Jeremy Soller 5b0c8b361b Merge branch 'master' into 'master'
add mathematical constants

See merge request redox-os/relibc!880
2026-01-12 12:38:28 -07:00
Pascal Reich 08f93dfbdc add mathematical constants 2026-01-12 12:38:28 -07:00
Jeremy Soller ffce2c2d25 Merge branch 'fix-ppoll' into 'master'
Handle signal mask in epoll_pwait

See merge request redox-os/relibc!879
2026-01-09 14:32:38 -07:00
Jeremy Soller b9fc058a47 Remove finished todo 2026-01-09 13:34:15 -07:00
Jeremy Soller a04c27a71e Early exit from poll if there are fds, and all are closed 2026-01-09 12:59:00 -07:00
Jeremy Soller 0a9095bb17 Fix epoll_pwait callback internally handling EINTR 2026-01-09 12:21:38 -07:00
Jeremy Soller d8f47cf5fb Handle signal mask in epoll_pwait 2026-01-09 11:46:54 -07:00
Jeremy Soller c433f39788 Merge branch 'add-mkdirat' into 'master'
Implement mkdirat

See merge request redox-os/relibc!878
2026-01-09 06:09:09 -07:00
Jeremy Soller 88b5a95da4 Merge branch 'p12' into 'master'
fix(pthread): use spinlock before the TCB has been activated

See merge request redox-os/relibc!875
2026-01-09 06:02:02 -07:00
Anhad Singh df647941c5 misc(pthread): remove the need for tid_mutex
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-01-09 22:55:58 +11:00
Connor-GH 75ca2cf29e Implement mkdirat
Linux's variant uses the syscall as intended. Redox's variant uses fpath to build a path to pass to mkdir from the file descriptor plus the file name, which isn't atomic due to the fpath lookup being subject to TOCTOU when paired with mkdir.
2026-01-08 17:56:49 -06:00
Jeremy Soller d5bf6db1b6 Merge branch 'inet-syscall' into 'master'
Adapt inet socket implementing SYS_CALL

See merge request redox-os/relibc!877
2026-01-08 08:52:30 -07:00
Jeremy Soller 0caf852888 Merge branch 'fix-accept-hang' into 'master'
Fix accept() hang, don't accept() on recvfrom

See merge request redox-os/relibc!876
2026-01-08 06:12:07 -07:00
Anhad Singh 665d2d489a fix(pthread): use spinlock before the TCB has been activated
Co-authored-by: @4lDO2
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-01-08 16:28:56 +11:00
Jeremy Soller 2c11d0f3cb Merge branch 'p12' into 'master'
fix(ld_so/dso): `TPOFF` with undefined symbol index

See merge request redox-os/relibc!874
2026-01-07 22:10:05 -07:00
Anhad Singh 79c0df3dda fix(ld_so/dso): TPOFF with undefined symbol index
Fixes random `rustc` errors/page fault:
```
Dump of assembler code for function _RNvYNCNkNvNtNtCskfd1poFMNVt_21rustc_data_structures4sync12worker_local8REGISTRY00INtNtNtCs713rKgAoQ4g_4core3ops8function6FnOnceTINtNtB1o_6option6OptionQIB23_INtNtNtB1o_4cell4once8OnceCellNtB8_8RegistryEEEEE9call_onceBc_:
   0x0000000007651e50 <+0>:	41 56              	push   r14
   0x0000000007651e52 <+2>:	53                 	push   rbx
   0x0000000007651e53 <+3>:	50                 	push   rax
   0x0000000007651e54 <+4>:	48 8b 1d 6d 9c 46 02	mov    rbx,QWORD PTR [rip+0x2469c6d]        # 0x9abbac8
   0x0000000007651e5b <+11>:	64 48 8b 04 25 00 00 00 00	mov    rax,QWORD PTR fs:0x0
   0x0000000007651e64 <+20>:	0f b6 4c 18 08     	movzx  ecx,BYTE PTR [rax+rbx*1+0x8]
   0x0000000007651e69 <+25>:	48 01 d8           	add    rax,rbx
   0x0000000007651e6c <+28>:	83 f9 01           	cmp    ecx,0x1
   0x0000000007651e6f <+31>:	74 07              	je     0x7651e78 <_RNvYNCNkNvNtNtCskfd1poFMNVt_21rustc_data_structures4sync12worker_local8REGISTRY00INtNtNtCs713rKgAoQ4g_4core3ops8function6FnOnceTINtNtB1o_6option6OptionQIB23_INtNtNtB1o_4cell4once8OnceCellNtB8_8RegistryEEEEE9call_onceBc_+40>
   0x0000000007651e71 <+33>:	83 f9 02           	cmp    ecx,0x2
   0x0000000007651e74 <+36>:	75 0a              	jne    0x7651e80 <_RNvYNCNkNvNtNtCskfd1poFMNVt_21rustc_data_structures4sync12worker_local8REGISTRY00INtNtNtCs713rKgAoQ4g_4core3ops8function6FnOnceTINtNtB1o_6option6OptionQIB23_INtNtNtB1o_4cell4once8OnceCellNtB8_8RegistryEEEEE9call_onceBc_+48>
   0x0000000007651e76 <+38>:	31 c0              	xor    eax,eax
   0x0000000007651e78 <+40>:	48 83 c4 08        	add    rsp,0x8
   0x0000000007651e7c <+44>:	5b                 	pop    rbx
   0x0000000007651e7d <+45>:	41 5e              	pop    r14
   0x0000000007651e7f <+47>:	c3                 	ret
   0x0000000007651e80 <+48>:	48 8d 35 69 11 00 00	lea    rsi,[rip+0x1169]        # 0x7652ff0 <_RINvNtNtNtNtCs7Gz96wxcBnT_3std3sys12thread_local6native5eager7destroyINtNtNtCs713rKgAoQ4g_4core4cell4once8OnceCellNtNtNtCskfd1poFMNVt_21rustc_data_structures4sync12worker_local8RegistryEEB1U_.llvm.5183627946997663933>
   0x0000000007651e87 <+55>:	48 89 c7           	mov    rdi,rax
   0x0000000007651e8a <+58>:	49 89 c6           	mov    r14,rax
   0x0000000007651e8d <+61>:	ff 15 c5 6b 47 02  	call   QWORD PTR [rip+0x2476bc5]        # 0x9ac8a58
   0x0000000007651e93 <+67>:	4c 89 f0           	mov    rax,r14
   0x0000000007651e96 <+70>:	64 48 8b 0c 25 00 00 00 00	mov    rcx,QWORD PTR fs:0x0
    # rcx = 0x20aeb000 [FSBASE]
    # rbx = 0x2b40
   0x0000000007651e9f <+79>:	c6 44 19 08 01     	mov    BYTE PTR [rcx+rbx*1+0x8],0x1 # <--- PAGE FAULT
   0x0000000007651ea4 <+84>:	48 83 c4 08        	add    rsp,0x8
   0x0000000007651ea8 <+88>:	5b                 	pop    rbx
   0x0000000007651ea9 <+89>:	41 5e              	pop    r14
   0x0000000007651eab <+91>:	c3                 	ret
```

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-01-08 11:45:36 +11:00
Wildan M f56bfc4883 Adapt inet socket implementing SYS_CALL 2026-01-08 04:05:19 +07:00
Wildan M ad3a39771b Add more test 2026-01-08 01:42:46 +07:00
Wildan M 02752dda27 Enable some tests 2026-01-07 22:59:34 +07:00
Wildan M 99c942318a Fix inet hang, don't accept() on recvfrom 2026-01-07 22:59:20 +07:00
Jeremy Soller 8c20bc7899 Merge branch 'sys-socket-tests' into 'master'
Add sys_socket tests, Update failing tests

See merge request redox-os/relibc!872
2026-01-07 07:03:07 -07:00
Jeremy Soller 28e238c8e4 Merge branch 'flock-mutex' into 'master'
Use pthread recursive mutex for flockfile

See merge request redox-os/relibc!871
2026-01-07 07:02:35 -07:00
Jeremy Soller fe284c1229 Merge branch 'cond-n-timedlock' into 'master'
Release pthread cond workaround, fix mutex timedlock

See merge request redox-os/relibc!870
2026-01-07 07:01:58 -07:00
Jeremy Soller 992063148f Merge branch 'p12' into 'master'
misc(macros.rs): `{e}print{ln}` use `format_args!()`

See merge request redox-os/relibc!868
2026-01-07 06:59:36 -07:00
Anhad Singh a97216aa93 misc(macros.rs): {e}print{ln} use format_args!()
Allows to capture identifiers in format strings.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-01-07 13:16:07 +11:00
Wildan M 053525fba1 Update failing tests 2026-01-07 04:52:35 +07:00
Wildan M 9c67018022 Add sys_socket tests 2026-01-07 04:48:31 +07:00
Jeremy Soller 6e23a1342f Merge branch 'pthread-timedwait' into 'master'
Implement pthread_cond_timedwait futex properly

See merge request redox-os/relibc!867
2026-01-06 12:05:13 -07:00
Wildan M 6b191f8c63 Adjust mutex test 2026-01-07 01:44:51 +07:00
Wildan M 6ef56f5bc9 Use pthread recursive mutex for flockfile 2026-01-07 00:54:20 +07:00
Wildan M 9789af36f0 Put timespec convert into common fn 2026-01-07 00:07:50 +07:00
Wildan M ba4d789f6e Calculate pthread_mutex_timedlock clock 2026-01-06 23:33:00 +07:00
Wildan M b063aadaa5 Release pthread cond workaround, simplify 2026-01-06 23:32:15 +07:00
Jeremy Soller 5cae0f91ea Merge branch 'utmp-wctype-cleanup' into 'master'
utmp and wctype header cleanup

See merge request redox-os/relibc!866
2026-01-06 06:24:37 -07:00
Jeremy Soller 81ee7889d9 Merge branch 'pwd-pty-cleanup' into 'master'
pwd and pty header cleanup

See merge request redox-os/relibc!865
2026-01-06 06:22:06 -07:00
auronandace 0042a808b0 utmp and wctype header cleanup 2026-01-06 10:08:13 +00:00
Wildan M 10b5513e09 Fix other pthread tests 2026-01-06 16:12:50 +07:00
Wildan M fab87ae2d8 Fix i586 compilation and add more checks 2026-01-06 15:56:57 +07:00
auronandace 9936d2e5d4 pwd and pty header cleanup 2026-01-06 08:56:04 +00:00
Wildan M 0ade938c63 Add pthread/timedwait to Makefile 2026-01-06 15:43:11 +07:00
Wildan M 242ed32b42 Implement pthread_cond_timedwait futex properly 2026-01-06 15:33:58 +07:00
Jeremy Soller 3eeaf4eb22 Merge branch 'putc-unlocked-test' into 'master'
Add putc_unlocked tests

See merge request redox-os/relibc!863
2026-01-05 06:22:18 -07:00
Jeremy Soller a3079a0ef2 Merge branch 'doc-test' into 'master'
Enhance single test run, document check.sh

See merge request redox-os/relibc!862
2026-01-05 06:20:52 -07:00
Wildan M 7f30fd2c42 Restore correct sleep values 2026-01-05 14:38:39 +07:00
Wildan M 13b105a54e Fix failing tests 2026-01-05 14:38:11 +07:00
Wildan M 1e587dc77b Add putc_unlocked tests 2026-01-05 12:43:51 +07:00
Wildan M 11d2bcede6 Enhance single test run, document check.sh 2026-01-05 11:23:14 +07:00
Jeremy Soller 79f88ab6ad Merge branch 'malloc-usable-size' into 'master'
Implement malloc_usable_size

See merge request redox-os/relibc!860
2026-01-03 19:01:36 -07:00
Wildan M b5b2d0f4a0 Add malloc/usable_size into tests 2026-01-04 02:46:40 +07:00
Wildan M 0a5b046299 Update dlmalloc 2026-01-04 02:44:50 +07:00
Wildan M 7d1c3961b5 Implement malloc_usable_size 2026-01-04 02:15:29 +07:00
Jeremy Soller 7f1bbc7426 Merge branch 'sysauxv-sysfile-sysrandom-cleanup' into 'master'
sys_auxv sys_file and sys_random header cleanup

See merge request redox-os/relibc!858
2026-01-02 14:46:44 -07:00
auronandace 34c3ec3e6b sys_auxv sys_file and sys_random header cleanup 2026-01-02 21:23:58 +00:00
Jeremy Soller db0ef9cde8 Merge branch 'systime-systimeb-sysmman-cleanup' into 'master'
sys_time sys_timeb and sys_mman header cleanup

See merge request redox-os/relibc!857
2026-01-02 12:21:42 -07:00
auronandace 5576521c12 sys_time sys_timeb and sys_mman header cleanup 2026-01-02 18:24:01 +00:00
Jeremy Soller 5a1b5eab07 Merge branch 'inttypes-malloc-errno-cleanup' into 'master'
inttypes malloc and errno header cleanup

See merge request redox-os/relibc!856
2026-01-02 06:37:40 -07:00
Jeremy Soller 878aa97579 Merge branch 'getopt-cleanup' into 'master'
getopt cleanup

See merge request redox-os/relibc!855
2026-01-02 06:33:33 -07:00
Jeremy Soller c2491060e4 Merge branch 'multicore-workaround' into 'master'
Run relibc tests CI in single core again

See merge request redox-os/relibc!854
2026-01-02 06:31:53 -07:00
auronandace 09c5eb43b7 inttypes malloc and errno header cleanup 2026-01-02 11:43:50 +00:00
auronandace d00994be35 getopt cleanup 2026-01-02 09:01:31 +00:00
Wildan M 7fcdbec309 Run relibc tests CI in single core again 2026-01-01 23:41:28 +07:00
Jeremy Soller b269ccbd6f Merge branch 'p12' into 'master'
misc(Makefile): add other crates as source

See merge request redox-os/relibc!853
2026-01-01 09:09:52 -07:00
Anhad Singh 4c90ea3506 misc(Makefile): add other crates as source
Otherwise it would say there is nothing to do and `touch src && make`
would be required to trigger a rebuild.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-01-02 02:45:44 +11:00
Jeremy Soller 2d6ae4a750 Merge branch 'p12' into 'master'
fix(string/memcmp): use `read_unaligned` where alignment is not guaranteed

See merge request redox-os/relibc!852
2026-01-01 07:17:18 -07:00
Anhad Singh 5f256f91cd fix(string/memcmp): use read_unaligned where alignment is not guaranteed
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-01-02 00:52:40 +11:00
Jeremy Soller 5d9c80e427 Merge branch 'netinet-in-tcp-netif-cleanup' into 'master'
netinet_in netinet_tcp and net_if header cleanup

See merge request redox-os/relibc!851
2025-12-31 13:27:17 -07:00
auronandace 10218009d1 netinet_in netinet_tcp and net_if header cleanup 2025-12-31 19:57:21 +00:00
Jeremy Soller 0f0880d750 Merge branch 'time-utime-cleanup' into 'master'
time and utime header cleanup

See merge request redox-os/relibc!850
2025-12-31 09:38:55 -07:00
auronandace 911c36ecd3 time and utime header cleanup 2025-12-31 15:54:25 +00:00
Jeremy Soller 2a39863003 Merge branch 'crypt-cleanup' into 'master'
crypt header cleanup

See merge request redox-os/relibc!849
2025-12-31 07:17:47 -07:00
auronandace 191b8b5f8b crypt header cleanup 2025-12-31 13:58:44 +00:00
Jeremy Soller fb6ee6c43b Merge branch 'fix-riscv64' into 'master'
Fix riscv64gc build on CI

See merge request redox-os/relibc!812
2025-12-31 06:08:15 -07:00
Jeremy Soller 05a3e9270e Merge branch 'fix-dl-tls-i586-global_asm' into 'master'
re-add the global_asm macro import for i586

See merge request redox-os/relibc!848
2025-12-31 06:07:35 -07:00
Jeremy Soller 9540268e57 Merge branch 'arpa-inet-semaphore-cleanup' into 'master'
arpa_inet and semaphore header cleanup

See merge request redox-os/relibc!847
2025-12-31 06:05:03 -07:00
Jeremy Soller 07d1064f40 Merge branch 'ifaddrs-defs' into 'master'
Add constants to complement ifaddrs.h

See merge request redox-os/relibc!846
2025-12-31 06:04:29 -07:00
Wildan M 97dbcb72bc Fix testing riscv64gc 2025-12-31 17:23:10 +07:00
auronandace 0a9902d78f re-add the global_asm macro import for i586 2025-12-31 09:53:06 +00:00
auronandace 6e25b2be7f arpa_inet and semaphore header cleanup 2025-12-31 09:14:21 +00:00
Wildan M baee8f2851 Add constants to complement ifaddrs.h 2025-12-31 16:03:03 +07:00
Jeremy Soller 806b3657f1 Merge branch 'setlocale-c' into 'master'
Fix setlocale with "C"

See merge request redox-os/relibc!845
2025-12-30 16:38:14 -07:00
Jeremy Soller 556bcf4ced Merge branch 'locale-fnmatch-dirent-ctype-cleanup' into 'master'
locale fnmatch dirent and ctype header cleanup

See merge request redox-os/relibc!844
2025-12-30 14:13:43 -07:00
auronandace 6696d26eb4 locale fnmatch dirent and ctype header cleanup 2025-12-30 20:57:47 +00:00
Wildan M 9734bdbde6 Fix setlocale with "C" 2025-12-31 02:29:55 +07:00
Jeremy Soller 0e506e97af Merge branch 'locale-h' into 'master'
Implement more locale.h functions

See merge request redox-os/relibc!840
2025-12-29 10:00:44 -07:00
Jeremy Soller 15d82a9086 Merge branch 'master' into 'master'
fix(dl-tls): TLS overallocation

See merge request redox-os/relibc!843
2025-12-29 06:57:57 -07:00
Anhad Singh 75f6b9d64e fix(dl-tls): TLS overallocation
* `offset` is the offset in TLS to copy initial data to NOT the segment
  size
* Only zero the region which is required to be zeroed

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-29 17:13:23 +11:00
Jeremy Soller 6a0c256b84 Merge branch 'rm-bits-stdlib' into 'master'
Remove bits/stdlib

See merge request redox-os/relibc!842
2025-12-28 06:21:22 -07:00
Wildan M 8867ba80df Remove bits/stdlib 2025-12-28 19:43:54 +07:00
Wildan M e0d41a17e7 Disable test requiring custom locales 2025-12-28 15:45:17 +07:00
Wildan M e67933ef1b Use POSIX localedef format 2025-12-28 03:24:20 +07:00
Wildan M 19d95a226c Add tests for new locale.h functions 2025-12-27 22:25:01 +07:00
Wildan M a5035d68e3 Implement more locale.h functions 2025-12-27 22:24:41 +07:00
Jeremy Soller be446db7c3 Merge branch 'single-test-n-linkflag' into 'master'
Add single test run and Add link flag

See merge request redox-os/relibc!841
2025-12-27 06:42:04 -07:00
Wildan M 5bd0515c6a Add link flag for boostrapping 2025-12-27 19:42:55 +07:00
Wildan M 2f4753bdfa Add single test run in check script 2025-12-27 19:42:24 +07:00
Jeremy Soller 81569dea40 Merge branch 'master' into 'master'
fix(ld_so): minor fixes

See merge request redox-os/relibc!839
2025-12-26 08:09:12 -07:00
Anhad Singh 4245e9148e fix(load_objects_recursive): TLS overallocation
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-27 01:12:07 +11:00
Jeremy Soller bb3cadfca4 Merge branch 'reduce-warn-2' into 'master'
Reduce cbindgen warning from errno.h

See merge request redox-os/relibc!838
2025-12-25 05:56:43 -07:00
Jeremy Soller 20c237c03e Merge branch 'strtold' into 'master'
Convert strtold to Rust

See merge request redox-os/relibc!837
2025-12-25 05:55:56 -07:00
Wildan M 8f97d2298a Reduce cbindgen warning from errno.h 2025-12-25 16:50:26 +07:00
Wildan M 08485648f6 Convert strtold to Rust 2025-12-25 16:11:36 +07:00
Jeremy Soller d82db81ae2 Merge branch 'os-test-fixes' into 'master'
os-test fixes

See merge request redox-os/relibc!825
2025-12-24 20:52:45 -07:00
Jeremy Soller fbf280c3d7 Fix padding of infinite float 2025-12-24 20:32:54 -07:00
Jeremy Soller f3afff08de Adjust ftell for write buffer 2025-12-24 20:13:13 -07:00
Jeremy Soller ae509fd641 Merge branch 'fix-memccpy' into 'master'
Fix memccpy

See merge request redox-os/relibc!836
2025-12-24 12:39:34 -07:00
auronandace 98d90ac580 revert previous 2 changes and add Safety note 2025-12-24 14:32:08 +00:00
auronandace d4d82843de fix type 2025-12-24 12:56:30 +00:00
auronandace 16f1f71acb ensure internal memcpy does not copy past src or dest len 2025-12-24 12:42:28 +00:00
auronandace 4e744c3f55 only import the needed types 2025-12-24 11:05:12 +00:00
auronandace 96da8e5ed4 fix memccpy, copy correct amount of bytes and still copy if c not found 2025-12-24 11:02:15 +00:00
Jeremy Soller 9207d35150 Merge branch 'header-spec-link-cleanup' into 'master'
Header spec link cleanup

See merge request redox-os/relibc!835
2025-12-23 16:54:43 -07:00
auronandace 6dd3a38f30 mark getpwnam as unsafe 2025-12-23 09:28:10 +00:00
auronandace 4786080073 only import needed types in syslog 2025-12-23 09:23:46 +00:00
auronandace 321b65d7e1 Update and add spec links, correct typo 2025-12-23 09:21:28 +00:00
Jeremy Soller 1dd1528fc9 Merge branch 'unistd-cleanup' into 'master'
Unistd cleanup

See merge request redox-os/relibc!834
2025-12-22 12:40:22 -07:00
auronandace 8414205d04 only import the needed types 2025-12-22 17:47:29 +00:00
auronandace 8deb1f32c3 mark two functions unsafe 2025-12-22 17:40:51 +00:00
Jeremy Soller 250f072973 Merge branch 'fix-aarch64-test' into 'master'
Fix aarch64 test compilation

See merge request redox-os/relibc!832
2025-12-22 06:43:14 -07:00
Jeremy Soller 46dc91a723 Merge branch 'doc-setjmp-and-glob' into 'master'
Doc setjmp and glob

See merge request redox-os/relibc!833
2025-12-22 06:41:49 -07:00
auronandace 4102e1b47d only import needed types 2025-12-22 10:16:15 +00:00
auronandace 5d4b6bc2ee update and add spec links for glob and setjmp 2025-12-22 10:12:50 +00:00
Anhad Singh a7918b108d misc(ld_so/start): consistent log formatting
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-22 19:06:10 +11:00
Anhad Singh fa2cf35007 feat(ld_so/x86_64): do not use the call trick
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-22 18:19:24 +11:00
Wildan M 91873d21fe Fix aarch64 test compilation 2025-12-22 04:03:32 +07:00
Jeremy Soller 99e8cd93e0 Merge branch 'drm10' into 'master'
Add drm MODE_GET_PROPERTY, MODE_SET_PROPERTY and MODE_GET_PROP_BLOB

See merge request redox-os/relibc!831
2025-12-21 13:34:05 -07:00
Jeremy Soller bd6dea9b52 Merge branch 'doc-monetary' into 'master'
update and add spec links for monetary

See merge request redox-os/relibc!830
2025-12-21 13:33:18 -07:00
Jeremy Soller 517b62a781 Merge branch 'chmod-test' into 'master'
Fix fstatat tests

See merge request redox-os/relibc!829
2025-12-21 13:32:40 -07:00
bjorn3 a710decf1b Add drm MODE_GET_PROPERTY, MODE_SET_PROPERTY and MODE_GET_PROP_BLOB 2025-12-21 20:38:53 +01:00
auronandace fa15f44f58 update and add spec links for monetary 2025-12-21 17:13:08 +00:00
Wildan M 74341384d2 Fix statat tests 2025-12-21 23:05:26 +07:00
Jeremy Soller c60b352652 Merge branch 'clock-getres' into 'master'
Implement clock_getres

See merge request redox-os/relibc!826
2025-12-21 06:08:49 -07:00
Wildan M ff60a2483b Implement clock_getres 2025-12-21 15:13:46 +07:00
Jeremy Soller eb0693ece0 Merge branch 'drm9' into 'master'
Add drm MODE_ADD_FB and MODE_RM_FB

See merge request redox-os/relibc!828
2025-12-20 15:56:15 -07:00
bjorn3 b69c6a2e11 Add drm MODE_ADD_FB and MODE_RM_FB 2025-12-20 22:10:39 +01:00
Jeremy Soller b9d9eed22f Merge branch 'drm8' into 'master'
Fix definition of drm_mode_crtc

See merge request redox-os/relibc!827
2025-12-20 08:32:54 -07:00
bjorn3 16decee904 Fix definition of drm_mode_crtc 2025-12-20 16:03:50 +01:00
Jeremy Soller 0d75833b93 Merge branch 'os-test-linux' into 'master'
Fix various os-test issues when using relibc on Linux

See merge request redox-os/relibc!824
2025-12-19 13:57:43 -07:00
Jeremy Soller c489dee545 Add TIOCGSID definition for Redox 2025-12-19 13:38:20 -07:00
Jeremy Soller e4bc87f97d Update tcgetsid link 2025-12-19 13:27:00 -07:00
Jeremy Soller b1c9847b97 Include sys/stat.h and unistd.h in fcntl.h, remove bits/fcntl.h 2025-12-19 13:01:45 -07:00
Jeremy Soller c45d06e747 Add locale_t 2025-12-19 12:55:55 -07:00
Jeremy Soller 3765148270 Fix incompatible functions 2025-12-19 12:55:43 -07:00
Jeremy Soller 84c3ba910c Implement tcgetwinsize and fix tcsetwinsize 2025-12-19 12:27:10 -07:00
Jeremy Soller 593e4bf416 Include sys/types.h in termios.h 2025-12-19 12:22:27 -07:00
Jeremy Soller 7301eff5ba Stub ifaddrs.h 2025-12-19 12:18:21 -07:00
Jeremy Soller 3654575ca1 Implement fexecve on Linux 2025-12-19 12:18:02 -07:00
Jeremy Soller 1bbdcc1202 Implement fwscanf and similar 2025-12-19 12:12:16 -07:00
Jeremy Soller 302f4ab2d1 Add AT_EACCESS and AT_SYMLINK_FOLLOW for Linux 2025-12-19 11:59:51 -07:00
Jeremy Soller 09f0e57f1b Fix dladdr definition 2025-12-19 11:55:34 -07:00
Jeremy Soller 0405048890 Format limits and sysconf 2025-12-19 11:46:38 -07:00
Jeremy Soller 3b963b2745 Add missing sigsetsize argument to EPOLL_PWAIT syscall on Linux 2025-12-19 11:46:11 -07:00
Jeremy Soller b707c37883 Implement tcgetsid using ioctl 2025-12-19 10:32:56 -07:00
Jeremy Soller 7e987b67bc Add more limits and expose them through sysconf 2025-12-19 10:18:15 -07:00
Jeremy Soller 6617f6afda Define F_OFD fcntl commands 2025-12-19 09:23:33 -07:00
Jeremy Soller c1d3ff3d53 Add POSIX limits 2025-12-19 09:15:45 -07:00
Jeremy Soller c780954767 Merge branch 'doc-float-and-fenv' into 'master'
Doc float and fenv

See merge request redox-os/relibc!823
2025-12-19 09:00:16 -07:00
Jeremy Soller 9d15760ef5 Fix chown on linux by adding fchownat flags to syscall 2025-12-19 08:59:18 -07:00
Jeremy Soller 4daa52a6bd Implement _Fork, which is fork without pthread_atfork hooks 2025-12-19 08:49:53 -07:00
auronandace c5c4d9e10c only import the needed types 2025-12-19 15:41:56 +00:00
auronandace 2fa1641299 update and add spec links 2025-12-19 15:39:29 +00:00
Jeremy Soller 6ef2884f03 Merge branch 'hang-workaround' into 'master'
Add timeout for workaround hang test

See merge request redox-os/relibc!822
2025-12-19 06:18:23 -07:00
Jeremy Soller c895f71df8 Merge branch 'doc-signal' into 'master'
Doc signal

See merge request redox-os/relibc!821
2025-12-19 05:45:02 -07:00
Jeremy Soller 8f930003e3 Merge branch 'reduce-warn' into 'master'
Reduce logs on openlibm and warning on time.h

See merge request redox-os/relibc!820
2025-12-19 05:44:09 -07:00
Wildan M cad498d8de Add timeout for workaround hang test 2025-12-19 19:13:03 +07:00
auronandace bf1462c763 only import the needed types 2025-12-19 10:19:56 +00:00
Wildan M fc2937b648 Correct out strcpy expected output 2025-12-19 17:15:28 +07:00
auronandace 34a16aca5d update and add spec links 2025-12-19 10:13:35 +00:00
Wildan M e2f8eb43a6 Reduce logs on openlibm and warning on time.h 2025-12-19 15:06:20 +07:00
Jeremy Soller 0d07e30430 Merge branch 'dyn-tests' into 'master'
Use dynamic link and add more tests

See merge request redox-os/relibc!814
2025-12-18 21:42:12 -07:00
Jeremy Soller 2c8c15aa45 Merge branch 'master' into 'master'
fix(sync/futex_wait): handle `EINTR`

See merge request redox-os/relibc!819
2025-12-18 20:15:05 -07: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
Wildan M f6fa58bbbc Fix NATIVE_RELIBC=0 2025-12-18 12:26:34 +07:00
Jeremy Soller 13b93e0f90 Merge branch 'master' into 'master'
fix(redox-rt/signal/x86_64): corrupted `r8`/`r10`

See merge request redox-os/relibc!817
2025-12-17 21:34:45 -07:00
Wildan M 42d5369d41 Make test runner hang proof 2025-12-18 10:16:08 +07:00
Wildan M fb01e89508 Adjust test sleeps 2025-12-18 10:13:40 +07:00
Anhad Singh afbd5986a5 fix(redox-rt/signal/x86_64): corrupted r8/r10
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-18 14:03:13 +11:00
Jeremy Soller a88ce5116a Merge branch 'replace-unlink-rmdir-with-unlinkat' into 'master'
refactor: Replace unlink and rmdir with unlinkat. Improve fork using ForkScratchPad.

See merge request redox-os/relibc!805
2025-12-17 18:32:08 -07:00
Ibuki Omatsu efa5b73015 refactor: Replace unlink and rmdir with unlinkat. Improve fork using ForkScratchPad. 2025-12-17 18:32:07 -07:00
Wildan M d902941b14 Use dynamic link for tests 2025-12-18 07:52:26 +07:00
Jeremy Soller 2162d50358 Merge branch 'drm7' into 'master'
Support dumb buffer drm ioctls

See merge request redox-os/relibc!816
2025-12-17 15:58:49 -07:00
bjorn3 22f5f23642 Support dumb buffer drm ioctls 2025-12-17 22:56:11 +01:00
bjorn3 2199c0fa10 Remove unused method from drm::Dev 2025-12-17 22:14:32 +01:00
Jeremy Soller e10013d5bf Merge branch 'fix_getopt' into 'master'
Allow NULL as longindex parameter on getopt_long

See merge request redox-os/relibc!815
2025-12-17 12:02:10 -07:00
Bendeguz Pisch 89d7ed0120 Allow NULL as longindex parameter on getopt_long 2025-12-17 18:34:28 +01:00
Jeremy Soller 563be395f9 Merge branch 'fix-strlcat-and-strlcpy' into 'master'
fix strlcat and strlcpy bytes amount

See merge request redox-os/relibc!813
2025-12-17 08:20:52 -07:00
auronandace 0392c0b736 fix strlcat and strlcpy bytes amount 2025-12-17 14:56:59 +00:00
Jeremy Soller 8c533a450d Merge branch 'arm-ci' into 'master'
Update aarch64 CI test

See merge request redox-os/relibc!811
2025-12-17 06:26:57 -07:00
Wildan M ea0fac88c1 Update aarch64 CI test 2025-12-17 09:48:48 +07:00
Jeremy Soller 3ebd43b4ce Merge branch 'drm' into 'master'
Implement DRM ioctls for Redox

See merge request redox-os/relibc!801
2025-12-16 12:56:22 -07:00
Jeremy Soller d1b2c8a232 Merge branch 'drm6' into 'drm'
Move drm ioctl (de)serialization into a new redox-ioctl crate

See merge request redox-os/relibc!810
2025-12-16 12:55:28 -07:00
bjorn3 61dc527156 Move drm ioctl (de)serialization into a new redox-ioctl crate
This will make it easier to share this code with gpu drivers in the base
repo.
2025-12-16 20:38:05 +01:00
Jeremy Soller 3e6e90afd8 Merge branch 'doc-stdio' into 'master'
Doc stdio

See merge request redox-os/relibc!809
2025-12-16 11:07:33 -07:00
auronandace 95f7a12b8b only import needed types 2025-12-16 16:46:05 +00:00
auronandace 887a53c1b2 update and add spec links 2025-12-16 16:42:08 +00:00
Jeremy Soller f2ff75606e Merge branch 'doc-wchar' into 'master'
Doc wchar

See merge request redox-os/relibc!808
2025-12-16 07:02:52 -07:00
auronandace e913e2447b fix fmt 2025-12-16 11:20:37 +00:00
auronandace 59295af7d8 mark 2 functions as unsafe 2025-12-16 11:14:02 +00:00
auronandace e041d5b552 only import needed types 2025-12-16 11:10:55 +00:00
auronandace 973b96a727 update and add spec links 2025-12-16 10:59:38 +00:00
Jeremy Soller 220b8eae52 Merge branch 'drm5' into 'drm'
Port remaining drm ioctls to the new infrastructure

See merge request redox-os/relibc!807
2025-12-15 15:58:28 -07:00
bjorn3 c4ffcedbd0 Port remaining drm ioctls to the new infrastructure 2025-12-15 23:34:44 +01:00
Jeremy Soller ff25ae3470 Merge branch 'drm4' into 'drm'
Introduce infrastructure for serializing ioctls

See merge request redox-os/relibc!806
2025-12-15 14:54:48 -07:00
bjorn3 cf90f89b42 Introduce infrastructure for serializing ioctls
And use it for a couple of drm interfaces
2025-12-15 22:26:52 +01:00
Jeremy Soller 6a362acb4f Merge branch 'fix-strlcpy-and-strlcat' into 'master'
fix strlcpy and strlcat

See merge request redox-os/relibc!804
2025-12-15 07:01:28 -07:00
auronandace c2da2a8e47 fix expected output of strcpy test 2025-12-15 08:28:25 +00:00
auronandace 6c62e7e401 fix strlcpy and strlcat 2025-12-15 07:58:44 +00:00
Jeremy Soller 8d136acfb0 Merge branch 'drm3' into 'drm'
Use drm-sys for DRM types and consts

See merge request redox-os/relibc!803
2025-12-14 14:41:08 -07:00
bjorn3 93f9401cf0 Use drm-sys for DRM types and consts 2025-12-14 22:32:43 +01:00
Jeremy Soller e7a81dac77 Merge branch 'drm2' into 'drm'
drm: Use new VERSION, GET_CAP and SET_CLIENT_CAP driver commands

See merge request redox-os/relibc!802
2025-12-14 12:53:39 -07:00
bjorn3 d70e2dc610 drm: Use new VERSION, GET_CAP and SET_CLIENT_CAP driver commands 2025-12-14 20:47:41 +01:00
bjorn3 395c686f8d Rustfmt 2025-12-14 20:46:36 +01:00
bjorn3 6bce162b92 Fix read-only and write-only ioctls
Read-only ioctls write data to userspace, while write-only ioctls read
data from userspace. This matches the read and write syscalls.
2025-12-14 20:45:26 +01:00
Jeremy Soller 105b24a21f Implement DRM ioctls for Redox 2025-12-14 08:39:00 -07:00
Jeremy Soller ec8d28b164 Merge branch 'doc-pthread' into 'master'
Doc pthread

See merge request redox-os/relibc!800
2025-12-13 14:49:59 -07:00
auronandace d2429a1164 only import the needed types 2025-12-13 21:10:51 +00:00
auronandace 59e028d96d Update and add spec links 2025-12-13 20:56:02 +00:00
Jeremy Soller ea9c546d9b Merge branch 'doc-sys-times-and-termios' into 'master'
update and add spec links and only import needed types for sys_times and termios

See merge request redox-os/relibc!799
2025-12-13 06:28:59 -07:00
auronandace eff0a795bc update and add spec links and only import needed types for sys_times and termios 2025-12-13 08:56:43 +00:00
Jeremy Soller d5d64994e7 Merge branch 'doc-regex' into 'master'
Doc regex

See merge request redox-os/relibc!798
2025-12-12 14:25:46 -07:00
auronandace db82136fe4 only import needed types in regex 2025-12-12 21:08:31 +00:00
auronandace 2b4c2f9ddf update and add spec links to regex 2025-12-12 21:06:15 +00:00
Jeremy Soller 9db10bb0a9 Merge branch 'master' into 'master'
fix(redox-rt/proc): `min_mmap_addr` being set too low

See merge request redox-os/relibc!796
2025-12-12 07:01:22 -07:00
Anhad Singh f7aa718596 fix(redox-rt/proc): min_mmap_addr being set too low
`cmp::min` -> `cmp::max` Want to make sure we set the `min_mmap_addr` to
the top of the executable.

`update_min_mmap_addr(STACK_TOP - STACK_SIZE, STACK_SIZE);` needs to be
removed since we cannot allocate above that.

Reverts to the old behaviour. In future may want to consider loading the
executeable here instead of the dynamic linker (and before the dynamic
linker) to avoid any further conflicts.

Fixes `gcc` crashing at "failed to map
/usr/libexec/gcc/x86_64-unknown-redox/13.2.0/cc1. errno: 17" (where 17
-> EEXIST).

Co-authored-by: @bjorn3
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-12 17:49:36 +11:00
Jeremy Soller 41c627b2e7 Merge branch 'doc-grp' into 'master'
Doc grp

See merge request redox-os/relibc!795
2025-12-11 09:25:32 -07:00
auronandace 329c7c42f8 only import needed types 2025-12-11 15:10:03 +00:00
auronandace a1b23a3dbf update and add spec links to grp 2025-12-11 15:06:57 +00:00
Jeremy Soller 0fdd15b76d Merge branch 'add-ci' into 'master'
Write unified test script and make test readable

See merge request redox-os/relibc!794
2025-12-10 11:37:25 -07:00
Wildan M a948dffb38 Restore hangs workaround 2025-12-10 23:41:12 +07:00
Wildan M 31797971bc Write unified test script and make test readable 2025-12-10 23:28:57 +07:00
Jeremy Soller e2870172d8 Merge branch 'p2' into 'master'
fix(redox-rt/proc): `from_raw` should negate `raw` for `KillProcTarget::ProcGroup`

See merge request redox-os/relibc!793
2025-12-10 06:17:26 -07:00
Jeremy Soller 89986a6b10 Merge branch 'arm-dynlink' into 'master'
Fix missing symbols for ARM dynamic linking

See merge request redox-os/relibc!763
2025-12-10 06:16:16 -07:00
Wildan Mubarok d6eaa0dbf9 Fix missing symbols for ARM dynamic linking 2025-12-10 06:16:16 -07:00
Jeremy Soller b8bae33fde Merge branch 'master' into 'master'
fix(riscv64/x86): build

See merge request redox-os/relibc!792
2025-12-09 21:52:38 -07:00
Anhad Singh 3f986068e9 fix(redox-rt/proc): from_raw should negate raw for
`KillProcTarget::ProcGroup`

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-10 14:46:16 +11:00
Anhad Singh aa86e9e027 fix(riscv64/x86): build
Stub `__tlsdesc_dynamic` for riscv64/x86 for now.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-10 13:52:37 +11:00
Jeremy Soller b5aad8faab Merge branch 'master' into 'master'
fix(ld_so): page faulting when library not found

See merge request redox-os/relibc!791
2025-12-09 19:28:06 -07:00
Anhad Singh 64d3793190 fix(ld_so): page faulting when library not found
The error handling was already in place. The reason it was page faulting
is that, on failure, the function exits as soon as it encounters an
`Err` variant. When that happens, the DSO object for which the
dependency was being loaded is dropped. Dropping it calls `munmap` to
unload the executable and also runs the functions in `.fini`. However,
`run_fini` should only be called if the `DSO` is being unloaded after it
has been successfully loaded (i.e. all dependencies were satisfied and
all init functions had run).

Closes #1599

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-10 13:24:53 +11:00
Jeremy Soller 7d6296f29d Merge branch 'cleanup_exec5' into 'master'
redox-rt: Remove unnecessary image_file field from FexecResult::Interp

See merge request redox-os/relibc!790
2025-12-09 15:42:59 -07:00
bjorn3 dc77995b57 redox-rt: Remove unnecessary image_file field from FexecResult::Interp 2025-12-09 22:22:09 +01:00
Jeremy Soller 44512df6a3 Merge branch 'cleanup_exec4' into 'master'
Use non-fixed and anonymous remote mmap and get rid of BTreeMap in redox-rt

See merge request redox-os/relibc!789
2025-12-09 13:05:43 -07:00
bjorn3 c96aeea39f redox-rt: Get rid of BTreeMap usage in fexec_impl 2025-12-09 21:04:45 +01:00
bjorn3 0158b111e0 redox-rt: Use non-fixed and anonymous remote mmap 2025-12-09 21:04:40 +01:00
Jeremy Soller 02f6dd3faf Merge branch 'master' into 'master'
fix(ld_so): dynamic linker on aarch64

See merge request redox-os/relibc!788
2025-12-09 06:28:14 -07:00
Anhad Singh 8572c855fc feat(ld_so/dso): TLSDESC
The dynamic linker now works on aarch64. You can also try it on Linux by
setting `TEST_RUNNER` to `qemu-aarch64` when running `make test
TARGET=aarch64-unknown-linux-gnu`

Co-authored-by: @willnode
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-09 22:28:39 +11:00
Anhad Singh 979de28ebc feat(aarch64/ld_so): implement _start routine 2025-12-09 15:07:11 +11:00
Anhad Singh 843f3f89ff fix(tests/Makefile): use correct dynamic linker path depending on target 2025-12-09 15:02:34 +11:00
Anhad Singh 396a0d20bf fix(build): target specific sysroot directory 2025-12-09 14:13:09 +11:00
Jeremy Soller 7fcab3a43a Merge branch 'master' into 'master'
fix(ci): make it green

See merge request redox-os/relibc!786
2025-12-08 16:50:39 -07:00
Jeremy Soller ee9040873a Merge branch 'cleanup_exec3' into 'master'
Move cloexec handling to happen right before the final exec

Closes #234

See merge request redox-os/relibc!787
2025-12-08 16:48:24 -07:00
bjorn3 1ede79fe88 Move cloexec and deactivate_tcb handling into redox-rt 2025-12-08 22:19:57 +01:00
bjorn3 b607877c07 Move cloexec handling to happen right before the final exec
This way if the target can't be executed, cloexec fds remain open as
expected.
2025-12-08 20:39:55 +01:00
Anhad Singh 2575639212 fix(tests/time): explictly set timezone instead of assuming 2025-12-09 01:18:32 +11:00
Anhad Singh eb4ce618e2 fix(header/time): define TIME_UTC
Workaround for a bug inside `cbindgen`. For some reason it does not like
us exporting constants that depend on other constants that are *not*
defined as a part of the same module.
2025-12-09 01:13:22 +11:00
Jeremy Soller 52ceed2f67 Merge branch 'doc-netdb-and-poll' into 'master'
Doc netdb and poll

See merge request redox-os/relibc!785
2025-12-08 06:16:57 -07:00
auronandace 1ed1096e60 add clippy annotation to netdb thanks to safety note 2025-12-08 08:41:00 +00:00
auronandace 651768ad54 only import the needed types in netdb and poll 2025-12-08 08:34:38 +00:00
auronandace e45c7de6f6 update and add spec links for netdb and poll 2025-12-08 08:30:17 +00:00
Jeremy Soller ff7ab99baf Merge branch 'fix-time-test' into 'master'
mark timespec_get and timespec_getres as unsafe and annotate no mangle

See merge request redox-os/relibc!784
2025-12-07 15:49:07 -07:00
auronandace 27bd869119 mark timespec_get and timespec_getres as unsafe and annotate no mangle 2025-12-07 21:07:49 +00:00
Jeremy Soller fe5273890a Merge branch 'cleanup_exec2' into 'master'
Hard code the default scheme to file

See merge request redox-os/relibc!783
2025-12-07 12:37:08 -07:00
bjorn3 4dae665cbf Hard code the default scheme to file
Init no longer changes the default scheme to initfs at any point in
time. And for sandboxing you would be switching scheme namespace, not
default scheme.

It should be possible to mix and match relibc version from before and
after this change without breaking exec, though I haven't tested it.
2025-12-07 19:51:45 +01:00
Jeremy Soller d3f54836d1 Merge branch 'cleanup_exec' into 'master'
Account for nul terminator in total_args_envs_auxvpointee_size

See merge request redox-os/relibc!782
2025-12-07 11:40:27 -07:00
bjorn3 45a58f1a9e Account for nul terminator in total_args_envs_auxvpointee_size 2025-12-07 19:38:14 +01:00
Jeremy Soller 8f38bbe511 Merge branch 'cleanup_exec' into 'master'
Calculate total_args_envs_size in redox_rt::proc::fexec_impl

See merge request redox-os/relibc!781
2025-12-07 11:31:56 -07:00
Jeremy Soller 9ace82b9e1 Merge branch 'printf-negative-precision-fix' into 'master'
printf: use None if precision given in the next argument is negative

See merge request redox-os/relibc!779
2025-12-07 11:29:01 -07:00
bjorn3 6021ece539 Calculate total_args_envs_size in redox_rt::proc::fexec_impl
Calculating it earlier is a micro-optimization that doesn't seem like it
matters at all compared to all other costs of spawning a process. But at
the same time it makes things more fragile. And in fact bootstrap
actually passed the wrong value. It passed the
total_args_envs_auxvpointee_size that it computed rather than the
total_args_envs_size. While over-approximation doesn't cause UB, it
unnecessarily increases the amount of memory used after exec.

In addition pass &[&[u8]] rather than iterators for args and envs to
enable precomputing the total arg and env size. This also prevents you
from forgetting to pass a reversed iterator.
2025-12-07 18:52:47 +01:00
Jeremy Soller 6609f127be Merge branch 'doc-select-utsname' into 'master'
Doc select utsname

See merge request redox-os/relibc!780
2025-12-07 10:13:47 -07:00
auronandace bb7ad19792 only import the needed types for sys_utsname and sys_select 2025-12-07 17:04:59 +00:00
auronandace 64d688dc4e update and add spec links to sys_utsname and sys_select 2025-12-07 17:01:51 +00:00
Connor-GH 1b86d87475 printf: use None if precision given in the next argument is negative 2025-12-07 10:16:33 -06:00
Jeremy Soller 228420291e Merge branch 'dlinfo-alias' into 'master'
Fix Dl_info alias not exported

See merge request redox-os/relibc!778
2025-12-05 06:15:10 -07:00
Wildan M 8e4e43dcc4 Fix Dl_info alias not exported 2025-12-05 16:14:29 +07:00
Jeremy Soller 2a7c7c5d42 Merge branch 'impl-timespec_get' into 'master'
Implement timespec_get and timespec_getres

See merge request redox-os/relibc!777
2025-12-04 14:00:24 -07:00
Josh Megnauth 4538fdb0c9 Implement timespec_get and timespec_getres
`timespec_get` and `timespec_getres` are both C23 functions. They're
similar to the POSIX functions `clock_gettime` and `clock_getres`, but
both sets of functions define extra, exclusive features. I didn't
implement the extra features yet, partially because Redox doesn't seem
to support them yet either.
2025-12-04 20:38:35 +00:00
Jeremy Soller 14b011da84 Merge branch 'p0' into 'master'
fix(platform/redox): add missing imports

See merge request redox-os/relibc!776
2025-12-04 08:33:53 -07:00
Anhad Singh e7b6c25d72 fix(platform/redox): add missing imports
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-05 01:07:18 +11:00
Jeremy Soller ca669fc60d Merge branch 'doc-locale-and-sched' into 'master'
Doc locale and sched

See merge request redox-os/relibc!775
2025-12-04 06:20:21 -07:00
auronandace 1ce298eaa9 only import needed types in locale and sched 2025-12-04 09:11:57 +00:00
auronandace f0850889d2 update and add spec links to locale and sched 2025-12-04 09:08:14 +00:00
Jeremy Soller 1b6c0d94b9 Merge branch 'p0' into 'master'
fix(platform/redox): fstatat

See merge request redox-os/relibc!774
2025-12-03 17:53:51 -07:00
Anhad Singh 5e1036bc15 fix(platform/redox): fstatat
This commit fixes multiple issues with `fstatat` implementation for
Redox.

1. `flags` are now properly handled. The `flags` argument specifies AT_* flags
   not O_* flags.
2. Open with O_PATH to avoid actually *opening* the file which may block
   or cause permission issues.
3. Close the temporary file descriptor regardless of success of failure.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-04 11:31:24 +11:00
Jeremy Soller 9baf4d5c68 Merge branch 'doc-sysstat-and-syssocket' into 'master'
Doc sysstat and syssocket

See merge request redox-os/relibc!773
2025-12-03 07:47:14 -07:00
auronandace 1e27ad561f only import needed types in sys_socket and sys_stat 2025-12-03 14:16:19 +00:00
auronandace cae30932b3 update and add spec links in sys_socket and sys_stat 2025-12-03 14:06:55 +00:00
Jeremy Soller c24f4bdd54 Merge branch 'correct-dlfcn' into 'master'
Correct dlfcn

See merge request redox-os/relibc!772
2025-12-03 03:50:08 -07:00
auronandace 5e6c9b8868 make Dl_info_t the type and Dl_info the alias 2025-12-02 20:26:28 +00:00
auronandace a702cb9555 only imported needed types in dlfcn 2025-12-02 20:24:05 +00:00
Jeremy Soller 96c0c058f5 Merge branch 'cleanup-sys-wait' into 'master'
Cleanup sys wait

See merge request redox-os/relibc!771
2025-12-02 12:43:07 -07:00
auronandace 68b4693564 only import needed types in sys_wait 2025-12-02 19:37:16 +00:00
auronandace ec9fd09335 update header spec link, add spec links to functions 2025-12-02 19:34:32 +00:00
auronandace ccc1d0b6fe remove commented out wait3 and rusage 2025-12-02 19:30:19 +00:00
Jeremy Soller cf3aaf4e43 Merge branch 'only-needed-sys-un-uio' into 'master'
only import the needed types in sys_un and sys_uio

See merge request redox-os/relibc!770
2025-12-02 09:54:04 -07:00
auronandace 02b302253b only import the needed types in sys_un and sys_uio 2025-12-02 15:41:01 +00:00
Jeremy Soller f15163704e Merge branch 'master' into 'master'
fix(all): aarch64 compilation

See merge request redox-os/relibc!769
2025-11-30 21:16:31 -07:00
Anhad Singh 1fdddef6a0 fix(ld_so): linker script for aarch64-unknown-linux-gnu
Ignore TLS.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-01 15:10:50 +11:00
Anhad Singh a7d08aa37e fix(tests/getopt_long): c should be an int not a char
`getopt_long` returns an `int` not a `char`. On aarch64 `char` is
unsigned but on x86 is signed. This is why it had worked so far without
any issues.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-01 14:55:00 +11:00
Anhad Singh 6bcdac4202 fix(platform/linux): use FCHOWNAT to implement lchown(2)
`LCHOWN` syscall is not available on aarch64.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-01 14:46:08 +11:00
Anhad Singh 6d68ca9957 fix(platform/linux): use FACCESSAT to implement access(2)
`ACCESS` syscall is not available on aarch64.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-01 14:46:08 +11:00
Anhad Singh 90963fdfb9 feat(platform/linux): stub rlct_clone
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-01 14:46:07 +11:00
Anhad Singh 4f1920ab96 feat(ld_so/tcb): implement os_arch_activate for aarch64 linux
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-01 14:46:07 +11:00
Anhad Singh 6262c4ae50 fix(ld_so): getting TP on linux
`ARCH_GET_FS` is x86_64 specific. On aarch64 it is not platform
specific and just need to read out the TP from `TPIDR_EL0`

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-01 14:46:07 +11:00
Anhad Singh 35a10eb940 feat(ld_so): add linker script for aarch64-unknown-linux-gnu
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-01 14:46:07 +11:00
Anhad Singh 7f21c95503 misc(Cargo.toml): bump sc
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-01 14:46:07 +11:00
Jeremy Soller c4941007c6 Merge branch 'document-sys-uio' into 'master'
update header spec reference and add spec references to functions

See merge request redox-os/relibc!768
2025-11-29 11:08:38 -07:00
auronandace 44cd0971b1 update header spec reference and add spec references to functions 2025-11-29 17:48:56 +00:00
Jeremy Soller 53e89724b7 Merge branch 'document-dlfcn' into 'master'
Document dlfcn

See merge request redox-os/relibc!767
2025-11-29 09:24:09 -07:00
auronandace 329db0dd9c add Dl_info_t alias for Dl_info 2025-11-29 15:33:31 +00:00
auronandace a25cf92162 update header reference and add references to functions 2025-11-29 15:22:39 +00:00
Jeremy Soller 8ad1d3c110 Merge branch 'fix-netdb-test' into 'master'
Move netdb to varied output test

See merge request redox-os/relibc!766
2025-11-29 06:44:56 -07:00
Jeremy Soller b15eb5c506 Merge branch 'impl-posix_fallocate' into 'master'
Implement posix_fallocate

See merge request redox-os/relibc!751
2025-11-29 06:44:34 -07:00
Wildan M 7e48f2d2fc Move netdb to varied output test 2025-11-28 19:08:32 -08:00
Josh Megnauth 8e5937ca25 Implement posix_fallocate
`posix_fallocate` ensures that a byte range in a file is allocated so
that subsequent writes don't fail. Unlike ftruncate, posix_fallocate
does not shrink files.

The Linux syscall fallocate is similar to posix_fallocate except with
far more control over how byte ranges are allocated (e.g. it supports
file holes and other features). This MR doesn't implement fallocate as
it requires syscall and redoxfs support.

Finally, I changed the flags for flock from usize to c_int. That matches
what we have in libc and also avoids some silly, needless type casting.
2025-11-28 19:49:21 -05:00
Jeremy Soller 27355b953b Merge branch 'getsubopt' into 'master'
Fix getsubopt and add test

See merge request redox-os/relibc!765
2025-11-28 08:14:44 -07:00
Wildan M 8e16c9c80c Fix getsubopt and add test 2025-11-28 06:59:51 -08:00
Jeremy Soller f9c78622bd Merge branch 'fix-inet-eopnopsupp' into 'master'
Fix netstack triggering EOPNOTSUPP

See merge request redox-os/relibc!764
2025-11-24 07:08:11 -07:00
Wildan M c90bb71deb Fix netstack triggering EOPNOTSUPP 2025-11-23 22:00:26 -08:00
Jeremy Soller 339e97ac65 Fix type of ai_addrlen 2025-11-21 11:37:16 -07:00
Jeremy Soller 549cae066f Add sys/queue.h from NetBSD like Alpine Linux does 2025-11-20 09:37:09 -07:00
Jeremy Soller 01f01d3bd4 Fix for F_DUPFD_CLOEXEC, add TODO for usage in upper table 2025-11-17 17:46:57 -07:00
Jeremy Soller db2600881f Add F_DUPFD_CLOEXEC 2025-11-17 17:44:49 -07:00
Jeremy Soller c6849f21e4 Fix compilation on i586 2025-11-16 08:54:54 -07:00
Jeremy Soller 099c35f3ca Merge branch 'use-upper-fdtbl' into 'master'
use upper fd table

See merge request redox-os/relibc!760
2025-11-16 08:35:32 -07:00
Jeremy Soller b263819d91 Merge branch 'switch-x86' into 'master'
Switch x86 GCC to i586

See merge request redox-os/relibc!762
2025-11-16 06:31:24 -07:00
Wildan M 3ab012e441 Switch x86 GCC to i586 2025-11-16 13:23:56 +07:00
Jeremy Soller 0844e6fc90 WIP: use upper fd table 2025-11-15 07:55:37 -07:00
Jeremy Soller d445714769 Merge branch 'bump-toolchain' into 'master'
Fix relibc freestanding build by bumping toolchain

See merge request redox-os/relibc!761
2025-11-15 06:09:15 -07:00
Wildan M 4e8a8cad5c Fix relibc freestanding build by bumping toolchain 2025-11-15 19:04:57 +07:00
Jeremy Soller 74e3ad1c2c Do TLS alignment in reliable way 2025-11-13 12:07:06 -07:00
Jeremy Soller afb8f46020 Implement ppoll 2025-11-13 10:47:29 -07:00
Jeremy Soller aeb243746c Add recv/sendmsg flags to metadata 2025-11-13 10:19:45 -07:00
Jeremy Soller c4050203e8 Revert "Align TLS to 16 bytes again"
This reverts commit 860a8e6e4b.
2025-11-13 08:16:22 -07:00
Jeremy Soller 764a30ef3d Merge branch 'setsockopt-ignore-eopnotsupp' into 'master'
fix: Ignore EOPNOTSUPP error from sys_call in setsockopt.

See merge request redox-os/relibc!759
2025-11-12 06:00:44 -07:00
Ibuki Omatsu e675da5a30 fix: Ignore EOPNOTSUPP error from sys_call in setsockopt. 2025-11-12 06:00:44 -07:00
4lDO2 512c4f0aa8 Clarification of st_mode bits extraction code. 2025-11-12 12:10:11 +01:00
Jeremy Soller 860a8e6e4b Align TLS to 16 bytes again 2025-11-10 17:05:57 -07:00
Jeremy Soller 32b3d2d343 Fix pthread key collision 2025-11-10 15:40:34 -07:00
Jeremy Soller 1c6bbf24af Merge branch 'getpeername' into 'master'
fix: Fix getpeername for unix sockets adding SocketCall::GetPeerName and using SYS_CALL.

See merge request redox-os/relibc!757
2025-11-10 06:20:46 -07:00
Ibuki Omatsu 06d5cb0bfd fix: Fix getpeername for unix sockets adding SocketCall::GetPeerName and using SYS_CALL. 2025-11-10 06:20:46 -07:00
Jeremy Soller ed5a2a66ad Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2025-11-08 20:59:05 -07:00
Jeremy Soller 052f000668 Ensure pipes have O_RDONLY or O_WRONLY set 2025-11-08 20:58:58 -07:00
Jeremy Soller 0ba941b489 Merge branch 'check_vs_libc_crate' into 'master'
Add derive macro to check types vs libc crate.

See merge request redox-os/relibc!756
2025-11-08 09:38:18 -07:00
4lDO2 513514a804 fix typo when libc check feature not enabled 2025-11-08 17:35:51 +01:00
4lDO2 4855cf3875 Fix compilation on Linux. 2025-11-08 17:31:57 +01:00
4lDO2 3ad0420b85 Add derive macro to check types vs libc crate. 2025-11-08 17:30:34 +01:00
Jeremy Soller 9eaa9e82b0 Pass through all SOL_SOCKET options, fix getsockopt option_len handling 2025-11-08 08:00:43 -07:00
Jeremy Soller f7cfacfbc8 Remove leftover dbg 2025-11-07 20:17:16 -07:00
Jeremy Soller 0ee947c389 Fix recvmsg stream being too small by one usize 2025-11-07 20:11:59 -07:00
Jeremy Soller ef5e54547f Close accepted socket on getpeername error 2025-11-07 18:46:54 -07:00
Jeremy Soller 16814d2e32 Fix socklen_t type 2025-11-07 18:10:17 -07:00
Jeremy Soller 443145fdee On Redox, if recvfrom/sendto has flags, use recvmsg/sendmsg 2025-11-07 11:05:04 -07:00
Jeremy Soller cb0acf3e57 Revert "Make sure TLS modules are aligned to 16 bytes for SSE"
This reverts commit d39fe6c9fb.
2025-11-01 10:44:34 -06:00
Jeremy Soller 222278edf9 Format 2025-11-01 10:41:15 -06:00
Jeremy Soller 0f04d34269 Merge branch 'i586_target_part2' into 'master'
Add missing linker script for i586

See merge request redox-os/relibc!755
2025-11-01 08:59:06 -06:00
bjorn3 82aae48e9b Add missing linker script for i586 2025-11-01 15:48:44 +01:00
Jeremy Soller 30fc02ff8f Merge branch 'i586_target' into 'master'
Support the i586-unknown-redox target

See merge request redox-os/relibc!754
2025-11-01 08:37:01 -06:00
bjorn3 782fe53aa4 Support the i586-unknown-redox target
This is necessary to allow switching to unpatched rustc in the future
2025-11-01 15:32:05 +01:00
Jeremy Soller 109f7c463a Merge branch 'improve-readme' into 'master'
Improve the library description in README

See merge request redox-os/relibc!741
2025-10-31 09:24:16 -06:00
Jeremy Soller a33bb699e6 Remove weak linkage from getopt functions and globals 2025-10-30 14:39:27 -06:00
Jeremy Soller ab2a948d0b Abort on panic or oom, remove stabilized let_chains feature 2025-10-30 09:33:29 -06:00
Jeremy Soller c2eed49e2d Add NAME_MAX 2025-10-29 12:30:28 -06:00
Jeremy Soller 62513befa6 Merge branch 'shared-dyn-fix' into 'master'
Fix ld_so multiple objects loading the same object

Closes #227

See merge request redox-os/relibc!752
2025-10-29 08:06:07 -06:00
Wildan M abdfd3d0ac Fix ld_so multiple objects loading the same object 2025-10-29 15:46:35 +07:00
Jeremy Soller 44492d4566 Merge branch 'impl-renameat' into 'master'
Implement renameat, renameat2

See merge request redox-os/relibc!732
2025-10-27 07:38:37 -06:00
Josh Megnauth f5d432644f Implement renameat, renameat2
Like the other "at" functions, renameat renames files with respect with
a directory descriptor. "renameat2" is Linux specific but really nice -
it adds a flag which supports atomically swapping two files or failing
if the target already exists. The latter is easily supported in relibc.
The former requires redoxfs support.

Besides the impl itself, I refactored "cap_path_at" into what it really
is: a mini openat2-like function.
2025-10-21 14:47:39 -04:00
Jeremy Soller 56386f1e26 Merge branch 'timer-signal' into 'master'
Support SIGEV_SIGNAL and TIMER_ABSTIME

See merge request redox-os/relibc!750
2025-10-16 11:00:39 -06:00
Wildan M c8fce67873 Support SIGEV_SIGNAL and TIMER_ABSTIME 2025-10-16 22:37:24 +07:00
Jeremy Soller 6092acc5bd Merge branch 'timer-fn' into 'master'
Implement POSIX timer functions

See merge request redox-os/relibc!747
2025-10-15 08:10:06 -06:00
Wildan Mubarok 2efcd20fbc Implement POSIX timer functions 2025-10-15 08:10:06 -06:00
Jeremy Soller a8f6205b10 Merge branch 'spec-and-import' into 'master'
update spec links and imports for assert and fcntl headers

See merge request redox-os/relibc!748
2025-10-15 06:35:18 -06:00
Jeremy Soller 6acf185685 Merge branch 'fix-uname-arm' into 'master'
Fix compilation on ARM/RISC-V due to c_char being different

Closes #230

See merge request redox-os/relibc!749
2025-10-13 08:52:44 -06:00
Wildan M b102d17ff5 Fix compilation on ARM/RISCV due to c_char being different 2025-10-13 20:57:28 +07:00
auronandace e4eada2e52 update spec links and imports for assert and fcntl headers 2025-10-12 17:25:03 +01:00
Jeremy Soller d50ce16e0f Merge branch 'add-posix-dent' into 'master'
Define posix_dent for posix_getdents

See merge request redox-os/relibc!746
2025-10-12 08:23:36 -06:00
Wildan M 135fba1f9f rename posix_dent d_off 2025-10-12 20:37:21 +07:00
Wildan M 1712290deb Define posix_dent for posix_getdents 2025-10-12 20:25:37 +07:00
Jeremy Soller d8a7ace2ab Merge branch 'spec-and-import' into 'master'
update spec links and imports for libgen and sys_resource

See merge request redox-os/relibc!745
2025-10-11 12:28:31 -06:00
auronandace 03c646222e update spec links and imports for libgen and sys_resource 2025-10-11 19:21:36 +01:00
Jeremy Soller 02e4d98020 Merge branch 'panic-strlen' into 'master'
Avoid panic by uninitialized string of strlen

See merge request redox-os/relibc!744
2025-10-09 10:58:28 -06:00
Wildan M 036dd3fb73 Avoid panic by unitialized string of strlen 2025-10-09 23:52:45 +07:00
Jeremy Soller 82fa75a124 Merge branch 'cleanup-sysstatvfs' into 'master'
Cleanup sysstatvfs

See merge request redox-os/relibc!743
2025-10-09 10:51:19 -06:00
auronandace 900e27538b fix formatting 2025-10-09 17:14:26 +01:00
auronandace 159b6dcdde only import what is needed 2025-10-09 17:08:43 +01:00
auronandace 0d34c229ff update and add spec links 2025-10-09 17:02:54 +01:00
Jeremy Soller 5f8fb9c0aa Merge branch 'mem-sysconf' into 'master'
Implement reading memory

See merge request redox-os/relibc!742
2025-10-09 08:36:10 -06:00
Wildan M efad028739 Fix getting total memory 2025-10-09 21:15:03 +07:00
Wildan M cc325b8b0a Fix compile 2025-10-09 13:24:03 +07:00
Wildan M a118d5659b Implement reading memory 2025-10-09 13:15:05 +07:00
Jeremy Soller 1dda8a00e7 Merge branch 'nulstr' into 'master'
Generalize CStr into NulStr, adding WStr

See merge request redox-os/relibc!739
2025-10-07 10:50:08 -06:00
Ribbon 2bd918f113 Improve the library description in README 2025-10-07 12:17:37 -03:00
4lDO2 1c5732ba36 Share almost all code between printf and wprintf. 2025-10-07 15:58:34 +02:00
Jeremy Soller df60387d5d Merge branch 'sysconf-mem' into 'master'
Define stub memory constants

See merge request redox-os/relibc!740
2025-10-07 07:46:56 -06:00
Wildan M 38a64f2247 Define stub memory constants 2025-10-07 20:27:32 +07:00
4lDO2 96917f519e Reuse PrintfIter for both printf and wprintf. 2025-10-06 16:16:48 +02:00
4lDO2 62cc63c351 WIP: Reimpl WPrintfIter also in safe code. 2025-10-06 16:16:48 +02:00
4lDO2 04719d6f77 Add WStr type. 2025-10-06 16:16:48 +02:00
4lDO2 9bc464686f Generalize CStr into NulStr to allow wide strings. 2025-10-06 16:16:48 +02:00
4lDO2 6dc2606886 Expand CStr to make PrintfIter fully safe. 2025-10-06 16:16:48 +02:00
Jeremy Soller 45337004b8 Merge branch 'expose-pie' into 'master'
Expose PIE information with LD_DEBUG

See merge request redox-os/relibc!738
2025-10-06 06:34:14 -06:00
Jeremy Soller 4d3c3cdd3b Merge branch 'strip-multarch' into 'master'
Fix stripcore.sh for multi arch

See merge request redox-os/relibc!737
2025-10-06 06:33:46 -06:00
Jeremy Soller fcb03dc2cd Merge branch 'out2' into 'master'
Expand Out wrapper and use it in utsname.

See merge request redox-os/relibc!736
2025-10-06 06:31:46 -06:00
Wildan M ab8021fdbe Expose PIE information with LD_DEBUG 2025-10-06 12:53:22 +07:00
Wildan M 03a3f6027d Fix stripcore.sh for multi arch 2025-10-06 12:44:20 +07:00
4lDO2 f4cd024c2b Also add align check to projection macro. 2025-10-05 21:53:24 +02:00
Jeremy Soller cf42111165 Merge branch 'fix_arm64' into 'master'
Fix compilation on arm64

See merge request redox-os/relibc!735
2025-10-05 13:05:12 -06:00
4lDO2 24cf96393c Expand Out wrapper and use it in utsname. 2025-10-05 20:01:12 +02:00
bjorn3 70487a2555 Fix compilation on arm64 2025-10-05 19:42:21 +02:00
Jeremy Soller 71a87bfd2b Merge branch 'fix-libm' into 'master'
Strip conflicting symbols from compiler builtins

See merge request redox-os/relibc!734
2025-10-05 11:11:27 -06:00
Wildan Mubarok 9c43abbcf9 Add f functions 2025-10-05 17:05:25 +00:00
Wildan Mubarok 3593615918 Revert changes 2025-10-05 16:48:28 +00:00
Wildan M 9351537ca0 Strip conflicting symbols from compiler builtins 2025-10-05 23:42:35 +07:00
Jeremy Soller 48a6dcf39e Merge branch 'unsafe_op-ld_so' into 'master'
unsafe_op_in_unsafe_fn: ld_so, generic-rt, redox-rt

See merge request redox-os/relibc!733
2025-10-05 06:52:25 -06:00
Josh Megnauth e39b27664f unsafe_op_in_unsafe_fn: ld_so, generic/redox-rt
There are a few functions where I allowed the lint. The lower level and
FFI nature of relibc means that there are areas with a lot of unsafe.
Some functions are basically long blocks of unsafe or contain lots of
small blocks of unsafe. unsafe_op_in_unsafe_fn doesn't add clarity to
these functions. Instead, it reduces readability by adding an indent or
small "unsafe { .. }" clutter.
2025-10-04 21:36:51 -04:00
Jeremy Soller 7ed934a01d Fix compilation of redox-rt without proc feature 2025-10-04 08:05:46 -06:00
Jeremy Soller 9528c7163b Rename mangled rust allocator symbols 2025-10-04 08:01:00 -06:00
Jeremy Soller bb42c12921 Merge branch 'nightly-2025-10-03' into 'master'
Support nightly-2025-10-03

See merge request redox-os/relibc!730
2025-10-04 07:53:14 -06:00
Jeremy Soller ced734c162 Add RawCell::unsafe_set 2025-10-04 07:50:16 -06:00
Jeremy Soller 82084440ad Support nightly-2025-10-03 2025-10-03 21:51:10 -06:00
Jeremy Soller f3f37c3176 Merge branch 'raw_cell' into 'master'
Add RawCell<T> wrapper.

See merge request redox-os/relibc!731
2025-10-03 12:56:15 -06:00
4lDO2 618b43ccae Add RawCell<T> wrapper. 2025-10-03 20:24:08 +02:00
Jeremy Soller 43b0f235ca Implement pthread_getattr_np 2025-09-30 12:49:22 -06:00
Jeremy Soller d39fe6c9fb Make sure TLS modules are aligned to 16 bytes for SSE 2025-09-29 17:08:51 -06:00
Jeremy Soller f35ddf0ec1 Merge branch 'getpeername-fix' into 'master'
Fix panic on getpeername

See merge request redox-os/relibc!728
2025-09-26 14:25:16 -06:00
Wildan M 8fa68e2927 fmt 2025-09-27 01:13:14 +07:00
Wildan M 7527de3a25 Fix panic on getpeername 2025-09-27 01:02:20 +07:00
Jeremy Soller 95cf8d9e6a Merge branch 'fix-linux-build' into 'master'
Fix Linux build

See merge request redox-os/relibc!727
2025-09-26 05:45:26 -06:00
Josh Megnauth b22f333319 Fix Linux build 2025-09-26 02:05:03 -04:00
Jeremy Soller 12857af043 Merge branch 'posix_getdents' into 'master'
Implement posix_getdents

See merge request redox-os/relibc!724
2025-09-23 10:57:13 -06:00
Wildan Mubarok 7416ba6ff3 Implement posix_getdents 2025-09-23 10:57:13 -06:00
Jeremy Soller dc7491387b Merge branch 'sema-fix' into 'master'
Fix timespec for semaphore

See merge request redox-os/relibc!725
2025-09-22 19:20:12 -06:00
Wildan Mubarok a4aa1a30a3 Fix timespec for semaphore 2025-09-23 00:44:02 +00:00
Jeremy Soller 6110a77044 Merge branch 'cstr_strchr' into 'master'
Add safe strchr method for CStr.

See merge request redox-os/relibc!723
2025-09-21 10:35:10 -06:00
4lDO2 9aeb9abd97 Add safe strchr method for CStr. 2025-09-21 17:00:45 +02:00
Jeremy Soller 38d667a58e Merge branch 'printf-use-float-abs' into 'master'
printf: Use f64::abs

See merge request redox-os/relibc!639
2025-09-21 08:17:46 -06:00
Jeremy Soller 6729abbcba Merge branch 'fchmodat' into 'master'
Implement fchmodat

See merge request redox-os/relibc!714
2025-09-21 08:16:49 -06:00
4lDO2 5ce0574647 Explain redox-rt more accurately. 2025-09-21 16:16:00 +02:00
Josh Megnauth 85c5e889fb Implement fchmodat
Capability based `fchmod`. I also implemented unit tests for chmod,
fchmod, and fchmodat.

The unit tests check Redox-specific behavior, so some of the tests are
disabled for Linux.
2025-09-21 10:04:11 -04:00
Jacob Lorentzon f3cc5dfb5c Merge branch 'out' into 'master'
Add `Out<T>` wrapper

See merge request redox-os/relibc!717
2025-09-21 14:36:12 +02:00
Jacob Lorentzon 9c5f11fbc8 Add Out<T> wrapper 2025-09-21 14:36:12 +02:00
Josh Megnauth 1a2c8175d4 printf: Use f64::abs 2025-09-21 06:52:59 +00:00
4lDO2 3ad1ba516e sigaltstack: don't fail when onstack && new==NULL. 2025-09-20 11:38:14 +02:00
4lDO2 38e724ece9 Properly inherit ignored sigs across exec. 2025-09-20 11:08:41 +02:00
4lDO2 37c2f3026a Clear pending SIGCHLD also when set to SIG_DFL. 2025-09-20 10:37:26 +02:00
Jeremy Soller 239d275453 Merge branch 'fix-ci-smp' into 'master'
Fix CI by set it as single core

See merge request redox-os/relibc!721
2025-09-19 17:01:03 -06:00
Wildan Mubarok 0422ed2ae5 Fix CI by set it as single core 2025-09-19 22:29:41 +00:00
Jeremy Soller 9fa3eceaeb Implement getsockaddr for SO_DOMAIN and SO_TYPE 2025-09-19 14:59:47 -06:00
Jeremy Soller fe520f8e10 Merge branch 'fix-path' into 'master'
Change PATH separator to double colon

See merge request redox-os/relibc!719
2025-09-19 11:06:10 -06:00
Wildan M b541ee43be Change PATH separator to double colon 2025-09-19 21:48:38 +07:00
Jeremy Soller f4a7bcf92d Merge branch 'shadow-h' into 'master'
Implement shadow.h and argon2 crypt

See merge request redox-os/relibc!718
2025-09-19 06:45:18 -06:00
Jeremy Soller 50036b1026 Merge branch 'add-const-to-fnmatch' into 'master'
add constant to fnmatch.h

See merge request redox-os/relibc!716
2025-09-19 06:39:53 -06:00
Wildan M b8598f50ff Add argon2 crypt 2025-09-19 15:41:05 +07:00
Wildan M d3e44fa6b9 Apparently need to import FILE constant 2025-09-19 14:37:49 +07:00
Wildan M 0636af21a4 Add shadow.h support 2025-09-19 14:04:55 +07:00
auronandace 1bacd51b81 specify the type properly 2025-09-18 16:30:30 +01:00
auronandace 6607549abf add constant to fnmatch.h 2025-09-18 16:17:11 +01:00
Jeremy Soller 05b0b69c7e Merge branch 'export-fexecve' into 'master'
Export fexecve

See merge request redox-os/relibc!715
2025-09-18 06:32:46 -06:00
Josh Megnauth 03c0e3024c Export fexecve
It turns out we have fexecve but it wasn't exported in unistd.h.

Related: #184
2025-09-18 02:38:15 -04:00
Jeremy Soller 42363abb73 Merge branch 'readlinkat' into 'master'
Implement readlinkat

See merge request redox-os/relibc!708
2025-09-17 21:10:24 -06:00
Josh Megnauth c555503a35 Implement readlinkat
Like readlink except capability based. Most of this patch is refactoring
fstatat into a reusable, openat-like private function.
2025-09-18 01:27:55 +00:00
Jeremy Soller 56460260b1 Merge branch 'fdopendir' into 'master'
Implement fdopendir and fdclosedir

See merge request redox-os/relibc!712
2025-09-17 06:45:51 -06:00
Josh Megnauth c6a9a165ec Implement fdopendir and fdclosedir
`fdopendir` takes ownership of a directory file descriptor instead of
opening one with a path. `fdclosedir` is a FreeBSD extension that
transfers ownership of the file descriptor in DIR to the user.
2025-09-17 08:24:48 -04:00
Jeremy Soller ae103c7e94 Merge branch 'refactor/remove-unused-nightly' into 'master'
lib: remove unused Nightly features

See merge request redox-os/relibc!713
2025-09-16 12:54:43 -06:00
elle 5613fe2cdb lib: remove unused Nightly features
Removes unused Nightly features from the library.
2025-09-16 18:37:33 +00:00
Jeremy Soller 33adf4c209 Merge branch 'grp-impl' into 'master'
Fix grp.h implementation

See merge request redox-os/relibc!711
2025-09-15 15:38:17 -06:00
Wildan Mubarok 2f35c4a665 Fix getgrouplist len 2025-09-15 21:29:27 +00:00
Wildan Mubarok 94fbdd5159 Fix grp implementation 2025-09-15 21:14:53 +00:00
Jeremy Soller fdb7532a67 Merge branch 'null_getaddrinfo' into 'master'
Implement getaddrinfo NULL nodename, AI_PASSIVE, AI_NUMERICHOST

Closes #223

See merge request redox-os/relibc!710
2025-09-15 06:47:27 -06:00
Jeremy Soller 7f9785f592 Merge branch 'at-symlink-nofollow' into 'master'
Impl AT_SYMLINK_NOFOLLOW and AT_EMPTY_PATH

See merge request redox-os/relibc!707
2025-09-15 06:46:48 -06:00
Wildan M 726a0fb1a8 Implement getaddrinfo NULL nodename, AI_PASSIVE, AI_NUMERICHOST 2025-09-15 15:10:50 +07:00
Josh Megnauth 28901b1b62 Impl AT_SYMLINK_NOFOLLOW and AT_EMPTY_PATH
AT_SYMLINK_NOFOLLOW acts on the symlink itself rather than following it.

AT_EMPTY_PATH acts on the directory if path is empty.

Currently, this is implemented in fstatat itself but the code is general
enough to be refactored once we get the other *at functions. It could
likely just live in openat itself.
2025-09-15 06:12:10 +00:00
Jeremy Soller e1fa1ee7b7 Merge branch 'real_cpu' into 'master'
Implement reading CPU count

See merge request redox-os/relibc!709
2025-09-14 06:31:16 -06:00
Wildan M d527cf455f Implement reading CPU count 2025-09-14 18:45:38 +07:00
4lDO2 e0f44e5ff5 Correct chdir comment. 2025-09-11 13:40:11 +02:00
4lDO2 437786f6a1 Restrict posix_exit to & 0xFF to fix EINVAL panic. 2025-09-10 15:10:06 +02:00
4lDO2 23c65bab66 Revert to using abort() for extraordinary panics. 2025-09-09 20:09:29 +02:00
Jeremy Soller 7c4a87da39 Merge branch 'getens' into 'master'
Add getens and expose it to libredox

See merge request redox-os/relibc!705
2025-09-09 07:35:19 -06:00
Ibuki Omatsu b14aae168f Add getens and expose it to libredox 2025-09-09 07:35:19 -06:00
Jeremy Soller 3554fd706c Merge branch 'refactor/fix-compiler-warnings' into 'master'
lib: fix compiler warnings

See merge request redox-os/relibc!704
2025-09-09 06:54:11 -06:00
elle e148be2296 redox-rt: remove unused code from proc 2025-09-08 21:03:28 +00:00
elle 5a8c166e67 redox-rt: clean up unused code
Removes unused imports, and replaces calls to `core::intrinsics::abort`
with `panic` macro call.
2025-09-08 21:03:28 +00:00
elle 5032708f88 redox-rt: fix dead code in sync 2025-09-08 21:03:27 +00:00
elle 9f446e2fd3 redox-rt: remove signal dead code 2025-09-08 21:03:27 +00:00
elle a5c41f77d0 ld_so: remove access dead code 2025-09-08 21:03:27 +00:00
elle 5d77f617f5 ld_so: use mutex for _r_debug
Uses a `spin::Mutex` for the global static `_r_debug` instance to remove
warning about a global mutable static.

Guarantees exclusive mutable access to the `_r_debug` variable.
2025-09-08 20:23:36 +00:00
elle a434c0ef12 cargo: add explicit editions
Adds explicit `edition` definitions to sub-crates.
2025-09-08 20:23:36 +00:00
elle 7a78c5a719 generic-rt: move format args into format string 2025-09-08 20:23:36 +00:00
elle 6b9103a5ec generic-rt: remove use of core instrinsics
Fixes warning about not using compiler intrinsics.

Calls into the `panic` macro instead of directly calling the `abort`
intrinsic.

Slightly changes the behavior of the function by printing the
panic message, unwinding, and aborting.
2025-09-08 20:23:36 +00:00
elle 01c8942a3c build: rename unsused crate_dir variable 2025-09-08 20:23:36 +00:00
elle 09015a218e ld_so: remove unsafe transmute in mmap_and_copy
Refactors casting the `raw` address as a byte array to use idiomatic
Rust APIs instead of the unsafe call to `transmute`.
2025-09-08 20:23:36 +00:00
Jeremy Soller 7e0c6a91e0 Merge branch 'refactor/remove-array-chunks' into 'master'
lib: remove `array_chunks` nightly feature

See merge request redox-os/relibc!703
2025-09-08 12:22:19 -06:00
elle bd13557f98 lib: remove array_chunks nightly feature
Removes the nightly `array_chunks` feature, since it is marked as
unlikely to be merged.

Usage is trivially refactored using iterators.
2025-09-08 17:08:22 +00:00
Jeremy Soller 2f0d5eb970 Use patched openlibm to fix riscv64 2025-09-07 21:17:18 -06:00
Jeremy Soller 0a13e2574f Fix sigsetjmp definition on riscv64 2025-09-07 20:04:10 -06:00
Jeremy Soller e291a2527a Merge branch 'fix-rename-broken-link' into 'master'
Fix renaming broken symbolic link

Closes #212

See merge request redox-os/relibc!702
2025-09-07 07:06:02 -06:00
Josh Megnauth 55c2e5b8ea Fix renaming broken symbolic link
Closes: #212

The fix is simply to not follow links when opening a file to be renamed.
O_NOFOLLOW, a non-POSIX extension, does exactly that while not needing
renameat or openat.
2025-09-07 07:44:10 -04:00
Jeremy Soller adc8f9f3b3 Merge branch 'lstat-unlink-test' into 'master'
Add lstat test

See merge request redox-os/relibc!701
2025-09-06 07:16:59 -06:00
Jeremy Soller 705270dba3 Merge branch 'const-init-pthread_atfork' into 'master'
Const init pthread_atfork; export in pthread.h

See merge request redox-os/relibc!698
2025-09-06 07:13:16 -06:00
Josh Megnauth 639e0f2cd7 Add lstat test 2025-09-05 23:59:36 -04:00
Josh Megnauth 51bc7f7d2c Const init pthread_atfork; export in pthread.h
`pthread_atfork` should be exported in pthread.h according to the
standard. We only exported our function in unistd.h. `glibc` exports it
in both pthread.h and unistd.h whereas musl only exports it in pthread.h
(which is standards compliant).

I exported it in both headers. Cbindgen doesn't seem to reexport `pub
use` so I declared the function twice. We might have to reexamine our
`pub use` to check what's exported and what isn't.
2025-09-01 22:21:15 -04:00
Jeremy Soller c281579ca1 Merge branch 'fix_clang_bindgen_issue' into 'master'
fixing bindgen c++ [[noreturn]] issue.

See merge request redox-os/relibc!697
2025-08-30 11:30:34 -06:00
Andrzej J. Skalski 42493b88eb fixing bindgen c++ [[noreturn]] issue. 2025-08-30 11:30:34 -06:00
Jeremy Soller 3bd7f21f05 Merge branch 'sem-timedwait' into 'master'
Add sem_timedwait and sem_clockwait

See merge request redox-os/relibc!696
2025-08-28 06:24:27 -06:00
Wildan M 4c6c5da8f2 fix fmt 2025-08-28 16:13:16 +07:00
Wildan M 80ea3bc6a1 Add sem_clockwait and fix timedwait clock_id 2025-08-28 12:58:54 +07:00
Wildan M 7ab71a0ad5 Add sem_timedwait 2025-08-28 08:36:16 +07:00
Jeremy Soller 3a08d40c67 Merge branch 'add-temporary-fstatat' into 'master'
Implement fstatat

See merge request redox-os/relibc!695
2025-08-27 06:42:55 -06:00
Josh Megnauth c899feb774 Implement fstatat
Linux's variant uses the syscall as intended. Redox's variant uses fpath
to build a path to pass to fstat from the file descriptor plus the file
name. Unlike the syscall, this isn't atomic so the liminal space between
fpath/getcwd and fstat is subject to TOCTOU.

Beyond fstatat, I moved the stat test to its correct location and added
an assert since the output of the test is unchecked.

I also added AT_FDCWD which seems to be -100 across Unixes. The other
AT_* constants are unimplemented for now.
2025-08-27 08:21:41 -04:00
Jeremy Soller fd9a1c9668 Workaround clang issue with [[noreturn]] in C files 2025-08-24 18:30:13 -06:00
Jeremy Soller 92bc01247a Merge branch 'add-confstr' into 'master'
Implement confstr (unistd.h)

See merge request redox-os/relibc!694
2025-08-22 21:36:06 -06:00
Josh Megnauth 9d2f5d95dc Implement confstr (unistd.h)
The implementation for confstr is straightforward. Most of the constants
return 1 on both musl and glibc. The only constant that doesn't is
required for Fish.

I also switched an #[unsafe(no_mangle)] from my last patch back
to a #[no_mangle] because we need to bump cbindgen. #[unsafe(no_mangle)]
is required for Rust 2024.
2025-08-22 22:13:51 -04:00
Jeremy Soller 4758685217 Merge branch 'netdb-openssh' into 'master'
Implement getnameinfo and getaddrinfo loopback

See merge request redox-os/relibc!693
2025-08-20 06:59:31 -06:00
Jeremy Soller d513ba003c Merge branch 'fix-linux-sysconf' into 'master'
Improve sysconf.h on Linux

Closes #218

See merge request redox-os/relibc!691
2025-08-20 06:58:27 -06:00
Jeremy Soller f046864f10 Merge branch 'ixany-openssh' into 'master'
Add termios IXANY

See merge request redox-os/relibc!692
2025-08-20 06:54:47 -06:00
Wildan M 14bb1c87c3 Fix fmt 2025-08-20 18:40:18 +07:00
Wildan M 5334455a20 Implement getnameinfo and getaddrinfo loopback 2025-08-20 18:26:27 +07:00
Wildan Mubarok c3437b70a9 Add termios IXANY 2025-08-20 07:39:15 +00:00
Josh Megnauth 70ae45ff85 Improve sysconf.h on Linux
I copied the constants and definitions from musl which we can presume is
correct. Relibc is missing some features which affects our sysconf as
well, such as constants in limits.h or a working resources.h.
2025-08-20 02:05:05 -04:00
Jeremy Soller 8f9614920d Merge branch 'rlimit_constants_i32' into 'master'
Switch resource.h enum to c_int instead of u64

See merge request redox-os/relibc!690
2025-08-17 08:17:02 -06:00
Josh Megnauth d14ae1c148 Switch resource.h enum to c_int instead of u64
Most platforms use a c_int though glibc uses a u32. GNU defines a type,
__rlimit_resource_t, for the RLIMIT enum that is a u32.

Using a c_int is nicer for a few reasons. The first is that our
(unimplemented) functions receive a c_int for the enum - using a u32 is
technically wrong but doesn't affect anything since the constants are
turned into macros by cbindgen.

The second reason is that a c_int is nicer for libc and nix (the crate)
too since we don't need to pollute the crates with guards for Redox.
2025-08-16 23:52:03 -04:00
Jeremy Soller 89ddc82d42 Merge branch 'add-vdisable' into 'master'
Add termios constant for VDISABLE

See merge request redox-os/relibc!689
2025-08-15 06:58:42 -06:00
Josh Megnauth c3c9e3f619 Add termios constant for VDISABLE
_POSIX_VDISABLE is an extension that disables terminal special
characters.

See:
* redox-os/termios!3
* redox-os/base!27
2025-08-14 01:57:24 -04:00
Jeremy Soller f170902a29 Add u_int types for compatibility 2025-08-13 09:36:26 -06:00
Jeremy Soller f5bc50f104 Merge branch 'paths-h' into 'master'
Add paths.h for Fish

See merge request redox-os/relibc!687
2025-08-11 14:14:58 -06:00
Jeremy Soller 09b71bdbe0 Merge branch 'fix-trace' into 'master'
Fix trace feature

See merge request redox-os/relibc!686
2025-08-11 14:11:49 -06:00
Jeremy Soller 551c79c526 Merge branch 'redoxer-test' into 'master'
Enable some tests in Redox

See merge request redox-os/relibc!685
2025-08-11 14:11:16 -06:00
Darley Barreto b0aac4e8f6 Enable some tests in Redox 2025-08-11 14:11:15 -06:00
Jeremy Soller a57dbfb13f Merge branch 'test-statvfs' into 'master'
Add basic test for statvfs

See merge request redox-os/relibc!683
2025-08-11 14:10:31 -06:00
Jeremy Soller 7e1940b941 Merge branch 'printf-m-modifier' into 'master'
Add %m to printf & fix CI

See merge request redox-os/relibc!682
2025-08-11 14:09:37 -06:00
Josh Megnauth cfe00d3316 Add paths.h for Fish
Fish only requires BSHELL. The constants are implementation specific so
this header will evolve as needed.

Cbindgen doesn't emit defines for strings (even CStrs) so I only
provided what's needed for Fish in a C header for now with the ideal
implementation, in Rust, unbuilt.
2025-08-09 01:16:12 -04:00
Wildan Mubarok c7a1966a67 Fix trace feature 2025-08-08 23:41:07 +00:00
Wildan M b3b806cafd Simplify test code 2025-08-07 08:46:54 +07:00
Wildan M c7405e09bd Add statvfs tests to Makefile 2025-08-07 07:35:40 +07:00
Wildan M 0248aab7d4 Add basic test for statvfs 2025-08-07 07:19:56 +07:00
Josh Megnauth 728fb55203 Add %m to printf & fix CI
%m is a format specifier that prints an error string for errno. The
specifier is technically only for syslog, but musl and glibc implement
it for printf itself. Parsing for a single specifier in a single
function is error prone, especially when syslog itself is variadic.
2025-08-06 02:38:47 -04:00
Jeremy Soller 710911febb Merge branch 'fix-syslog-tests' into 'master'
Move syslog tests to the correct location

See merge request redox-os/relibc!681
2025-08-04 20:35:27 -06:00
Josh Megnauth 292a4b18a9 Move syslog tests to correct location 2025-08-04 22:20:17 -04:00
Jeremy Soller 4a805ea97c Add some compatibility defines for libssh 2025-08-04 19:54:45 -06:00
Jeremy Soller 311d5621b8 Merge branch 'signals-stuff' into 'master'
Fixes to improve signals for openposixtestsuite

See merge request redox-os/relibc!680
2025-08-04 07:37:14 -06:00
Ron Williams b7589a63c5 Fixes to improve signals for openposixtestsuite 2025-08-04 07:37:14 -06:00
Jeremy Soller 1105a2092f Merge branch 'syslog-expand-features' into 'master'
Better priorities & LOG_UPTO for syslog.h

See merge request redox-os/relibc!679
2025-08-02 06:52:35 -06:00
Josh Megnauth e677ad55d5 Better priorities & LOG_UPTO for syslog.h
* Fix PERROR to match musl/glibc better
* More unit tests + enabled on Linux
* Pack priority and facility into one i32 and check the bits with
  bitflags
* Add LOG_UPTO (logic is straight from musl)

Not done:
* "%m" - this could just be added to printf
* LOG_CONS
2025-08-01 23:45:26 -04:00
Jeremy Soller 1694cd3a4d fix redox stat st_blocks 2025-08-01 12:44:10 -06:00
Jeremy Soller 6dd10a1f11 Fix connect on redox 2025-08-01 10:33:55 -06:00
Jeremy Soller 4f9267be59 Merge branch 'syslog-add-linux' into 'master'
Linux support for syslog.h

See merge request redox-os/relibc!675
2025-07-26 06:56:50 -06:00
Josh Megnauth 64d9847e37 Linux support for syslog.h
Linux's syslog is a local socket, so this uses the recent UDS work.

* Most of redox.rs is refactored into mod.rs now which has all of the C
  facing functions and consts.
* I wrapped the global logger in a Mutex instead of a RwLock. The logger
  is almost always locked for writing so a Mutex is simpler as RwLock
  provides no benefits.
* I implemented LOG_PERROR which also prints errors to stderr as well as
  the log.
* Syslog should be sys/syslog.h with syslog.h as an alias (the
  original code only had syslog.h).
2025-07-24 21:46:49 -04:00
Jeremy Soller 9e1ff3185e Merge branch 'backport-cstr-fns' into 'master'
Backport count_bytes and is_empty for CStr

See merge request redox-os/relibc!678
2025-07-22 06:42:12 -06:00
Josh Megnauth 57c46f4dd8 Backport count_bytes and is_empty for CStr 2025-07-21 23:47:50 -04:00
Jeremy Soller 6babec246d Merge branch 'fix-gocgo' into 'master'
Update pthread_attr_getstacksize to fix Go CGO

See merge request redox-os/relibc!676
2025-07-21 07:54:37 -06:00
Jeremy Soller 2e92f987a9 Merge branch 'grp-header' into 'master'
Fix grp.h headers for Go

See merge request redox-os/relibc!677
2025-07-21 07:53:33 -06:00
Wildan Mubarok 0af7d7fdb5 Revert gid_t/uid_t 2025-07-21 00:22:38 +00:00
Wildan Mubarok 2c4bd8d061 Fix grp.h and gid_t/uid_t for Go 2025-07-21 00:15:02 +00:00
Wildan Mubarok b23ac06a01 Update pthread_attr_getstacksize to fix Go CGO 2025-07-20 17:01:47 +00:00
Jeremy Soller 648d3be78e Merge branch 'get_socket_token' into 'master'
feat: Add redox_get_socket_token_v0 as a symbol for libredox.

See merge request redox-os/relibc!674
2025-07-19 07:36:21 -06:00
Ibuki.O b86f8a36fa feat: Add redox_get_socket_token_v0 as a symbol for libredox. 2025-07-19 13:31:44 +09:00
4lDO2 518798f64e Return EINVAL when killing with sig > 64. 2025-07-18 21:50:01 +02:00
4lDO2 40b8064eae Fix raise signal number being -32. 2025-07-18 20:35:33 +02:00
Jeremy Soller 2672e2aa43 Merge branch 'bind-connect-redoxfs' into 'master'
feat: Integrate UDS bind and connect operation with RedoxFS and switch get_proc_credentials to a capability-based approach.

See merge request redox-os/relibc!665
2025-07-18 08:57:49 -06:00
Ibuki Omatsu d44010170f feat: Integrate UDS bind and connect operation with RedoxFS and switch get_proc_credentials to a capability-based approach. 2025-07-18 08:57:49 -06:00
Jeremy Soller eb2d61fdff Merge branch 'impl_syslog' into 'master'
Implement syslog functionality

See merge request redox-os/relibc!626
2025-07-17 22:49:51 -06:00
Bendeguz Pisch 4fc80ea7b0 Implement syslog functionality 2025-07-17 22:49:51 -06:00
Jeremy Soller 46c2f99919 Merge branch 'unix-domain-socket' into 'master'
feat: Implement Unix Domain Socket and related features.

See merge request redox-os/relibc!662
2025-07-17 22:48:37 -06:00
Ibuki Omatsu 206239f9a2 feat: Implement Unix Domain Socket and related features. 2025-07-17 22:48:37 -06:00
Jeremy Soller f6528d27dd Merge branch 'add-disabled-rename-symlink-test' into 'master'
Add disabled test for rename symlink bug

See merge request redox-os/relibc!673
2025-07-13 06:44:52 -06:00
Josh Megnauth c7da3c2c6b Add disabled test for rename symlink bug
This test should rename disabled until redox-os/relibc#212 is fixed. The
test works on Linux so it should work on Redox eventually too.

The issue is non-trivial because it involves a syscall, frename, that
may need to be redesigned. frename requires a file descriptor, but
opening a file resolves links which in turn fails with broken symlinks.
2025-07-12 21:33:33 -04:00
Jeremy Soller 1b61d1ba17 Merge branch 'ci-fixes' into 'master'
Fix CI, Add signal.h constants

See merge request redox-os/relibc!672
2025-07-11 20:28:45 -06:00
Ron Williams 770dc71816 Fix CI, Add signal.h constants 2025-07-11 20:28:45 -06:00
Jeremy Soller b68ff56115 Revert "Merge branch 'use-redox-path-in-cwd' into 'master'"
This reverts merge request !669
2025-07-11 06:28:48 -06:00
Jeremy Soller e86bbb0856 Merge branch 'strerror-exact-buf-size' into 'master'
Const calculate buffer size for strerror

See merge request redox-os/relibc!648
2025-07-10 14:16:56 -06:00
Jeremy Soller 8cd1b7e797 Merge branch 'use-redox-path-in-cwd' into 'master'
Use redox_path in canonicalize_using_cwd_internal

See merge request redox-os/relibc!669
2025-07-10 14:16:32 -06:00
Josh Megnauth 1d5179eb71 Const calculate buffer size for strerror
The current buffer size is hard set to 256. Using const evaluation, the
maximum buf size can be calculated at compile time.
2025-07-10 03:18:17 +00:00
Josh Megnauth db6097733c Use redox_path in canonicalize_using_cwd_internal
`redox_path` handles most of the logic anyway.
2025-07-09 22:30:51 -04:00
Jeremy Soller baef620c7a Merge branch 'revert-74ebfb25' into 'master'
Revert "Merge branch 'rustifying' into 'master'"

See merge request redox-os/relibc!667
2025-07-06 12:55:10 -06:00
Jeremy Soller 5673575354 Revert "Merge branch 'rustifying' into 'master'"
This reverts merge request !663
2025-07-06 12:54:39 -06:00
Jeremy Soller 84d4100845 Merge branch 'sccache-opt' into 'master'
Add CC_WRAPPER support

See merge request redox-os/relibc!666
2025-07-04 19:53:50 -06:00
Wildan Mubarok 7a4a32e52b Add CC_WRAPPER support 2025-07-04 19:53:50 -06:00
Jeremy Soller 84bbf90ce1 Fix ___tls_get_addr on x86 2025-07-03 10:52:46 -06:00
Jeremy Soller 1550bb54b5 Merge branch 'expose_sys_call_through_libredox' into 'master'
Expose sys_call through libredox

See merge request redox-os/relibc!664
2025-06-30 14:14:55 -06:00
bjorn3 585cd80002 Expose sys_call through libredox
This makes it significantly easier to use outside of crates that already
depend on redox-rt, making it actually useful to many schemes.
2025-06-30 20:17:26 +02:00
Jeremy Soller 74ebfb256d Merge branch 'rustifying' into 'master'
Rustify some functions (following TODO)

See merge request redox-os/relibc!663
2025-06-25 08:39:01 -06:00
David DA SILVA 7fd3a8d698 Rustify some functions (following TODO) 2025-06-25 08:39:01 -06:00
Jeremy Soller 63418095e5 Merge branch 'update-syscall' into 'master'
Update redox_syscall

See merge request redox-os/relibc!660
2025-06-12 12:23:29 -06:00
Jeremy Soller fa5d8204df Merge branch 'Fix-relative-path-mv' into 'master'
Fix issue with rename to relative destination

See merge request redox-os/relibc!659
2025-06-12 10:58:26 -06:00
Ron Williams 02f0571da5 Update redox_syscall 2025-06-12 09:41:28 -07:00
James Matlik 19de978799 Fix issue with rename to relative destination 2025-06-12 08:56:21 -04:00
Jeremy Soller be49c1936a Make x86_64 mcontext not opaque 2025-05-13 10:05:32 -06:00
Jeremy Soller ac3eb38c0d Include bits/sys/ioctl.h in sys/ioctl.h 2025-05-13 08:13:49 -06:00
Jeremy Soller 012868b40c Merge branch 'master' into 'master'
Adjust shell scripts to properly get bash from environment

See merge request redox-os/relibc!657
2025-05-11 16:03:52 -06:00
Jeremy Soller b919a83efd Respect CARGO_TARGET_DIR 2025-05-11 15:03:00 -06:00
zinzaguras 7b877b713f Adjust shell scripts to properly get bash from environment 2025-05-11 03:02:40 +03:00
Jeremy Soller 0bd38ac2ad Fix DTPMOD relocation 2025-05-09 10:06:06 -06:00
Jeremy Soller b887ad1ce6 Fix DTPOFF relocation 2025-05-07 21:04:31 -06:00
Jeremy Soller 0b1133a965 ld_so: do relocations before TLS 2025-05-07 16:27:00 -06:00
Jeremy Soller 4daade9721 log where unresolved symbol was required 2025-05-07 10:38:21 -06:00
Jeremy Soller b2a6f00429 Use u64 for relibc internal fd set definition, does not affect C definition 2025-05-07 09:25:15 -06:00
Jeremy Soller 2b06118d5f Fix deadlock when logging scopes 2025-05-06 21:50:38 -06:00
Jeremy Soller a31584cdef Fix dangling pointer with empty scandir 2025-05-06 21:28:05 -06:00
Jeremy Soller 78bab94ee0 Add end of dynamic library mapping to debug messages 2025-05-06 20:45:39 -06:00
Jeremy Soller d194554fdc Temporarily use insertion sort for qsort 2025-05-06 13:52:35 -06:00
Jeremy Soller 38cca8acc0 Fix select macros 2025-05-06 11:34:48 -06:00
Jeremy Soller 70d6a11606 openpty: terminate path with NUL 2025-05-06 09:28:58 -06:00
Jeremy Soller 3402246d87 define NFDBITS 2025-05-05 21:05:07 -06:00
Jeremy Soller 1e48b13948 Debug recvmsg on redox 2025-05-04 09:32:10 -06:00
Jeremy Soller 275b92ee92 Make setitimer return enosys instead of panic on redox 2025-05-04 08:32:25 -06:00
Jeremy Soller bb105d41ad scanf: fix parsing 0 when using %i 2025-05-03 21:15:58 -06:00
Jeremy Soller f8da7399d8 Use crates.io posix-regex and support extended regex 2025-05-03 16:31:04 -06:00
Jeremy Soller 0f3f6f3c15 Use flink to implement link on redox 2025-05-03 12:18:45 -06:00
Jeremy Soller bce8eac3c7 Move CMSG functions to C macros 2025-05-03 11:21:27 -06:00
Jeremy Soller a1db57a5a3 Get main function in crt0 to fix dynamic linking issues 2025-05-03 11:20:20 -06:00
Jeremy Soller 185cc2bc0f Merge branch 'unwraps-in-dns' into 'master'
Handle unwraps in get_dns_server()

See merge request redox-os/relibc!655
2025-05-02 22:15:06 -06:00
Josh Megnauth f85b33c3ed Handle unwraps in get_dns_server() 2025-05-02 23:01:12 -04:00
Jeremy Soller cafdcd35d1 Expose setegid and seteuid 2025-05-02 11:36:51 -06:00
Jeremy Soller a2e040ce4d Merge branch 'strto-detect-endptr' into 'master'
Fix strtol/ul endptr with detected base

See merge request redox-os/relibc!656
2025-05-02 10:36:05 -06:00
Jeremy Soller 863171105d Move htonl, htons, ntohl, ntohs to netinet/in.h to support more packages 2025-05-02 09:49:37 -06:00
Arne de Bruijn de3dd54266 Fix strtol/ul endptr with detected base
The "0" or "0x" characters with base 0 were not accounted for in the
returned endptr value.
2025-05-02 12:18:34 +02:00
Jeremy Soller 58572ceefc Define _SC_NPROCESSORS_CONF 2025-05-01 14:54:04 -06:00
Jeremy Soller c06155bd66 Merge branch 'alarm-unimplemented' into 'master'
Mark setitimer as unimplemented, obsolete

See merge request redox-os/relibc!654
2025-04-24 01:22:57 +00:00
Ron Williams c779c1d941 Mark setitimer as unimplemented, obsolete 2025-04-21 23:29:35 -07:00
4lDO2 f216665916 No-op, don't exit, as result of SIG_DFL SIGCONT. 2025-04-21 15:23:28 +02:00
Jeremy Soller 4dd8cbe15e Merge branch 'no_suid' into 'master'
Remove the code to use escalated for suid binaries

See merge request redox-os/relibc!653
2025-04-21 12:21:21 +00:00
bjorn3 f51690c3a8 Remove the code to use escalated for suid binaries 2025-04-21 11:07:01 +02:00
Jeremy Soller 4eb7e73afb Merge branch 'signals-tests-2' into 'master'
Add a WIP signals test suite

See merge request redox-os/relibc!652
2025-04-20 20:00:00 +00:00
4lDO2 8863a8967f Fix sigpause-suspend. 2025-04-20 21:17:40 +02:00
4lDO2 3947cda43a Fix sigpause-revert test. 2025-04-20 21:17:40 +02:00
4lDO2 95d2b59120 Improvements to sigpause and sigrelse tests. 2025-04-20 21:17:40 +02:00
4lDO2 799a9ef8d5 Misc improvements. 2025-04-20 21:17:40 +02:00
4lDO2 d1081b278c Fix sigset-5 and sigset-10. 2025-04-20 21:17:39 +02:00
4lDO2 cb23a518c0 Improve sigprocmask-9 test. 2025-04-20 21:17:39 +02:00
4lDO2 df228ddd79 Add remaining tests. 2025-04-20 21:17:39 +02:00
4lDO2 240a41861c Rebase, misc fixes for test suite. 2025-04-20 21:17:39 +02:00
Josh Williams 77cf9fc2a1 added tests to makefile and run_tests 2025-04-20 21:17:39 +02:00
Josh Williams 38e3320fb0 fixed sigprocmask-10 on linux 2025-04-20 21:17:39 +02:00
Josh Williams 493839baf5 fixed killpg-child on linux 2025-04-20 21:17:39 +02:00
Josh Williams a017dd1909 most recent updates to sigset-5 and 10 2025-04-20 21:17:39 +02:00
Josh Williams 70b997b249 switched to master makefile, run_tests and test_helpers 2025-04-20 21:17:39 +02:00
Josh Williams 2d3374f176 add tests to makefile and run_tests 2025-04-20 21:17:38 +02:00
Josh Williams 2bc44dba9d modify makefile and run_tests
fix compiler warnings
2025-04-20 21:17:38 +02:00
Josh Williams a2e19224a4 add signals-tests to makefile and run_tests 2025-04-20 21:17:38 +02:00
Josh Williams a7e9135bc9 clean up more tests 2025-04-20 21:17:38 +02:00
Josh Williams 6f787d20e5 clean up some tests 2025-04-20 21:17:38 +02:00
Josh Williams 9116eaa66d clean up a bunch of tests 2025-04-20 21:17:38 +02:00
Josh Williams 901b8099a2 add stdint.h to test_helpers
add tests for signals
2025-04-20 21:17:35 +02:00
4lDO2 32c5e89c82 Return ID of new session in setsid. 2025-04-20 17:10:51 +02:00
4lDO2 696ae4eca1 Add DisableSetpgid call. 2025-04-20 16:24:46 +02:00
Jacob Lorentzon a9fd150c91 Merge branch 'redox_cur_procfd_v0' into 'master'
Add redox_cur_procfd_v0 method to get own proc_fd

See merge request redox-os/relibc!651
2025-04-20 14:22:13 +00:00
bjorn3 4755d1ae24 Add redox_cur_procfd_v0 method to get own proc_fd 2025-04-20 16:19:45 +02:00
4lDO2 a30f13ee9b Fix setuid. 2025-04-20 14:00:35 +02:00
Jeremy Soller 040009ab3d Merge branch 'userspace_proc' into 'master'
Use process manager

See merge request redox-os/relibc!649
2025-04-19 18:04:40 +00:00
4lDO2 9e73f93c5c Use redox-os/syscall git dep. 2025-04-19 19:27:23 +02:00
4lDO2 8f234edf69 Fix riscv64 fork asm. 2025-04-19 19:27:04 +02:00
4lDO2 2fe8dc8f6e Add (untested) riscv64 sighandler SYS_CALL asm. 2025-04-19 19:27:03 +02:00
4lDO2 0e0246bc69 Let procmgr handle process names. 2025-04-19 19:27:03 +02:00
4lDO2 8cfc7e8fac Do not treat ppid as constant. 2025-04-19 19:27:03 +02:00
4lDO2 aa034fccc8 Compile on riscv64gc. 2025-04-19 19:27:03 +02:00
4lDO2 e6c06a7cf7 Fix signals for spawned threads, and async signal waiting. 2025-04-19 19:27:03 +02:00
4lDO2 35357b2f14 Clear pending when act becomes Ign (no multi-thread). 2025-04-19 19:27:03 +02:00
4lDO2 a1937f438c Allow read-only sigaction for SIG{KILL,STOP}. 2025-04-19 19:27:03 +02:00
4lDO2 8f2d9ef1db Ensure allowset bits for SIGSTOP and SIGKILL are always set. 2025-04-19 19:27:03 +02:00
4lDO2 5dfc76dda8 Fix signal handlers after EINTR nanosleep. 2025-04-19 19:27:03 +02:00
4lDO2 c25b4c67e1 Add kill-waitpid test. 2025-04-19 19:27:02 +02:00
4lDO2 37b60b67e0 Add and fix test for kill&waitpid. 2025-04-19 19:27:02 +02:00
4lDO2 0083043736 Write and fix waitpid_multiple test. 2025-04-19 19:27:02 +02:00
4lDO2 a293b02992 Fix aarch64 signal test. 2025-04-19 19:27:02 +02:00
4lDO2 403beeb9f6 Fix sigqueue test for aarch64. 2025-04-19 19:27:02 +02:00
4lDO2 d559450d69 Use abort() rather than unreachable! when exit fails. 2025-04-19 19:27:02 +02:00
4lDO2 d0335b30de Use redox_rt::protocol for sig numbers. 2025-04-19 19:27:02 +02:00
4lDO2 e86dc155c6 Add reference to NLnet project. 2025-04-19 19:27:02 +02:00
4lDO2 1c6b3ad78b Fix aarch64 child_hook. 2025-04-19 19:27:01 +02:00
4lDO2 fb8e3cd751 Fix sigqueue on i686. 2025-04-19 19:27:01 +02:00
4lDO2 26c92af7ba Fix SigSet length. 2025-04-19 19:27:01 +02:00
4lDO2 05481b36a6 Fix IPC size on i686. 2025-04-19 19:27:01 +02:00
4lDO2 2fbbdcc1c9 Aarch64 fix, make i686 compile. 2025-04-19 19:27:01 +02:00
4lDO2 0213ac2d15 Probably fix aarch.
Bootloader is currently panicking so a bit hard to test.
2025-04-19 19:27:01 +02:00
4lDO2 c773544906 Fix sigentry for realtime sigs, fixing sigqueue test. 2025-04-19 19:27:01 +02:00
4lDO2 f813f5a222 Fix sigtimedwait realtime signals, almost handler too. 2025-04-19 19:27:01 +02:00
4lDO2 6d72048b13 Store proc_fd in MaybeUninit with external discriminant. 2025-04-19 19:27:01 +02:00
4lDO2 6e947a9b2f Simplify FdGuard. 2025-04-19 19:27:00 +02:00
4lDO2 3a8d63d2b8 Handle self-kill for posix_kill{,_thread}. 2025-04-19 19:27:00 +02:00
4lDO2 134914c580 Expand waitpid test. 2025-04-19 19:27:00 +02:00
4lDO2 c99e9c7db3 Add waitpid test back. 2025-04-19 19:27:00 +02:00
4lDO2 2fb247266b Fix typo in pthread_exit test. 2025-04-19 19:27:00 +02:00
4lDO2 a8ee9e72ee Fix possible TCB.thread_fd() use-after-free. 2025-04-19 19:27:00 +02:00
4lDO2 9e769fcb57 Add pthread_exit test.
This caught a bug in the kernel where it would return Ok(24) when
passing zero extra-munmap length.
2025-04-19 19:27:00 +02:00
4lDO2 cc6fadb8bb Only SyncSigTctl if there exists a proc fd. 2025-04-19 19:27:00 +02:00
4lDO2 dc2988968e Use SignalThread call and fix fork sighandler sync with procmgr. 2025-04-19 19:26:59 +02:00
4lDO2 93e88b0ce8 Reacquire thread fd as procmgr-owned in make_init. 2025-04-19 19:26:59 +02:00
4lDO2 b30ccb61fe Enforce procmgr errors, fix attrs path. 2025-04-19 19:26:59 +02:00
4lDO2 ac7e0755f1 Fix SyncSigPctl invocation. 2025-04-19 19:26:59 +02:00
4lDO2 98c8beae3d Sync sig pages using proc and thread calls. 2025-04-19 19:26:59 +02:00
4lDO2 59090a83f4 Fix thread+proc fd init in ld.so 2025-04-19 19:26:59 +02:00
4lDO2 a4dc232a33 Impl getres[ug]id C function. 2025-04-19 19:26:59 +02:00
4lDO2 8bd510ff59 Simplify [res][ug]id getters and setters. 2025-04-19 19:26:59 +02:00
4lDO2 9999bb6068 Add ThisGroup selector for kill. 2025-04-19 19:26:59 +02:00
4lDO2 747d11062b Rename KillTarget -> ProcKillTarget. 2025-04-19 19:26:58 +02:00
4lDO2 88848c25fe Add (backend todo) proc calls for kill+sigq. 2025-04-19 19:26:58 +02:00
4lDO2 f4a64cfbc3 Add setresguid. 2025-04-19 19:26:58 +02:00
4lDO2 48df8f5bba Add unstable interface for getting current thread fd. 2025-04-19 19:26:58 +02:00
4lDO2 779c1e60c5 Add todo!() to fix compilation. 2025-04-19 19:26:58 +02:00
4lDO2 9566a00ad1 WIP: waitpid and exit IPC calls. 2025-04-19 19:26:58 +02:00
4lDO2 4138b68117 Implement setrens and waitpid using procmgr. 2025-04-19 19:26:58 +02:00
4lDO2 0c1835a545 Implement waitpid using new SYS_CALL. 2025-04-19 19:26:58 +02:00
4lDO2 bd68da3df9 Fix relibc exec thisproc usage. 2025-04-19 19:26:58 +02:00
4lDO2 1cd450a9ae Implement get{r,e}{u,g}id. 2025-04-19 19:26:57 +02:00
4lDO2 ad5efd0f11 Reach init fork 2025-04-19 19:26:57 +02:00
4lDO2 26399569de Reach init w/proc manager. 2025-04-19 19:26:57 +02:00
4lDO2 b851422214 WIP: use proc manager in non-init fork. 2025-04-19 19:26:57 +02:00
4lDO2 91e58e8568 WIP: dynamic and static proc info 2025-04-19 19:26:57 +02:00
4lDO2 422a32690d Replace removed syscalls with redox-rt stubs. 2025-04-19 19:26:57 +02:00
4lDO2 31570e99ab Patch redox_syscall. 2025-04-19 19:26:57 +02:00
Jeremy Soller 10cc54bbd4 Merge branch 'master' into 'master'
tcb: fix non x86

See merge request redox-os/relibc!650
2025-04-19 16:51:43 +00:00
Anhad Singh c64058c8b7 tcb: aarch64 2025-04-20 02:41:35 +10:00
Jeremy Soller 228d53dcd5 More improvements for relocation handling 2025-04-18 16:03:09 -06:00
Jeremy Soller 03f863d742 ld_so: better support for other arches 2025-04-18 14:26:39 -06:00
Jeremy Soller 310b097da6 Fix check for Sym size 2025-04-18 12:39:27 -06:00
Jeremy Soller 3cd57bde69 Fix deprecated option in rustfmt.toml 2025-04-18 12:38:39 -06:00
Jeremy Soller b48c2f74a3 Merge branch 'add-err_h' into 'master'
Implement BSD's err.h

See merge request redox-os/relibc!646
2025-04-18 12:34:46 +00:00
Josh Megnauth a4826bd48c Implement BSD's err.h 2025-04-18 12:34:45 +00:00
Jeremy Soller 8312a67d17 Set ld.so path based on target 2025-04-17 09:34:24 -06:00
Jeremy Soller 6e165e2ef0 Fix build on i686 2025-04-14 09:16:27 -06:00
Jeremy Soller 2f4b60fbf2 Merge branch 'itimer_stub' into 'master'
Make redox itimer relibc stub rather than kernel stub.

See merge request redox-os/relibc!647
2025-04-13 20:14:41 +00:00
4lDO2 d68f5d8d3d Make redox itimer relibc stub rather than kernel stub. 2025-04-13 18:18:05 +02:00
Jeremy Soller a0a5b5b7fd Merge branch 'better_exec' into 'master'
Couple of improvements to the exec implementation

See merge request redox-os/relibc!645
2025-04-12 20:24:20 +00:00
bjorn3 ea4c41686c Rustfmt 2025-04-12 22:15:05 +02:00
bjorn3 17172720a7 Always pass offset to read_all and rename to pread_all 2025-04-12 21:49:42 +02:00
bjorn3 050edcdcc6 Pass PROT_READ to mmap when the segment has PF_R
This will allow the kernel to not add an implicit PROT_READ for every
mmap in the future.
2025-04-12 20:13:39 +02:00
bjorn3 095646517d Use a single mmap + read for each segment 2025-04-12 20:10:28 +02:00
Jeremy Soller f79a2fb657 Merge branch 'revert_ub_workaround' into 'master'
Revert "Add a workaround for UB on arm64"

See merge request redox-os/relibc!644
2025-04-12 16:26:09 +00:00
bjorn3 d85fe6bdd5 Revert "Add a workaround for UB on arm64"
The kernel bug that caused this has been fixed.

This reverts commit 4d82cd90f8.
2025-04-12 17:14:01 +02:00
Jeremy Soller 5ea71a02c7 Merge branch 'fix_aarch64' into 'master'
Add a workaround for UB on arm64

See merge request redox-os/relibc!643
2025-04-12 12:05:41 +00:00
bjorn3 4d82cd90f8 Add a workaround for UB on arm64 2025-04-12 13:54:30 +02:00
bjorn3 52c429c207 Add a couple of PROT_READ
Even though they are only used for writing, it is still UB to create a
mutable reference to memory that can't be read.
2025-04-12 13:52:42 +02:00
Jeremy Soller ed575e9259 Implement sigsetjmp on all archs 2025-04-11 20:18:27 -06:00
Jeremy Soller 72d2b1137c Implement quick_exit and at_quick_exit 2025-04-11 18:09:44 -06:00
Jeremy Soller d9a28156ce Disable at_quick_exit 2025-04-11 16:25:12 -06:00
Jeremy Soller b3fbea62da Define __uint32_t and __uint64_t for openlibm 2025-04-11 15:47:57 -06:00
Jeremy Soller 27f3924126 Fix msg_controllen and cmsg_len types 2025-04-10 14:52:26 -06:00
Jeremy Soller 5b5be9aae8 Add IPV6_JOIN/LEAVE_GROUP 2025-04-10 14:43:35 -06:00
Jeremy Soller 9a93fde7b5 Fix gettid on Redox 2025-04-10 13:18:33 -06:00
Jeremy Soller b0be913956 Implement preadv and pwritev 2025-04-10 08:56:06 -06:00
4lDO2 6d0f8d9bd7 Update syscall. 2025-04-06 15:48:36 +02:00
Jeremy Soller 1cbe2038ec Merge branch 'escalated_consume' into 'master'
Use call rather than close in final escalated step.

See merge request redox-os/relibc!641
2025-04-06 13:30:23 +00:00
Jeremy Soller b05f7479ba environ_iter: handle environ being null 2025-04-05 20:56:38 -06:00
4lDO2 93cc8d81a4 Use call rather than close in final escalated step. 2025-04-05 20:06:26 +02:00
Jacob Lorentzon 1ed930ec41 Merge branch 'openat' into 'master'
Add redox_openat_v1

See merge request redox-os/relibc!642
2025-04-05 18:01:51 +00:00
Darley Barreto d2cc45f59c Add redox_openat_v1 2025-04-05 14:50:02 -03:00
Jeremy Soller baaaf8f130 Merge branch 'strptime-subfmt-no-clobber' into 'master'
fix(strptime): Don't clobber struct tm

See merge request redox-os/relibc!640
2025-04-02 18:58:10 +00:00
Josh Megnauth 090391d94f fix(strptime): Don't clobber struct tm
Our strptime implementation uses subformatting to handle specifiers that
expand to other specifiers. For example, '%T' expands to "%H:%M%:%S".
Relibc calls strptime again to handle '%T' by expanding it.

However, our strptime zeroes out struct tm which clobbers old values. If
strptime is called with a format string like "%D%t%T", the set values
for '%D' are clobbered.

Zeroing out the struct is extra, unneeded work as well. The user may
want to preserve old values. We don't read from struct tm so we don't
have to worry about invalid values. Finally, `musl` and `glibc` don't
clear the values either so we can default to their behavior.
2025-04-01 23:35:29 -04:00
Jeremy Soller 7f2a2ffe13 Merge branch 'fix_initialize_freestanding_bug' into 'master'
Prevent initialize_freestanding from accidentally closing fd 0

See merge request redox-os/relibc!638
2025-03-30 19:41:27 +00:00
bjorn3 20d77672e7 Add back asm_const feature
It isn't stable yet on the nightly used by redox
2025-03-30 21:04:58 +02:00
bjorn3 cf0fdb42ea Prevent initialize_freestanding from accidentally closing fd 0 2025-03-30 21:00:51 +02:00
Jeremy Soller b08e47812c Merge branch 'misc_cleanups' into 'master'
Couple of misc improvements

See merge request redox-os/relibc!637
2025-03-30 18:44:11 +00:00
bjorn3 facc643e18 Couple of misc improvements
Fix a bunch of warnings and clarify that execve will never return Ok by
using Infallible
2025-03-30 20:18:01 +02:00
Jeremy Soller 121e733990 Merge branch 'fix_arm64' into 'master'
Fix building for arm64

See merge request redox-os/relibc!636
2025-03-30 16:26:41 +00:00
bjorn3 50766b0469 Fix building on newer nighlies 2025-03-30 16:37:13 +02:00
bjorn3 8650ac293e Fix building on targets with unsigned c_char 2025-03-30 16:35:29 +02:00
Jeremy Soller 80b7fb65b3 Merge branch 'time-improvements' into 'master'
Time improvements

See merge request redox-os/relibc!635
2025-03-29 19:29:21 +00:00
Darley Barreto 26573d02d1 Time improvements 2025-03-29 19:29:20 +00:00
Jeremy Soller 53c3d7971d Merge branch 'update_posix_regex_to_master' into 'master'
Update posix-regex to master branch

See merge request redox-os/relibc!634
2025-03-29 14:02:40 +00:00
Nicolás Antinori 28713e6bf1 Update posix-regex to master branch 2025-03-29 14:02:40 +00:00
Jeremy Soller 6206581a73 Merge branch 'strptime-tests' into 'master'
Add strptime tests

See merge request redox-os/relibc!633
2025-03-29 14:01:29 +00:00
Josh Megnauth e827b4f61f Add strptime tests 2025-03-29 14:01:29 +00:00
Jeremy Soller ea39361329 Update dlmalloc-rs 2025-03-25 17:51:55 -06:00
Jeremy Soller c7e33dcad8 Merge branch 'printf-b' into 'master'
feat(c23): Implement `%b` and `%B` format

See merge request redox-os/relibc!630
2025-03-23 00:11:31 +00:00
GrayJack c7d94ae4d7 feat(c23): Implement %b and %B format 2025-03-22 20:15:56 -03:00
Jeremy Soller 78d7d66839 Merge branch 'strftime-iso-8601' into 'master'
strftime: ISO-8601 leap weeks

See merge request redox-os/relibc!628
2025-03-21 01:53:05 +00:00
Jeremy Soller 7c47e48d3c Merge branch 'printf-doc' into 'master'
docs: Add documentation of the printf format

See merge request redox-os/relibc!629
2025-03-20 23:20:38 +00:00
GrayJack 0a1ea4d57e docs: Add documentation of the printf format 2025-03-20 19:46:46 -03:00
Josh Megnauth ccc1b7f560 strftime: ISO-8601 leap weeks 2025-03-20 02:34:26 -04:00
Jeremy Soller 5ddf2ad000 Merge branch 'strptime-T-formatter' into 'master'
strptime: Implement %T, minor cleanups

See merge request redox-os/relibc!627
2025-03-18 14:59:39 +00:00
Josh Megnauth 8e6bcb6653 strptime: Implement %T, minor cleanups
* %T is implemented but untested for now (we lack strptime tests)
* I switched some unexported, immutable statics to const as it's a
  better fit
* parse_am_pm() now correctly strips prefixed whitespace AND doesn't
  allocate heap memory
2025-03-18 00:45:50 -04:00
Jeremy Soller de56c143a3 Merge branch 'use-cstr-literals-minimal' into 'master'
Use C string literals & deprecate `c_str!`

See merge request redox-os/relibc!625
2025-03-16 17:56:05 +00:00
Josh Megnauth 51c04d2470 Use C string literals & deprecate c_str! 2025-03-14 21:17:53 -04:00
Jeremy Soller 34c95ea662 Merge branch 'more-time' into 'master'
Few improvements to `time.h`

See merge request redox-os/relibc!622
2025-02-26 23:58:57 +00:00
Darley Barreto dda7142385 Few improvements to time.h 2025-02-26 23:58:57 +00:00
Jeremy Soller 14b2de180f Merge branch 'cbindgen-supports-builtins' into 'master'
Remove obsolete varargs workaround

See merge request redox-os/relibc!621
2025-02-24 20:25:37 +00:00
Josh Megnauth 7eb0968e91 Remove obsolete varargs workaround 2025-02-22 23:53:11 -05:00
Jacob Lorentzon 44f148ad6c Merge branch 'fix-vsscanf-signature' into 'master'
fix: cbindgen emits wrong vsscanf signature

See merge request redox-os/relibc!619
2025-02-22 13:43:22 +00:00
Josh Megnauth d63f0249e2 fix: cbindgen emits wrong vsscanf signature
`cbindgen` emits `...` instead of `va_list` when the final parameter is
named `__valist`.
2025-02-22 00:19:51 -05:00
Jeremy Soller 84f3d84ef9 Merge branch 'fix-USHRT_MAX' into 'master'
fix: USHRT_MAX is too large

See merge request redox-os/relibc!618
2025-02-18 22:17:50 +00:00
Josh Megnauth 27cd6a2b88 fix: USHRT_MAX is too large
The original expanded to 16 nibbles which is technically correct because
the standard defines USHRT_MAX as being at LEAST 65535. However, in
practice everything seems to set the max as the max length of two bytes.
2025-02-18 00:06:58 -05:00
Jeremy Soller b6b273af05 Merge branch 'sys-time-docs' into 'master'
Add docs, deprecations for sys/time.h

See merge request redox-os/relibc!616
2025-02-17 14:06:22 +00:00
Peter Limkilde Svendsen 6c94ed589a Mention select() declaration 2025-02-15 00:20:26 +01:00
Peter Limkilde Svendsen b9c4a910dd Reorder alphabetically 2025-02-15 00:18:18 +01:00
Peter Limkilde Svendsen 1fea91cb1a Add docs and deprecations for sys/time.h 2025-02-15 00:15:54 +01:00
Jeremy Soller 759f2a3a17 Merge branch 'netinet-docs' into 'master'
Add docs for netinet headers

See merge request redox-os/relibc!615
2025-02-14 15:12:35 +00:00
Peter Limkilde Svendsen 63aee953a1 Add docs for netinet headers 2025-02-12 21:24:16 +01:00
Jeremy Soller 56a1d9c3e9 Merge branch 'pvalloc2' into 'master'
Add pvalloc()

See merge request redox-os/relibc!614
2025-02-12 17:58:25 +00:00
Jeremy Soller 2eba1f5c6e Merge branch 'strings-docs' into 'master'
Add docs, missing functions for strings.h

See merge request redox-os/relibc!611
2025-02-12 17:57:54 +00:00
Peter Limkilde Svendsen b3f36faf87 Add pvalloc() 2025-02-11 21:13:51 +01:00
Jeremy Soller 365ec7fe7c Merge branch 'wscanf' into 'master'
wscanf and vwscanf implementation proposal

See merge request redox-os/relibc!613
2025-02-10 14:39:45 +00:00
Nicolás Antinori 205e09cac4 Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc into wscanf 2025-02-09 13:24:46 -03:00
Nicolás Antinori 28b471300b added vwscanf 2025-02-09 02:29:20 -03:00
Nicolás Antinori 230a15046d cleanup 2025-02-08 14:24:44 -03:00
Nicolás Antinori 47ed7a5907 fixed return value 2025-02-08 14:11:25 -03:00
Nicolás Antinori da3e1e94fa added get_char_encoded_length function 2025-02-08 14:05:37 -03:00
Jeremy Soller a16cd75508 Merge branch 'fix-sigqueue-test' into 'master'
Fix sigqueue test

See merge request redox-os/relibc!612
2025-02-07 22:04:03 +00:00
Ron Williams 6ea993bf46 Fix sigqueue test 2025-02-07 22:04:01 +00:00
Nicolás Antinori ca9cfde3d6 clean up code 2025-02-07 16:04:25 -03:00
Nicolás Antinori 9d49a2745f it is working, but with an unsafe 2025-02-07 15:56:21 -03:00
Jeremy Soller da174f9626 Fixes for 32-bit builds 2025-02-07 09:18:56 -07:00
Nicolás Antinori 61c31f348c changed wscanf parameters 2025-02-06 19:58:54 -03:00
Nicolás Antinori 18659e821f compiling but not working :) 2025-02-06 19:45:54 -03:00
Peter Limkilde Svendsen bda6a944b6 Fix error on deprecated functions 2025-02-04 19:53:09 +01:00
Peter Limkilde Svendsen 05eb0e85de Set #[no_mangle] on ffsl(), ffsll() 2025-02-03 23:07:02 +01:00
Peter Limkilde Svendsen 306196da2a Implement ffsl(), ffsll() 2025-02-03 22:47:45 +01:00
Peter Limkilde Svendsen 79badf4cfa Add missing function stubs 2025-02-03 22:46:27 +01:00
Peter Limkilde Svendsen 39f564ea23 Add docs and deprecations for strings.h 2025-02-03 22:37:37 +01:00
Jeremy Soller 7edc231f31 Merge branch 'clock_getcpuclockid-paramtype-fix' into 'master'
Fix clock_getcpuclockid() parameter type

See merge request redox-os/relibc!610
2025-02-03 20:59:41 +00:00
Peter Limkilde Svendsen a98fe90498 Fix clock_getcpuclockid() parameter type 2025-02-03 21:50:51 +01:00
Jeremy Soller f4e456e5b5 Merge branch 'time-docs' into 'master'
Add docs for time.h

See merge request redox-os/relibc!609
2025-02-03 14:51:43 +00:00
Peter Limkilde Svendsen 0f0bc8fc5e Formatting 2025-02-02 22:42:05 +01:00
Peter Limkilde Svendsen 3f88c9042d Add missing function stubs 2025-02-02 22:41:45 +01:00
Peter Limkilde Svendsen b0c6991f57 Reorder alphabetically 2025-02-02 22:28:32 +01:00
Peter Limkilde Svendsen ef6b64a7c2 Doc and pub use for strptime 2025-02-02 22:22:39 +01:00
Peter Limkilde Svendsen ee4f346ef0 Add docs and deprecations for time.h 2025-02-02 22:19:57 +01:00
Jeremy Soller 1972a5f44c Merge branch 'unistd-docs' into 'master'
Add docs for unistd.h

See merge request redox-os/relibc!608
2025-02-02 15:28:29 +00:00
Peter Limkilde Svendsen 85f01e8412 Add stubs for missing functions 2025-02-01 18:36:07 +01:00
Peter Limkilde Svendsen 26fdc200bf Add docs for unistd submodules 2025-02-01 18:07:51 +01:00
Peter Limkilde Svendsen 99e0948e0c Reexport ctermid, cuserid 2025-02-01 18:07:23 +01:00
Peter Limkilde Svendsen 5116c80d2f Reorder functions alphabetically 2025-02-01 17:34:20 +01:00
Peter Limkilde Svendsen bfde89c7cc Add docs and deprecations for unistd.h 2025-02-01 17:23:36 +01:00
Jeremy Soller e7a24b3f7f Merge branch 'sleep-intr' into 'master'
Make nanosleep and sleep handle interrupts correctly, plus fix alarm

See merge request redox-os/relibc!605
2025-01-31 21:10:15 +00:00
Ron Williams c528c0885f Make nanosleep and sleep handle interrupts correctly, plus fix alarm 2025-01-31 21:10:14 +00:00
Jeremy Soller 1871e8b08b Merge branch 'arpa-inet-docs' into 'master'
Add docs for arpa/inet.h, allow testing deprecated functions

See merge request redox-os/relibc!607
2025-01-31 21:09:42 +00:00
Jeremy Soller 4012354154 Merge branch 'dirent-docs' into 'master'
Add docs for dirent.h

See merge request redox-os/relibc!606
2025-01-31 21:09:21 +00:00
Peter Limkilde Svendsen b441916279 Add docs for dirent.h 2025-01-31 21:09:21 +00:00
Peter Limkilde Svendsen 38d22bd735 Suppress warnings about deprecated declarations in C 2025-01-30 21:41:52 +01:00
Peter Limkilde Svendsen a285728610 Formatting 2025-01-30 21:35:43 +01:00
Peter Limkilde Svendsen f4c75e99cd Align function parameter names and types with POSIX 2025-01-30 21:35:11 +01:00
Peter Limkilde Svendsen b36ae4cab5 Reorder functions alphabetically 2025-01-30 21:23:54 +01:00
Peter Limkilde Svendsen 5ec734a672 Add docstrings and deprecations for arpa/inet.h 2025-01-30 21:19:20 +01:00
Jeremy Soller 9c57e263c4 Merge branch 'fix-199-interpreter-args' into 'master'
Support arguments in shebang (#!)

Closes #199

See merge request redox-os/relibc!603
2025-01-25 00:08:21 +00:00
Josh Megnauth c458d3d7a2 Support arguments in shebang (#!) 2025-01-25 00:08:20 +00:00
Jeremy Soller aa7c438ebe Merge branch 'patch5' into 'master'
fix(ld.so): properly do copy relocations

See merge request redox-os/relibc!604
2025-01-18 13:17:38 +00:00
Anhad Singh d3073fdad4 feat(ld.so): more debug info for scopes
When scopes is set for `LD_DEBUG`, more debug information is displayed
now,

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-19 00:11:51 +11:00
Anhad Singh 99449094d4 chore: formatting
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-19 00:03:07 +11:00
Anhad Singh 4a08220664 fix(ld.so): copy relocations
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-18 23:51:53 +11:00
Anhad Singh e3dc5d0617 chore(dso): remove unused members
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-18 21:20:10 +11:00
Jeremy Soller 76014e8271 Merge branch 'patch5' into 'master'
feat(ld.so): add support for DT_RELR

See merge request redox-os/relibc!602
2025-01-15 13:52:06 +00:00
Anhad Singh 3440985729 fix(dso): 32-bit
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-15 21:32:40 +11:00
Anhad Singh a631703837 cleanup(makefile): unify rule for libc.so
Does the same thing.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-15 19:16:37 +11:00
Anhad Singh cf21cf24fc feat(libc.so): link flags
* -z pack-relative-relocs
* --sort-common
* --gc-sections

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-15 13:49:28 +11:00
Anhad Singh 07ff79069e feat(ld.so): add support for DT_RELR
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-15 13:49:27 +11:00
Jeremy Soller a3c12e27e4 Fix build for i686 2025-01-14 18:01:26 -07:00
Jeremy Soller b011dbe366 Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2025-01-14 12:24:38 -07:00
Jeremy Soller 5a69226af6 Fix compilation with new nightly 2025-01-14 12:24:33 -07:00
Jeremy Soller f4fff7448e Merge branch 'patch5' into 'master'
fix(ld.so): less locks

See merge request redox-os/relibc!601
2025-01-13 22:23:41 +00:00
Jeremy Soller f9590c4b17 Update rust-toolchain 2025-01-13 14:33:43 -07:00
Anhad Singh b9e0505715 fix(ld.so): less locks
Acquire the global scope lock at the start of relocate.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-13 23:48:03 +11:00
Jeremy Soller 90f30c5f51 Make NulTerminated::new return option 2025-01-09 13:33:56 -07:00
Jeremy Soller af50d18d16 Return error instead of panic when load_library cannot find root DSO 2025-01-09 13:33:29 -07:00
Jeremy Soller 02520b194e Fix compilation with trace feature 2025-01-09 12:23:23 -07:00
Jeremy Soller 01d7f7b44a Fixup last commit 2025-01-09 10:22:28 -07:00
Jeremy Soller 431d55aa24 Add setlinebuf 2025-01-09 10:21:17 -07:00
Jeremy Soller 77d96541d9 Merge branch 'langinfo' into 'master'
Implement 'langinfo.h' and refactor strftime() to use langinfo constants

See merge request redox-os/relibc!599
2025-01-08 21:31:46 +00:00
Jeremy Soller a7b608260a Merge branch 'patch5' into 'master'
feat(ld.so): performance improvements

See merge request redox-os/relibc!600
2025-01-08 14:44:34 +00:00
Anhad Singh aae27c5e0c feat(ld.so): switch to object crate
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-08 16:50:47 +11:00
Anhad Singh e49072655c feat(ld.so): partially switch to object
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-08 16:50:10 +11:00
Anhad Singh e219f9768e feat(ld.so): GNU hash table
Note that the ELF specification mandates the presence of either the GNU
hash table or SysV hash table. See Figure 2-7. Dynamic Array Tags.

Also both can be present, though that is not currently handled.

BLAZINGLY FAST!

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-08 16:48:26 +11:00
Guillaume Gielly 420a902e2b Readd item constants... 2025-01-07 13:55:54 +01:00
Guillaume Gielly b0c45af008 Refactor langinfo module to use a static string table for constants 2025-01-07 13:47:05 +01:00
Jeremy Soller b67d7e2fdf Merge branch 'fix-gnu-make-glob' into 'master'
fix: GNU seems to prefer its own glob.h

See merge request redox-os/relibc!598
2025-01-07 00:15:33 +00:00
Guillaume Gielly b5b5bd2522 Support building with #![deny(unsafe_op_in_unsafe_fn)] 2025-01-05 23:02:04 +01:00
Guillaume Gielly cf106906b5 Code cleanup 2025-01-05 22:30:35 +01:00
Guillaume Gielly ffd5edd283 Add strptime() module and clean up unused strptime function 2025-01-05 20:10:50 +01:00
Guillaume Gielly ba225e2000 Refactor strftime() to use langinfo constants for locale-based formatting :
- replaced hardcoded day and month names with calls to nl_langinfo,
- integrated langinfo constants  DAY_1, ABDAY_1, MON_1, ABMON_1) for weekday and month names,
- used AM_STR and PM_STR for AM/PM strings in %p and %P specifiers,
- add comments.
2025-01-05 19:45:29 +01:00
Guillaume Gielly 770e768818 Implement 'langinfo.h' 2025-01-05 18:20:42 +01:00
Josh Megnauth 922878b22e fix: GNU seems to prefer its own glob.h
Make (and possibly other) GNU programs seem to prefer using its own
`glob.h`. For Make, its configure detects if GNU's glob then uses it if
it is OR compiles a bundled version if it's not.

Make fails to link now that we have `glob.h` (duplicated symbols).
2025-01-05 02:37:41 -05:00
Jeremy Soller 25b0da4876 Merge branch 'sigsetjmp_x64_implementation' into 'master'
Implement sigsetjmp and siglongjmp for X64

See merge request redox-os/relibc!478
2025-01-04 00:29:19 +00:00
Bendeguz Pisch 35a3efd936 Implement sigsetjmp and siglongjmp for X64 2025-01-04 00:29:19 +00:00
Jeremy Soller 9265b778c6 Merge branch 'impr_time' into 'master'
Adding `tzset`, timezone awareness, and some tweaks

See merge request redox-os/relibc!596
2025-01-02 20:19:34 +00:00
Darley Barreto c14b2cee4c Adding tzset, timezone awareness, and some tweaks 2025-01-02 20:19:34 +00:00
Jeremy Soller 94e264d253 Merge branch 'patch5' into 'master'
fix(ld.so): errors UB

See merge request redox-os/relibc!595
2025-01-01 14:18:37 +00:00
Anhad Singh bfe1c0b545 fix(ld.so): redox build
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-31 19:30:37 +11:00
Anhad Singh 01e6eda258 misc(dlfcn): cleanup
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-31 19:03:05 +11:00
Anhad Singh 42d884c6a3 fix(ld.so): errors UB
Currently, how ld.so errors are handled by functions in dlfcn is wrong.
dlopen calls `linker.load_library` which returns a
`Result<ObjectHandler, goblin::Error>`. Now `goblin::Error` may have
variants that are heap allocated. For example:
`Error::Malformed(format!("invalid path: '{}': {}", path, err))`. The
error string would be allocated by ld.so's allocator but will be dropped
inside libc. This is UB.

After this patch, we now return a custom `DlError` instead. To get more
information about the error, `LD_DEBUG=all` can be set.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-31 18:35:20 +11:00
Anhad Singh 9cf72fd0b2 feat(ld.so): add all option for LD_DEBUG
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-31 18:00:45 +11:00
Anhad Singh 60f700fb50 chore(linker): remove todo
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-31 15:26:23 +11:00
Anhad Singh c25292ae21 misc(ld.so): clippy fixes
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-31 15:25:40 +11:00
Jeremy Soller f08952b1b0 Merge branch 'patch5' into 'master'
feat: rwlock

Closes #196

See merge request redox-os/relibc!594
2024-12-30 17:17:05 +00:00
Jeremy Soller e4162ef850 Merge branch 'monetary' into 'master'
Implement 'monetary.h' and and a basic strfmon() function

See merge request redox-os/relibc!589
2024-12-30 17:15:35 +00:00
Jeremy Soller ac9505c246 Merge branch 'fix-199-improved-hashbang' into 'master'
Handle prepended whitespace for hashbang

See merge request redox-os/relibc!591
2024-12-30 17:14:24 +00:00
Josh Megnauth 513f1951fe Handle prepended whitespace for hashbang 2024-12-30 17:14:24 +00:00
Anhad Singh 0449c35e52 chore: fix formatting
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-31 01:23:51 +11: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 bc51d8e1d5 fix(pal/redox): use RwLock instead of InnerRwLock
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-31 01:07:36 +11:00
Anhad Singh 4232858b89 misc(tests/ptrace): update expected
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-31 00:54:58 +11:00
Anhad Singh 2c307616d8 fix(tests/ptrace.c): persistent logs
Even though it might seem like it, it is not necessary that write(2) is
the only system call performed. It could be that the libc has to
allocate memory (via MMAP) or makes use of a futex. To produce
consistant results, only log on SYS_write and when the syscall number
has been patched.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-31 00:54:58 +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
Jeremy Soller 647141a3fc Merge branch 'popen-test-fix' into 'master'
fix popen tests

See merge request redox-os/relibc!593
2024-12-29 00:58:44 +00:00
Ron Williams a4ca5b4e85 fix popen tests 2024-12-28 16:34:27 -08:00
Jeremy Soller 1196bea3e4 Merge branch 'imp_str' into 'master'
Add missing functions to `string.h`

See merge request redox-os/relibc!592
2024-12-28 22:46:45 +00:00
Darley Barreto ae5a5256b4 Add missing functions to string.h 2024-12-28 22:46:45 +00:00
Jeremy Soller 841abb180a Merge branch 'dup2-tests' into 'master'
fix popen, improve tests

See merge request redox-os/relibc!590
2024-12-27 14:02:55 +00:00
Ron Williams 9df3708a1a fix popen, improve tests 2024-12-26 17:14:15 -08:00
Guillaume Gielly ff940da768 Simplify text alignement 2024-12-26 20:49:30 +01:00
Guillaume Gielly 1658d16b4e Prevents buffer overflow on 'scale' 2024-12-26 20:40:49 +01:00
Guillaume Gielly 2f96ac181a Refactor and logic of format_monetary() 2024-12-26 20:35:43 +01:00
Guillaume Gielly ed4c1f089e Refactor strfmon() 2024-12-26 19:33:16 +01:00
Guillaume Gielly 4bcf779119 Remove useless custon floatingpoint and use libm instead 2024-12-26 19:10:57 +01:00
Jeremy Soller 8deec75e45 Merge branch 'patch5' into 'master'
feat(ld.so): lazy binding and scopes

See merge request redox-os/relibc!586
2024-12-25 13:18:31 +00:00
Anhad Singh 1ffd7187ef feat(dlfcn): define RTLD_DEFAULT
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-25 19:27:31 +11:00
Anhad Singh 2be4316aec feat(dlfcn): return DSO as the handle
Fine because:
> The value of this handle should not be interpreted in any way by the
> caller.
From: https://pubs.opengroup.org/onlinepubs/009696599/functions/dlopen.html

* Add tests for unload
* Implement NOLOAD so we can test that the loaded object has been
  destroyed.
* Minor cleanup.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-25 16:17:51 +11:00
Anhad Singh 1612c78774 fix(ld.so): disable lazy binding on non-x86_64
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-24 20:51:53 +11:00
Anhad Singh 023a005688 fix(ld.so): non-pie lazy
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-24 20:51:53 +11:00
Anhad Singh 1db68ab978 feat(ld.so): scopes
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-24 20:51:53 +11:00
Anhad Singh 13d819ac89 misc(ld.so: __plt_resolve_inner): println -> trace
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-24 20:51:53 +11:00
Anhad Singh e3587017f6 fix(ld.so): stub plt stub for non-x86_64
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-24 20:51:53 +11:00
Anhad Singh 0a0ecb018f fix(ld.so: adjust_stack): remove dead code
Does not do anything.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-24 20:51:53 +11:00
Anhad Singh c6fd0517ac feat(ld.so: config): handle LD_BIND_NOW
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-24 20:51:53 +11:00
Anhad Singh 5ae1b8e974 feat(ld.so): lazy binding
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-24 20:51:53 +11:00
Anhad Singh 30970e111a feat(ld.so): enable warnings just for ld.so
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-24 20:51:53 +11:00
Anhad Singh 959982b8a4 fix(ld.so): use Strtab::get_at()
> use of deprecated method `goblin::strtab::Strtab::<'a>::get`: Bad performance, use get_at() instead

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-24 20:51:53 +11:00
Anhad Singh cc5e0ceebc fix(ld.so): function signature
No longer expects a self TLS.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-24 20:51:53 +11:00
Anhad Singh eb82f9afeb misc(lint): unused variables and imports
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-24 20:51:53 +11:00
Anhad Singh 500848bc76 fix(ld.so): remove unreachable loop {}
_exit() is noreturn

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-24 20:51:53 +11:00
Guillaume Gielly f20c0552dd Enhance monetary formatting implementation and improve comments for clarity 2024-12-23 21:56:45 +01:00
Guillaume Gielly 610909bd2b Implement 'monetary.h', including initial structure and strfmon() function 2024-12-23 21:32:56 +01:00
Jeremy Soller 427e177bec Merge branch 'memcpy-slices' into 'master'
Reimplement memcpy() using slices, fix unaligned read/write, add test

See merge request redox-os/relibc!587
2024-12-23 19:14:45 +00:00
Peter Limkilde Svendsen 93b6374d1e Reimplement memcpy() using slices, fix unaligned read/write, add test 2024-12-23 19:14:44 +00:00
Jeremy Soller a4ba9cf0ad Merge branch 'relibc' into 'master'
Implement 'tar.h'

See merge request redox-os/relibc!588
2024-12-20 14:27:31 +00:00
gugz0r ff66c10a27 Code cleanup. 2024-12-19 13:58:05 +01:00
Ribbon 41c88ed288 Document the build instructions and improve the README 2024-12-19 02:41:40 +00:00
gugz0r e96eb6dac6 Fix formatting issues detected by rustfmt. 2024-12-18 23:11:02 +01:00
gugz0r 6fc19f8fdf Add tests and improve comments. 2024-12-18 22:59:36 +01:00
gugz0r a4cd089189 Implement 'tar.h' 2024-12-18 22:11:33 +01:00
Jeremy Soller bc79bc4ac2 Merge branch 'unsafe_blocks-glob-inttypes-libgen' into 'master'
Unsafe blocks: `glob`, `inttypes`, `libgen`

See merge request redox-os/relibc!584
2024-12-18 14:04:12 +00:00
Jeremy Soller 69578c46cb Merge branch 'cpio' into 'master'
Implement `cpio.h`

See merge request redox-os/relibc!585
2024-12-18 14:03:52 +00:00
Jeremy Soller 392168e524 Merge branch 'patch3' into 'master'
fix(Makefile): delay

See merge request redox-os/relibc!582
2024-12-18 14:03:18 +00:00
bitstr0m ce7e553ae9 Implement cpio.h 2024-12-17 10:38:43 +00:00
Josh Megnauth af7f5c4a3f Unsafe blocks: glob, inttypes, libgen
Related to #194.
2024-12-17 02:15:49 -05:00
Anhad Singh 632716ada7 fix(Makefile): delay
I noticed a pretty significant delay (of ~5s on my machine) after
executing `make`.

This was because TARGET was currently defined as a recursively expanded
variable. This means that the command:

rustc -Z unstable-options --print target-spec-json | grep llvm-target | cut -d '"' -f4

..will get run everytime TARGET is mentioned. This patch fixes the above
by defining the variable as an immediately expanded value. This will
ensure the command only get run once and still skips if predefined.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-17 15:57:17 +11:00
Jeremy Soller 14ecc9540a Merge branch 'patch4' into 'master'
fix(ci): formatting

See merge request redox-os/relibc!583
2024-12-16 19:57:53 +00:00
Anhad Singh 39c8cc864d fix(ci): formatting
Was my fault.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-17 03:14:33 +11:00
Jeremy Soller a54dc95f43 Merge branch 'devel2' into 'master'
feat(ld.so): config via env vars

See merge request redox-os/relibc!581
2024-12-16 15:38:40 +00:00
Anhad Singh de9e8a6177 feat(ld.so): config
Currently supported options are `LD_DEBUG` and `LD_LIBRARY_PATH`.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-17 01:07:17 +11:00
Jeremy Soller 6fdcd4f44a Merge branch 'unsafe_blocks-getopt-grp' into 'master'
Unsafe blocks: `getopt.h`, `grp.h`

See merge request redox-os/relibc!580
2024-12-15 14:34:38 +00:00
Jeremy Soller 444bb5b485 Merge branch 'glob' into 'master'
Implement `glob.h`

See merge request redox-os/relibc!579
2024-12-15 14:32:11 +00:00
Jeremy Soller 0da7e3befb Merge branch 'unsafe_blocks-fcntl-fnmatch' into 'master'
Unsafe blocks: `fcntl.h`, `fnmatch.h`

See merge request redox-os/relibc!578
2024-12-13 14:38:48 +00:00
Jeremy Soller 15de4e67c5 Merge branch 'redox_dynlink' into 'master'
fix(ld.so): redox

See merge request redox-os/relibc!577
2024-12-13 14:13:11 +00:00
Josh Megnauth 14988e33b2 Unsafe blocks: getopt.h, grp.h 2024-12-13 01:20:24 -05:00
bitstr0m 5d6ae507e1 Implement glob.h 2024-12-12 15:17:16 +00:00
Anhad Singh 9928091aad fix(ci)
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-12 16:11:42 +11:00
Anhad Singh d3bab6eeee fix(redox: ld.so): unmap old TCB
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-12 16:00:11 +11:00
Anhad Singh 20b9af633d chore: bump redox_syscall
Bumps redox_syscall to 0.5.8

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-12 13:50:04 +11:00
Jeremy Soller a04870d1f3 Merge branch 'devel' into 'master'
feat(dbg): lift the latest version

See merge request redox-os/relibc!576
2024-12-11 13:49:40 +00:00
Josh Megnauth 624947211a Unsafe blocks: fcntl.h, fnmatch.h 2024-12-11 01:56:30 -05:00
Anhad Singh 8c1722d583 fix(ld.so): redox
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-11 16:51:51 +11:00
Jeremy Soller 76f1a4c0a8 Merge branch 'unsafe_blocks-dlfcn-dl_tls' into 'master'
Unsafe blocks: `dl-tls`, `dlfcn`

See merge request redox-os/relibc!575
2024-12-10 14:49:31 +00:00
Anhad Singh 064c7c31c5 feat(dbg): lift the latest version
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-10 22:15:11 +11:00
Josh Megnauth a7cb1c4176 Unsafe blocks: dl-tls, dlfcn 2024-12-10 02:13:32 -05:00
Jeremy Soller dfb71665be Merge branch 'dirent-unsafe_op_in_unsafe_fn' into 'master'
Use unsafe blocks in `dirint.h`

See merge request redox-os/relibc!574
2024-12-09 12:56:51 +00:00
Jeremy Soller 0dd6e27597 Merge branch 'dynamic_linker' into 'master'
fix(ld_so): for Linux

See merge request redox-os/relibc!570
2024-12-09 12:56:04 +00:00
Josh Megnauth 1642c1e1bc Use unsafe blocks in dirint.h 2024-12-08 01:54:55 -05:00
Anhad Singh de00d6c6b9 fix(ld.so): temporary fix
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-05 23:34:16 +11:00
Anhad Singh 32077ee341 fix(ld.so): set tls module id to 0 if no tls
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-05 23:33:41 +11:00
Anhad Singh e34ecc31a1 Revert "feat(redox_rt): map PT_TLS"
This reverts commit 4b959776e0.
2024-12-05 23:12:32 +11:00
Anhad Singh c286ad2868 fix(ld.so): do not depend on TLS at all
In the next big refactor (next PR), all of the platform functionality
used by both relibc and ld.so will be moved into a `platform`/`sysdeps`
crate and then ld.so would be moved out of relibc and not link with it.

I think doing it in a seperate PR would make it more managable, as when
I did half of it, the diff was pretty huge and that way it would be
easier to review too :)

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-05 23:11:59 +11:00
Anhad Singh a527cc53ea tests(pthread): status must be 0 if not leader
Fix CI break.

man pthread_barrier_wait(3)
> ...the constant PTHREAD_BARRIER_SERIAL_THREAD shall be returned to
> one *unspecified* thread and zero shall be  returned  to  each  of  the  remaining
> threads.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-05 16:24:10 +11:00
Anhad Singh 55ba8d8f6b misc(load_objs_recursive): do not add empty masters
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-05 15:00:35 +11:00
Anhad Singh d8f7590848 fix(__tls_get_addr): NULL check
Has to be done before adding the offsets.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-05 15:00:35 +11:00
Anhad Singh 1c846f8013 fix comment
x86 and x86_64 are below TP and others are above TP

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-05 15:00:35 +11:00
Anhad Singh 43301848b9 Apply 1 suggestion(s) to 1 file(s)
Co-authored-by: Andrey Turkin <andrey.turkin+redox@gmail.com>
2024-12-05 02:55:34 +00:00
Jeremy Soller 6d94805cda Merge branch 'fix-glib-netinet-in' into 'master'
Impl `sockaddr_storage`, structs in `netinet.h`

See merge request redox-os/relibc!573
2024-12-03 21:45:47 +00:00
Josh Megnauth 6295ce73ea Impl sockaddr_storage, structs in netinet.h 2024-12-03 21:45:47 +00:00
Jeremy Soller 618954dd39 Merge branch 'add-stdnoreturn-h' into 'master'
Add `stdnoreturn.h`

See merge request redox-os/relibc!572
2024-12-03 21:41:59 +00:00
Jeremy Soller 98aa4ea57c Merge branch 'fix-200-round_up_to_page_size-overflow' into 'master'
fix: `round_up_to_page_size` overflow

Closes #200

See merge request redox-os/relibc!569
2024-12-03 21:41:36 +00:00
Jeremy Soller 366c036a3a Merge branch 'all-posix-headers' into 'master'
Add TODOs for remaining POSIX headers

See merge request redox-os/relibc!571
2024-12-03 21:41:07 +00:00
Anhad Singh 4b959776e0 feat(redox_rt): map PT_TLS
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-30 00:02:52 +11:00
Anhad Singh f6fa4e8246 feat(ld_so): setup sighandler
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-30 00:02:33 +11:00
Anhad Singh e9f3147e3b fix(tcb): do not use Vec::from_raw_parts
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-29 20:55:02 +11:00
Anhad Singh 1a7726541a fix TCB and TLS
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-29 18:40:16 +11:00
Anhad Singh c88eb3d5d0 Revert "fix(linker): deref uninit TCB"
This reverts commit 37dbf5cbb2.
2024-11-29 00:03:09 +11:00
Josh Megnauth 96de114be8 Add stdnoreturn.h
This header is more or less the same across libc implementations.

`musl` uses its `_Noreturn` macro to detect which `noreturn`
should be used: C11 or GCC's extension as a fallback.

`glibc` simply defines `noreturn` as `_Noreturn`.

This implementation is based off of `musl`'s.

`_Noreturn` is deprecated as of C23.
2024-11-27 01:25:53 -05:00
Peter Limkilde Svendsen 5045d40fa2 Add TODOs for remaining POSIX headers 2024-11-26 22:02:42 +01:00
Anhad Singh e8e6b8cbc5 fix(expected): dynamic bins
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-26 19:51:06 +11:00
Anhad Singh cdb4843164 fix(tests): fix UB in mk{fifo,nod,nodat}
Memory chunk is allocated with `malloc` and used as the `dest` buffer
for `strncat`. The `dest` argument in `strncat` has to be NUL terminated,
however it was not.

This commit fixes this issue in mk{fifo,nod,noat}.c.

Almost all dynamic tests pass now.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-26 16:56:05 +11:00
Josh Megnauth 6ec03b6f4a fix: round_up_to_page_size overflow
Closes: #200

The spec doesn't define which error code to set if `len` is too large.
`ENOMEM` is the closest defined condition that fits:

>> [...] the range [addr,addr+len) exceeds that allowed for the address
space of a process [...]

Logically, `len` would lead to `addr` exceeding the address space of a
process if rounding it up to the next page size causes an overflow.
2024-11-26 00:37:12 -05:00
Anhad Singh 22bbdb025c misc(tests): fix compilation of dlfcn.c
From man dlopen(3)
> According to the ISO C standard, casting between function
> pointers and 'void *', as done above, produces undefined results.
> POSIX.1-2001 and POSIX.1-2008 accepted this state of affairs and
> proposed the following workaround:
>
>   *(void **) (&cosine) = dlsym(handle, "cos");
>
> This (clumsy) cast conforms with the ISO C standard and will
> avoid any compiler warnings.
>
> The 2013 Technical Corrigendum 1 to POSIX.1-2008 improved matters
> by requiring that conforming implementations support casting
> 'void *' to a function pointer.  Nevertheless, some compilers
> (e.g., gcc with the '-pedantic' option) may complain about the
> cast used in this program.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-25 18:00:03 +11:00
Anhad Singh 6020c54ce7 chore(test): add expected outputs for dynamic tests
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-25 16:16:07 +11:00
Anhad Singh 37dbf5cbb2 fix(linker): deref uninit TCB
The bug is described for `x86_64` and Linux but is the same for other architectures and on Redox.

`Tcb::current()` is used to retrieve the current TCB, which is done by by reading `fs:[0x10]`. The TCB layout describes that at offset `0x10`, there is `tcb_ptr: *mut GenericTcb<...>`, which is nothing more but a pointer to itself.

This is fine as otherwise a system call would be required to get the TCB (`arch_prctl(ARCH_GET_FS)` on Linux).

However, this is problematic as the function may be called when the FS base is not set, and in that case the expected output of the function should be [`None`], but we don't currently handle that.

To fix this, any code paths that maybe call this function on an uninitialized TCB are be switched to call `current_slow()`. Which just uses `arch_prctl(ARCH_GET_FS)` to get the FS base and check if it's non-zero.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-25 16:09:06 +11:00
Anhad Singh 00746c2566 misc(tests): disable dlfcn test for now
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-25 12:31:33 +11:00
Anhad Singh b9bef59d8a fix(libc.so): link with libgcc
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-25 12:20:32 +11:00
Anhad Singh 7aa340570f chore: enable dynamic tests
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-25 12:13:03 +11:00
Jeremy Soller a64a6a4cd0 Merge branch 'fix-failing-features-test' into 'master'
Temporarily disable `noreturn` attribute test

See merge request redox-os/relibc!568
2024-11-24 13:55:06 +00:00
Josh Megnauth daa77e7149 Temporarily disable noreturn attribute test 2024-11-24 13:55:05 +00:00
Jeremy Soller 3c79fd759a Merge branch 'exit-return-never' into 'master'
Exit should return never (`!`)

See merge request redox-os/relibc!567
2024-11-23 19:55:38 +00:00
Jeremy Soller b95bd0dfa6 Merge branch 'fix-socket-set-edom-timeout-overflow' into 'master'
fix: Multiplication overflow in setsockopt

Closes #201

See merge request redox-os/relibc!566
2024-11-23 19:53:33 +00:00
Josh Megnauth a709dd47bf fix: Multiplication overflow in setsockopt 2024-11-23 19:53:33 +00:00
Josh Megnauth 90f934c769 Exit should return never (!)
`_Exit`, `exit`, and related functions should return `!` because they
don't return. This also signals to cbindgen that it should emit
`[[noreturn]]` for those functions.
2024-11-23 03:33:00 -05:00
Jeremy Soller a430a7861d Merge branch 'pwd-docs' into 'master'
Add docs for pwd.h

See merge request redox-os/relibc!563
2024-11-21 15:07:30 +00:00
Peter Limkilde Svendsen 864f4306ce Add docs for pwd.h 2024-11-21 15:07:30 +00:00
Jeremy Soller 7a729571ec Merge branch 'sys-auxv-docs' into 'master'
Add docs for sys/auxv.h

See merge request redox-os/relibc!564
2024-11-21 15:07:25 +00:00
Jeremy Soller 8381218ab1 Merge branch 'sys-file-docs' into 'master'
Add docs for sys/file.h

See merge request redox-os/relibc!565
2024-11-21 15:07:21 +00:00
Peter Limkilde Svendsen 5591eeacb3 Add docs for sys/file.h 2024-11-20 23:21:48 +01:00
Peter Limkilde Svendsen 399b0ad81f Add docs for sys/auxv.h 2024-11-20 23:17:10 +01:00
Jeremy Soller e528eae801 Merge branch 'string-docs' into 'master'
Add docs for string.h, add missing functions

See merge request redox-os/relibc!562
2024-11-19 00:20:40 +00:00
Peter Limkilde Svendsen 2a7d01f02d Add docs for string.h, add missing functions 2024-11-19 00:20:40 +00:00
Jeremy Soller 46c2d36193 Merge branch 'fix-dns-extra-output' into 'master'
fix(netdb): Buffer overrun when parsing DNS

See merge request redox-os/relibc!559
2024-11-18 13:43:23 +00:00
Josh Megnauth fc1e220a99 fix(netdb): Buffer overrun when parsing DNS 2024-11-18 13:43:22 +00:00
Jeremy Soller 32fca670ea Merge branch 'memmem-cast-mut' into 'master'
Use only one .cast_mut() in memmem()

See merge request redox-os/relibc!561
2024-11-17 20:09:46 +00:00
Peter Limkilde Svendsen 864d5e4795 Use only one .cast_mut() in memmem() 2024-11-17 20:19:52 +01:00
Jeremy Soller 2c73cc947c Merge branch 'memmem' into 'master'
Implement memmem()

See merge request redox-os/relibc!560
2024-11-17 16:18:15 +00:00
Peter Limkilde Svendsen 6a765ed88f Implement memmem() 2024-11-17 16:18:14 +00:00
Jeremy Soller ce7b85b0df Merge branch 'dont-overallocate-cstrings' into 'master'
Avoid over allocations & reallocations

See merge request redox-os/relibc!558
2024-11-17 16:17:22 +00:00
Jeremy Soller 88987eb000 Merge branch 'pty-utmp-docs' into 'master'
Add docs for pty.h and utmp.h

See merge request redox-os/relibc!557
2024-11-17 16:17:04 +00:00
Jeremy Soller 09bcfd0711 Merge branch 'errno-const-macros' into 'master'
Test errno constant macros, make ENOTSUP available in Rust

See merge request redox-os/relibc!556
2024-11-17 16:16:47 +00:00
Peter Limkilde Svendsen 42011f28d8 Test errno constant macros, make ENOTSUP available in Rust 2024-11-17 16:16:47 +00:00
Jeremy Soller caac784caa Merge branch 'iso646' into 'master'
Add iso646.h and corresponding tests

See merge request redox-os/relibc!555
2024-11-17 16:16:11 +00:00
Jeremy Soller 7b2e315c17 Merge branch 'cbindgen-use-attributes' into 'master'
Emit C attributes via cbindgen

See merge request redox-os/relibc!548
2024-11-17 16:15:07 +00:00
Josh Megnauth 5348273ccc Emit C attributes via cbindgen 2024-11-17 16:15:07 +00:00
Jeremy Soller dbe5c85411 Merge branch 'inttypes-docs' into 'master'
Add docs for inttypes.h

See merge request redox-os/relibc!554
2024-11-17 16:13:32 +00:00
Jeremy Soller 693769da1e Merge branch 'sys-random-docs' into 'master'
Add docs for sys/random.h

See merge request redox-os/relibc!553
2024-11-17 16:13:17 +00:00
Jeremy Soller 093d11c451 Merge branch 'elf-docs' into 'master'
Add basic docs for elf.h

See merge request redox-os/relibc!552
2024-11-17 16:13:01 +00:00
Jeremy Soller c57022894b Merge branch 'crypt-docs' into 'master'
Add docs for crypt.h

See merge request redox-os/relibc!551
2024-11-17 16:12:44 +00:00
Peter Limkilde Svendsen b8ad113a84 Add docs for crypt.h 2024-11-17 16:12:43 +00:00
Jeremy Soller 63cb0401e5 Merge branch 'calloc-no-intrinsics' into 'master'
Avoid unnecessary intrinsic in calloc

See merge request redox-os/relibc!550
2024-11-17 16:12:27 +00:00
Josh Megnauth d6ac5f8947 Avoid over allocations & reallocations
As we know, vectors amortize the cost of adding new elements by reserving
space for multiple elements when full. This is useful but may lead to
allocating more memory than necessary.

`relibc` generally avoids over allocations by reserving the exact amount
of space when possible. I fixed a few areas that still over allocated or
reallocated unnecessarily by leveraging iterators that are more likely
to know sizes.
2024-11-14 22:53:12 -05:00
Peter Limkilde Svendsen 66eb440d79 Add docs for pty.h and utmp.h 2024-11-13 18:19:22 +01:00
Peter Limkilde Svendsen 56d05e2cdc Add iso646.h and corresponding tests 2024-11-10 16:19:15 +01:00
Peter Limkilde Svendsen 2f1e183cc6 Add docs for inttypes.h 2024-11-09 18:24:18 +01:00
Peter Limkilde Svendsen 0090dea50f Add docs for sys/random.h 2024-11-09 18:12:58 +01:00
Peter Limkilde Svendsen 1474dce2a7 Add basic docs for elf.h 2024-11-09 18:02:47 +01:00
Peter Limkilde Svendsen c440c61e58 Avoid unnecessary intrinsic in calloc 2024-11-09 17:35:09 +01:00
Jeremy Soller a45c7b26d9 Merge branch 'stdlib-docs' into 'master'
Add docs for stdlib.h, add stubs for missing functions

See merge request redox-os/relibc!549
2024-11-08 14:45:26 +00:00
Peter Limkilde Svendsen 890be6fc02 Add docs for stdlib.h, add stubs for missing functions 2024-11-08 14:45:26 +00:00
Jeremy Soller 659cb66c30 Merge branch 'netdb-h_errno' into 'master'
Set `h_errno` for gethostbyname/addr

See merge request redox-os/relibc!547
2024-11-02 12:21:47 +00:00
Josh Megnauth bf1ea4e799 Set h_errno for gethostbyname/addr 2024-11-02 12:21:47 +00:00
Jeremy Soller 2dad215394 Merge branch 'net-if-docs' into 'master'
Add docs for net/if.h

See merge request redox-os/relibc!546
2024-10-31 23:59:00 +00:00
Peter Limkilde Svendsen 36ed4cbd7a Add docs for net/if.h 2024-10-31 23:59:00 +00:00
Jeremy Soller 715dee0c47 Merge branch 'semaphore-docs' into 'master'
Add docs for semaphore.h

See merge request redox-os/relibc!545
2024-10-31 23:58:52 +00:00
Peter Limkilde Svendsen 8367249c1a Add docs for semaphore.h 2024-10-31 23:58:52 +00:00
Jeremy Soller 5135a43e9e Merge branch 'sys-un-docs' into 'master'
Add docs for sys/un.h

See merge request redox-os/relibc!544
2024-10-31 21:43:34 +00:00
Jeremy Soller d56c4dad2c Merge branch 'sys-mman-docs' into 'master'
Add docs for sys/mman.h, make mremap pub

See merge request redox-os/relibc!543
2024-10-31 21:43:21 +00:00
Peter Limkilde Svendsen 6c1ccd161a Add docs for sys/mman.h, make mremap pub 2024-10-31 21:43:21 +00:00
Jeremy Soller eb37133e01 Merge branch 'ftime-maybeuninit' into 'master'
Use MaybeUninit for ftime arg, document safety

See merge request redox-os/relibc!542
2024-10-31 21:43:00 +00:00
Peter Limkilde Svendsen ee428d10f8 Use MaybeUninit for ftime arg, document safety 2024-10-31 21:43:00 +00:00
Peter Limkilde Svendsen 5f2ece19a2 Add docs for sys/un.h 2024-10-31 22:26:34 +01:00
Jeremy Soller 0373bc0d1c Merge branch 'wctype-docs' into 'master'
Add docs for wctype.h, fix unsafe handling

See merge request redox-os/relibc!541
2024-10-31 12:05:16 +00:00
Peter Limkilde Svendsen e43a9bd2f6 Add docs for wctype.h, fix unsafe handling 2024-10-31 12:05:16 +00:00
Jeremy Soller 83b0a8b493 Merge branch 'sys-timeb-docs' into 'master'
Add docs for sys/timeb.h, require unsafe blocks

See merge request redox-os/relibc!540
2024-10-31 12:04:48 +00:00
Peter Limkilde Svendsen 76f36f09df Add docs for sys/timeb.h, require unsafe blocks 2024-10-31 12:04:48 +00:00
Jeremy Soller 1d5c02ab92 Merge branch 'utime-docs' into 'master'
Add utime.h docs, use unsafe blocks

See merge request redox-os/relibc!538
2024-10-29 23:01:21 +00:00
Peter Limkilde Svendsen 2e5c1f7b72 Add utime.h docs, use unsafe blocks 2024-10-29 23:01:21 +00:00
Jeremy Soller 691c562f96 Merge branch 'ctype-docs' into 'master'
Add ctype.h docs

See merge request redox-os/relibc!539
2024-10-29 23:01:17 +00:00
Peter Limkilde Svendsen 3e7f0eebd4 Add ctype.h docs 2024-10-29 23:57:14 +01:00
Jeremy Soller b37af1e345 Merge branch 'rand48-docs' into 'master'
Add docs to rand48 functions

See merge request redox-os/relibc!537
2024-10-29 21:13:55 +00:00
Jeremy Soller c09c92cd13 Merge branch 'endian-pub' into 'master'
Make endian.h functions pub, add docs

See merge request redox-os/relibc!536
2024-10-29 21:12:28 +00:00
Peter Limkilde Svendsen 35d7a0ac3f Add docs to rand48 functions 2024-10-29 21:22:27 +01:00
Peter Limkilde Svendsen c37a094e66 Make endian.h functions pub, add docs 2024-10-29 20:46:29 +01:00
Jeremy Soller 91c3db877a Merge branch 'errno-docs' into 'master'
Add docs, deny unsafe op in unsafe fn for errno

See merge request redox-os/relibc!534
2024-10-29 15:05:09 +00:00
Peter Limkilde Svendsen d1ffa4f062 Add docs, deny unsafe op in unsafe fn for errno 2024-10-29 15:05:08 +00:00
Jeremy Soller 15c4611121 Merge branch 'add-docstrings' into 'master'
Add various basic docstrings

See merge request redox-os/relibc!533
2024-10-29 15:04:57 +00:00
Jeremy Soller 394480150b Merge branch 'fix-perror-doesnt-follow-spec-prefix' into 'master'
fix(stdio): `perror` should be allowed to take NULL prefixes as per spec

See merge request redox-os/relibc!530
2024-10-29 12:27:22 +00:00
Josh Megnauth 6f5794f636 fix(stdio): perror should be allowed to take NULL prefixes as per spec 2024-10-29 12:27:22 +00:00
Jeremy Soller 2919d0a6e8 Merge branch 'fix-out-of-bounds-panic-netdb-gethostbyname' into 'master'
fix(netdb): Out of bounds in gethostbyaddr and less transmutes

See merge request redox-os/relibc!535
2024-10-29 12:26:46 +00:00
Josh Megnauth 701e57197a fix(netdb): Out of bounds in gethostbyaddr and less transmutes 2024-10-29 12:26:46 +00:00
Peter Limkilde Svendsen 06fec0b843 Add various basic docstrings 2024-10-27 23:25:57 +01:00
Jeremy Soller 9ac0226c93 Merge branch 'nulterminated-fused' into 'master'
Implement FusedIterator for NulTerminated, NulTerminatedInclusive

See merge request redox-os/relibc!532
2024-10-27 13:43:37 +00:00
Peter Limkilde Svendsen d41ec992af Implement FusedIterator for NulTerminated, NulTerminatedInclusive 2024-10-27 13:43:37 +00:00
Jeremy Soller 9fb744a9c0 Merge branch 'libuv-port-relibc' into 'master'
Add C code necessary for libuv to work

See merge request redox-os/relibc!529
2024-10-24 16:58:52 +00:00
Dorian Davi efcbbb8592 Add C code necessary for libuv to work 2024-10-24 16:58:52 +00:00
Jeremy Soller 89b5637240 Merge branch 'strchr-iter' into 'master'
Add NulTerminatedInclusive iterator, rewrite/fix strchr/wcschr

See merge request redox-os/relibc!531
2024-10-22 22:12:24 +00:00
Peter Limkilde Svendsen 41264dc8b1 Add NulTerminatedInclusive iterator, rewrite/fix strchr/wcschr 2024-10-22 22:12:24 +00:00
Jeremy Soller 95affabb18 For now, do not build C compiler-rt 2024-10-18 15:52:42 -06:00
Jeremy Soller d7b130942d Include C-only compiler builtins, improves aarch64 target 2024-10-18 15:06:43 -06:00
Jeremy Soller f22150e77b Merge branch 'poll-unsafe-blocks' into 'master'
Use unsafe blocks in poll.h implementation

See merge request redox-os/relibc!526
2024-10-16 13:14:07 +00:00
Peter Limkilde Svendsen 2e48a31a47 Use unsafe blocks in poll.h implementation 2024-10-16 13:14:07 +00:00
Jeremy Soller 0a29bfae68 Merge branch 'strings-unsafe-blocks' into 'master'
Use unsafe blocks in strings.h implementation

See merge request redox-os/relibc!525
2024-10-15 18:47:22 +00:00
Peter Limkilde Svendsen 66b9c8ec87 Use unsafe blocks in strings.h implementation 2024-10-15 18:47:22 +00:00
Jeremy Soller 1c3d59ee95 Merge branch 'strcasecmp-iter' into 'master'
Refactor strcasecmp, strncasecmp with iterators

See merge request redox-os/relibc!524
2024-10-15 18:10:52 +00:00
Peter Limkilde Svendsen b60fb9bace Refactor strcasecmp, strncasecmp with iterators 2024-10-15 18:10:52 +00:00
Jeremy Soller 5a5349c996 Merge branch 'riscv' into 'master'
Initial RISC-V64 support

See merge request redox-os/relibc!523
2024-10-15 18:10:30 +00:00
Andrey Turkin a4122753e6 Initial RISC-V64 support 2024-10-11 06:44:54 +03:00
Jeremy Soller ff853a7b82 Define HOST_NAME_MAX 2024-10-10 15:14:53 -06:00
Jeremy Soller c254ab3219 Add sys/poll.h 2024-10-10 15:06:49 -06:00
Jeremy Soller ef22cf9dfa Implement mkdtemp 2024-10-09 08:58:47 -06:00
Jeremy Soller 952b583e35 Merge branch 'update-rand-crates' into 'master'
Update versions of rand crates for new rand core

See merge request redox-os/relibc!521
2024-10-06 15:19:23 +00:00
Jeremy Soller e115ebb203 Merge branch 'test-runner' into 'master'
Make relibc-tests easy to run on Redox

See merge request redox-os/relibc!522
2024-10-06 15:18:30 +00:00
Ron Williams 84399fb83a fix formatting 2024-10-06 05:43:17 -07:00
Ron Williams 72e5b514f4 Make all tests runnable in the same list 2024-10-06 05:33:56 -07:00
Ron Williams d2ef712fa7 Improve test running on Redox 2024-10-06 04:26:13 -07:00
Kirpal Grewal e653cafb33 Update versions of rand crates for new rand core 2024-10-05 15:48:57 +01:00
Jeremy Soller a91cb17e4e Merge branch 'remove_access_wrapper' into 'master'
Remove ld.so's now unnecessary access() wrapper.

See merge request redox-os/relibc!520
2024-09-30 16:52:30 +00:00
4lDO2 57f098931a Remove ld.so's now unnecessary access() wrapper. 2024-09-30 16:55:27 +02:00
Jeremy Soller d794dc7704 Merge branch 'test' into 'master'
Add sigaltstack test

See merge request redox-os/relibc!518
2024-09-28 16:09:48 +00:00
4lDO2 07af4e49f7 Add sigaltstack test. 2024-09-28 16:51:17 +02:00
Jeremy Soller f5c0b8b0d1 Merge branch 'impl_net_if_h' into 'master'
Impl net/if.h

See merge request redox-os/relibc!517
2024-09-28 12:50:01 +00:00
Raffaele Ragni 1864a97a8e Impl net/if.h 2024-09-28 12:50:00 +00:00
Jeremy Soller 487b8f0e56 Merge branch 'pal_errno2' into 'master'
Remove the C-style "-1 or errno" e() function entirely

See merge request redox-os/relibc!516
2024-09-27 16:31:00 +00:00
4lDO2 eee603efa8 Remove the "-1 errno" e() function. 2024-09-27 15:35:04 +02:00
4lDO2 070b4cd05c Switch PalPtrace to Rusty error handling. 2024-09-27 15:35:04 +02:00
4lDO2 d474163e0e Switch to Rusty error handling in PalSocket. 2024-09-27 15:35:01 +02:00
Jeremy Soller 1679aadfad Merge branch 'pal_errno' into 'master'
Eliminate all errno-based error handling in the Pal trait

See merge request redox-os/relibc!515
2024-09-27 13:03:30 +00:00
4lDO2 4da5ad37d1 Convert PalEpoll to Rusty error handling. 2024-09-27 11:22:36 +02:00
4lDO2 1a46a24c70 Rustify PalSignal error handling. 2024-09-27 11:12:19 +02:00
4lDO2 8b8b00da01 Use unsigned return values in read()-like Pal fns.
Returning a negative number of bytes makes absolutely no sense, besides
the "-1 and errno" pattern, which is now converted to Result<_, Errno>.
2024-09-27 10:39:26 +02:00
4lDO2 986754e7b3 Remove all remaining errno interfaces from Pal. 2024-09-27 10:29:32 +02:00
4lDO2 313b32c815 Switch almost all of Pal to Rusty error handling. 2024-09-27 10:19:44 +02:00
Jeremy Soller 549bdc5c72 Merge branch 'pal_errno' into 'master'
Change a bunch of Pal functions to use Rusty error handling

See merge request redox-os/relibc!514
2024-09-26 16:47:30 +00:00
4lDO2 4b687c25d2 Convert more Pal methods to Result. 2024-09-26 16:24:01 +02:00
4lDO2 6e5959b3fa Convert a bunch of c_int to Result<(), Errno>. 2024-09-26 16:21:34 +02:00
Jeremy Soller 509c4520a5 Merge branch 'umask' into 'master'
Preserve umask across execv.

See merge request redox-os/relibc!512
2024-09-25 19:01:05 +00:00
4lDO2 ec216e56e2 Preserve umask across execv. 2024-09-25 20:28:50 +02:00
Jeremy Soller 47f44ee12f Merge branch 'umask' into 'master'
Move umask to a regular global variable.

See merge request redox-os/relibc!511
2024-09-25 17:54:01 +00:00
4lDO2 7fa5b679cc Move umask to a regular global variable.
The umask value is per-process, so because all POSIX open-like functions
now occur via relibc, this is valid.
2024-09-25 19:39:41 +02:00
Jeremy Soller a736f596b9 Merge branch 'sigq' into 'master'
Implement realtime signals and remaining signal.h APIs

See merge request redox-os/relibc!493
2024-09-24 18:44:08 +00:00
4lDO2 293b041ea7 Move psignal test to correct (non-expect) category. 2024-09-24 19:34:53 +02:00
4lDO2 79e1550215 Use only sig & 63 when checking SA_ONSTACK. 2024-09-24 19:34:53 +02:00
4lDO2 fed49a29af Properly deallocate thread stack on pthread_exit. 2024-09-24 19:34:53 +02:00
4lDO2 af6435e12d Implement psignal and psiginfo. 2024-09-24 19:34:53 +02:00
4lDO2 2b7a1ea94b Fix sigsuspend and add it to the sigqueue test. 2024-09-24 19:34:53 +02:00
4lDO2 9701e9c544 Add sigtimedwait to test, and various fixes. 2024-09-24 19:34:53 +02:00
4lDO2 5c78356290 Implement sigtimedwait on Redox. 2024-09-24 19:34:52 +02:00
4lDO2 8e5ddbd654 Implement sigsuspend. 2024-09-24 19:34:52 +02:00
4lDO2 33f0df3b27 Deduplicate and simplify sigprocmask code. 2024-09-24 19:34:52 +02:00
4lDO2 21d23092cd Mostly fix i686. 2024-09-24 19:34:52 +02:00
4lDO2 e82ced6e4e Fix non-edge-case signal handling on aarch64. 2024-09-24 19:34:52 +02:00
4lDO2 d6396cb4e8 Probably complete aarch64 asm.
It contains all signal logic x86_64 already has, although statistically
it will certainly have a few errors.
2024-09-24 19:34:52 +02:00
4lDO2 9a7cfaeaf1 Simplify aarch64 asm slightly. 2024-09-24 19:34:52 +02:00
4lDO2 e860a19e8f WIP: Update i686 signal asm. 2024-09-24 19:34:52 +02:00
4lDO2 09108634cf Set uc_stack properly.
POSIX does not appear to explicitly mention that this should be the
sigaltstack, but other Linux appears to treat it as the sigaltstack.
2024-09-24 19:34:52 +02:00
4lDO2 30caf55429 Set siginfo_t.si_{pid,uid} from kill signals too. 2024-09-24 19:34:51 +02:00
4lDO2 e5136e66c1 Draft of updated aarch64 signal trampoline. 2024-09-24 19:34:51 +02:00
4lDO2 d0db6a1ce0 Fix i686. 2024-09-24 19:34:51 +02:00
4lDO2 f6761407e5 Pass si_pid to all realtime signals. 2024-09-24 19:34:51 +02:00
4lDO2 6fe7c264f6 Pass si_code to siginfo_t struct. 2024-09-24 19:34:51 +02:00
4lDO2 cce268afbf Pass old stack pointer in uc_stack. 2024-09-24 19:34:51 +02:00
4lDO2 cdae79c129 Fix i686 compilation. 2024-09-24 19:34:51 +02:00
4lDO2 abc2ec7bb5 Add prototype ucontext_t support. 2024-09-24 19:34:51 +02:00
4lDO2 b48da5622d Add rtsig to i686 trampoline too. 2024-09-24 19:34:50 +02:00
4lDO2 13e7b77643 Implement basic support for (kernel) rt signals. 2024-09-24 19:34:50 +02:00
4lDO2 47e07654cb WIP: use rt signal constants from sigabi 2024-09-24 19:34:50 +02:00
4lDO2 75b2dcaa45 WIP: implement sigqueue 2024-09-24 19:34:23 +02:00
Jeremy Soller 1e97bae11b Merge branch 'kek/chroot3' into 'master'
Add capability to set the default scheme

See merge request redox-os/relibc!510
2024-09-23 14:36:45 +00:00
Kamil Koczurek 408a7b2ab6 Add capability to set the default scheme 2024-09-23 14:36:45 +00:00
Jeremy Soller 97b8c1cee1 Merge branch 'ptr-iter' into 'master'
Implement iterators on pointers

See merge request redox-os/relibc!507
2024-09-22 23:42:28 +00:00
Peter Limkilde Svendsen 0a23acd401 Implement iterators on pointers 2024-09-22 23:42:28 +00:00
4lDO2 7e38bb1476 Fix Linux compilation. 2024-09-21 13:42:43 +02:00
Jeremy Soller 4d29614ea8 Better stub for sigsuspend on redox 2024-09-19 21:01:07 -06:00
Jeremy Soller 1ac8c4834b Format 2024-09-19 16:09:11 -06:00
Jeremy Soller 1b7d059707 Add getrusage 2024-09-19 16:08:54 -06:00
Jeremy Soller 8a0b2dcbd0 Fix pthread_cleanup macros 2024-09-19 15:52:42 -06:00
Jeremy Soller 110aeadaa6 Fix backslashes in bits_pthread macros 2024-09-19 15:45:20 -06:00
Jeremy Soller 73fcc88aa2 Add O_SYNC for redox 2024-09-19 15:44:46 -06:00
Jeremy Soller eb33ac46f9 Export struct siginfo 2024-09-19 15:16:47 -06:00
Jeremy Soller 7371cbcab0 unistd: implement daemon function 2024-09-19 14:59:04 -06:00
Jeremy Soller 35743d7a18 Sync errno in File functions 2024-09-18 14:33:56 -06:00
Jeremy Soller 709875b87a Merge branch 'build-fix' into 'master'
Simplify Makefile and remove debug.

See merge request redox-os/relibc!506
2024-09-14 01:19:26 +00:00
4lDO2 0ded9780f1 Use multiline string in unistd config. 2024-09-14 00:49:08 +02:00
4lDO2 d0b02a3fb7 Simplify Makefile and remove debug. 2024-09-12 16:10:28 +02:00
4lDO2 a9f05d3c3c Add trailing NUL byte check on Redox. 2024-09-12 16:10:25 +02:00
Jeremy Soller 4935b98180 Make ino_t be c_ulonglong 2024-09-11 16:14:03 -06:00
Jeremy Soller 0b03a68150 Fix unistd header generation 2024-09-11 15:59:31 -06:00
Jeremy Soller ec663bea46 Merge branch 'dents' into 'master'
Improve redox getdents impl and use syscall when applicable

See merge request redox-os/relibc!504
2024-09-11 21:37:42 +00:00
4lDO2 c0e7af5289 Backwards-compatibly rewrite getdents to use special syscall. 2024-09-11 23:32:19 +02:00
4lDO2 198caa3bc5 Rustify Sys::open and some fs:: error handling. 2024-09-11 23:22:32 +02:00
4lDO2 b9653e689b Implement From<Errno> for io::Error. 2024-09-11 23:22:32 +02:00
4lDO2 4bd0d2a1ef Move pthread::Errno to separate module. 2024-09-11 23:22:29 +02:00
Jeremy Soller e73b891e77 Merge branch 'unsafe-blocks-in-sync' into 'master'
use unsafe blocks in `sync/`

See merge request redox-os/relibc!505
2024-09-11 21:21:36 +00:00
Jeremy Soller d6ef87ad3c Merge branch 'feat/ignore_neg_fd_poll' into 'master'
feat: ignore negative fd and clear its revents in poll(2)

See merge request redox-os/relibc!484
2024-09-11 21:17:31 +00:00
Jeremy Soller 3c2bc98275 Merge branch 'crypt-unsafe-blocks' into 'master'
Use unsafe blocks in crypt.h implementation

See merge request redox-os/relibc!503
2024-09-11 21:14:46 +00:00
Peter Limkilde Svendsen d806e79d36 Use unsafe blocks in crypt.h implementation 2024-09-11 21:14:46 +00:00
Jeremy Soller bf46e331bb Merge branch 'assert-unsafe-blocks' into 'master'
Use unsafe blocks in assert.h implementation

See merge request redox-os/relibc!502
2024-09-11 21:14:33 +00:00
Peter Limkilde Svendsen 8c583cc978 Use unsafe blocks in assert.h implementation 2024-09-11 21:14:33 +00:00
Jeremy Soller 753ddef64a Merge branch 'arpa_inet-unsafe-blocks' into 'master'
Use unsafe blocks in arpa/inet.h implementation

See merge request redox-os/relibc!501
2024-09-11 21:14:14 +00:00
Peter Limkilde Svendsen 58bb5a9689 Use unsafe blocks in arpa/inet.h implementation 2024-09-11 21:14:14 +00:00
JustAnotherDev 7df5b16f9e set deny(unsafe_op_in_unsafe_fn) for 2024-09-11 20:55:05 +01:00
Jeremy Soller 3da3ff114e Merge branch 'fix-test-instructions' into 'master'
Fix the Redox OS test execution command

See merge request redox-os/relibc!500
2024-09-07 12:33:09 +00:00
Ribbon fbac03940a Fix the Redox OS test execution command 2024-09-07 12:33:08 +00:00
Jeremy Soller 7a86d10189 Merge branch 'test-endian-macros' into 'master'
Test endian.h macros

See merge request redox-os/relibc!499
2024-09-07 02:58:29 +00:00
Peter Limkilde Svendsen bb5adffdff Test endian.h macros 2024-09-06 22:28:24 +02:00
Jeremy Soller 37bd940776 Merge branch 'endian-test-fix' into 'master'
Fix little-endian-specific endian.h tests

See merge request redox-os/relibc!498
2024-09-06 19:20:10 +00:00
Peter Limkilde Svendsen 1cbbafd8b1 Fix little-endian-specific endian.h tests 2024-09-06 19:26:33 +02:00
Jeremy Soller 6e4fdf70f5 Merge branch 'endian' into 'master'
Add `endian.h`

See merge request redox-os/relibc!497
2024-09-04 18:36:09 +00:00
Arnold Loubriat 9e20c351d8 Add endian.h 2024-09-04 00:50:30 +02:00
4lDO2 933b447c7a redox-rt: fix i686 pctl pending offset 2024-08-29 14:11:52 +02:00
Jeremy Soller b819940646 Merge branch 'random-array-static-mut' into 'master'
Un-mutexify random() default buffer

See merge request redox-os/relibc!496
2024-08-18 22:19:22 +00:00
Peter Limkilde Svendsen d20b29c552 Un-mutexify random() default buffer 2024-08-18 22:19:22 +00:00
Jeremy Soller 35ebc1ab8f Merge branch 'explain-redox-rt' into 'master'
Explain what redox-rt is

See merge request redox-os/relibc!495
2024-08-17 14:54:57 +00:00
Ribbon 274ffd0e6f Explain what redox-rt is 2024-08-17 14:13:35 +00:00
Jeremy Soller c1845235f0 Merge branch 'random-mutex' into 'master'
Put random() state behind mutex

See merge request redox-os/relibc!491
2024-08-15 23:26:16 +00:00
Peter Limkilde Svendsen 3193656f22 Put random() state behind mutex 2024-08-15 23:26:16 +00:00
Jeremy Soller 092663c50a Merge branch 'no_legacy_scheme' into 'master'
Remove all uses of the legacy scheme syntax

See merge request redox-os/relibc!492
2024-08-15 14:57:30 +00:00
Jeremy Soller fb174136b3 Merge branch 'fixes' into 'master'
Fixes for forkpty and dprintf tests

See merge request redox-os/relibc!494
2024-08-15 14:54:11 +00:00
4lDO2 651445d0c9 Move forkpty test from EXPECT_NAMES to NAMES. 2024-08-10 13:08:11 +02:00
4lDO2 70e31a9454 Dup stdout rather than opening /dev/stdout.
The former is more portable, even on Linux if for example sudo/doas is used.
2024-08-10 13:00:13 +02:00
4lDO2 8dc3cca1e6 Allow (nonstandard?) pthread old{ty,state} == NULL 2024-08-10 12:59:20 +02:00
bjorn3 49c708f537 Remove all uses of the legacy scheme syntax" 2024-08-04 13:49:10 +02:00
Jeremy Soller a38638542d Merge branch 'ctermid' into 'master'
Implement ctermid()

See merge request redox-os/relibc!490
2024-08-01 18:42:29 +00:00
Jeremy Soller dc9a577354 Merge branch 'mktime-timegm-refactor' into 'master'
Refactor mktime, timegm and fix wcpncpy test

See merge request redox-os/relibc!487
2024-08-01 18:42:01 +00:00
Peter Limkilde Svendsen 17076f37b9 Refactor mktime, timegm and fix wcpncpy test 2024-08-01 18:42:01 +00:00
Jeremy Soller 455d7323e9 Merge branch 'swscanf_works' into 'master'
swscanf and vswscanf implementation proposal

See merge request redox-os/relibc!472
2024-08-01 18:41:14 +00:00
Nicolás Antinori 198c5502b7 swscanf and vswscanf implementation proposal 2024-08-01 18:41:14 +00:00
Jeremy Soller af4fbf374e Merge branch 'dprintf' into 'master'
Implement dprintf and vdprintf

See merge request redox-os/relibc!489
2024-08-01 18:39:58 +00:00
Agoston Szepessy cdf5c70d5b Implement ctermid() 2024-07-25 11:32:26 +02:00
Agoston Szepessy bb1e8fe8d7 Implement dprintf and vdprintf 2024-07-23 22:15:53 +02:00
Jeremy Soller ce8181573c Merge branch 'getpass' into 'master'
Implement getpass()

See merge request redox-os/relibc!488
2024-07-23 19:31:23 +00:00
Agoston Szepessy b5f767ea30 More PR feedback
Use u8 internally instead of `c_char`.
2024-07-23 18:07:09 +02:00
Agoston Szepessy 99ade44c12 PR feedback
- Remove `stdio` functions and use `File` API completely.
- Remove `unsafe` from wrapper function.
- Move static buffer to `getpass()` instead of keeping it in wrapper.
2024-07-23 16:56:39 +02:00
Agoston Szepessy 545e9e7b29 Implement getpass using File API
Returns a Result for better error handling.
2024-07-23 16:07:25 +02:00
Agoston Szepessy a83d4cbced Implement getpass()
Also make fields in `termios` public; required for modifying them.

There's an new type of test: `EXPECT_INPUT_BINS`. These require a `.exp`
file to be present along with the `.c` file. The `.exp` file takes the
produced binary as an argument and sends input to the program. This is
useful for testing functions like `getpass()`.
2024-07-23 16:07:25 +02:00
Jeremy Soller 798d17c5b3 Add __rdl_oom to renamesyms 2024-07-21 21:38:20 -06:00
Jeremy Soller 853d5e2d0e Merge branch 'fix-cbindgen-panic' into 'master'
Exclude dirs during build with no cbindgen.toml

See merge request redox-os/relibc!486
2024-07-21 13:00:03 +00:00
Agoston Szepessy 51e264ddf2 Exclude dirs with no cbindgen.toml
Fixes the panic that occurs on builds.
2024-07-21 14:06:35 +02:00
Jeremy Soller 005fe68884 Merge branch 'pid' into 'master'
Process/thread distinction improvements

See merge request redox-os/relibc!485
2024-07-20 22:12:05 +00:00
4lDO2 5f62c30539 Update aarch64's child_hook. 2024-07-20 22:18:25 +02:00
4lDO2 f7d9f4e21e Fix infinite loop & spurious signals for i686. 2024-07-20 19:41:04 +02:00
4lDO2 b71c34dd2d Fix i686 fork. 2024-07-20 14:42:51 +02:00
Steve Lau c7300009cd feat: ignore negative fd and clear its revents in poll(2) 2024-07-20 20:41:52 +08:00
4lDO2 35c9485701 WIP: Implement process signals for i686 trampoline. 2024-07-20 13:01:30 +02:00
4lDO2 232f6e9ade Fix hardcoding of SUPPORTS_AVX. 2024-07-19 18:44:21 +02:00
4lDO2 518ba4c884 Raise unblocked signals in setmask, restore control flag. 2024-07-19 18:41:00 +02:00
4lDO2 44ec1676ae Activate new threads' TCBs early. 2024-07-18 23:59:48 +02:00
4lDO2 01ce7f5aa1 Fix sigchld test. 2024-07-18 23:59:48 +02:00
4lDO2 d458b6cdcd Handle waitpid WUNTRACED stop signals properly. 2024-07-18 23:59:48 +02:00
4lDO2 1067295d65 Fix signal restart logic. 2024-07-18 23:59:48 +02:00
4lDO2 6dd9332af2 WIP: Handle spurious signals properly.
These can occur in the following scenario:

- thread 1 has blocked signal A
- thread 2 has not blocked signal A
- signal A is sent to a process with thread 1 and thread 2
- thread 1 is simultaneously unblocking signal A, and thus jumps to the
  trampoline
- thread 2 is awoken, but thread 1 won the "fetch_andn" to clear the
  signal bit.

If the signal asm is jumped to automatically after each timer interrupt,
this scenario will also be relatively common due to that.
2024-07-18 23:59:48 +02:00
4lDO2 ff7eace6a7 Obtain offset of sig pctl more sanely. 2024-07-18 23:59:48 +02:00
4lDO2 ac5ac928f2 Implement raise() using pthread_kill. 2024-07-18 23:59:48 +02:00
4lDO2 4354bc94e8 Fix process-targeted signals. 2024-07-18 23:59:47 +02:00
4lDO2 15cdc4e0aa Fix (modified) audiod. 2024-07-18 23:59:47 +02:00
4lDO2 d00ec085e1 WIP: Support receiving process-targeted signals. 2024-07-18 23:59:47 +02:00
4lDO2 0b3be2d190 Write correct value to kernel when exiting thread. 2024-07-18 23:59:47 +02:00
4lDO2 4cb6644181 Implement exit_this_thread on Redox. 2024-07-18 23:59:47 +02:00
4lDO2 c286dd6d33 Use new-thread proc API 2024-07-18 23:59:47 +02:00
4lDO2 bf26de70e2 Add setresuid/setresgid (suid/sgid stub on Redox). 2024-07-18 23:54:46 +02:00
Jeremy Soller 312b66e547 Merge branch 'usignal2' into 'master'
Implement syscall restart

See merge request redox-os/relibc!483
2024-07-17 09:38:41 +00:00
4lDO2 dfb234079e Fix signal fxrstor offset. 2024-07-16 14:46:09 +02:00
4lDO2 66a32016b5 Move sa_restart test to correct category. 2024-07-16 14:43:25 +02:00
4lDO2 22cab7ca8d Fix errors on non-x86_64. 2024-07-16 13:32:18 +02:00
4lDO2 17cb748217 Implement syscall restart for waitpid. 2024-07-16 12:48:14 +02:00
4lDO2 4c20a9abb2 Enable syscall restart in futex_wait. 2024-07-16 11:55:06 +02:00
Jeremy Soller aed9fe7c66 Merge branch 'random-bool-modfix' into 'master'
Fix missing modulo in random_bool()

See merge request redox-os/relibc!482
2024-07-16 09:16:21 +00:00
Peter Limkilde Svendsen e5be15cc9b Fix missing modulo in random_bool() 2024-07-16 09:16:20 +00:00
4lDO2 bcce7e18db Implement SA_RESTART for read and write. 2024-07-15 23:24:41 +02:00
Jeremy Soller 85faefc597 Merge branch 'safer-rand48' into 'master'
Refactor rand48 functions with less unsafe

See merge request redox-os/relibc!473
2024-07-15 17:44:57 +00:00
Peter Limkilde Svendsen dbcf8049fc Refactor rand48 functions with less unsafe 2024-07-15 17:44:56 +00:00
Jeremy Soller 3cd21243ec Merge branch 'usignal' of gitlab.redox-os.org:4lDO2/relibc 2024-07-15 09:38:36 -06:00
4lDO2 e97f26c763 Use crates.io syscall dependency. 2024-07-15 17:31:12 +02:00
4lDO2 67976e759e Switch to upstream syscall dependency. 2024-07-15 17:19:42 +02:00
Jeremy Soller 78eda3f7ed Merge branch 'patch-1' into 'master'
Add instructions to test relibc against a recipe

See merge request redox-os/relibc!471
2024-07-15 14:48:05 +00:00
4lDO2 315ba323a4 Move sigchld test from EXPECT_NAMES to NAMES. 2024-07-09 15:42:33 +02:00
4lDO2 44db740260 Update dependencies. 2024-07-09 15:39:58 +02:00
4lDO2 77c9e53ee2 Fix sigchld test. 2024-07-09 15:39:57 +02:00
4lDO2 284f51b47e Fix struct sigaction defintion. 2024-07-09 15:39:57 +02:00
4lDO2 cf390d6a52 Add SIGCHLD test. 2024-07-09 15:39:53 +02:00
4lDO2 b64b0ebe18 Handle kill and killpg EINTR. 2024-07-09 15:00:58 +02:00
4lDO2 78247c8525 Pass signal correctly to SYS_KILL. 2024-07-09 15:00:58 +02:00
4lDO2 4ee878c474 Always use fxsave, store 'YMM_UPPER' manually. 2024-07-09 15:00:58 +02:00
4lDO2 2fe1d614f8 Fix aarch64 EINTR handler. 2024-07-09 15:00:58 +02:00
4lDO2 5916b94707 Fix aarch64 fork_ret. 2024-07-09 15:00:58 +02:00
4lDO2 618643b299 Work around aarch64 bootstrap crash. 2024-07-09 15:00:58 +02:00
4lDO2 5277f2f640 Fix typo in currently_pending. 2024-07-09 15:00:58 +02:00
4lDO2 c9d22e484b Write draft aarch64 trampoline that compiles. 2024-07-09 15:00:58 +02:00
4lDO2 8298417dee Implement sigpending on Redox. 2024-07-09 15:00:58 +02:00
4lDO2 c639fd37ba Implement sigaltstack. 2024-07-09 15:00:57 +02:00
4lDO2 6d5d0eb61e Set initial sigactions to SIG_DFL and correct bits. 2024-07-09 15:00:57 +02:00
4lDO2 6a3d247a90 Clear the signal bit in the handler. 2024-07-09 15:00:57 +02:00
4lDO2 a446ac1945 Fix (rare) stack corruption on x86_64. 2024-07-09 15:00:57 +02:00
4lDO2 c0e079132a AND rather than set sigmask inside signal. 2024-07-09 15:00:57 +02:00
4lDO2 126daaa186 Improve i686 trampoline and fix PIC. 2024-07-09 15:00:57 +02:00
4lDO2 5460ffc4c9 Jump to trampoline after SYS_{READ,WRITE} EINTR. 2024-07-09 15:00:57 +02:00
4lDO2 a166a1ebb2 For now, put ptr to pctl in TCB. 2024-07-09 15:00:57 +02:00
4lDO2 63509e75ce Use new signal ABI where 'actions' are in shmem. 2024-07-09 15:00:56 +02:00
4lDO2 71800d2b73 Fix spurious ign signal. 2024-07-09 15:00:56 +02:00
4lDO2 f28fe4a387 Use fetch_add instead of CAS when setting sigmask.
This makes sigprocmask, the way it is currently implemented, wait-free
(technically I think x86 only guarantees LOCK XADD is lock-free and
fair, but still).
2024-07-09 15:00:56 +02:00
4lDO2 39f45b0f67 Fix i686 trampoline. 2024-07-09 15:00:56 +02:00
4lDO2 5b8d53ddd3 Fix x86_64 trampoline. 2024-07-09 15:00:56 +02:00
4lDO2 cda5f18946 Change interrupt stack format, emulate atomicity. 2024-07-09 15:00:56 +02:00
4lDO2 9bb34901bf Adjust trampolines, only ip and 'archdep' regs are saved. 2024-07-09 15:00:56 +02:00
4lDO2 568fc09277 Reset sighandler in fexec before switching addrsp. 2024-07-09 15:00:56 +02:00
4lDO2 442954915b Fix x86_64 spurious signal jump condition. 2024-07-09 15:00:56 +02:00
4lDO2 2d66993b3f Adapt to now-inverted signal mask (allowset). 2024-07-09 15:00:55 +02:00
4lDO2 157d9fb2ba Set sigmask to sa_mask inside handler. 2024-07-09 15:00:55 +02:00
4lDO2 630bf2ae3d Fix popf operand size. 2024-07-09 15:00:55 +02:00
4lDO2 590ad70a9f Fix trampoline for i686. Ctrl-C now works. 2024-07-09 15:00:55 +02:00
4lDO2 c93b43b4b7 Build on i686, remove unnecessary #[no_mangle]. 2024-07-09 15:00:55 +02:00
4lDO2 18b5c73b61 Compile on the other arches. 2024-07-09 15:00:55 +02:00
4lDO2 f37bb3cb16 Fix sigaction test on Linux, and rustfmt. 2024-07-09 15:00:55 +02:00
4lDO2 0ea2b5d45f Fix compilation on Linux. 2024-07-09 15:00:55 +02:00
4lDO2 3db425fef6 Correctly find signal number and check action. 2024-07-09 15:00:54 +02:00
4lDO2 98a2a566d9 Almost succeed at repeatedly accepting signals. 2024-07-09 15:00:54 +02:00
4lDO2 d6588668e2 Fix pre-Rust part of trampoline!. 2024-07-09 15:00:54 +02:00
4lDO2 a1e1a159ae Initialize altstack properly. 2024-07-09 15:00:54 +02:00
4lDO2 a265c8b7a0 Reimplement libredox sig{procmask,action}. 2024-07-09 15:00:54 +02:00
4lDO2 b6eb7dcf0f Impl From<Errno> for syscall::Error. 2024-07-09 15:00:54 +02:00
4lDO2 c217745524 Mark sig{add,del}set unsafe, rather than unsound. 2024-07-09 15:00:54 +02:00
4lDO2 8f66730d37 Set child sighandler *after* cloning address space. 2024-07-09 15:00:54 +02:00
4lDO2 20284eb2b2 Fix rlct_clone. 2024-07-09 15:00:54 +02:00
4lDO2 42c24dd755 Successfully run more userspace. 2024-07-09 15:00:53 +02:00
4lDO2 7fcf5a1aca Ignore special bits when selecting signal. 2024-07-09 15:00:53 +02:00
4lDO2 a2ab86d253 Implement signal selection in asm, for SA_ONSTACK. 2024-07-09 15:00:53 +02:00
4lDO2 d45adade1d Remove obsolete proc usage, now reaches init. 2024-07-09 15:00:53 +02:00
4lDO2 4e93f68324 Implement hack to ensure TCB exists in bootstrap. 2024-07-09 15:00:53 +02:00
4lDO2 a60710c597 Add missing signal arch offsets. 2024-07-09 15:00:53 +02:00
4lDO2 58d1153536 Split part of TCB into generic-rt 2024-07-09 15:00:53 +02:00
4lDO2 736a445af6 Use new proc control struct too. 2024-07-09 15:00:53 +02:00
4lDO2 edfe46c60b Write x86-64 signal trampoline asm stub. 2024-07-09 15:00:52 +02:00
4lDO2 5177ca3926 Remove memoffset dependency. 2024-07-09 15:00:52 +02:00
4lDO2 7d562920c2 Add sigaction boilerplate. 2024-07-09 15:00:52 +02:00
4lDO2 98ac085c5d Add sigprocmask stub to rt. 2024-07-09 15:00:52 +02:00
4lDO2 e1d3bf475a Increase SIGRTMIN to 35. 2024-07-09 15:00:52 +02:00
4lDO2 53ed7aae59 Move rlct_clone, sigprocmask, sigaction, to rt. 2024-07-09 15:00:52 +02:00
4lDO2 0440df142a Patch redox-syscall to fork. 2024-07-09 15:00:52 +02:00
4lDO2 4eb20628f3 Move some of signal config to redox-rt. 2024-07-09 15:00:52 +02:00
4lDO2 a800693266 Refactor: move redox-exec into redox-rt::proc. 2024-07-09 15:00:52 +02:00
Jeremy Soller e6f94291be Merge branch 'derick/fixes' into 'master'
Four distinct fixes for significant incorrectness bugs, as three small commits

See merge request redox-os/relibc!481
2024-07-09 12:57:23 +00:00
Derick Eddington 572f211be0 Fix getgrgid_r. 2024-07-06 22:47:55 -07:00
Derick Eddington 7c81de68b8 Fix header::grp::parse_grp. 2024-07-06 22:47:55 -07: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
Jeremy Soller 90af01986c Merge branch 'improve-instructions' into 'master'
Improve the testing instructions on the README

See merge request redox-os/relibc!477
2024-06-24 16:58:53 +00:00
Ribbon 482d094614 Improve the testing instructions on the README 2024-06-24 16:35:57 +00:00
Jeremy Soller 6044734a7c Merge branch 'document-tests' into 'master'
Document the test instructions and improve the title

See merge request redox-os/relibc!476
2024-06-23 23:48:30 +00:00
Ribbon d3d3dbab86 Document the test instructions and improve the title 2024-06-23 18:24:34 +00:00
Jeremy Soller 01bfb658db Merge branch 'schemev2plus' into 'master'
Implement pread and pwrite using the syscalls.

See merge request redox-os/relibc!475
2024-06-14 12:31:07 +00:00
4lDO2 4c11b607de Implement pread and pwrite using the syscalls. 2024-06-14 14:10:47 +02:00
Jeremy Soller ac08f016cd Merge branch 'ld_so_cleanup' into 'master'
Cleanup ld_so organization and move pthread_t into TCB

See merge request redox-os/relibc!474
2024-06-10 12:21:23 +00:00
4lDO2 6e86e64fdf Move pthread into TCB. 2024-06-08 11:36:22 +02:00
4lDO2 326c8a6231 Split shared ld_so code and actual ld_so stubs. 2024-06-08 11:36:06 +02:00
Jeremy Soller 73952b69ed Update to new nightly 2024-05-11 14:00:59 -06:00
Jeremy Soller b7a4527ab8 Do not print on unsupported epoll flags 2024-05-06 15:24:56 -06:00
Jeremy Soller 8ab61e3d9a Convert syscall events to EPOLL events 2024-05-06 15:16:31 -06:00
Jeremy Soller 0f5e6a5649 Correct EPOLL constants 2024-05-06 15:00:50 -06:00
Jeremy Soller 59e7d2d70f Return 0 when epoll_ctl is successful 2024-05-06 14:29:21 -06:00
Jeremy Soller 371cde006b Format 2024-05-06 14:28:42 -06:00
Wildan Mubarok c2c7965bdd Apply README suggestions 2024-04-16 15:20:23 +00:00
Wildan M 22cf77093b Add instructions to test relibc against a recipe 2024-04-16 16:32:35 +07:00
Jeremy Soller 373c2e30a2 Merge branch 'fix_sync' into 'master'
Various futex fixes

See merge request redox-os/relibc!470
2024-04-05 20:31:07 +00:00
Jacob Lorentzon 1fba2ef10a Various futex fixes 2024-04-05 20:31:06 +00:00
Jeremy Soller 7cf68bc8ee Merge branch 'fix_fpath' into 'master'
Fix double slashes in fpath.

See merge request redox-os/relibc!469
2024-04-02 13:25:53 +00:00
4lDO2 c53c38bcae Fix double slashes in fpath. 2024-04-02 15:10:03 +02:00
Jeremy Soller 84c0f5023e Merge branch 'unistd-constants' into 'master'
Add tests for unistd.h constants

See merge request redox-os/relibc!467
2024-03-27 12:21:14 +00:00
Peter Limkilde Svendsen a91a4082c4 Add tests for unistd.h constants 2024-03-27 12:21:14 +00:00
Jeremy Soller 612910ee80 Merge branch 'fork_clone_sync' into 'master'
Protect fork() and clone() behind a rwlock.

See merge request redox-os/relibc!468
2024-03-27 12:20:27 +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
Jeremy Soller e03700421c Merge branch 'rwlock' into 'master'
Fix pthread rwlock code

See merge request redox-os/relibc!466
2024-03-26 15:46:32 +00:00
Jacob Lorentzon f7ac690c45 Fix pthread rwlock code 2024-03-26 15:46:32 +00:00
Jeremy Soller 071b10c641 Merge branch 'fix_thread_spawn' into 'master'
Don't map thread stacks as MAP_SHARED (lol), fix i686 signal trampoline

See merge request redox-os/relibc!465
2024-03-25 12:26:12 +00:00
4lDO2 6e1a0668aa Fix i686 signal trampoline asm. 2024-03-25 11:26:59 +01:00
4lDO2 b4799fdc28 Don't map thread stacks as MAP_SHARED, lol.
MAP_SHARED means it will continue to be shared after forks, which
obviously isn't the correct behavior. `acid thread` doesn't segfault
infinitely, anymore.
2024-03-25 11:25:37 +01:00
4lDO2 df91c67cf0 Implement redox_mkfs_v1. 2024-03-18 17:18:42 +01:00
Jeremy Soller 70abce96c1 Merge branch 'event_abi' into 'master'
Implement the event queue ABI.

See merge request redox-os/relibc!454
2024-03-18 12:34:48 +00:00
4lDO2 76154f555a Update redox_event. 2024-03-17 22:13:26 +01:00
4lDO2 53f7b640bd Update redox_syscall. 2024-03-17 18:13:05 +01:00
4lDO2 f2c53e03ee Implement the event queue ABI. 2024-03-17 18:02:07 +01:00
Jeremy Soller 6ff5691d18 Merge branch 'signals' into 'master'
Implement new low-level signal trampoline

See merge request redox-os/relibc!460
2024-03-17 16:58:42 +00:00
Jacob Lorentzon e0b640d530 Implement new low-level signal trampoline 2024-03-17 16:58:42 +00:00
Jeremy Soller e7ebd7c381 Merge branch 'fix_arm64_thread_spawn' into 'master'
Fix thread spawning on aarch64

See merge request redox-os/relibc!463
2024-03-17 16:32:16 +00:00
bjorn3 7ac379a7a1 Fix thread spawning on aarch64
* Correctly align the stack
* Fix argument order of the ldp instructions
* Remove unnecessary ldr x5 instruction
2024-03-17 17:09:41 +01:00
Jeremy Soller 65589f9c93 Merge branch 'sys-resource-constants' into 'master'
Add tests for further sys/resource.h constants

See merge request redox-os/relibc!462
2024-03-12 20:40:56 +00:00
Peter Limkilde Svendsen d189b05f11 Add tests for further sys/resource.h constants 2024-03-12 20:40:55 +00:00
Jeremy Soller cbd42b229b Merge branch 'relibc_ioctl_siocatmark' into 'master'
Add stub for SIOCATMARK command of ioctl.

See merge request redox-os/relibc!461
2024-03-10 15:12:14 +00:00
bpisch a9db7af754 Add stub for SIOCATMARK command of ioctl. 2024-03-09 08:56:37 +01:00
Jeremy Soller dc9f3e207f Merge branch 'fix_posix_prio_process' into 'master'
Fix posix prio process (same as MR458 with fixed commits)

See merge request redox-os/relibc!459
2024-03-04 13:41:43 +00:00
Bendeguz Pisch 2284bc4af5 Fix posix prio process (same as MR458 with fixed commits) 2024-03-04 13:41:43 +00:00
Jeremy Soller 4d2d062f07 Fix build 2024-03-01 08:01:15 -07:00
Jeremy Soller d3aac3585c Merge branch 'errno-naming' into 'master'
Use standard casing and mangling for internal errno

See merge request redox-os/relibc!457
2024-03-01 00:25:42 +00:00
Peter Limkilde Svendsen a7137512fa Use standard casing and mangling for internal errno 2024-03-01 00:25:42 +00:00
Jeremy Soller 4f8d16a3b9 Merge branch 'crypt' into 'master'
Add Crypt functions

See merge request redox-os/relibc!453
2024-03-01 00:23:42 +00:00
Darley Barreto 55dc2019f2 Add Crypt functions 2024-03-01 00:23:42 +00:00
Jeremy Soller 7074432184 Merge branch 'errno-cell' into 'master'
Use Cell representation for errno

See merge request redox-os/relibc!456
2024-02-29 14:07:40 +00:00
Peter Limkilde Svendsen 9093f6bc47 Use Cell representation for errno 2024-02-29 14:07:40 +00:00
Jeremy Soller 9ef3374c30 Merge branch 'getpagesize-panic' into 'master'
Panic when getpagesize() cannot succeed as specified

See merge request redox-os/relibc!455
2024-02-19 00:19:03 +00:00
Peter Limkilde Svendsen aea9e2b432 Panic when getpagesize() cannot succeed as specified 2024-02-19 00:19:03 +00:00
Jeremy Soller 534e7ef80c Make redox fpath only return new format 2024-02-12 15:09:13 -07:00
Jeremy Soller 8313fc1c77 Fix array pointer mismatch in parse_grp 2024-02-10 14:27:50 -07:00
Jeremy Soller 2058c6693c Use TEST_RUNNER for make run in tests folder 2024-02-08 15:36:33 -07:00
Jeremy Soller a7b2294b62 Add more networking constants 2024-02-03 13:17:40 -07:00
Jeremy Soller 5b78afe5be Do not set constants UNLOCKED and LOCKED 2024-02-02 15:40:41 -07:00
Jeremy Soller f708800898 Add struct user for linger 2024-02-02 15:35:08 -07:00
Jeremy Soller 47ac9e2d0b Add more TCP socket options 2024-02-02 15:31:08 -07:00
Jeremy Soller 9b2b9e6c26 Add struct linger 2024-02-02 15:30:51 -07:00
Jeremy Soller 5d4f1a3105 Merge branch 'update_rust_toolchain' into 'master'
Update rust-toolchain.toml

See merge request redox-os/relibc!452
2024-01-26 17:28:19 +00:00
bjorn3 619c5f3eb8 Update rust-toolchain.toml
This matches the version actually used by Redox OS. It also supports the
sparse index, which prevents having to clone the crates.io registry git
repo when rust-analyzer tries to run cargo metadata on relibc.
2024-01-25 15:24:50 +01:00
Jeremy Soller af7441e834 Implement grantpt as no-op 2024-01-18 13:26:14 -07:00
Jeremy Soller ab3ececc9a Merge branch 'scheme-fmt' into 'master'
Scheme fmt

See merge request redox-os/relibc!451
2024-01-18 19:58:28 +00:00
Jeremy Soller 7eefdaf45b Use redox-path external crate 2024-01-18 11:07:51 -07:00
Jeremy Soller 02ac8a6363 Move redox path handling to redox-path crate 2024-01-17 15:51:11 -07:00
Jeremy Soller ffe152cc51 Fall back to the file scheme if no scheme provided 2024-01-17 15:09:20 -07:00
Jeremy Soller 83e4095e42 Merge branch 'ptys' into 'master'
Add forkpty, ptsname and posix_openpt

See merge request redox-os/relibc!450
2024-01-17 03:05:50 +00:00
Darley Barreto 9d8094baee Add forkpty, ptsname and posix_openpt 2024-01-17 03:05:50 +00:00
Jeremy Soller a2321e4b2b Add initgroups 2024-01-16 20:00:57 -07:00
Jeremy Soller d4b0e172f0 Add recvmsg (stub on redox) 2024-01-16 19:47:39 -07:00
Jeremy Soller faadbc3d70 Merge branch 'remove-ralloc' into 'master'
Remove ralloc

See merge request redox-os/relibc!449
2024-01-13 17:01:58 +00:00
Darley Barreto 298340abf9 Remove ralloc 2024-01-13 10:57:02 -03:00
Jeremy Soller 88da47a690 Fix incorrect reference to iovec in sys/socket.h 2024-01-12 15:44:02 -07:00
Jeremy Soller 52612784b6 Add sendmsg stub 2024-01-12 15:36:01 -07:00
Jeremy Soller eb3b93d14a Define strtold in C until Rust and cbindgen can use f128 2024-01-12 12:21:20 -07:00
Jeremy Soller 17ac6ef039 Remove inline from strtold 2024-01-12 12:05:47 -07:00
Jeremy Soller 225655b711 Do not mark strtold as static 2024-01-12 11:53:47 -07:00
Jeremy Soller b8ee20cb66 Remove duplicate wprintf definitions 2024-01-12 11:29:33 -07:00
Jeremy Soller a8f9f64274 Fix stack_chk_guard size on 32-bit 2024-01-11 09:41:17 -07:00
Jeremy Soller 578a7dade3 Merge branch 'libredox_strerror' into 'master'
Add a strerror_r-like libredox API.

See merge request redox-os/relibc!448
2024-01-11 16:00:09 +00:00
4lDO2 375e0c78bf Add a strerror_r-like libredox API. 2024-01-11 16:12:58 +01:00
Jeremy Soller 40004887db Merge branch 'no_c' into 'master'
Make relibc (except libm) pure Rust

See merge request redox-os/relibc!440
2024-01-11 13:08:06 +00:00
4lDO2 5630b6e0df Make relibc (except libm) pure Rust 2024-01-11 13:08:06 +00:00
Jeremy Soller 49ee2f0593 Stub some terminal ioctls on Redox 2024-01-08 20:35:17 -07:00
Jeremy Soller 107fcfeb7e Implement getsid and setsid for Redox 2024-01-08 14:43:35 -07:00
Jeremy Soller f4511a487f Clean up rustfmt options, and format 2024-01-08 14:10:30 -07:00
Jeremy Soller 1258d296d1 Merge branch 'fix_read_to_end' into 'master'
Add back Drop impl for Guard to fix Read::read_to_end

See merge request redox-os/relibc!446
2024-01-08 05:00:02 +00:00
bjorn3 eff6700ff4 Add back Drop impl for Guard to fix Read::read_to_end 2024-01-07 15:30:53 +01:00
Jeremy Soller b4275813f8 Merge branch 'canonicalize-libcscheme' into 'master'
fix canonicalize of libc:

See merge request redox-os/relibc!445
2024-01-05 19:28:06 +00:00
Ron Williams 0340ba3b36 fix canonicalize of libc: 2024-01-05 05:26:51 -08:00
Jeremy Soller 2a40638ec3 Fix assert definition 2024-01-03 13:02:51 -07:00
Jeremy Soller 6b88ad6271 Merge branch 'inline-core-io' into 'master'
Refactor: inline `core_io`

Closes #175

See merge request redox-os/relibc!441
2024-01-03 19:19:58 +00:00
Jeremy Soller 92b56f3f92 Format 2024-01-03 11:46:29 -07:00
Jeremy Soller 99f097cf90 Implement openpty and login_tty 2024-01-03 11:46:18 -07:00
Jeremy Soller 70dc59210d Add TIOCSCTTY, currenty unimplemented 2024-01-03 10:10:07 -07:00
Jeremy Soller b1383a960d Merge branch 'ae/impl-mknod' into 'master'
Implement mknod and mknodat

See merge request redox-os/relibc!442
2024-01-03 16:43:28 +00:00
Abdullah Emad 0caf011122 Implement mknod and mknodat 2024-01-03 16:43:28 +00:00
Jeremy Soller 7cddea96c8 Merge branch 'libc-scheme' into 'master'
add libc scheme for /dev/tty etc.

See merge request redox-os/relibc!443
2024-01-03 16:40:42 +00:00
Ron Williams b54cadb88f add libc scheme for /dev/tty etc. 2024-01-02 02:20:45 -08:00
Arthur Paulino d4eddbf42e Refactor: inline core_io
* Extract the minimal set of definitions from `core_io` to `relibc` itself

* Remove dependency on `core_io`
2023-12-24 17:06:27 -03:00
Jeremy Soller 0f9aca12dd Add missing stdarg header to sys_mman 2023-12-12 09:21:13 -07:00
Jeremy Soller e2e401db41 Merge branch 'dlmalloc' into 'master'
Replace C dlmalloc

See merge request redox-os/relibc!430
2023-12-12 15:04:17 +00:00
Darley Barreto ce1e31d567 Replace C dlmalloc 2023-12-12 15:04:17 +00:00
Jeremy Soller 780e6ff81c Merge branch 'fix_pthread_cancel' into 'master'
Fix thread cleanup after main exits.

See merge request redox-os/relibc!439
2023-12-11 16:09:14 +00:00
4lDO2 b2385367cb Fix CI 2023-12-09 13:29:36 +01:00
4lDO2 3a54aa778d Fix thread cleanup after main exits. 2023-12-09 13:24:31 +01:00
Jeremy Soller 50c5ce2fb4 Merge branch 'fix_utimes_null' into 'master'
Fixed utimes segfault when given nullptr

See merge request redox-os/relibc!438
2023-12-07 15:39:38 +00:00
Martin Welgemoed 02780057f0 Fixed utimes segfault when given nullptr 2023-12-07 15:39:38 +00:00
Jeremy Soller 99862e27b3 Merge branch 'cfmakeraw_fix' into 'master'
cfmakeraw: missing disable of ICRNL

See merge request redox-os/relibc!437
2023-12-07 15:38:15 +00:00
Jeremy Soller 5d65474fe4 Merge branch 'repository-layout' into 'master'
Improve the README

See merge request redox-os/relibc!436
2023-12-07 15:35:13 +00:00
Ribbon aff816f07d Improve the README 2023-12-07 15:35:13 +00:00
Ron Williams 41faf1bd2e cfmakeraw: missing disable of ICRNL 2023-11-24 11:53:39 -08:00
Jeremy Soller 84de1e8234 Merge branch 'strict_tests' into 'master'
Enforce -Wall -Wextra -Werror in tests

See merge request redox-os/relibc!434
2023-11-15 17:21:56 +00:00
4lDO2 5f929ed51e Enable -Wextra in tests. 2023-11-12 12:07:49 +01:00
4lDO2 c76a12347f Enforce -Werror in tests. 2023-11-12 11:45:15 +01:00
Jeremy Soller 48f7ca7fe0 Merge branch 'more_libredox' into 'master'
Impl libredox fstat{,vfs}, futimens, clock_gettime.

See merge request redox-os/relibc!433
2023-11-05 12:52:57 +00:00
4lDO2 7f29349dbc Impl libredox fstat{,vfs}, futimens, clock_gettime. 2023-11-05 13:35:37 +01:00
Jeremy Soller 79ef751d7d Merge branch 'cstr' into 'master'
Switch to a lightweight CStr wrapper

See merge request redox-os/relibc!431
2023-11-04 18:29:38 +00:00
4lDO2 75d1c67ca2 Switch to a lightweight CStr wrapper 2023-11-04 18:29:38 +00:00
4lDO2 b5a4dc65e5 Implement redox_{mmap,munmap}_v1. 2023-11-04 16:41:06 +01:00
Jeremy Soller 27c1349b79 Merge branch 'seperator' into 'master'
Correctly parse `/etc/passwd` and `/etc/group` on Redox

See merge request redox-os/relibc!432
2023-11-02 02:39:37 +00:00
Ian Douglas Scott f195c8c126 Correctly parse /etc/passwd and /etc/group on Redox
Redox uses `;` as separators in these files, and doesn't have the
"password" flag in `/etc/group`. With these, it seems to parse fine.
2023-11-01 19:31:46 -07:00
4lDO2 928d609a71 Fix posix-regex version. 2023-10-27 11:51:27 +02:00
Jeremy Soller d248ab248f Merge branch 'use_libc_crate_correctly' into 'master'
Use libc crate correctly, and future-proof

See merge request redox-os/relibc!429
2023-10-26 22:17:19 +00:00
4lDO2 ae46e37ca7 Run rustfmt 2023-10-26 15:51:04 +02:00
4lDO2 3c1107f21a Future-proof against incorrect libc crate usage. 2023-10-26 15:37:15 +02:00
4lDO2 b6b1ea5488 Fix incorrect libredox libc crate usage. 2023-10-26 15:35:15 +02:00
4lDO2 7fce3c5734 Fix grp.h soundness and incorrect ::libc usage. 2023-10-26 15:34:55 +02:00
Jeremy Soller 4532eb166c Merge branch 'simple-wcsrtombs' into 'master'
Simplify wcsrtombs and make test follow standard

See merge request redox-os/relibc!428
2023-10-25 12:33:42 +00:00
Darley Barreto f7d151e287 Simplify wcsrtombs and make test follow standard 2023-10-25 09:13:41 -03:00
Jeremy Soller b0624b4178 Merge branch 'tests/getline' into 'master'
getline, getdelim: fix issues, extend tests

See merge request redox-os/relibc!418
2023-10-20 14:34:06 +00:00
Florian Meißner b65cd4e511 getline, getdelim: fix issues, extend tests 2023-10-20 14:34:06 +00:00
Jeremy Soller 0cfddca06f Merge branch 'sendfd' into 'master'
Make escalated communication pathless using sendfd.

See merge request redox-os/relibc!424
2023-10-19 16:31:37 +00:00
4lDO2 7eb37eb340 Update syscall 2023-10-19 17:17:18 +02:00
4lDO2 966c59ca0c Make escalated communication pathless using sendfd. 2023-10-19 17:17:18 +02:00
Jeremy Soller 76242fc7bc Merge branch 'fix/ungetwc' into 'master'
Fix ungetwc for multi byte chars

See merge request redox-os/relibc!425
2023-10-19 14:58:57 +00:00
Darley Barreto 3d2dd71b8b Fix ungetwc for multi byte chars 2023-10-19 14:58:57 +00:00
Jeremy Soller 8f085eabbe Merge branch 'wcslen-related' into 'master'
Add wcpcpy, wcpncpy, wcsdup, wcsnlen, wcsnrtombs

See merge request redox-os/relibc!426
2023-10-19 14:58:37 +00:00
Darley Barreto 05992b8451 Add wcpcpy, wcpncpy, wcsdup, wcsnlen, wcsnrtombs 2023-10-19 14:58:37 +00:00
Jeremy Soller 15f2c050b7 Merge branch 'add_utime_consts' into 'master'
Add UTIME_OMIT and UTIME_NOW

See merge request redox-os/relibc!427
2023-10-19 14:57:58 +00:00
Henri Hannetel 330b50d734 Add UTIME_OMIT and UTIME_NOW 2023-10-19 14:57:58 +00:00
Jeremy Soller 2c7ec0dc8e Merge branch 'fgetwc' into 'master'
Make fgetwc real multibyte

See merge request redox-os/relibc!423
2023-10-14 00:29:42 +00:00
Darley Barreto db9bbaeb48 Make fgetwc real multibyte 2023-10-14 00:29:42 +00:00
4lDO2 16b5837d31 Fix Linux compilation error. 2023-10-12 20:10:40 +02:00
Jeremy Soller 9c6035a754 Merge branch 'libredox' into 'master'
Implement (not yet the entire) libredox ABI

See merge request redox-os/relibc!419
2023-10-10 18:56:26 +00:00
Jeremy Soller 94aa061dde Merge branch 'fix-toolchain-build' into 'master'
Use a .flag() with an if statement for mno-outline-atomics

See merge request redox-os/relibc!422
2023-10-08 12:50:01 +00:00
Enver Balalic 1c9de673dc Use a .flag() with an if statement for mno-outline-atomics 2023-10-08 12:50:00 +00:00
4lDO2 920bafb130 Impl libredox getpid, kill, sigprocmask, sigaction. 2023-10-08 12:21:54 +02:00
Jeremy Soller 515219be2d Merge branch 'fix-x86-toolchain-build' into 'master'
Use flag_if_supported instead of flag for mno-outline-atomics

See merge request redox-os/relibc!421
2023-10-02 12:22:12 +00:00
Enver Balalic 6939a6e079 Use flag_if_supported instead of flag for mno-outline-atomics
The x86 build fails due to unknown flag when using just .flag()
2023-10-02 13:42:15 +02:00
Jeremy Soller a63fb22a36 Merge branch 'fix-aarch-toolchain-build' into 'master'
Add -mno-outline-atomics when building C code

See merge request redox-os/relibc!420
2023-10-01 20:30:49 +00:00
Enver Balalic 239674c76a Add -mno-outline-atomics when building C code
Fixes building the aarch64 toolchain. Disables emitting
`__aarch64_swp4_sync` and similar functions.
2023-10-01 20:32:42 +02:00
4lDO2 a1530dd10f Implement libredox ABI 2023-10-01 19:01:44 +02:00
Jeremy Soller c55649452a Define struct ucred 2023-09-13 11:33:55 -06:00
Jeremy Soller 635248cdff Define _SC_GETGR_R_SIZE_MAX 2023-09-13 11:26:44 -06:00
Jeremy Soller 6f46f87ddb Print when using unimplemented redox stubs 2023-09-13 11:17:25 -06:00
Jeremy Soller afdc26f9cc Add getgroups/setgroups (stub on redox) 2023-09-13 11:16:59 -06:00
Jeremy Soller 13f22d72c6 Merge branch 'rw_van_230911' into 'master'
epoll: correct error when skipping time events

See merge request redox-os/relibc!416
2023-09-11 16:29:51 +00:00
Jeremy Soller d4180de8ff Rename __rust_no_alloc_shim_is_unstable 2023-09-11 09:54:15 -06:00
Ron Williams ba43320112 epoll: correct error when skipping time events 2023-09-11 08:43:00 -07:00
Jeremy Soller c75a6e64e6 Rename __rust_alloc_error_handler functions 2023-09-11 09:21:01 -06:00
Jeremy Soller b9e5b22f7d Always return C locale from setlocale 2023-09-09 18:59:25 -06:00
Jeremy Soller ab7e3da661 strsignal must return mutable char pointer 2023-09-09 09:22:26 -06:00
Jeremy Soller 57fae4ccfc Include signal.h from sys/select.h 2023-09-09 08:58:10 -06:00
Jeremy Soller a9042abdb9 Rename both __rg and __rust allocator symbols 2023-09-07 15:42:10 -06:00
Jeremy Soller 134b89b271 Update core_io 2023-09-07 14:46:07 -06:00
Jeremy Soller 3359d4a040 Merge branch 'master' into 'master'
Groups

See merge request redox-os/relibc!407
2023-08-21 12:05:16 +00:00
Jacob Schneider 2f887ae434 Groups 2023-08-21 12:05:16 +00:00
Jeremy Soller 3327bc820d Merge branch 'better_proc_apis' into 'master'
Use improved `proc:` APIs from demand paging

See merge request redox-os/relibc!415
2023-08-07 15:34:47 +00:00
4lDO2 068ce3df7c Use redox_syscall git dependency. 2023-08-02 15:14:05 +02:00
4lDO2 084d6b0344 Some MAP_FIXED optimizations. 2023-08-01 13:27:34 +02:00
4lDO2 5aa3ae25b4 Reimplement "clone grant using fmap". 2023-08-01 13:27:33 +02:00
4lDO2 67a0d7aebb Remove redox-exec debug log. 2023-08-01 13:26:22 +02:00
4lDO2 76c948b562 Succeed at loading init! 2023-08-01 13:26:21 +02:00
4lDO2 29d265c11c mmap RAII guard. 2023-08-01 13:26:21 +02:00
4lDO2 d164d84c7f Fix address+size calculation in redox-exec. 2023-08-01 13:26:21 +02:00
4lDO2 01d2f4f036 WIP: Use fmap in program loader. 2023-08-01 13:26:18 +02:00
Jeremy Soller 98743997f5 Merge branch 'remove_redox_physmap_physunmap' into 'master'
Remove redox_phys{map,unmap}.

See merge request redox-os/relibc!414
2023-07-20 14:39:14 +00:00
4lDO2 b063533a8e Remove redox_phys{map,unmap}. 2023-07-20 16:34:04 +02:00
Jeremy Soller 884dce8ec3 Merge branch 'fix_aarch64_sp_align' into 'master'
aarch64: align sp in _start

See merge request redox-os/relibc!412
2023-07-07 13:53:17 +00:00
Ivan Tan 4cb564bc99 aarch64: align sp in _start 2023-07-07 18:58:42 +08:00
Jeremy Soller d006b95701 Merge branch 'fix_uio' into 'master'
Limit src len to dst len in uio::scatter().

See merge request redox-os/relibc!411
2023-07-05 11:32:02 +00:00
4lDO2 4973935b71 Limit src len to dst len in uio::scatter(). 2023-07-05 11:13:14 +02:00
Jeremy Soller c36c4a377a Merge branch 'pipe_scheme' into 'master'
Replace syscall::pipe2 with pipe scheme.

See merge request redox-os/relibc!410
2023-06-30 12:19:59 +00:00
4lDO2 9c6bc9ab0d Replace syscall::pipe2 with pipe scheme. 2023-06-27 16:32:50 +02:00
Jeremy Soller 6d8241e266 Merge branch 'rw_van_230625' into 'master'
epoll: check for zero or negative size argument

See merge request redox-os/relibc!409
2023-06-27 13:35:43 +00:00
Ron Williams 92d1d68024 remove Cargo.lock 2023-06-26 19:17:24 -07:00
Ron Williams 67213ef41a epoll: add check for zero length plus tests 2023-06-26 13:53:43 -07:00
Jeremy Soller 825e5c773a Use status instead of res to determine stopped status in redox waitpid implementation 2023-06-24 19:50:44 -06:00
Jeremy Soller 33d0d670e5 Fix size of event: read in redox epoll implementation 2023-06-24 19:50:20 -06:00
Jeremy Soller 1ef7954077 Merge branch 'aarch64-stuff' into 'master'
Fix misaligned stack pointer on aarch64

See merge request redox-os/relibc!408
2023-06-13 11:34:49 +00:00
uuuvn 41c1f46523 Fix misaligned stack pointer on aarch64 2023-06-13 09:49:06 +00:00
Jeremy Soller 3997cd9551 Format changes to src/platform/redox/clone.rs 2023-06-11 08:10:50 -06:00
Jeremy Soller 3cbaff12fd Merge branch 'rw_van_230610' into 'master'
change winsize to struct winsize

See merge request redox-os/relibc!406
2023-06-10 20:32:55 +00:00
Ron Williams 53abd37bdc change winsize to struct winsize 2023-06-10 13:26:41 -07:00
Jeremy Soller ec1fb94f6d Merge branch 'functions/strto_float/nan_inf' into 'master'
strtof(), strtod(): handle NaN and Infinity

See merge request redox-os/relibc!405
2023-06-05 23:04:26 +00:00
Florian Meißner b66df46f33 strtof(), strtod(): handle NaN and Infinity 2023-06-05 23:04:25 +00:00
Jeremy Soller fe02a5bd98 Merge branch 'tcsetwinsize' into 'master'
Adding tcsetwinsize

See merge request redox-os/relibc!404
2023-06-02 23:23:20 +00:00
Darley Barreto a237165bf8 Adding tcsetwinsize 2023-06-02 23:23:19 +00:00
Jeremy Soller 3023dbb3c0 Add qsort test 2023-06-01 08:11:27 -06:00
Jeremy Soller 7195c9a687 Remove half of prior workaround 2023-05-31 21:40:25 -06:00
Jeremy Soller ffc53bf23b Workaround hang on pthread_create 2023-05-31 20:39:58 -06:00
Jeremy Soller 3f13a228ed Merge branch 'fix-warnings' into 'master'
Fix warnings

See merge request redox-os/relibc!349
2023-05-30 21:24:58 +00:00
Noa df6f4678e8 Fix warnings 2023-05-30 13:46:17 -05:00
Jeremy Soller acbe323656 Merge branch 'functions/system/return_shell_exists' into 'master'
system(): on command == NULL, return nonzero if shell exists

See merge request redox-os/relibc!403
2023-05-30 13:37:33 +00:00
Florian Meißner 14709b3d5c system(): on command == NULL, return nonzero if shell exists 2023-05-29 20:54:34 +02:00
Jeremy Soller 63b7b76ab3 Format 2023-05-22 10:01:18 -06:00
Jeremy Soller 54e2e84be8 Merge branch 'wcsto_' into 'master'
Adding some wcst* functions

See merge request redox-os/relibc!400
2023-05-22 16:01:04 +00:00
Darley Barreto 9642d2ab02 Adding some wcst* functions 2023-05-22 16:01:04 +00:00
Jeremy Soller 127f34a244 Merge branch 'rustfmt' into 'master'
Rustfmt

See merge request redox-os/relibc!398
2023-05-17 13:45:41 +00:00
4lDO2 cdd0f67b23 Rustfmt. 2023-05-17 15:28:10 +02:00
Jeremy Soller 7251fc7c47 Fix type error after fcntl redefinition 2023-05-17 07:24:19 -06:00
Jeremy Soller 7d9cd5ab88 Include bits/pthread.h in signal.h for pthread_t 2023-05-17 07:22:05 -06:00
Jeremy Soller ef6375cb09 Merge branch 'lockf_impl' into 'master'
lockf implementation proposal

See merge request redox-os/relibc!396
2023-05-17 11:56:49 +00:00
David Carlier bae8bb68df lockf implementation proposal 2023-05-16 23:40:40 +01:00
Jeremy Soller a768852bec Merge branch 'pthread_fixes' into 'master'
Fix sem_t definition and allow nullable pthread destructors

See merge request redox-os/relibc!395
2023-05-12 18:57:58 +00:00
4lDO2 89429f26c0 Follow POSIX by allowing NULL pthread_key_t dtors. 2023-05-12 18:09:22 +02:00
4lDO2 951e9dd1eb Define sem_t as typedef, not union. 2023-05-12 13:59:07 +02:00
Jeremy Soller c1376d01dc Implement pthread_kill 2023-05-11 21:00:21 -06:00
Jeremy Soller 2941e5b36a Add _POSIX_THREADS definition 2023-05-11 17:18:16 -06:00
4lDO2 9040c2a2a2 fix semaphores 2023-05-11 17:18:12 -06:00
Jeremy Soller 75cc16a559 Add empty libpthread.a 2023-05-11 14:16:51 -06:00
Jeremy Soller d6af37e977 Fix a missing cast to sigset_t 2023-05-11 12:44:19 -06:00
Jeremy Soller aa1e63d730 Update libc crate 2023-05-11 12:15:07 -06:00
Jeremy Soller a38e7aaa4b Update sigset_t to c_ulonglong 2023-05-11 12:13:10 -06:00
Jeremy Soller 24c4c10f52 Update libc 2023-05-11 12:09:08 -06:00
Jeremy Soller 66f1f32ac2 Pad RlctAttr for 32-bit systems 2023-05-11 12:06:53 -06:00
Jeremy Soller 64849c7d59 Fix types for 32-bit systems 2023-05-11 11:44:24 -06:00
Jeremy Soller e2fd33db40 Ensure wchar_t and wint_t definitions can coexist with GCC stddef.h 2023-05-11 11:26:55 -06:00
Jeremy Soller 51c93c4b39 Cleanup of wchar_t and wint_t definitions 2023-05-11 10:41:49 -06:00
Jeremy Soller 4266364183 Merge branch 'fix-tests' into 'master'
Fix tests

See merge request redox-os/relibc!394
2023-05-11 15:57:27 +00:00
Darley Barreto 511d99aa21 Fix tests 2023-05-11 15:57:27 +00:00
Jeremy Soller 848fde933b Merge branch 'remove_pthreads_emb' into 'master'
Replace pthreads-emb with a native implementation

See merge request redox-os/relibc!380
2023-05-11 13:56:11 +00:00
Jeremy Soller 34c11d6b76 Merge branch 'wprintf' into 'master'
wprintf

See merge request redox-os/relibc!352
2023-05-11 13:52:09 +00:00
Jeremy Soller 3473088510 Add expected wprintf output 2023-05-11 07:48:52 -06:00
Jeremy Soller 29c898dff0 Cargo format 2023-05-11 07:48:51 -06:00
Jeremy Soller e1ecdbd8a5 Implement vfwprintf 2023-05-11 07:48:49 -06:00
Jeremy Soller 410e897807 Fix double build when building sysroot 2023-05-11 07:48:23 -06:00
Jeremy Soller 98193b2eeb Add tests for wprintf 2023-05-11 07:48:23 -06:00
Jeremy Soller 5a5bd0c983 Add stubs for wprintf functions 2023-05-11 07:48:21 -06:00
Jeremy Soller db8ed860e9 Rerun build.rs if src/c changes 2023-05-11 07:47:33 -06:00
Jeremy Soller 63ea94c439 Merge branch 'sigwait_impl' into 'master'
signal adding sig(timed)wait implementations

See merge request redox-os/relibc!392
2023-05-10 12:49:38 +00:00
Jeremy Soller 69fbd110ef Merge branch 'wcsrtombs' into 'master'
Fixing wcsrtombs

See merge request redox-os/relibc!391
2023-05-10 12:48:33 +00:00
Darley Barreto 82eb083091 Fixing wcsrtombs 2023-05-10 12:48:33 +00:00
David Carlier a5cfc5d260 signal adding sig(timed)wait implementations 2023-05-09 20:33:03 +01:00
Jeremy Soller b25bbae2e0 Merge branch 'time__var_impl' into 'master'
clock_getres/clock_settime additions

See merge request redox-os/relibc!389
2023-05-09 14:24:25 +00:00
Jeremy Soller 4b238bf0d6 Merge branch 'ungetwc' into 'master'
Implementing ungetwc

See merge request redox-os/relibc!390
2023-05-09 14:23:25 +00:00
Darley Barreto c659bf11f9 Implementing ungetwc 2023-05-09 14:23:25 +00:00
David Carlier 2db85f9a3f clock_getres/clock_settime additions 2023-05-08 18:52:05 +01:00
Jeremy Soller 9661efe619 Merge branch 'wcsrtombs' into 'master'
Adding `wcsrtombs`.

Closes #166

See merge request redox-os/relibc!388
2023-05-08 12:39:54 +00:00
Darley Barreto 7155005be2 Adding wcsrtombs. 2023-05-08 12:39:53 +00:00
4lDO2 4169e99aa5 Stop requiring #![feature(atomic_mut_ptr)]. 2023-05-07 19:20:20 +02:00
4lDO2 a7708a9fc8 Fix AtomicPtr::as_ptr compiler version problem. 2023-05-07 11:17:04 +02:00
Jeremy Soller 26a8e316f1 Merge branch 'rw_van_230506' into 'master'
fix tzset cbindgen declarations

See merge request redox-os/relibc!386
2023-05-06 20:24:35 +00:00
Ron Williams 95e9162d22 change tzname to be mut 2023-05-06 13:20:30 -07:00
4lDO2 84e5b41200 Improve once test. 2023-05-06 17:02:55 +02:00
4lDO2 d8bc60e0fb Add more pthread tests. 2023-05-06 17:02:55 +02:00
4lDO2 90a789368e Add missing pthread_barrierattr_destroy. 2023-05-06 17:02:54 +02:00
4lDO2 fc01985410 WIP: fix errno and args output 2023-05-06 17:02:54 +02:00
4lDO2 ccfbdc0ae4 Run regular non-expect-based tests too. 2023-05-06 17:02:54 +02:00
4lDO2 5cd110a92b WIP: Add pthread tests. 2023-05-06 17:02:54 +02:00
4lDO2 74130f2c0e Update libc patch. 2023-05-06 17:02:54 +02:00
4lDO2 439b054486 Rustify pthread_rwlock_t. 2023-05-06 17:02:54 +02:00
4lDO2 e75381fd1a Patch libc via git recipe rather than local. 2023-05-06 17:02:54 +02:00
4lDO2 7e91f3f950 Add pthread tests. 2023-05-06 17:02:54 +02:00
4lDO2 d5781306d8 Support custom pthread stacks. 2023-05-06 17:02:54 +02:00
4lDO2 f60461cbf7 Use drop_in_place for pthread_attr_destroy. 2023-05-06 17:02:53 +02:00
4lDO2 b4600182b8 Also add SIGRTMAX. 2023-05-06 17:02:53 +02:00
4lDO2 c92ab239e3 Send RLCT_CANCEL and not SIGTERM when main exits. 2023-05-06 17:02:53 +02:00
4lDO2 79dfddf82c Switch to a boring mutex+condvar based barrier.
While the atomic version might be better, at the moment the priority is
to just to get RLCT working reliably.
2023-05-06 17:02:53 +02:00
4lDO2 4e5596698d Hack to support multiple compiler versions. 2023-05-06 17:02:53 +02:00
4lDO2 a3e1eed100 Wake all when unlocking internal mutexes.
This is because we don't yet count the number of waiting threads,
instead just flagging where or not there are any waiters.
2023-05-06 17:02:53 +02:00
4lDO2 7bcfa9cfd9 Fix Linux. 2023-05-06 17:02:53 +02:00
4lDO2 d1da867919 Make sighold unsafe. 2023-05-06 17:02:53 +02:00
4lDO2 e6df6ccfb3 Fix once and try to improve barrier. 2023-05-06 17:02:53 +02:00
4lDO2 8d9dd0df45 Improve pthread_cleanup_{push,pop}. 2023-05-06 17:02:53 +02:00
4lDO2 714e73112d Simplify Mutex implementation, for now. 2023-05-06 17:02:52 +02:00
4lDO2 fb3242badc New attempt at pthread_cleanup_{push,pop}. 2023-05-06 17:02:52 +02:00
4lDO2 dc8ee7b2f0 Adjust pthread_cond_t size. 2023-05-06 17:02:52 +02:00
4lDO2 beac24828d Use futex directly in waitval. 2023-05-06 17:02:52 +02:00
4lDO2 4faa315591 Use broadcast in Cond, for now. 2023-05-06 17:02:52 +02:00
4lDO2 492be53c2c Remove old pthreads-emb OS-specific code. 2023-05-06 17:02:52 +02:00
4lDO2 1d989d5cb6 Improve barrier.
Maybe it would be better to simply stick to a mutex and condvar, as
libstd does. Optimization is for later anyway.
2023-05-06 17:02:52 +02:00
4lDO2 4353ef33cd Fix pthread_join by not writing if retval == NULL. 2023-05-06 17:02:52 +02:00
4lDO2 14bfd2efd7 Redefine PTHREAD_BARRIER_SERIAL_THREAD. 2023-05-06 17:02:52 +02:00
4lDO2 9356098fb2 WIP: More complete pthread mutex implementation. 2023-05-06 17:02:52 +02:00
4lDO2 38f89cb4bb Improved barrier implementation. 2023-05-06 17:02:51 +02:00
4lDO2 cf34e2512e Move condvar impl to a mostly-safe module. 2023-05-06 17:02:51 +02:00
4lDO2 22ffed707f Fix embarrasing deadlock! 2023-05-06 17:02:51 +02:00
4lDO2 b455e2e374 Misc improvements, move barrier to safe module. 2023-05-06 17:02:51 +02:00
4lDO2 316203102a Implement pthread_cleanup_{push,pop}. 2023-05-06 17:02:51 +02:00
4lDO2 bd6cc20a75 Make pthread types opaque, and check against libc. 2023-05-06 17:02:51 +02:00
4lDO2 f0d8b6fd31 Specify the type in pthread initializers as well.
Otherwise it would be possible to do e.g.

`pthread_mutex_t mutex = PTHREAD_ONCE_INITIALIZER;```,
which would expand to
```pthread_mutex_t mutex = {0};```.
2023-05-06 17:02:51 +02:00
4lDO2 b9f19f4326 Get pcid to work using this pthread impl. 2023-05-06 17:02:51 +02:00
4lDO2 6a658bc33d Add needed functions for acid to link. 2023-05-06 17:02:51 +02:00
4lDO2 2593101ea7 Get it to compile 2023-05-06 17:02:50 +02:00
4lDO2 558d43082c WIP: Expand native pthreads implementation. 2023-05-06 17:02:50 +02:00
4lDO2 5b56d6305d Remove pthreads-emb, add custom sched.h 2023-05-06 17:02:50 +02:00
Jeremy Soller e09e2eb287 Merge branch 'fix_mspace_bug' into 'master'
Fix mspaces not being protected by locks.

See merge request redox-os/relibc!387
2023-05-06 13:15:56 +00:00
4lDO2 b5a620e5f1 Fix mspaces not being protected by locks. 2023-05-06 14:42:33 +02:00
Ron Williams c3f3da6958 fix tzset cbindgen declarations 2023-05-06 02:55:36 -07:00
Jeremy Soller 4c7d1a567b Merge branch 'termios_cfsetspeed_shortcut' into 'master'
termios adding cfsetspeed bsd extension which set both __c_ispeed/__c_ospeed fields

See merge request redox-os/relibc!385
2023-05-05 19:45:10 +00:00
David Carlier c2b00e8c6b termios adding cfsetspeed bsd extension which set both __c_ispeed/__c_ospeed fields 2023-05-05 16:56:23 +01:00
Jeremy Soller 6d6e068beb Merge branch 'rw_van_230504' into 'master'
Fix platform::errno = ... in signal.rs

See merge request redox-os/relibc!384
2023-05-05 15:30:49 +00:00
Ron Williams c105548036 Fix platform::errno = ... in signal.rs 2023-05-04 19:29:12 -07:00
Jeremy Soller 5980327865 Merge branch 'signal_impl2' into 'master'
signal add fewer more implementations

See merge request redox-os/relibc!378
2023-05-04 21:39:13 +00:00
Jeremy Soller 68b2859892 Merge branch 'setsid__impl' into 'master'
setsid implementation

See merge request redox-os/relibc!381
2023-05-04 21:38:40 +00:00
Jeremy Soller 8cba3451fd Merge branch 'cfmakeraw__impl' into 'master'
cfmakeraw implementation proposal

See merge request redox-os/relibc!382
2023-05-04 21:38:03 +00:00
Jeremy Soller 26f55b3019 Merge branch 'gitoxide-port' into 'master'
Add no-op tzset, plus required static vars

See merge request redox-os/relibc!383
2023-05-04 21:37:33 +00:00
Ron Williams efeca2f909 Add no-op tzset, plus required static vars 2023-05-04 13:12:04 -07:00
David Carlier c88279f204 cfmakeraw implementation proposal 2023-05-04 20:18:14 +01:00
David Carlier 5041df0015 setsid implementation 2023-05-04 19:09:32 +01:00
David Carlier 07cc3614c2 signal add fewer more implementations 2023-04-29 09:01:25 +01:00
Jeremy Soller bf7cdc4413 Merge branch 'no_mangle_fixes' into 'master'
fix no_mangle annotation missing

See merge request redox-os/relibc!377
2023-04-26 18:49:07 +00:00
David Carlier eb87e2b796 fix no_mangle annotation missing 2023-04-26 19:42:29 +01:00
Jeremy Soller 30996e353b Merge branch 'signal_various_impl' into 'master'
signal add few missing implementations

See merge request redox-os/relibc!376
2023-04-26 18:28:21 +00:00
Jeremy Soller 8a002ecc1d Merge branch 'sync_impl' into 'master'
sync implementation

See merge request redox-os/relibc!375
2023-04-26 18:24:48 +00:00
Jeremy Soller 0a652622ae Merge branch 'fdatasync_impl' into 'master'
unistd: fdatasync implementation.

See merge request redox-os/relibc!373
2023-04-26 18:22:57 +00:00
David Carlier c44fda84c4 signal add few missing implementations 2023-04-25 22:16:59 +01:00
David Carlier a561e682a3 sync implementation 2023-04-22 13:20:18 +01:00
David Carlier 3456b4f30e unistd: fdatasync implementation. 2023-04-19 21:48:54 +01:00
Jeremy Soller 673c1e3adc Merge branch 'unlockpt_impl' into 'master'
stdlib: unlockpt implementation proposal

See merge request redox-os/relibc!372
2023-04-19 15:48:09 +00:00
David Carlier 40b1cec31e stdlib: unlockpt implementation proposal 2023-04-18 21:24:53 +01:00
Jeremy Soller 1df8a14e6d Merge branch 'getsetpriority_impl' into 'master'
sys_resource: get/setpriority implementations.

See merge request redox-os/relibc!369
2023-04-17 14:35:36 +00:00
Jeremy Soller bd551a1306 Merge branch 'getsubopt_impl' into 'master'
stdlib: getsubopt implementation proposal.

See merge request redox-os/relibc!371
2023-04-17 14:35:07 +00:00
Jeremy Soller 898a9481d6 Merge branch 'madvise_impl' into 'master'
sys_mman: adding madvise.

See merge request redox-os/relibc!370
2023-04-17 14:34:53 +00:00
David Carlier cde60c9f0e stdlib: getsubopt implementation proposal. 2023-04-16 10:58:46 +01:00
David Carlier 116583cdc7 sys_mman: adding madvise. 2023-04-15 10:41:42 +01:00
David Carlier 7f36abc33c sys_resource: get/setpriority implementations. 2023-04-15 07:16:25 +01:00
Jeremy Soller d5c88c7ca6 Merge branch 'rw_van_230414' into 'master'
Fix typos in setrlimit

See merge request redox-os/relibc!368
2023-04-15 00:06:15 +00:00
Ron Williams b0fe3ab095 fix typo in linux setrlimit 2023-04-14 15:21:15 -07:00
Ron Williams cbd42c23a4 fix typo in setrlimit 2023-04-14 14:45:16 -07:00
Jeremy Soller 77639ddd49 Merge branch 'setrlimit_impl' into 'master'
sys_resource: setrlimit implementation proposal.

See merge request redox-os/relibc!366
2023-04-14 14:17:40 +00:00
David Carlier f5ee873961 sys_resource: setrlimit implementation proposal. 2023-04-13 20:59:52 +01:00
Jeremy Soller 14009eb1d8 Merge branch 'getdtablesize_impl' into 'master'
unistd: getdtablesize implementation proposal

See merge request redox-os/relibc!365
2023-04-12 17:15:31 +00:00
David Carlier 66786f619d unistd: getdtablesize implementation proposal 2023-04-11 20:45:02 +01:00
Jeremy Soller 6b262a5b79 Merge branch 'cuserid_impl' into 'master'
stdio: implements legacy cuserid proposal.

See merge request redox-os/relibc!362
2023-04-05 21:23:14 +00:00
David Carlier 637dd22d3d stdio: implements legacy cuserid proposal. 2023-04-05 22:17:09 +01:00
Jeremy Soller 4fc069e6b5 Merge branch 'sys_mman_further_updates' into 'master'
sys_mman add further mmap/madvise flags.

See merge request redox-os/relibc!361
2023-04-04 12:40:49 +00:00
David Carlier 1928cf4fab sys_mman add further mmap/madvise flags. 2023-04-04 07:09:49 +01:00
Jeremy Soller cfeaba45eb Merge branch 'fix-symlink-installation-on-macos' into 'master'
Fix symlinking on MacOS that doesn't have the -r option

See merge request redox-os/relibc!360
2023-04-03 17:17:50 +00:00
Jeremy Soller c3740162fd Merge branch 'pte_waitpid' into 'master'
pte: pte_osThreadWaitForEnd checking return of Sys::waitpid

Closes #165

See merge request redox-os/relibc!359
2023-04-03 17:11:47 +00:00
Will Angenent 9ddb2b1b47 Fix symlinking on MacOS that doesn't have the -r option 2023-04-02 13:59:51 +00:00
David Carlier 4d244dee96 pte: pte_osThreadWaitForEnd checking return of Sys::waitpid
close #165
2023-03-30 08:24:01 +01:00
Jeremy Soller 07329c9efe Merge branch 'sys_mman_update' into 'master'
sys/mman.h update addinng mlockall and posix_madvise flags

See merge request redox-os/relibc!357
2023-03-29 16:31:21 +00:00
David Carlier 53cdd95267 sys/mman.h update addinng mlockall and posix_madvise flags 2023-03-28 18:26:52 +01:00
Jeremy Soller dafa716c53 Merge branch 'wctrans_api' into 'master'
wctrans/towctrans implementation proposal.

Closes #32

See merge request redox-os/relibc!356
2023-03-28 12:58:17 +00:00
David Carlier ec6243bc5b wctrans/towctrans implementation proposal.
close #32
2023-03-27 19:15:08 +01:00
Jeremy Soller 2c3561e888 Merge branch 'reallocarray_impl' into 'master'
reallocarray introduction available on glibc 2.26. allocates an array of m*n...

See merge request redox-os/relibc!355
2023-03-26 23:27:10 +00:00
Jeremy Soller 3f76a08122 Merge branch 'socket_poll_constants' into 'master'
adding SOCK_RDM and a couple of POLL* constants.

Closes #164

See merge request redox-os/relibc!354
2023-03-26 09:06:29 +00:00
David Carlier 3fe37e36fa reallocarray introduction available on glibc 2.26. allocates an array of m*n elements but checking for overflow. 2023-03-26 08:35:44 +01:00
David Carlier 66fdebc0cb adding SOCK_RDM and a couple of POLL* constants.
close #164
2023-03-26 08:11:50 +01:00
Jeremy Soller ae745427cd Merge branch 'string_strlcpy_api' into 'master'
strlcpy/strlcat api for portability's sake.

See merge request redox-os/relibc!353
2023-03-25 13:53:00 +00:00
David Carlier 34f2fff983 strlcpy/strlcat api for portability's sake.
those functions differently than the strn* ones as
they do not pad with zero to remaining bytes but guarantees
a null terminator.
2023-03-24 09:44:33 +00:00
Jeremy Soller 0144ea1a9d Merge branch 'explicit_bzero_in_strings' into 'master'
explicit_bzero implementation proposal

See merge request redox-os/relibc!337
2023-03-22 21:58:50 +00:00
David Carlier 63deaec9d8 update inline asm 2023-03-22 06:56:06 +00:00
David Carlier 44f343bec8 explicit_bzero implementation proposal 2023-03-22 06:25:26 +00:00
Jeremy Soller 0646140d99 Remove detailed abort, too many compatibility issues 2023-03-10 11:33:53 -07:00
Jeremy Soller e7b70fdb93 Ensure assert_fail and abort have noreturn attribute 2023-03-10 11:23:56 -07:00
Jeremy Soller 334e33cfde Fix abort definition for C++ 2023-03-10 10:45:19 -07:00
Jeremy Soller 2b3e9a3bd0 Use backup abort on C++ 2023-03-10 10:23:08 -07:00
Jeremy Soller cc0ac982c4 Implement __fpurge 2023-03-10 08:37:54 -07:00
Jeremy Soller 9c055142cf Add sys/types.h to utime.h 2023-03-10 07:54:02 -07:00
Jeremy Soller dab147f862 Change stdint include order so __need_ defines are set 2023-03-10 07:53:53 -07:00
Jeremy Soller 47bd55451f Detailed information on abort using macro and new __abort function 2023-03-09 20:19:27 -07:00
Jeremy Soller 04d2f296a9 Fix for epoll on i686 redox 2023-03-03 19:58:05 -07:00
Jeremy Soller 9a7dfc4f4d Disable test:redox for now 2023-03-01 11:06:41 -07:00
Jeremy Soller 063d25414e Use redoxer.sh for Redox testing 2023-03-01 10:54:27 -07:00
Jeremy Soller 903393574e redoxer.sh will clear build-std from CARGOFLAGS 2023-03-01 10:53:58 -07:00
Jeremy Soller eceaa065cf Fix fmt gitlab CI 2023-03-01 10:44:14 -07:00
Jeremy Soller e6f47cbc27 Fix build:linux gitlab CI 2023-03-01 10:42:45 -07:00
Jeremy Soller 9b8fb50177 Merge branch 't-nil-master-patch-88790' into 'master'
Provide possible fix for `x86_64-linux-gnu-ar: command not found` (or similar) in README.md

See merge request redox-os/relibc!351
2023-02-27 16:10:03 +00:00
Florian Meißner 59cbc5be32 Provide possible fix for x86_64-linux-gnu-ar: command not found (or similar) in README.md 2023-02-27 12:40:30 +00:00
Jeremy Soller f5651b22ea Do not overwrite static TCB 2023-02-13 08:31:59 -07:00
Jeremy Soller 9c16224e82 Update libc crate 2023-02-11 14:45:26 -07:00
Jeremy Soller 0bd476d28a Update to new Rust toolchain 2023-02-11 13:45:07 -07:00
Jeremy Soller a37916101f Add M_2_PI 2023-01-17 22:11:46 -07:00
Jeremy Soller 6acc5dba79 Merge branch 'wcstombs' into 'master'
Fix definition of `wcstombs`

See merge request redox-os/relibc!350
2023-01-14 11:29:27 +00:00
Ian Douglas Scott ff70567cd6 Fix definition of wcstombs 2023-01-13 21:49:28 -08:00
Jeremy Soller 073f1e3e05 Fix incorrect pthread PID 2023-01-12 08:12:40 -07:00
Jeremy Soller ba87e4893a Create empty libdl and librt libraries 2022-12-19 09:33:39 -07:00
Jeremy Soller 058509bd88 Define float_t and double_t 2022-12-19 09:10:14 -07:00
Jeremy Soller 21efe2d3a1 Clarify localeconv mutability 2022-12-16 20:10:01 -07:00
Jeremy Soller 0fab7f1864 Make localeconv return mutable pointer, matching specification 2022-12-16 19:55:13 -07:00
Jeremy Soller 6516695519 Format 2022-12-16 17:39:30 -07:00
Jeremy Soller 393489b38b Add wcswidth and test 2022-12-16 17:39:06 -07:00
Jeremy Soller 7d27737c3f Disable dynamic tests as they are not compiling 2022-12-16 17:18:07 -07:00
Jeremy Soller 59b2e32953 Fix compilation on 32-bit systems 2022-12-02 08:00:36 -07:00
Jeremy Soller 041d1604b5 Make off_t and time_t long long 2022-12-02 07:42:26 -07:00
Jeremy Soller 9e0c53f222 Make long 32-bits on 32-bit systems 2022-12-01 18:33:00 -07:00
Jeremy Soller da4d277f12 Use futex again for semaphore 2022-12-01 14:05:12 -07:00
Jeremy Soller 9b04c2e5d3 Add missing imports 2022-12-01 10:50:27 -07:00
Jeremy Soller df75b8d037 Semaphore improvements 2022-12-01 10:48:53 -07:00
Jeremy Soller ee0193aa7e Add missing import 2022-11-11 17:06:50 -07:00
Jeremy Soller 16abc91341 cargo fmt and cargo fix 2022-11-11 13:27:18 -07:00
Jeremy Soller d1a86c850e Hack to use the correct TLS size for the first TLS module 2022-11-11 10:08:00 -07:00
Jeremy Soller b13e96ffb8 Ensure there is a stub Tcb for dynamically linked binaries 2022-11-11 09:42:47 -07:00
Jeremy Soller f65c1c27c7 Implement wcwidth 2022-11-10 10:12:41 -07:00
Jeremy Soller 5032cdb6d8 Add MADV constants 2022-10-25 08:16:00 -06:00
Jeremy Soller b30c33adc3 Add getsid stub 2022-10-17 11:37:58 -06:00
Jeremy Soller fc8e55abd8 Add FIONREAD on Redox 2022-10-17 10:39:31 -06:00
Jeremy Soller 976ca7893f Use current Tcb if it is set even if no linker objects are loaded 2022-09-11 14:07:05 -06:00
Jeremy Soller 367be58666 Set linker_ptr when using static TLS 2022-09-11 11:11:49 -06:00
Jeremy Soller e7b6252bd3 Make semaphore always sched_yield 2022-09-01 15:43:11 -06:00
Jeremy Soller 53c8f0facd Simplify semaphore for debugging 2022-09-01 10:56:18 -06:00
Jeremy Soller 6a9f8b204b Remove PTE prints 2022-08-30 08:49:55 -06:00
Jeremy Soller 0250ea022f pte clone for aarch64 2022-08-26 20:16:58 -06:00
Jeremy Soller c59b94d102 Hacks to support aarch64 static TLS 2022-08-25 19:03:49 -06:00
Jeremy Soller b0d3e5b154 Correct instruction to read aarch64 thread pointer 2022-08-25 18:58:45 -06:00
Jeremy Soller 58ceae44e7 ld_so init for aarch64 2022-08-24 20:41:32 -06:00
Jeremy Soller 6591cf699d Set aarch64 tcb 2022-08-24 19:24:26 -06:00
Jeremy Soller 38576a37ab Fix mistake in aarch64 fork ret 2022-08-24 18:40:06 -06:00
Jeremy Soller adbdf1d73d Fixes for redox-exec on aarch64 2022-08-24 15:45:36 -06:00
Jeremy Soller 9fad841ad0 Update redox_syscall 2022-08-24 08:51:01 -06:00
Jeremy Soller 2cd461fa21 Use relibc chdir for fchdir 2022-08-24 08:50:50 -06:00
Jeremy Soller 915359d11d Disable use of EnvRegisters on aarch64 2022-08-24 07:49:29 -06:00
Jeremy Soller 7c7c8d4774 Merge branch 'cwd_fix' into 'master'
Check for ENOENT/ENOTDIR in chdir().

See merge request redox-os/relibc!347
2022-08-23 13:43:53 +00:00
4lDO2 1987ae7c77 Check for ENOENT/ENOTDIR in chdir(). 2022-08-23 10:49:29 +02:00
Jeremy Soller e0be408287 fegetround is implemented in openlibm, remove no_mangle 2022-08-22 08:39:53 -06:00
Jeremy Soller eac4a349d8 Set default FPU control word to 0x37F 2022-08-22 08:10:42 -06:00
Jeremy Soller 1243330146 Implement pte_clone_ret for x86 2022-08-20 22:20:42 -06:00
Jeremy Soller c547f9677f Use GS for i686 thread pointer 2022-08-20 21:11:18 -06:00
Jeremy Soller c96b3114ab More fixes for x86 2022-08-20 20:56:42 -06:00
Jeremy Soller 8b629a562b Syntax error 2022-08-20 20:52:19 -06:00
Jeremy Soller a1d0b8fc35 More x86 fixes 2022-08-20 20:51:01 -06:00
Jeremy Soller c1b20cdeab Add x86 _start 2022-08-20 20:43:41 -06:00
Jeremy Soller 619245024a Use 32-bit program headers too 2022-08-20 20:10:15 -06:00
Jeremy Soller 791460d5d1 Use 32-bit elf headers on 32-bit redox 2022-08-20 19:48:47 -06:00
Jeremy Soller 5526528364 Partial aarch64 implementation of relibc internal functions 2022-08-20 14:19:29 -06:00
Jeremy Soller 70a8fca3c1 Use target binutils for renamesyms 2022-08-19 13:16:25 -06:00
Jeremy Soller de29da4099 Rename __rg_oom 2022-08-19 12:54:18 -06:00
Jeremy Soller 60a4b59194 Fix push/pop of preserved registers on x86 2022-08-18 08:09:11 -06:00
Jeremy Soller 32770ed976 Improvements to x86 assembly in redox-exec 2022-08-18 08:01:14 -06:00
Jeremy Soller ebb0507f59 Impelement relibc_internal_fork_wrapper for x86 32-bit 2022-08-17 14:21:00 -06:00
Jeremy Soller 1315171a70 Merge branch 'relibc_cwd' into 'master'
Move processes' cwd state into relibc

See merge request redox-os/relibc!346
2022-08-15 21:07:54 +00:00
4lDO2 c26ce37620 Also fail if cwd could not be written to escalated. 2022-08-13 19:16:48 +02:00
4lDO2 5e74d173ab Fix ld.so access function on Redox. 2022-08-13 19:16:48 +02:00
4lDO2 36775eeb1b Implement EXDEV symlink resolution. 2022-08-13 19:16:48 +02:00
4lDO2 54b3f873f8 Move cwd from kernel to relibc. 2022-08-13 19:16:45 +02:00
Jeremy Soller 4b90afeb2a Merge branch 'hstrerror' into 'master'
Implement hstrerror

See merge request redox-os/relibc!341
2022-08-12 12:18:08 +00:00
Jeremy Soller 3eb52eabf5 Fix missing NUL for setenv 2022-08-04 08:55:01 -06:00
Jeremy Soller 2f271268af Add MSG_DONTWAIT 2022-08-01 10:09:31 -06:00
Jeremy Soller 9e2cbcc407 redox-exec: Add aarch64 stubs 2022-07-29 10:06:54 -06:00
Jeremy Soller 13e58007bc Add stubs for new asm functions on x86 2022-07-28 08:16:28 -06:00
Jeremy Soller 05e3a5ac8b redox-exec: Move x86_64 specific things to arch module 2022-07-28 08:08:01 -06:00
Jeremy Soller 1fe13b760e Merge branch 'redox-exec' into 'master'
Move fork implementation to redox-exec

See merge request redox-os/relibc!345
2022-07-28 13:38:34 +00:00
4lDO2 16d0f96d64 Move fork implementation to redox-exec 2022-07-28 14:19:31 +02:00
Jeremy Soller fc258e8b4f Merge branch 'fix-float-parser' into 'master'
strtof, strtod: Fix parsing floats with exponents

See merge request redox-os/relibc!344
2022-07-28 01:08:41 +00:00
Nagy Tibor 5b2a12ca6d strtof, strtod: Fix parsing floats with exponents 2022-07-28 01:11:55 +02:00
Jeremy Soller dc865148fc Get Linux to compile again 2022-07-27 10:10:41 -06:00
Jeremy Soller aa2397ce29 Merge branch 'userspace_fexec' into 'master'
Userspace fexec

See merge request redox-os/relibc!343
2022-07-27 15:39:33 +00:00
4lDO2 f438a4259a Use redox_syscall 0.3 from crates.io 2022-07-27 17:38:12 +02:00
4lDO2 13cbac293b Fix write to mmap-min-addr 2022-07-26 21:35:25 +02:00
4lDO2 985b2a59a9 Use better interfaces in exec/clone 2022-07-26 21:35:24 +02:00
4lDO2 d32dd52d3b Use 2021 edition in redox-exec 2022-07-26 21:34:48 +02:00
4lDO2 ed196516a2 Only inherit environ from ldso if previously NULL. 2022-07-26 21:34:48 +02:00
4lDO2 b58ad5bf13 In clone, use better asm function names and align. 2022-07-26 21:34:48 +02:00
4lDO2 4e5ccbffd1 Allow constructors to access env vars. 2022-07-26 21:34:48 +02:00
4lDO2 049a5156d7 Implement PT_INTERP, and thus dynamic linking.
With this change, gcc can now successfully compile a tiny program that
printfs an integer returned from a function, from a dynamically linked
library that it compiled as well.

Rustc however, is orders of magnitude more complex, and the next step is
to fix constructors which require access to `environ`, in ld.so
2022-07-26 21:34:48 +02:00
4lDO2 db16393fd7 Manually init FPU context in pte_clone. 2022-07-26 21:34:48 +02:00
4lDO2 24ecd6ee16 Fix waitpid deadlock. 2022-07-26 21:34:48 +02:00
4lDO2 8ac0626be7 Handle sigactions properly in execve and fork. 2022-07-26 21:34:48 +02:00
4lDO2 b930cc98d0 Correctly preserve and set MXCSR and FCW. 2022-07-26 21:34:47 +02:00
4lDO2 3701ea3be7 Conflict-proof #[global_allocator] symbols too.
The #[global_allocator] used by relibc is only relibc's business.
Symbols should therefore not leak if another applications for example
wants to override the system allocator (and for bootstrap, which links
to relibc but uses its own #[global_allocator] based on libc functions).
2022-07-26 21:34:47 +02:00
4lDO2 05446070ec Use same rust-toolchain version as elsewhere. 2022-07-26 21:34:47 +02:00
4lDO2 bac2509ccd Fix leaks for setuid/setgid too. 2022-07-26 21:34:47 +02:00
4lDO2 1476cdeb8f Split fexec_impl into crate, used by escalated. 2022-07-26 21:34:46 +02:00
4lDO2 df8e2deddc Fix file descriptor leak in fork(). 2022-07-26 21:34:12 +02:00
4lDO2 777a82b50f Refactor out clone, fix some fd leaks. 2022-07-26 21:34:12 +02:00
4lDO2 bb45466a4e Implement clone in userspace. 2022-07-26 21:34:11 +02:00
4lDO2 a7c817d81a WIP: Support setuid/setgid 2022-07-26 21:33:01 +02:00
4lDO2 37cc4e5383 WIP: Add setuid/setgid support. 2022-07-26 21:33:01 +02:00
4lDO2 c95d276af9 Allow POSIX's environ to be set.
Rust's libstd for example uses environ when using the `envs` builder
method for spawning processes, and therefore relibc cannot simply assume
environ will always point to the internal relibc env var Vec.
2022-07-26 21:33:01 +02:00
4lDO2 2186cd1fbd Implement fexec in userspace. 2022-07-26 21:32:56 +02:00
Jeremy Soller 0bd81aa3d4 Update llvm_asm to asm for aarch64 2022-07-26 11:46:50 -06:00
Jeremy Soller afb5094cda Add triple underscore tls_get_addr for x86 2022-07-22 19:35:59 -06:00
Jeremy Soller abe30ba884 Add i386 __restore_rt 2022-07-22 19:24:05 -06:00
Jeremy Soller ece0bd090d Fix x86 setjmp/longjmp 2022-07-22 19:23:46 -06:00
Jeremy Soller 559387cc64 Initial support for x86 32-bit 2022-07-22 16:24:45 -06:00
Jeremy Soller 7f3f2fa105 Add some messages when unimplemented PTE functions are called 2022-04-14 07:52:39 -06:00
Jeremy Soller 8576b99759 Add timeout to futex_wait calls 2022-04-04 20:23:29 -06:00
4lDO2 6d394ba4f4 Merge branch 'update-dependencies' into 'master'
Update dependencies for rust 2022-03-18.

See merge request redox-os/relibc!342
2022-03-27 09:21:22 +00:00
4lDO2 fb411c0b19 Use redox_syscall 0.2.12 from crates.io, not git 2022-03-24 17:12:05 +01:00
4lDO2 f14c95db6a Update syscall. 2022-03-24 17:12:05 +01:00
4lDO2 ebd597f748 Update dependencies for rust 2022-03-18. 2022-03-24 17:12:02 +01:00
Jeremy Soller ec0047c864 Fix redox readlink 2022-03-23 13:47:58 -06:00
Jeremy Soller f63d9cefad Add mlock and friends 2022-03-17 14:03:45 -06:00
Jeremy Soller 8a2ff1ec4a Only try to set FS on x86_64 2022-02-13 15:05:07 -07:00
Jeremy Soller 824184a66c Make sure strong symbols are preferred by ld_so 2021-12-15 12:05:21 -07:00
Jeremy Soller ecd934951d R_X86_64_TPOFF64 does not require symbol, allow it to be unset 2021-12-14 14:53:16 -07:00
Jeremy Soller e90fa3e32f Do not try to open traceme on special PIDs 2021-12-01 09:52:31 -07:00
Jeremy Soller c51aec1af6 Workaround waitpid deadlock by making ptrace state thread local 2021-11-30 21:19:48 -07:00
Jeremy Soller 7a8015eb68 Use r10 instead of rcx for linux pte_clone 2021-11-30 11:34:53 -07:00
Jeremy Soller 66615ef449 Use CLONE_THREAD for linux pte_clone 2021-11-30 11:27:02 -07:00
Jeremy Soller 6b46704ac3 Fix netdb stack overuse 2021-11-30 10:30:31 -07:00
Jeremy Soller 65bd3ed1e3 Fixes for program_invocation_name and program_invocation_short_name 2021-11-30 10:27:24 -07:00
Jeremy Soller a50d80ee28 Use anonymous fmap 2021-09-22 20:47:18 -06:00
Jeremy Soller b2dd1f8950 Add cfsetispeed and cfsetospeed stubs for redox 2021-09-14 20:56:35 -06:00
Jeremy Soller ae7cee26a6 Move wctype_t definition to wctype rust header 2021-09-14 20:36:23 -06:00
Jeremy Soller e5d2ba754a Match termios structure to that used in redox_termios 2021-09-13 20:39:40 -06:00
Noa 3373d5e246 Install rust-src 2021-08-14 22:52:49 -05:00
Noa f06af86ac6 Implement hstrerror 2021-08-13 17:27:10 -05:00
Jeremy Soller dbaeb8f067 Show ld.so expect message 2021-08-10 18:26:09 -06:00
4lDO2 da9beb8cb7 Merge branch 'manual_redox_tls' into 'master'
Initialize TLS manually on Redox as Linux does.

See merge request redox-os/relibc!340
2021-08-06 13:24:48 +00:00
4lDO2 ac860b6c94 Use redox_syscall 0.2.10. 2021-08-06 15:23:24 +02:00
4lDO2 a388b1ae4d Initialize TLS manually on Redox too. 2021-08-05 11:49:40 +02:00
Jeremy Soller b3d71ba8ba Make relibc_panic a weakly linked stub for crt and ld_so objects 2021-08-04 07:20:48 -06:00
Jeremy Soller 7f7d73de3c Link crt1.o to crt0.o 2021-08-03 16:11:22 -06:00
Jeremy Soller c99658a8da Update rust-toolchain and dependencies 2021-08-03 12:38:28 -06:00
Jeremy Soller e051b18490 Merge branch 'wctype' into 'master'
wctype

See merge request redox-os/relibc!339
2021-07-19 16:14:30 +00:00
Jeremy Soller fe287cd200 Update rust-toolchain 2021-07-19 10:12:22 -06:00
Jeremy Soller 753c190995 Implement wctype.h 2021-07-19 10:04:29 -06:00
Jeremy Soller 3f12d8917c Add casecmp source information 2021-07-19 09:37:18 -06:00
Jeremy Soller f8f18ed779 Remove old _wctype module 2021-07-19 09:17:11 -06:00
Jeremy Soller 9f3aa6d4a8 Define wctype_t and wctype 2021-07-19 09:16:56 -06:00
Jeremy Soller 606bfc9c50 Weaken more rust symbols 2021-07-18 20:21:12 -06:00
4lDO2 98c60c357f Merge branch 'update_toolchain' into 'master'
Update toolchain

See merge request redox-os/relibc!338
2021-06-18 15:13:03 +00:00
4lDO2 9eeb73319d Update core_io submodule to a valid commit. 2021-06-18 17:03:03 +02:00
4lDO2 d35c303ef0 Implement chroot as always returning EPERM. 2021-06-17 22:31:39 +02:00
4lDO2 d69c115421 Compile on latest nightly.
This also replaces all the assembly that previously used the AT&T style
with the (in my opinion) superior Intel syntax.

I tried prepending `.att_syntax prefix`, but that did not work...
2021-06-17 22:31:39 +02:00
4lDO2 700c53cf17 Update toolchain to 2021-06-15 2021-06-17 22:31:30 +02:00
Jeremy Soller b472cb87d1 trace ldso path and mmap address 2021-05-10 10:06:55 -06:00
Jeremy Soller 602fd9fe08 Fixes for TCB arch_read on aarch64 2021-04-28 21:29:09 -06:00
Jeremy Soller 22b1cb957f Update redox_syscall 2021-04-28 20:08:02 -06:00
Jeremy Soller 075fd5be62 Merge branch 'gmtime-yday-fix' into 'master'
Simplify gmtime_r() day-of-year calculation, correct comment

See merge request redox-os/relibc!311
2021-03-27 16:53:08 +00:00
Jeremy Soller 88cda09cb6 Merge branch 'centralize-page-size' into 'master'
Centralize page size info in platform abstraction

See merge request redox-os/relibc!334
2021-03-24 20:04:03 +00:00
Peter Limkilde Svendsen 9e8cd0bf07 Centralize page size info in platform abstraction 2021-03-24 00:02:39 +01:00
Jeremy Soller 9c423abb5f Update pthreads-emb 2021-03-16 21:47:04 -06:00
Jeremy Soller 7012c262f0 Use sched_yield when sleeping with msecs == 0 2021-03-16 21:46:24 -06:00
Jeremy Soller 307cd56824 Merge branch 'fix-tcsetattr' into 'master'
Handle TCSETSW and TCSETSF in ioctl

Closes #168

See merge request redox-os/relibc!324
2021-03-12 18:51:39 +00:00
Noah 49e3e44bf1 Handle TCSETSW and TCSETSF in ioctl 2021-03-12 12:50:17 -06:00
Jeremy Soller 7ed74c8c7d Merge branch 'rusty-tests' into 'master'
Convert test runner to rust

See merge request redox-os/relibc!333
2021-03-02 17:54:50 +00:00
Jeremy Soller 0cd4e349c0 Formatting of tests runner 2021-03-02 08:01:26 -07:00
Jeremy Soller 7fd366be70 Convert test runner to rust 2021-03-01 21:19:04 -07:00
Jeremy Soller 031194b999 Use header files in dlmalloc 2021-02-27 19:12:59 -07:00
Jeremy Soller a28e9ae378 Add pthreads to includes for C files 2021-02-27 19:11:25 -07:00
Jeremy Soller 6b5706dc95 Merge branch 'time-utc-cast' into 'master'
Use as-less cast for UTC string

See merge request redox-os/relibc!331
2021-02-28 02:06:22 +00:00
Jeremy Soller 41036ce454 Merge branch 'clocks-per-sec-test' into 'master'
Test for time.h constants

See merge request redox-os/relibc!332
2021-02-28 02:06:13 +00:00
Jeremy Soller 1c1682180f Add generated includes when building C files 2021-02-27 13:34:01 -07:00
Jeremy Soller 6b183aef26 Replace use of int 80h with syscall in __restore_rt 2021-02-27 13:08:48 -07:00
Peter Limkilde Svendsen e3a0fdbc4a Test for time.h constants 2021-02-23 18:35:24 +01:00
Peter Limkilde Svendsen f49be31762 Use as-less cast 2021-02-19 00:17:24 +01:00
Jeremy Soller e24d27a0b3 Use UTF-8 for redox paths 2021-02-14 14:06:52 -07:00
Jeremy Soller caad589fd1 Merge branch 'bufwriter' into 'master'
Use BufWriter (instead of LineWriter) for FILEs other than stdout and stderr

See merge request redox-os/relibc!328
2021-01-20 15:14:03 +00:00
Jeremy Soller a16f535ee8 Merge branch 'aarch64-fixups' into 'master'
aarch64: TLS arch_read implementation

See merge request redox-os/relibc!330
2021-01-18 22:56:49 +00:00
Robin Randhawa 886f467a75 aarch64: TLS arch_read implementation 2021-01-18 22:01:32 +00:00
Jeremy Soller f9edc108fa Merge branch 'ldscript' into 'master'
Change ld.so linker script file name for x86_64 Linux to fix compilation issue

See merge request redox-os/relibc!329
2021-01-14 19:24:02 +00:00
Mateusz Tabaka 910fb59006 Change ld.so linker script file name for x86_64 Linux to fix compilation issue 2021-01-14 19:50:36 +01:00
Mateusz Tabaka 02f202ff83 Use BufWriter (instead of LineWriter) for FILEs other than stdout and stderr
BufWriter has more capacity (8k vs 1k) and doesn't flush the stream after '\n'.
That change helps to reduce the number of syscalls, especially when dealing with text files.

Since BufWriter has a different way of getting number of pending elements than LineWriter -
Pending trait was introduced to deal with that.
2021-01-14 18:45:14 +01:00
Jeremy Soller d94e445ae2 Remove Linux search paths from Redox ld_so 2021-01-11 08:52:57 -07:00
Jeremy Soller 3c1300e8ec Improvements for aarch64 support 2021-01-11 08:52:20 -07:00
Jeremy Soller 04fd4520d3 Update to redox_syscall 0.2.3 2021-01-11 06:47:23 -07:00
Jeremy Soller c58e9d9589 Update redox_syscall 2021-01-10 10:53:29 -07:00
Jeremy Soller ccee7eae5f Merge branch 'tlssym' into 'master'
Fix dlsym of TLS variables

See merge request redox-os/relibc!327
2021-01-05 23:03:10 +00:00
Jeremy Soller fb4fa240b7 Merge branch 'destructor' into 'master'
Call DSO destructors during exit()

See merge request redox-os/relibc!326
2021-01-05 23:02:07 +00:00
Mateusz Tabaka 19ac34f2a0 Extend dlfcn tests 2021-01-05 22:48:41 +01:00
Mateusz Tabaka 6497d71d2f Fix dlsym of TLS variables 2021-01-05 22:33:22 +01:00
Mateusz Tabaka 6332828725 Call DSO destructors during exit() 2021-01-05 20:39:36 +01:00
Jeremy Soller 261951bcba Merge branch 'globalsyms' into 'master'
Fix global symbols relocations

See merge request redox-os/relibc!325
2021-01-05 01:00:05 +00:00
Mateusz Tabaka 021a8e00fc Fix stdio/scanf test case
inner_scanf prematurely exited before parsing collected string
2021-01-03 16:07:43 +01:00
Mateusz Tabaka a7480ea656 Fix global symbols relocations
Instead of a single source of symbols, now linker keeps a list of DSO (former Library) objects
with their own symbols map. That helps to process R_X86_64_COPY relocations correctly.
For example, if 'a.out' executable with dependencies ['libstdc++.so', 'libc.so'] is being loaded
and 'a.out' uses 'stdout' symbol from 'libc.so', its relocation process goes as follows:
- linker processes relocation entry 'stdout' of type R_X86_64_GLOB_DAT from 'libc.so',
- it goes through object list ['a.out', 'libstdc++.so', 'libc.so'] to find first object
  that exports 'stdout' symbol. The symbol is in 'a.out' with the value e.g. '0x404070',
- linker sets 'stdout' symbol GOT entry in 'libc.so' to '0x404070',
....
- linker processes relocation entry 'stdout' of type R_X86_64_COPY from 'a.out',
- it goes through object list excluding 'a.out': ['libstdc++.so', 'libc.so']. The symbol is found in 'libc.so',
- linker copies the 'stdout' symbol content from 'libc.so' to memory at address '0x404070' (in 'a.out' object).

Objects are relocated in reverse order they were loaded. So in the example above, linker starts with relocating
'libc.so' and ends with 'a.out'. It is necessary e.g. when linking with 'libstdc++.so' - there are many
relocations which symbols are found in 'libstdc++.so', so they need to be resolved before their contents are
copied to 'a.out'. That also matches GNU ld.so behavior.
2021-01-03 16:04:40 +01:00
Jeremy Soller 1a0edd8eeb Add program_invocation_short_name 2020-12-23 20:24:04 -07:00
Jeremy Soller 2f3987dd88 Add _SC_GETPW_R_SIZE_MAX 2020-12-23 19:47:53 -07:00
Jeremy Soller d1ee653b5c Add dirfd 2020-12-23 19:47:44 -07:00
Jeremy Soller 928b18b306 Add sysexits.h 2020-12-23 13:45:25 -07:00
Jeremy Soller 5ae7b7efe7 Use new semaphore to prevent spinning 2020-12-23 12:20:19 -07:00
Jeremy Soller 2f69f0e7f1 Add simple semaphore implementation using futex 2020-12-23 12:18:17 -07:00
Jeremy Soller 79452dbd80 Remove warnings in elf.h 2020-12-23 12:18:02 -07:00
Jeremy Soller bddd69d0c1 Print when abort is called 2020-12-23 11:20:07 -07:00
Jeremy Soller 5efaffe0f9 Ensure that nul test is passed after last commit and failed before 2020-12-23 08:25:44 -07:00
Jeremy Soller 94a6da9116 Fix lookahead buffer reading nul's 2020-12-23 08:20:11 -07:00
Jeremy Soller 07ec3b6591 Merge branch 'mk-subs' into 'master'
Add submodules target to main makefile

See merge request redox-os/relibc!323
2020-10-18 19:48:03 +00:00
hasheddan e5539a570f Add submodules target to main makefile
Adds a submodules convenience target to main makefile. Submodules must
be initialized before other targets can run successfully.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-10-18 13:45:29 -05:00
Jeremy Soller 9529e09568 Force overwrite of libc.so.6 if it exists 2020-10-06 11:12:42 -06:00
Jeremy Soller 29e2f29231 Merge branch 'fmt' into 'master'
Fix formatiing issues

See merge request redox-os/relibc!316
2020-10-02 03:22:42 +00:00
Jeremy Soller 3e49323a3a Merge branch 'dlopen' into 'master'
Add support for dlopen(NULL, ...)

See merge request redox-os/relibc!315
2020-10-02 03:21:42 +00:00
Jeremy Soller 21e72cafc6 Merge branch 'tls' into 'master'
Fix tls tests for dynamic linker

See merge request redox-os/relibc!317
2020-10-02 03:20:50 +00:00
Mateusz Tabaka eee9a80baa Fix tls tests for dynamic linker
* load TLS segment for executable - while we can skip PT_LOAD for executable,
  we still have to load TLS segment.
* set TCB address based on if elf is position independent
2020-10-01 15:45:55 +02:00
Mateusz Tabaka 79643c293b Fix formatiing issues 2020-09-30 11:40:38 +02:00
Mateusz Tabaka c11aad71b8 Add support for dlopen(NULL, ...) 2020-09-30 11:04:10 +02:00
Jeremy Soller 687f4d4923 Merge branch 'dynamic' into 'master'
Add tests for ld_so

See merge request redox-os/relibc!314
2020-09-30 00:42:45 +00:00
Mateusz Tabaka 675101ac0e Add tests for dynamic linker 2020-09-29 23:01:52 +02:00
Mateusz Tabaka 7829a7ade9 Add support for RUNPATH 2020-09-29 23:01:48 +02:00
Mateusz Tabaka 58cc9efbc0 Call pthread_init in libc's init_array 2020-09-29 19:20:24 +02:00
Mateusz Tabaka 42acd32ac0 Fix TCB master address 2020-09-29 19:15:21 +02:00
Mateusz Tabaka b05d8df5f8 Restore previous load address for ld_so
Current value gives us 0x1234000 - 0x400000 ~ 14 MB for executable,
which is too low for certain programs.
2020-09-29 18:58:35 +02:00
Mateusz Tabaka c000373a08 Add symlink from libc.so to libc.so.6
Typically it's the other way around, but we can't have shared library named libc.so.6 in target/release directory.
cargo includes 'target/release' in LD_LIBRARY_PATH for build script, so even if clean build runs fine,
every subsquent run will make build script link with relibc.
2020-09-29 00:08:11 +02:00
Jeremy Soller 2c6114be75 Merge branch 'asctime-ub-asserts' into 'master'
Catch UB in asctime_r()

See merge request redox-os/relibc!312
2020-09-17 23:19:08 +00:00
Peter Limkilde Svendsen 00642dd940 Test extreme tm member values 2020-09-17 23:10:13 +02:00
Peter Limkilde Svendsen aef1be7c1b Remove errno setting 2020-09-17 23:10:13 +02:00
Peter Limkilde Svendsen 8ef64676fe Use stricter/simpler type handling 2020-09-17 23:10:13 +02:00
Peter Limkilde Svendsen 18a12c6c3d Add range assertions to asctime_r() 2020-09-17 23:10:13 +02:00
Peter Limkilde Svendsen 071475783a Simplify day-of-year calculation, correct comment 2020-09-10 23:34:56 +02:00
Jeremy Soller 36bb60cacc Do not unmap stack while it is being used, add a comment to fix it later 2020-09-09 18:49:44 -06:00
Jeremy Soller 2ed55a926b Merge branch 'gmtime-refactor' into 'master'
Refactor gmtime_r(), fix localtime() test

See merge request redox-os/relibc!309
2020-09-08 18:45:20 +00:00
Jeremy Soller 9f25fa39ea Merge branch 'gmtime-tests' into 'master'
Add more gmtime() tests

See merge request redox-os/relibc!308
2020-09-08 18:44:55 +00:00
Peter Limkilde Svendsen ff6bc68260 Add more gmtime() tests 2020-09-08 18:44:55 +00:00
Jeremy Soller f285128657 Merge branch 'asctime-char-cast' into 'master'
Avoid assuming c_char is i8 in asctime()

See merge request redox-os/relibc!307
2020-09-08 18:44:38 +00:00
Jeremy Soller dd193bcb8c Merge branch 'fix-asprintf-test-free' into 'master'
Add needed include for asprintf() test

See merge request redox-os/relibc!306
2020-09-08 18:43:57 +00:00
Jeremy Soller 4a6ef0221f Merge branch 'weak_rust_probestack' into 'master'
link: Weaken __rust_probestack symbol

See merge request redox-os/relibc!310
2020-09-06 13:04:34 +00:00
Esteban Blanc 9e0e88346d link: Weaken __rust_probestack symbol 2020-09-06 10:26:42 +02:00
Peter Limkilde Svendsen 59b0a36e81 Fix localtime() test 2020-08-27 23:16:17 +02:00
Peter Limkilde Svendsen 63711f6ca7 Formatting 2020-08-27 23:16:17 +02:00
Peter Limkilde Svendsen 845c74a82e Refactor gmtime_r() 2020-08-27 23:16:17 +02:00
Peter Limkilde Svendsen 86138c9f8a Align parameter naming with POSIX 2020-08-27 23:16:17 +02:00
Jeremy Soller 3a0d2177cd Variable for weakened symbols, weaken umodti3 2020-08-25 08:21:31 -06:00
Peter Limkilde Svendsen 23b2eb2573 Avoid assuming c_char is i8 2020-08-23 21:45:08 +02:00
Jeremy Soller 5472e117a5 Weaken __fixdfti 2020-08-21 21:28:51 -06:00
Peter Limkilde Svendsen aec4a84e90 Include stdlib.h so free() can be used 2020-08-20 20:43:28 +02:00
Jeremy Soller 5af8e3ca35 Merge branch 'bump-fmap' into 'master'
Use renamed fmap call

See merge request redox-os/relibc!305
2020-08-17 12:36:11 +00:00
Jeremy Soller a78f829dca Merge branch 'brk' into 'master'
Emulate brk

See merge request redox-os/relibc!304
2020-08-17 12:35:16 +00:00
jD91mZM2 e33aea434f Use renamed fmap call 2020-08-17 13:57:39 +02:00
jD91mZM2 eaee4e6329 Emulate brk 2020-08-15 18:44:22 +02:00
Jeremy Soller 7db83596a2 Merge branch 'gcc_compile' into 'master'
Gcc compile

See merge request redox-os/relibc!303
2020-08-14 15:19:14 +00:00
oddcoder ab92ff9d41 make all ld printlns happen in case of verbose = true and apply cargo fmt
It seams that stdout of ld.so is not that much of an issue but actually
it unfortunately is. The major problem here is that sometimes programs
generate header files in stdout (./getmy_custom_headers > header.h) and
we need to keep that cleen. and this is very very popular in gcc.
2020-08-12 18:57:37 +02:00
oddcoder 7b29f6eb27 Avoid relinking already linked libs
This patch avoids collecting symbols, resolving relocs if they are
already done (usually for example libc.so during a dlopen for another
libfoo.so). This patch is purely for performance boost.
2020-08-12 18:57:37 +02:00
oddcoder 61fcc018fc Refer to libraries with soname if available and avoid loading libs twice
It is usually not optimal to load a library twice and for specifics,
it is **terrible** idea to load libc twice it was enough trouble
dealing with libc statically linked into ld.so. So What this patch does
it check for soname and if a library is already loaded it won't get
loaded again. Why soname ? because unfortunately some bins gets linked
againt libc.so while of their dependencies gets linked against
libc.so.6 while one is usually symbolic link for the other.
2020-08-12 18:57:37 +02:00
oddcoder 9826cea092 Add SONAME for libc.so
Usually it is possible to refer to library either by the file name or by
elf "soname" soname is very similar for specifying something like
(LIB/API version) combination so if for example you have ./prog that
loads libx.so which is version 5.1.1 and there is ./plugin.so that ./prog
would load that requires libx.so version 5.1.2 both libx.so should have
the same soname to hint that they offer the exact same functionality.
And this patch specifies the soname for relibc libc.so.
2020-08-12 18:57:37 +02:00
jD91mZM2 7b6ba2c73a Merge branch 'lD_PATH' into 'master'
L d path

See merge request redox-os/relibc!300
2020-08-12 10:19:32 +00:00
Ahmed Abd El Mawgood 40328a0d09 Modify ld_script so that it works on linux.
Honestly, I have no idea why are these modifications needed, but it
seams they are needed
2020-08-12 10:19:32 +00:00
jD91mZM2 b9828bd863 Merge branch 'elf_And_flock' into 'master'
Elf and flock

See merge request redox-os/relibc!283
2020-08-12 10:17:59 +00:00
jD91mZM2 d827c0f166 Run Linux tests in CI
commit 09cb17e66f46c6687fa0b9dc0895ad3279caa092
Author: jD91mZM2 <me@krake.one>
Date:   Mon Aug 10 18:03:20 2020 +0200

    comment out cargo tests

commit 1915c7306e40f5c6af36b04c765e25ad9ffe9d16
Author: jD91mZM2 <me@krake.one>
Date:   Mon Aug 10 17:58:52 2020 +0200

    Update redoxer docker image
2020-08-11 11:14:13 +02:00
Jeremy Soller 91f0be8790 Merge branch 'weaken_floattidf' into 'master'
Also weaken `__floattidf`

See merge request redox-os/relibc!299
2020-08-08 14:15:55 +00:00
oddcoder b5deadbeea Add (POSIX defined) struct flock
struct flock is posix defined locking mechanism on *nix platform

Example usage (copied from https://gavv.github.io/articles/file-locks/) :

  #include <fcntl.h>

  struct flock fl;
  memset(&fl, 0, sizeof(fl));

  // lock in shared mode
  fl.l_type = F_RDLCK;

  // lock entire file
  fl.l_whence = SEEK_SET; // offset base is start of the file
  fl.l_start = 0;         // starting offset is zero
  fl.l_len = 0;           // len is zero, which is a special value representing end
                        // of file (no matter how large the file grows in future)

  fl.l_pid = 0; // F_SETLK(W) ignores it; F_OFD_SETLK(W) requires it to be zero

  // F_SETLKW specifies blocking mode
  if (fcntl(fd, F_SETLKW, &fl) == -1) {
    exit(1);
  }

  // atomically upgrade shared lock to exclusive lock, but only
  // for bytes in range [10; 15)
  //
  // after this call, the process will hold three lock regions:
  //  [0; 10)        - shared lock
  //  [10; 15)       - exclusive lock
  //  [15; SEEK_END) - shared lock
  fl.l_type = F_WRLCK;
  fl.l_start = 10;
  fl.l_len = 5;

  // F_SETLKW specifies non-blocking mode
  if (fcntl(fd, F_SETLK, &fl) == -1) {
      exit(1);
  }

  // release lock for bytes in range [10; 15)
  fl.l_type = F_UNLCK;

  if (fcntl(fd, F_SETLK, &fl) == -1) {
      exit(1);
  }

  // close file and release locks for all regions
  // remember that locks are released when process calls close()
  // on any descriptor for a lock file
  close(fd);
2020-08-08 10:16:50 +02:00
oddcoder e14b3e09a5 Add elf.h header to relibc 2020-08-08 10:16:50 +02:00
jD91mZM2 d08c63b1e7 Merge branch 'fix-ci' into 'master'
Fix CI

See merge request redox-os/relibc!302
2020-08-07 14:16:45 +00:00
jD91mZM2 6952a079ae Fix CI 2020-08-07 14:16:45 +00:00
jD91mZM2 72532b8280 Fix printf issue found in GDB 2020-08-05 16:49:10 +02:00
Jeremy Soller 4f93e43593 Merge branch 'fix-linker' into 'master'
Make linker work somewhat on Redox

See merge request redox-os/relibc!296
2020-08-04 12:24:51 +00:00
jD91mZM2 0178565f71 Move text section of linker away
Seems to collide with the program being loaded
2020-08-04 12:24:51 +00:00
James Graves 00b08605a3 Also weaken __floattidf
Fixes link error with ion shell.
2020-08-03 14:37:32 -05:00
Jeremy Soller 2073d2a80e Use objcopy to remove duplicate symbols 2020-08-02 20:41:45 -06:00
Jeremy Soller 2008296a10 Add sys_mman expected output 2020-08-02 14:34:56 -06:00
Jeremy Soller ae8e070b9e Init TLS before allocator 2020-08-02 14:32:28 -06:00
Jeremy Soller 0c6398abcb Do not require allocation in static_init 2020-08-02 14:32:20 -06:00
Jeremy Soller ebb17654f8 Add llvm_asm features 2020-08-02 13:42:34 -06:00
Jeremy Soller 5d45042d5d Correct more asm! usages 2020-08-02 13:38:29 -06:00
Jeremy Soller 12777ba774 Use 2020-07-27 nightly, it has rustfmt 2020-08-02 13:06:44 -06:00
Jeremy Soller f2c2d7c52e Fix compilation on newer nightly, update nightly to 2020-08-01 2020-08-02 12:24:49 -06:00
Jeremy Soller f131391b0d Merge branch 'memory' into 'master'
Make munmap use funmap2

See merge request redox-os/relibc!297
2020-07-30 14:04:06 +00:00
jD91mZM2 7d4d73dd83 Update redox_syscall 2020-07-30 15:58:21 +02:00
jD91mZM2 4c148c1860 Make munmap use funmap2 2020-07-30 13:39:20 +02:00
4lDO2 a5e02650d7 Remove ptrace write call. 2020-07-25 22:30:38 +02:00
4lDO2 285a7c62d4 Use mmap2 version of redox_syscall. 2020-07-25 22:30:38 +02:00
4lDO2 e38d185870 Use fmap2 to support passing an address. 2020-07-25 22:30:38 +02:00
Jeremy Soller d6b03de7a4 Align stack to 128 bytes 2020-07-19 21:04:16 -06:00
Jeremy Soller 677f0c989d Merge branch 'dlopen_dlclose_dlsym' into 'master'
Dlopen dlclose dlsym

See merge request redox-os/relibc!290
2020-07-19 19:35:31 +00:00
oddcoder 37a462de5d Apply cargo fmt to the whole repo 2020-07-19 21:27:38 +02:00
no name 890a9ed033 Implement dlopen/close 2020-07-19 21:27:38 +02:00
oddcoder ea3265766c Allow struct Linker to specify which library space to use 2020-07-19 21:21:48 +02:00
oddcoder 02aa400c5c Add callbacks to ld.so version of Linker's function
It is fact that ld.so has libc statially linked into it.

Normally we wouldn't need ld.so functionality once the program is
finalyl loaded, but with the next few patches, we will have dlopen which
will reuse the same ld.so functionality.

The problem is that it seams that huge part of the code is possible not
referntially transparent. That is, it is not impossible that some of the
functions have internals states. So when using the struct Linker that is
initialized by ld.so's copy of libc. we must access it using the same
copy even if both copies are identical.
For example in dlopen if you do linker.load_library(..). That would
segfault because it is using the function from libc not ld.so

So I don't truly undestand why should this be needed, but after long
hours of being stuck I thought maybe.. maybe that is the issue and
indeed it turned out to be so.
2020-07-19 21:21:48 +02:00
oddcoder b4a6a7ece5 Refactor init and fini by merging common code 2020-07-19 21:21:48 +02:00
oddcoder 6d0c9dccd5 Allow Linker struct to specify with library name space to operate on 2020-07-19 21:21:48 +02:00
oddcoder 01b1738b3a Separate library specific data from main Linker struct 2020-07-19 21:21:48 +02:00
oddcoder aaf017d9d1 Fix regression introduced in 5fcf9206
I by mistake commented _dl_debug_state() function which would break
debugging
2020-07-19 21:21:48 +02:00
Jeremy Soller 36ac4166ef Define MAP_ANON for dlmalloc 2020-07-19 12:40:01 -06:00
Jeremy Soller cf8cbe625b Merge branch 'allocator' into 'master'
Allocator

See merge request redox-os/relibc!295
2020-07-18 19:51:37 +00:00
no name 40acadc7d5 Sanity checking 04f77881d0 2020-07-18 21:15:57 +02:00
oddcoder 4d982f86b2 use only mspaces 2020-07-18 21:05:18 +02:00
oddcoder f4f68a3441 Make use of mspaces 2020-07-18 21:03:46 +02:00
oddcoder 3a8817072c Initialize the mspaces of allocator and keep track of it 2020-07-18 21:03:20 +02:00
oddcoder 67c703610b Compile dlmalloc with mspace support 2020-07-18 20:54:58 +02:00
oddcoder 9a1efda121 Initial allocator structure 2020-07-18 20:54:30 +02:00
Jeremy Soller 04f77881d0 Merge branch 'TLS' into 'master'
Fix wrong TLS resolving

See merge request redox-os/relibc!294
2020-07-18 18:48:14 +00:00
oddcoder d4b2391221 Fix wrong TLS resolving
I attempted fixing this issue before at 43fbaf99. Although it did work,
it worked wrong, and it was just consistently working (but in wrong way)
until it didn't.

Since this is (hopefully) the real fix, I will try to explain exactly
what is going on.

This is explaination by example:

our TLS is memory of size 0x1000 starting at 0x7ffff6c50000,
but the real size is 0x000068 so we have padding stored at master.offset
= 0xf98

Now our symbol looks as follows

  Offset          Type                Sym. Value    Name
000000432b20  R_X86_64_DTPOFF64   0000000000000058 errno

The old code did 0x7ffff6c50000 + 0xf98 + 000000432b20 which is
obviosly overflowing the memory and wrong.

The right way 0x7ffff6c50000 + 0xf98 + 0000000000000058.

THe Tls base part and offset are added at __tls_get_addr function.
What is left is storing the 0x58 at the relocation address. The problem
is that we don't have 0x58, but we have (binary base + 0x58) in global
symbol table and binary base so what we store is the (binarybase + 0x58
- binary base).

I hope this does turn out to be wrong.
2020-07-18 20:45:37 +02:00
jD91mZM2 e17c6049c6 Fix libgmp compilation 2020-07-15 11:12:59 +02:00
Jeremy Soller cbd7ead0ff Merge branch 'add_fwide' into 'master'
Add fwide function

See merge request redox-os/relibc!291
2020-07-09 12:29:53 +00:00
Wren Turkal 9a1e9c327a Make byte stream functions set stream orientation.
When a byte-oriented stream function touches a stream, that stream
should be set to byte-oriented mode if it hasn't been set yet. If
it has been set, the opertion should only succeed if the stream is
already in byte-oriented mode.

Signed-off-by: Wren Turkal <wt@penguintechs.org>
2020-07-08 14:33:11 -07:00
Wren Turkal 746a86a267 Add unlocked variation of fwide function.
Signed-off-by: Wren Turkal <wt@penguintechs.org>
2020-07-08 14:33:11 -07:00
Wren Turkal b623e245c0 Make freopen reset the stream orientation.
Signed-off-by: Wren Turkal <wt@penguintechs.org>
2020-07-08 14:33:11 -07:00
Wren Turkal 865b7962a1 Add implmentation for fwide posix function.
This function is used to set the orientation of a stream to either
byte-oriented or wchar-oriented.

More info on this function is here:
https://man7.org/linux/man-pages/man3/fwide.3p.html

This implementation only impmlemnts the manual switching and does
not yet guard against using a byte-oriented stream with wchar
functions and vice versa. Those step will come in additional
commits.

Signed-off-by: Wren Turkal <wt@penguintechs.org>
2020-07-08 14:33:06 -07:00
Jeremy Soller c13ba64832 Merge branch 'socketpair' into 'master'
Various socket-related changes and other

See merge request redox-os/relibc!289
2020-07-01 13:56:58 +00:00
jD91mZM2 29ad5b75c9 Fix broken CVec
Oops, forgot to initiate the pointer after uses of CVec::new()
2020-06-29 21:03:29 +02:00
jD91mZM2 56e1eceb28 Replace AllocStringWriter with CVec 2020-06-29 17:44:57 +02:00
jD91mZM2 39ce623d2d Fix bind/connect's AF_UNIX socket path... again
I don't really know for sure what all these silly rules are, but I think
I got it now...
2020-06-29 11:36:07 +02:00
jD91mZM2 593925ceb4 Unambiguate all include guards
GNU binutils also uses _FNMATCH_H for a guard, maybe along others!
2020-06-29 11:34:51 +02:00
jD91mZM2 f8b49936bc Various unix socket fixes (+socketpair!) 2020-06-27 16:39:50 +02:00
jD91mZM2 b7053b673d Fix missing types when compiling GDB 2020-06-25 13:03:06 +02:00
Jeremy Soller 7ea5cd5133 Merge branch 'rename-lcg48-rand48' into 'master'
Rename lcg48 module as rand48

See merge request redox-os/relibc!287
2020-06-24 16:55:27 +00:00
Jeremy Soller ce2de698c4 Merge branch 'random-alignment' into 'master'
Don't assume u32 alignment of random() state buffer

See merge request redox-os/relibc!286
2020-06-24 16:46:59 +00:00
Peter Limkilde Svendsen 5c8393d5aa Don't assume u32 alignment of random() state buffer 2020-06-24 16:46:59 +00:00
Jeremy Soller 954f010cc1 Merge branch 'pie' into 'master'
Fix bugs in handling non pie elfs

See merge request redox-os/relibc!285
2020-06-24 12:33:47 +00:00
oddcoder 5fcf920675 Fix bugs in handling non pie elfs
The problem here was that we alway added the base address, and we
assumed that all addresses we access are relative but this is not the
case in case of non pie binaries. The issue is that all addresses were
base+offset. so if we added the base again it will ofcourse generate
wrong address.
2020-06-24 10:21:20 +02:00
Peter Limkilde Svendsen 59b040258a Rename lcg48 as rand48 2020-06-23 18:34:44 +02:00
Jeremy Soller 547edcc267 Merge branch 'arpa_inet-types' into 'master'
Use C type names in byteorder functions

See merge request redox-os/relibc!274
2020-06-22 21:57:24 +00:00
Jeremy Soller 22a7f71282 Merge branch 'ctime_r' into 'master'
Add test for ctime_r(), replace mem::uninitialized()

See merge request redox-os/relibc!273
2020-06-22 21:57:04 +00:00
Jeremy Soller c95a5fa574 Merge branch 'random' into 'master'
Implement random() and friends

See merge request redox-os/relibc!284
2020-06-22 21:56:39 +00:00
Peter Limkilde Svendsen cc33874363 Implement random() and friends 2020-06-22 21:56:39 +00:00
Jeremy Soller db6a589421 Merge branch 'LD_LIBRARY_PATH' into 'master'
Ld library path

See merge request redox-os/relibc!279
2020-06-20 13:17:40 +00:00
Jeremy Soller d7089a09bf Merge branch 'LD_SO_ASM_REM' into 'master'
Get rid of assembly code in call_inits_finis

See merge request redox-os/relibc!282
2020-06-20 13:13:26 +00:00
oddcoder 0977133cc9 Get rid of assembly code in call_inits_finis 2020-06-20 15:01:13 +02:00
Jeremy Soller 73e1d6307b Merge branch 'socket-fix' into 'master'
Socket fix

See merge request redox-os/relibc!281
2020-06-19 11:58:24 +00:00
jD91mZM2 cdc9aa06e3 Fix getpeername
Rust's TcpListener fails because of the address format being wrong. The format
comes from `accept`, but there we internally use this function.
2020-06-19 13:56:06 +02:00
Jeremy Soller ca8b848b48 Merge branch 'headers' into 'master'
Headers

See merge request redox-os/relibc!280
2020-06-14 20:38:04 +00:00
oddcoder f4d95ce43f Add sys/select.h to sys/types.h
This was triggered by gcc for some reason It included sys/types.h and
assumed sys/select.h to be there. And that seams to be the case in musl.

The problem with relibc here is that sys/types.h is are part of relibc
"include/*.h" files, while sys/select.h is generated by cbindgen. That
makes it impossible to #include select.h in types.h epsecially that
there are files like fcntl.c that uses types.h. They would complain
about missing headers. I fixed this by renaming sys/types.h to
sys/types_internal.h and then generating types.h using cbindgen as well
except for that. however fcntl and dlmalloc can include types_internal
instead of types.h
2020-06-14 22:00:16 +02:00
oddcoder a125b8be15 Make stdbool.h C++ compatiable
The problem here is that _Bool type is not defined in C++ yet this file
is using it. That leads to issues when compiling gcc. I borrowed the
same techniques used in other stdbool.h
2020-06-14 22:00:10 +02:00
oddcoder 81da1bb1a3 Fix the avoid accessing errno issue from ld_so for real this time
This patch implements access function for both redox and linux and makes
sure that neither access errno variable
2020-06-13 19:55:33 +02:00
no name d5b63a85a4 Revert "Fix compilation on Redox by removing use of access in ld_so"
This reverts commit d9bacaec04.
2020-06-13 19:55:33 +02:00
no name c3ae8022ba Revert "Handle missing paths in load_library search without using access"
This reverts commit b0dde81c75.

The main issue was not with "access" being used, it was with errno being
accessed. This patch accesses errno as well

LD_LIBRARY_PATH="/folder/with/no/libc" ./a.out

gives segfault with the following stack trace

0x00000000004d1cae in relibc::platform::sys::e (sys=18446744073709551614) at src/platform/linux/mod.rs:54
 54                  errno = -(sys as isize) as c_int;
(gdb) bt
 #0  0x00000000004d1cae in relibc::platform::sys::e (sys=18446744073709551614) at src/platform/linux/mod.rs:54
 #1  0x00000000004d361e in <relibc::platform::sys::Sys as relibc::platform::pal::Pal>::open (path=0x5555555634c0, oflag=524288, mode=0) at src/platform/linux/mod.rs:330
 #2  0x000000000049a2ad in relibc::fs::File::open (path=0x5555555634c0, oflag=524288) at src/fs.rs:28
 #3  0x0000000000482b49 in relibc::ld_so::linker::Linker::load_recursive (self=0x7fffffffdd30, name=..., path=...) at src/ld_so/linker.rs:119
 #4  0x0000000000484963 in relibc::ld_so::linker::Linker::load_library (self=0x7fffffffdd30, name=...) at src/ld_so/linker.rs:184
 #5  0x0000000000483b53 in relibc::ld_so::linker::Linker::load_data (self=0x7fffffffdd30, name=..., data=...) at src/ld_so/linker.rs:152
 #6  0x00000000004831fe in relibc::ld_so::linker::Linker::load_recursive (self=0x7fffffffdd30, name=..., path=...) at src/ld_so/linker.rs:140
 #7  0x000000000048228a in relibc::ld_so::linker::Linker::load (self=0x7fffffffdd30, name=..., path=...) at src/ld_so/linker.rs:97
 #8  0x0000000000414a3b in relibc_ld_so_start (sp=0x7fffffffe310, ld_entry=4198896) at src/ld_so/start.rs:182
 #9  0x0000000000401209 in _start () at src/ld_so/src/lib.rs:10
 #10 0x0000000000000001 in ?? ()
 #11 0x00007fffffffe592 in ?? ()
 #12 0x0000000000000000 in ?? ()
2020-06-13 19:55:33 +02:00
Jeremy Soller 68679e41f0 Add redoxer.sh script to simplify running tests on redox 2020-06-09 20:55:55 -06:00
Jeremy Soller b771313ffd Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2020-06-07 14:01:00 -06:00
Jeremy Soller b0dde81c75 Handle missing paths in load_library search without using access 2020-06-07 14:00:48 -06:00
Jeremy Soller 7bc11dc6c2 Merge branch 'relibc-netdb-v1' into 'master'
netdb: implement getnetbynane and getnetent

See merge request redox-os/relibc!278
2020-06-07 12:27:54 +00:00
Giuseppe Longo 12beb13987 netdb: implement getnetbynane and getnetent
This patch implements getnetbyname and getnetent functions.
2020-06-07 14:02:41 +02:00
Jeremy Soller d9bacaec04 Fix compilation on Redox by removing use of access in ld_so 2020-06-06 21:00:57 -06:00
Jeremy Soller d0c1160299 Merge branch 'scanf' into 'master'
Scanf

See merge request redox-os/relibc!277
2020-06-06 19:32:54 +00:00
oddcoder 92d6735e3f Add more scanf tests 2020-06-03 23:20:53 +02:00
oddcoder 8973535fdc Make scanf write to string and increase match count only when a pattern is matched
This is the behavior of glibc which I assume to be right
2020-06-03 23:20:52 +02:00
oddcoder 018f7a3f38 Fix scanf.stdout as per glibc 2020-06-03 23:20:52 +02:00
oddcoder a49139ca2f use lookahead buffer in inner_scanf 2020-06-03 23:20:52 +02:00
oddcoder 14e011b72c Implemment lookaheadreader with lookahead and commit api
The LookAheadReader api works similar to read but it has 2 methods,
lookahead: it will read 1 byte (with internal ftell) without modifying
the file's own ftell() and commit() which saves the current file ftell

LookAheadReader can wrap both buffers and files
2020-06-03 23:20:52 +02:00
oddcoder f068673adc Separate the logic from locking in ftello and fseeko 2020-06-03 23:20:52 +02:00
oddcoder 164ef739b3 Apply Cargo fmt for src/ld_so 2020-06-03 23:20:52 +02:00
Jeremy Soller 12d3838f42 Merge branch 'fpermissive' into 'master'
FIX error: right operand of shift expression '(1 << BLA)' is greater than or...

See merge request redox-os/relibc!276
2020-06-02 21:52:17 +00:00
no name c02849dd73 FIX error: right operand of shift expression '(1 << BLA)' is greater than or equal to the precision BLA of the left operand [-fpermissive] 2020-06-02 23:27:15 +02:00
Jeremy Soller 5aa74fd2f3 Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2020-06-02 08:35:41 -06:00
Jeremy Soller 604f1c11a2 Build xargo locally 2020-06-02 08:35:37 -06:00
Jeremy Soller b165eacffd Remove unnecessary compiler-builtins patch 2020-06-02 08:30:06 -06:00
Jeremy Soller e7f5e412a1 Merge branch 'LD_LIBRARY_PATH' into 'master'
Ld library path

See merge request redox-os/relibc!275
2020-06-01 12:23:46 +00:00
oddcoder 3aacc160a1 Remove dependency on errno in ld.so
During early parts of ld.so, errno and other thread local variables are
not yet initialized so we cannot use function (such as unistd::access)
that depends on such thread local variables (errno). For this reason
this patch creates small wrapper around the syscall that doesn't not
touch the errno
2020-06-01 11:49:38 +02:00
oddcoder 1b10c3d246 Prioterize search path instead of overwriting it.
Current LD_LIBRARY_PATH implementation overwrites the original search
path, which is not the best idea, instead this patch would check
LD_LIBRARY_PATH first and if it didn't find the libraries it is looking
for, then it will search the original search path
2020-06-01 11:41:19 +02:00
Jeremy Soller c7910a8754 Add __need_winit_t to wctype.h 2020-05-28 13:43:55 -06:00
Peter Limkilde Svendsen e4a7186b22 Use C type names in byteorder functions 2020-05-28 20:17:57 +02:00
Jeremy Soller ae34ade595 Use path to patch compiler-builtins 2020-05-27 20:24:59 -06:00
Jeremy Soller 8de10072b6 Add compiler-builtins patch 2020-05-27 20:18:52 -06:00
Peter Limkilde Svendsen ac52c3f205 Replace mem::uninitialized() 2020-05-26 17:58:59 +02:00
Peter Limkilde Svendsen b15c90ee32 Add test for ctime_r() 2020-05-26 00:20:14 +02:00
Jeremy Soller b2338968a2 Merge branch 'alignment-test-nullcheck' into 'master'
Don't accept null pointer in tests when requesting aligned memory

See merge request redox-os/relibc!272
2020-05-24 19:19:12 +00:00
Jeremy Soller 39346f5c05 Merge branch 'simplify-posix_memalign' into 'master'
Minor fixes to posix_memalign()

See merge request redox-os/relibc!271
2020-05-24 19:18:53 +00:00
Peter Limkilde Svendsen cf9c2ed0ba Don't accept null pointer when requesting aligned memory 2020-05-24 18:39:53 +02:00
Peter Limkilde Svendsen da8d2fa7aa Always set memptr in posix_memalign() 2020-05-24 18:29:57 +02:00
Peter Limkilde Svendsen 60b23003c7 Simplify alignment check in posix_memalign() 2020-05-24 18:17:27 +02:00
Jeremy Soller e4c26cfaa0 Merge branch 'gcc-regressions' into 'master'
Gcc regressions

See merge request redox-os/relibc!270
2020-05-23 15:16:36 +00:00
oddcoder 7eba6d88df Add test for negative pad stupport in printf 2020-05-23 16:20:20 +02:00
oddcoder ee5e2bad5a Support negative padding size in printf and friends
as it seams you can do something like
        printf ("A%*s%s/\n", -5, "B", "CC");
and it will print the padding to the left
2020-05-23 16:20:20 +02:00
oddcoder 1b131b8c60 Test off by one bug in vfscanf 2020-05-23 16:20:20 +02:00
oddcoder d7d3e00867 Fix off-by-1 error in vfscanf
Scanf function requires look ahead to function properly, In case of
scanning from a buffer that will not be an issue, but in our case we are
reading from file, so lookaheads needs to be undone (via lseek) in our
case. The only problem here is that if we opened a file that doesn't
support lseek such as many of the file /dev/*
2020-05-23 16:20:20 +02:00
oddcoder 6fba592fdb Implement regression test for ftell-ungetc bug 2020-05-23 16:20:20 +02:00
oddcoder 1733b3da6e Fix bug related to ungetc and ftell()
At least in relibc, each call to ungetc should decrement ftell() by one
also allowing negative ftell() this is not possible on relibc thus gcc
failing to compile (gcc compiles tools that is later used to compile gcc
itself and these tools are the ones that fail)
2020-05-23 16:20:20 +02:00
oddcoder 49dec86a5d Unit test arbitrarily long ungetc() 2020-05-23 16:20:20 +02:00
oddcoder 7a6f96373e Add support for multiple unget at the same time
According to the standards, only one ungetc may be guaranteed however
glibc allows more than one of those, and to be glibc compatiable, one
needs to be able to do the same, allowing only 1 ungetc may trigger bug
while compiling gcc as ungetc is used there alot
2020-05-23 16:20:20 +02:00
oddcoder 4c94dfac00 Add type definition for caddr_t
Normally one shouldn't be using this datatype ever, but then someone
have to tell that to gcc folks :(
2020-05-23 16:20:20 +02:00
Jeremy Soller 0cc0fbecdc Export getrandom function 2020-05-22 15:49:51 -06:00
Jeremy Soller a6fffd3fb5 Add getrandom and sys/random.h 2020-05-22 11:50:54 -06:00
Jeremy Soller 2cf3ccae72 Fix import of user_regs_struct 2020-05-21 20:01:47 -06:00
Jeremy Soller a1034b697d Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2020-05-21 14:59:41 -06:00
Jeremy Soller 06429ccc4c Fix redox socket inner_get_name 2020-05-21 14:59:22 -06:00
Jeremy Soller f6a119d3fc Merge branch 'binutils_regressions' into 'master'
Binutils regressions

See merge request redox-os/relibc!269
2020-05-13 22:02:31 +00:00
oddcoder 43fbaf9970 Fix a bug in thread local reloations
There was a bug (also uncovered via binutils) where R_X86_64_DTPOFF64 is
set uncorrectly. This program is the minimal reproducer of the seg fault

  #include <errno.h>
  int main() {
        int oerrno = errno;
  }

But it works after the bug fix.
2020-05-13 23:46:39 +02:00
oddcoder a39447e6a4 Test printf space padding regression 2020-05-08 22:38:42 +02:00
oddcoder d373bcb032 Avoid accessing memory without initialization 2020-05-08 22:38:42 +02:00
oddcoder 4a47bc4a6f Fix regressing in printf padding with space
There was bug in printf where space paddings cause segfault,
the problem was that it was pulled from the stack twice while it should
be only done once.
2020-05-08 22:38:42 +02:00
oddcoder d62f9b6819 Fix regression in ld.so elf size calculation
In patch 1182d12006, I mistakingly added
the size of the gap to the total size of the binary, which was not
accurate. As the size of the binary was calculate by subtracting the
upperbound from the lower bound, thus all gaps in the middle are taking
into account.
2020-05-08 22:38:42 +02:00
Jeremy Soller 8b7c45b39e Merge branch 'ld.so_regressions' into 'master'
Ld.so regressions

See merge request redox-os/relibc!268
2020-05-03 13:16:43 +00:00
oddcoder 850dfd971b Make "./a.out" entry the first in rmap list
This fixes a regression in gdb where sometimes it decides to ignore the
first entry in the list.
2020-05-03 14:59:55 +02:00
oddcoder 67be05d3a3 Use segments instead of sections for calculating which offset to write,
I noticed that the implementation is noth precise although it worked.
and instead of using the sections to identify memory addresses of
DT_DEBUG. I used segements
2020-05-03 14:59:52 +02:00
oddcoder 1182d12006 Fill gaps in binary memory image
Some ELFs can have gaps between the segments, this results in problems
when mprotecting or when converting (addr + size) into rust slice.
Motivated by this This patch will fill these gaps with mmaped addresses.
In theory no real memory should be allocated because mmap is lazy
allocator.
2020-05-03 13:57:24 +02:00
Jeremy Soller c799dad4e9 Merge branch 'wide-strings' into 'master'
Wide strings Functions

See merge request redox-os/relibc!267
2020-05-02 12:56:51 +00:00
oddcoder e9615065ac Add tests for both wcsncasecmp and wcscasecmp 2020-04-26 19:13:03 +02:00
oddcoder eac69c920d Implement wcscasecmp and wcsncasecmp
This patch implements wcscasecmp and wcsncasecmp. These two
function are required for binutils to link against relibc.
2020-04-26 19:13:03 +02:00
oddcoder 9725d3418a Test towlower and towupper 2020-04-26 19:13:03 +02:00
oddcoder 162999ac0b Move towlower and towupper to wctype.h and Implement it
This patch creates wctype.h and impelementat two functions
that belong to that header file towupper and towlower. These
functions are building blocks for wcscasecmp and wcsncasecmp
which are utilized by binutils.

The implementation for towlower and towupper seams to be complex
so this implementation is mimicking that of musl libc
2020-04-26 19:13:03 +02:00
Jeremy Soller a8a73f87c7 Merge branch 'procfs' into 'master'
Implement #include<sys/user.h> and #include<sys/procfs.h>

See merge request redox-os/relibc!266
2020-04-24 22:47:59 +00:00
oddcoder 3a923aa62d Implement #include<sys/user.h> and #include<sys/procfs.h>
This patch implements sys/user.h file that works for both x86_64 as well
as aarch64. This include file is used by sys/procfs.h which is needed
dependency for binutils. There is bug in this patch in aarch64 implementation
which is the lack of f128 implementation in rust, thus we can't create cbinding
for long double.
2020-04-24 22:08:49 +02:00
Jeremy Soller 763bb2488d Merge branch 'init_fini_ld.so' into 'master'
Init fini ld.so

See merge request redox-os/relibc!265
2020-04-19 12:40:00 +00:00
oddcoder b717f6cf5a Move IO Initialization to .init_array section
Most shared object in linux have their initialization in a separate
.init_array section. but glibc does not have the same behavour. Instead
the initialization is part of crt0. which (as it seams to me) run after
.init_array section. As such, this patch move IO initialization to
separate function that is marked as .init_array member and then the crt0
call this function only if init_array was never invoked (as in
statically linked binaries).
2020-04-19 14:21:23 +02:00
oddcoder 6aeb2d6fa2 Implement code that use .init_array and .fini_array
This patch implements ld.so code that makes use of both .init_array and
.fini_array. .init_array is fully utilized and is used in the correct
manner. However .fini_array is not used yet although the function that
runs .fini_array exists
2020-04-19 14:21:23 +02:00
oddcoder cc7ff54d12 Catch circular dependency when resolving loading shared libraries
This patch implements tree-based data-structure for catching circular
dependency where libA.so will depen on arbitrarily long chain (including
zero length) of libNs.so one of which will depend on libA.so again. The
main intention of this patch was merely capturing the dependency tree to
prioterize which Elf's .init_array and which .fini_array should run
first, but as a side effect it can capture circular dependencies as well.
2020-04-19 13:28:53 +02:00
Jeremy Soller 7724989b33 Merge branch 'Debugger_Support' into 'master'
Debugger support

See merge request redox-os/relibc!263
2020-04-15 17:59:01 +00:00
Jeremy Soller 77ad82a9dd Merge branch 'sigaction-restore' into 'master'
sigaction should set sigaction.sa_restorer

See merge request redox-os/relibc!264
2020-04-15 17:56:27 +00:00
Graham MacDonald 2283e25cde sigaction should set sigaction.sa_restorer 2020-04-14 23:37:54 +01:00
oddcoder de03566158 Enable RTLD debugging protocol system-wide
This patch makes use of the data structures and functions impelemented
in the last patch to enable RTLD debugging protocol as per SVR4
2020-04-13 12:39:51 +02:00
oddcoder 369d7b42c6 Initial implementation of SVR4 debugging interface for runtime linker 2020-04-13 12:12:48 +02:00
Jeremy Soller cdbbd4a426 Merge branch 'cbindgen' into 'master'
Remove vendored cbindgen, use cbindgen dependency to generate includes in build.rs

See merge request redox-os/relibc!261
2020-04-10 23:05:58 +00:00
Graham MacDonald 2253ef609e Remove vendored cbindgen, use cbindgen dependency to generate includes in build.rs 2020-04-10 23:05:58 +00:00
Jeremy Soller 69fc62278a Merge branch 'use_kernel_loaded_elf' into 'master'
Use Kernel mapped binaries when available.

See merge request redox-os/relibc!262
2020-04-07 21:42:37 +00:00
oddcoder cc305fc574 Use Kernel mapped binaries when available.
At least in linux kernel, assuming that a.out is an elf that is linked
against relibc's own ld.so. When a user attempts `./a.out`, Linux kernel
will map `./a.out`, then map `ld.so` and jump into ld.so entry point.
In relibc ld.so will simply ignore the kernel mapped a.out and create
its own mapping. This patch forces relic ld.so to use the already mapped
`a.out` when ever possible. This would normally have slight performance
improvement (especially that currently relibc doesn't map a.out but
instead copy the data into empty mmaped memory).

The real motivation behind this patch is while impelemnting Runtime
linker debugging protocol for relibc. part of the protocol is ld.so
inseting address of some ld.so managed data structure into .dynamic
seciton of a.out then the debugger would check it there. The thing is
that debuggers have information about the kernel loaded ./a.out and they
check that one specifically which is in our case totally ignored by
relibc.
2020-04-07 21:26:58 +02:00
Jeremy Soller 701e64b3a1 ld_so: Default to non-verbose 2020-03-29 20:17:29 -06:00
Jeremy Soller d7a859fb84 Keep exported functions 2020-03-24 20:05:38 -06:00
Jeremy Soller 6ed37efaeb Merge branch 'weak-symbols' into 'master'
Weak symbols

See merge request redox-os/relibc!260
2020-03-19 17:56:22 +00:00
Jeremy Soller 2629918100 Fix issue if test:redox is run without build:redox 2020-03-10 21:12:40 -06:00
Jeremy Soller 0090396132 Run cargo test 2020-03-10 21:03:52 -06:00
Jeremy Soller 880e3c7854 Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2020-03-10 20:57:13 -06:00
Jeremy Soller 2e27cf525e Work on adding cargo test capability 2020-03-10 20:57:07 -06:00
oddcoder 4860ab12fa Resolve Both strong and weak symbols
This patch keep 2 lists, one for strong symbols and one for weak
symbols. First it will check for the symbol to be resolved in the strong
symbols' list, if it is not there it will then check in the weak symbol
list.
2020-03-08 22:03:21 +02:00
oddcoder c2488b5094 Running ./fmt.sh
These files needs formating by the auto formatter and It keeps popping
up every time I format my own code.
2020-03-07 23:52:27 +02:00
oddcoder 04ea2f9397 Refactor Linker::Link
This patch does basically two things:
- First make `global` variable not public, And make it accessable via a
function `get_sym`.
- Isolate the procedure that collect global symbols into single function
that does that and call it `collect_syms`.

The motivation of this patch is the second one where this procedure is
extended, thus it needs a seamless way to access those symbols
2020-03-07 23:52:27 +02:00
Jeremy Soller 77a0294114 Merge branch 'stdc-compatiability' into 'master'
Stdc compatiability

See merge request redox-os/relibc!258
2020-03-06 03:58:42 +00:00
oddcoder 3ac6ef1848 Adjust stddef.h to be compatiable with other libc(s)
I faced many issues when compiling libstdC++-V3 and linking against
relibc mainly:
- Missing types (max_align_t)
- Different types definitions(ptrdiff_t , size_t)
- and the fact that wchar_t is part of standard C++ and it seams that we
  canno redefine standard types
2020-03-02 00:06:49 +02:00
oddcoder a2f2484e45 Add minimal basic features.h resembling musl lib's own 2020-03-01 22:59:39 +02:00
Jeremy Soller 79f265745a Fix redox ld_so 2020-02-28 19:33:20 -07:00
Jeremy Soller b1aad49df4 Merge branch 'linux-ld' of gitlab.redox-os.org:oddcoder/relibc 2020-02-28 19:12:19 -07:00
oddcoder bc53164293 Reduce Verbosity level when ld.so is invoked as interpreter 2020-02-24 11:56:12 +02:00
oddcoder 7f8dc2f251 Add support for invoking ld.so via execve() and friends
Introduction:

The original implementation of `relibc_ld_so_start` assumes that
ld.so will always be invoked manually as in "/lib/ld64.so ./a.out"
The problem is regarding this snippet.
    if sp.argc < 2 {
      eprintln!("ld.so [executable] [arguments...]");
      unistd::_exit(1);
      loop {}
    }

As such, In linux when user types "./a.out" he will recieve the message
    ld.so [executable] [arguments...]

This patch makes use of AUXV, specifically AT_ENTRY. When invoking ld.so
manually, AT_ENTRY happens to be the entry point of ld.so. But when
running `./a.out` directly, AT_ENTRY becomes the entry point of `a.out`
this patch compares AT_ENTRY to the entry point of ld.so, if they are
equal only then it will assume that argv[1] is the real program and
adjust the stack, otherwise it will proceed with the stack unadjusted.
2020-02-24 11:56:09 +02:00
Jeremy Soller e85148cc15 Merge branch 'oddcoder-master-patch-78534' into 'master'
Fix make libs in CI

See merge request redox-os/relibc!256
2020-02-18 17:09:48 +00:00
Ahmed Abd El Mawgood 9f86748a58 Fix make libs in CI
There is no make libc

➜  relibc git:(master) make libc
make: *** No rule to make target 'libc'.  Stop.
2020-02-14 18:42:38 +00:00
Jeremy Soller 3d2f86b39e Merge branch 'feature/support-af-unix-sockets' into 'master'
Support AF_UNIX sockets

See merge request redox-os/relibc!255
2020-02-07 02:19:42 +00:00
Tiago Lam 76f07b163b platform/redox: Support AF_UNIX in accept.
As with the previous commit, accept() was calling inner_get_name() and
assuming only "tcp:" or "udp:" addresses would be received. Thus, in
order to support AF_UNIX sockets, inner_get_name() was split into two,
inner_af_inet() and inner_af_unix() - where the former keeps the
previous logic, dealing with "tcp:" and "udp:" addresses, and the latter
deals now with "chan:" addresses and filling in the sockaddr_un
appropriately.
2020-02-06 08:41:51 +00:00
Tiago Lam d36cd72788 platform/redox: Support AF_UNIX in bind / connect.
Previously, domain AF_INET was assumed while processing bind() /
connect(), which end up calling bind_or_connect!. Instead, match on the
domain type and process the path for AF_UNIX domains.
2020-02-06 08:41:48 +00:00
Tiago Lam 12f6ffd152 platform/redox: Support AF_UNIX in socket.
To add support for UNIX sockets (AF_UNIX), of SOCK_STREAM type, the
"chan:" scheme is used, which will be supportedby the ipcd running in
userspace.

Later commits add similar AF_UNIX support for the rest of the methods in
impl PalSocket.
2020-02-06 08:21:12 +00:00
Tiago Lam 2bc667f71c header/sys_un: Set sockaddr_un members to public.
Future commits will make use of this, in order to support AF_UNIX
sockets.
2020-02-06 08:21:12 +00:00
Jeremy Soller 662051a91b Only call epoll_ctl once per descriptor, fixing vim on Redox 2020-01-28 20:15:01 -07:00
Jeremy Soller 4c4ce7ec03 Add Redox termios definitions 2020-01-27 21:01:59 -07:00
Jeremy Soller 9a449d4f6c Stub for SO_ERROR to fix curl 2020-01-21 20:29:26 -07:00
Jeremy Soller 2e5d4a4d25 Merge remote-tracking branch 'origin/truncate-n-mkfifo' 2020-01-20 11:17:15 -07:00
Jeremy Soller 1534373645 Merge branch 'ctype_conv' into 'master'
Use lossless type conversion in ctype.h

See merge request redox-os/relibc!246
2020-01-20 17:57:56 +00:00
Peter Limkilde Svendsen 0b4b3cd55c Use lossless type conversion in ctype.h 2020-01-20 17:57:56 +00:00
Jeremy Soller 10f2e0fefc Merge branch 'fd-dup-test-robusty' into 'master'
Fix fd dup tests to be more robust

See merge request redox-os/relibc!251
2020-01-20 17:48:43 +00:00
Jeremy Soller c6e3cb8ed3 Merge branch 'no-uninit' into 'master'
Replace occurences of uninitialized with MaybeUninit

See merge request redox-os/relibc!248
2020-01-20 16:54:22 +00:00
AdminXVII 884ec85838 Replace occurences of uninitialized with MaybeUninit
mem::uninitialized is deprecated, so move over the not-UB MaybeUninit.
2020-01-20 16:54:22 +00:00
Jeremy Soller 7d6288abbe Merge branch 'samuela-master-patch-09777' into 'master'
Fix ar usage in Makefile for macOS compatibility

See merge request redox-os/relibc!253
2020-01-20 16:41:24 +00:00
Jeremy Soller f167081f84 Merge branch 'fix-test' into 'master'
Re-enable netdb tests, fix compiler warning, improve brk coverage

See merge request redox-os/relibc!254
2020-01-20 16:22:09 +00:00
Graham MacDonald 18e1a5608f Re-enable netdb tests, fix compiler warning, improve brk coverage 2020-01-13 22:22:40 +00:00
samuela 0be4208aa7 Fix ar usage in Makefile for macOS compatibility 2020-01-08 17:59:38 +00:00
Jeremy Soller a3f7a174f6 WIP - implementation of dlfcn 2019-12-18 21:21:25 -07:00
Jeremy Soller 2cbc78f238 Add linker pointer 2019-12-18 21:15:00 -07:00
Jeremy Soller 36eb561128 Format 2019-12-18 20:01:48 -07:00
Jeremy Soller 086c8f6702 Allow running linker more than once 2019-12-17 21:35:47 -07:00
Jeremy Soller 0a06388d2a Store globals and mappings on Linker struct 2019-12-16 21:27:42 -07:00
Jeremy Soller b882ce527d Fix allocation of TLS masters if main image does not require TLS 2019-12-15 11:19:37 -07:00
Jeremy Soller 4818ad61ab Always zero mmap'd memory 2019-12-15 07:46:59 -07:00
Jeremy Soller 886f859bb9 Clear FPU registers before jumping to loaded program 2019-12-15 07:46:49 -07:00
Jeremy Soller 76798b7d6b Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2019-12-06 19:55:21 -07:00
Jeremy Soller fe3607d4e8 ld_so: Zero mapped memory and panic on unsupported relocation 2019-12-06 19:54:54 -07:00
Jeremy Soller 5baec1e4e8 Merge branch 'printf-inf-nan' into 'master'
Handle infinity and NaN in printf

See merge request redox-os/relibc!252
2019-12-05 01:37:17 +00:00
Peter Limkilde Svendsen 74555698fb Handle infinity and NaN in printf 2019-12-05 01:37:17 +00:00
Sean Kennedy a1c3510761 Fix fd dup tests to be more robust
i.e. not depending on the first fd to be 4.
2019-12-02 14:53:55 -05:00
Jeremy Soller 8ba70792e9 Implement DTPOFF64 2019-12-01 13:47:06 -07:00
Jeremy Soller 2ac349d2d2 Add msync function and stub for Redox 2019-12-01 10:58:47 -07:00
Jeremy Soller 15e6d23538 Update rust-toolchain 2019-11-29 18:06:12 -07:00
Jeremy Soller e3ce41da79 Fix compilation on newer nightly 2019-11-29 18:05:31 -07:00
Jeremy Soller 3db0588de0 Merge branch 'ctime_r' into 'master'
added ctime_r

See merge request redox-os/relibc!250
2019-11-28 02:41:58 +00:00
Andrzej J. Skalski 278a70c813 added ctime_r 2019-11-28 02:41:58 +00:00
Jeremy Soller 631fd4f0f5 Merge branch 'wcsstr' into 'master'
Implement wcsstr(), fix return type of wcslen()

See merge request redox-os/relibc!249
2019-11-14 02:46:53 +00:00
Peter Limkilde Svendsen 0b2c3fe5ea Implement wcsstr(), fix return type of wcslen() 2019-11-14 02:46:53 +00:00
Jeremy Soller ae69586f20 Implement getrlimit on Linux and stub on Redox 2019-09-18 20:29:25 -06:00
Jeremy Soller 46a330ec9e Fix compilation of sys/resource 2019-09-18 15:55:27 -06:00
Xavier L'Heureux f53e9b5d9a Remove the mkfifo test 2019-09-17 21:41:03 -04:00
Xavier L'Heureux e8b8b7eb25 Fix format and disable stat check for access time 2019-09-17 21:23:07 -04:00
Xavier L'Heureux 64f93fe6e0 Implement the truncate function 2019-09-17 19:57:43 -04:00
Xavier L'Heureux 5156a13b3e Add a test for futimens 2019-09-16 12:25:29 -04:00
Jeremy Soller 64dde1548c Merge branch 'patch-2' into 'master'
sys/uio.h: include sys/types.h

See merge request redox-os/relibc!244
2019-09-15 19:34:43 +00:00
Jeremy Soller 3b12a400bf Merge branch 'lcg48_refactor' into 'master'
lcg48 refactor

See merge request redox-os/relibc!243
2019-09-15 19:34:12 +00:00
Peter Limkilde Svendsen 7fdd450e16 lcg48 refactor 2019-09-15 19:34:12 +00:00
Jeremy Soller cc4c3a5cb4 Merge branch 'a64l_l64a_refactor' into 'master'
Refactor of a64l and l64a

See merge request redox-os/relibc!242
2019-09-15 19:33:29 +00:00
Peter Limkilde Svendsen a80ec357e3 Refactor of a64l and l64a 2019-09-15 19:33:29 +00:00
Jeremy Soller d1d45ff00d Merge branch 'warning' into 'master'
Fix few warnings

See merge request redox-os/relibc!236
2019-09-15 19:31:08 +00:00
Jeremy Soller f4b8847605 Merge branch 'mut-program_invocation_name' into 'master'
Make program_invocation_name modifiable

See merge request redox-os/relibc!240
2019-09-15 19:30:31 +00:00
Xavier L'Heureux 30d3cd5c88 Fix the mkfifo call on Linux and add a test to avoid regression 2019-09-13 12:35:08 -04:00
Matija Skala 81470916be sys/uio.h: include sys/types.h
needed for ssize_t
2019-09-08 08:36:22 +00:00
Steve McKay 4859c222e7 Make program_invocation_name modifiable
libiconv expects program_invocation_name to be an lvalue
2019-08-17 12:35:43 -04:00
jD91mZM2 4f2a93ea90 Vast refactor of pwd.h, add getpwent/setpwent/endpwent 2019-08-12 09:58:11 +02:00
jD91mZM2 aeab6a986d Fix a few GDB compilation issues 2019-08-12 09:30:05 +02:00
Jeremy Soller 8f502a3436 Merge branch 'fix-signal' into 'master'
Fix invalid memory reference in signal and sigaction

See merge request redox-os/relibc!239
2019-08-12 02:54:28 +00:00
Xavier L'Heureux 5799555566 Remove print statements 2019-08-11 21:53:32 -04:00
Xavier L'Heureux f2357390e9 Fix redox's implementation 2019-08-11 21:06:47 -04:00
Xavier L'Heureux 0a558de76c Fix reference getting moved
The sigaction handler called map on an option, creating a pointer to a
move value. This in turned caused UB for signal handlers. Avoid using
pointers directly, and instead prefer references.
2019-08-11 20:47:18 -04:00
Xavier L'Heureux 225583230f Test 2019-08-11 18:11:19 -04:00
Xavier L'Heureux 4c7f8c6369 test signals 2019-08-11 14:30:00 -04:00
Jeremy Soller 37a5da34b9 Fix pte_osSemaphorePend deadlock 2019-08-09 21:18:20 -06:00
Jeremy Soller e7d19e2a58 Move SIG_IGN and friends to C in order to define them correctly 2019-08-08 20:06:38 -06:00
Jeremy Soller 8feed5bbd5 Update Rust to 2019-08-08 2019-08-07 20:48:29 -06:00
jD91mZM2 a7b354c8e0 Update to latest syscall after merging ptrace 2019-08-04 19:46:10 +02:00
jD91mZM2 a1e45941bf Fix ptrace after latest kernel changes 2019-08-04 19:05:45 +02:00
jD91mZM2 b8c50c7c64 Format 2019-08-04 19:05:45 +02:00
jD91mZM2 c7d499d4f2 Upgrade to the 2018 edition
I didn't think it'd be this useful first, but thank god for `cargo fix --edition`!
2019-08-04 19:05:45 +02:00
jD91mZM2 72c2f59f17 Update redox_syscall to use bitflags 2019-08-04 19:05:45 +02:00
jD91mZM2 82abb3313e Support adding WUNTRACED 2019-08-04 19:05:45 +02:00
jD91mZM2 f389010fff Initial ptrace compatibility for Redox OS 2019-08-04 19:05:45 +02:00
jD91mZM2 7f702720af Fix header file generation for ptrace 2019-08-04 19:05:44 +02:00
jD91mZM2 43ff8801bc Format 2019-08-04 19:05:44 +02:00
jD91mZM2 35c1d5210c Implement the Once<T> synchronization structure
Not sure if I should add a RwLock for the ptrace state too...
2019-08-04 19:05:44 +02:00
jD91mZM2 e559a3e2e5 Stub for ptrace
It's happening...
2019-08-04 19:05:44 +02:00
Jeremy Soller a2721b8a31 Merge branch 'cbindgen' into 'master'
Fix cbindgen for disabled headers

See merge request redox-os/relibc!237
2019-07-31 14:07:35 +00:00
Mateusz Mikuła bd573fb7cc Fix cbindgen for disabled headers 2019-07-31 12:39:28 +02:00
Jeremy Soller f467791b12 Fix definition of SIG_ERR 2019-07-25 21:27:41 -06:00
jD91mZM2 cb63dec86f Add missing SIG_DFL and SIG_IGN constants 2019-07-25 17:34:59 +02:00
Jeremy Soller 25e67b9f58 Add setsockopt support for SO_RCVTIMEO and SO_SNDTIMEO 2019-07-24 17:18:01 -06:00
Jeremy Soller 9d7ec9b146 Fix getcwd on Redox 2019-07-21 07:57:31 -06:00
Mateusz Mikuła 9aac2672e3 Fix few warnings 2019-07-18 15:27:05 +02:00
Jeremy Soller f1be9266e2 Merge branch 'defines-cleanup' into 'master'
Remove defines that are generated by new cbindgen from bits

See merge request redox-os/relibc!234
2019-07-18 12:04:01 +00:00
Jeremy Soller aba76239b3 Merge branch 'ci' into 'master'
Don't use diff on Redox

See merge request redox-os/relibc!233
2019-07-18 11:55:54 +00:00
Mateusz Mikuła b599c453a0 Remove defines that are generated by new cbindgen from bits 2019-07-18 13:18:00 +02:00
Mateusz Mikuła c40b7d6fb4 Don't use diff on Redox 2019-07-18 13:01:22 +02:00
jD91mZM2 a8280e8991 Implement wcstol, wcstod, and printf:ing wchars 2019-07-18 12:29:22 +02:00
jD91mZM2 7c99077248 Implement wcstok 2019-07-18 08:15:40 +02:00
jD91mZM2 a2c8cfb4a5 Implement CVec, an abstraction to return vectors from Rust 2019-07-18 06:40:23 +02:00
jD91mZM2 c85145b5d1 Merge branch 'memoffset-update' into 'master'
Update memoffset to fix soundness issues

See merge request redox-os/relibc!232
2019-07-13 08:57:18 +00:00
Mateusz Mikuła 87bcc943e2 Update memoffset to fix soundness issues 2019-07-12 19:43:09 +02:00
jD91mZM2 29b5b989eb Format 2019-07-11 18:20:27 +02:00
jD91mZM2 1a0f72dad8 Fix CI & compatibility with older rust 2019-07-11 18:18:17 +02:00
jD91mZM2 57917c0e92 Fix various floating point issues in printf 2019-07-11 18:09:37 +02:00
Jeremy Soller 4621a824a8 Merge branch 'sigaltstack' into 'master'
Fix sigaltstack

See merge request redox-os/relibc!230
2019-07-10 12:34:24 +00:00
Mateusz Mikuła 799c10073d Fix sigaltstack 2019-07-10 14:01:43 +02:00
jD91mZM2 a6d6d2cfb0 Merge branch 'cbindgen-update' into 'master'
Cbindgen update

See merge request redox-os/relibc!229
2019-07-10 10:08:39 +00:00
Mateusz Mikuła 63a1319e50 Cbindgen update 2019-07-10 10:08:39 +00:00
Jeremy Soller 05f71567ab Format 2019-07-06 19:37:13 -06:00
Jeremy Soller 6a97b47d3f Do not expect unistd/isatty 2019-07-06 19:32:01 -06:00
Jeremy Soller 84745ca770 Fix fsync on Redox 2019-07-06 19:27:42 -06:00
Jeremy Soller 7b406dbc61 Improve test output 2019-07-06 19:25:16 -06:00
Jeremy Soller 06bab2aa81 Fix Redox fchdir 2019-07-06 19:25:05 -06:00
Jeremy Soller 27d97f6fe0 Use O_DIRECTORY in unistd/fchdir 2019-07-06 19:21:11 -06:00
Jeremy Soller 2c3195d54b Ignore clock function in time/time 2019-07-06 19:09:24 -06:00
Jeremy Soller 634b2ed835 Use actual break in unistd/brk 2019-07-06 19:09:16 -06:00
Jeremy Soller e27b22f63c Do not test sys_epoll by default 2019-07-06 19:02:35 -06:00
Jeremy Soller eae28f6dd9 Fix scandir test on Redox 2019-07-06 18:39:41 -06:00
Jeremy Soller 5c0b37a229 Run verify script on Redox 2019-07-06 17:31:52 -06:00
Jeremy Soller a49badbb66 Build tests for redox 2019-07-06 12:57:13 -06:00
Jeremy Soller e146cb3687 Allow multiple definitions 2019-07-06 12:48:58 -06:00
Jeremy Soller 6448119fbc Update pthreads-emb 2019-07-06 11:32:34 -06:00
jD91mZM2 8656c80614 Merge branch 'sigaltstack' into 'master'
Add sigaltstack

See merge request redox-os/relibc!218
2019-07-05 12:29:53 +00:00
Mateusz Mikuła c8887900b9 Add sigaltstack 2019-07-05 12:29:53 +00:00
jD91mZM2 9fb9820b23 Merge branch 'clippy' into 'master'
Clippy fixes

See merge request redox-os/relibc!223
2019-07-04 14:47:08 +00:00
Mateusz Mikuła 6742e41948 Clippy fixes 2019-07-04 14:47:08 +00:00
Jeremy Soller 38099fe3d9 Fix definition of errno to match what is used by musl 2019-07-03 19:47:55 -06:00
Jeremy Soller 208b56b487 Revert "Allow multiple definition in ld_so to avoid linking issues"
This reverts commit b4c738eb62.
2019-07-01 16:52:19 -06:00
Jeremy Soller b4c738eb62 Allow multiple definition in ld_so to avoid linking issues 2019-07-01 16:44:07 -06:00
Jeremy Soller 456c829da8 Fix CI 2019-07-01 16:37:47 -06:00
Jeremy Soller 50be35d152 Update cbindgen 2019-07-01 16:36:41 -06:00
jD91mZM2 dc2d22b384 Merge branch 'thread_local' into 'master'
Make errno thread local

See merge request redox-os/relibc!228
2019-07-01 18:36:34 +00:00
jD91mZM2 3ae46d8616 Merge branch 'expected_alloc_test' into 'master'
Move alloc tests to expected-output tests

See merge request redox-os/relibc!226
2019-07-01 18:35:56 +00:00
Peter Limkilde Svendsen 70857f9980 Move alloc tests to expected-output tests 2019-07-01 18:35:56 +00:00
Mateusz Mikuła ff94798253 Make errno thread local 2019-07-01 16:51:19 +02:00
jD91mZM2 bf13674e11 Merge branch 'getpagesize_check' into 'master'
Use try_from in getpagesize(), add test

See merge request redox-os/relibc!225
2019-07-01 11:03:58 +00:00
jD91mZM2 3be933ec63 Merge branch 'alloc_cleanup' into 'master'
Alloc functions cleanup

See merge request redox-os/relibc!224
2019-07-01 11:02:10 +00:00
Peter Limkilde Svendsen 02e26006e7 Alloc functions cleanup 2019-07-01 11:02:10 +00:00
jD91mZM2 b43e1bf83b Merge branch 'l64a' into 'master'
Implement l64a()

See merge request redox-os/relibc!227
2019-07-01 10:59:37 +00:00
Peter Limkilde Svendsen 6cc5216c9c Implement l64a() 2019-07-01 10:59:37 +00:00
jD91mZM2 e35f22b3df WIP: pthread_atfork
WIP mainly because we *should* use thread locals, but #[thread_local]
causes segfaults.
2019-07-01 09:07:11 +02:00
jD91mZM2 f9dca89c1f Merge branch 'cleanup' 2019-07-01 08:39:09 +02:00
Jeremy Soller 6a069d1d9e Add static TLS init on Linux 2019-06-30 21:31:57 -06:00
Jeremy Soller 2a68c68dc6 Use the same Stack struct for ld_so start as for relibc start 2019-06-30 21:31:31 -06:00
Jeremy Soller a72c5f4aca Add static tls test 2019-06-30 21:30:34 -06:00
jD91mZM2 6203a85713 Fix thread-locals 2019-06-27 08:25:08 +02:00
jD91mZM2 ec7abebc0b Fix a very slight error in the mutex
This was just my attempt at being smart, I didn't realize
`compare_exchange` returned the old value (I'm dumb!), so I thought
that if the value was 1 then it must have become 2. Normally with
small errors like these you should leave a comment explaining why, but
really, compare and *exchange* is pretty obvious. My bad.
2019-06-27 07:29:30 +02:00
jD91mZM2 d704a35b85 Untested: Remove duplicate Mutex efforts in pte.rs
See #151
2019-06-27 07:29:30 +02:00
jD91mZM2 2f4e57f87a Fix data race inside puts(...) & add dbg!() macro 2019-06-26 21:21:32 +02:00
jD91mZM2 e929538098 Uncomment pthread_atfork stub to get ion to build 2019-06-16 14:59:04 +02:00
Peter Limkilde Svendsen 8b975877e6 Formatting 2019-06-14 00:07:36 +02:00
Peter Limkilde Svendsen 3b06380738 Add test for getpagesize() 2019-06-14 00:06:11 +02:00
jD91mZM2 651d38300a Merge branch 'master' into 'master'
Use cbitset crate instead of custom bitset implementation in select

See merge request redox-os/relibc!221
2019-06-13 12:31:30 +00:00
lmiskiew 43f1b582ae Use cbitset crate instead of custom bitset implementation in select 2019-06-13 12:31:30 +00:00
Peter Limkilde Svendsen 6e88617762 Use fallible conversion in getpagesize() 2019-06-12 23:47:11 +02:00
jD91mZM2 e84ea94dd0 Execute fmt.sh 2019-06-12 14:45:33 +02:00
jD91mZM2 c29237d360 Revert "Regenerate test output after !220"
Well I'm dumb... This test was already ran in a way that wasn't
verifying output, because this test outputs things that can
differ. Excuse me for not noticing!

This reverts commit 0af78b1e06.
2019-06-12 14:42:38 +02:00
jD91mZM2 0af78b1e06 Regenerate test output after !220 2019-06-12 11:45:06 +02:00
jD91mZM2 8db2f51706 Merge branch 'assert_fail' into 'master'
Rename __assert to __assert_fail

See merge request redox-os/relibc!212
2019-06-12 09:33:59 +00:00
jD91mZM2 d9ed51b9f1 Merge branch 'lcg48_arr' into 'master'
Implement remaining LCG functions

See merge request redox-os/relibc!219
2019-06-12 09:31:18 +00:00
jD91mZM2 3013c5db50 Merge branch 'posix_memalign' into 'master'
Implement posix_memalign()

See merge request redox-os/relibc!220
2019-06-12 09:27:48 +00:00
jD91mZM2 de70b2ae98 Merge branch 'master' into 'master'
Fix out-of-bounds error in strsignal

See merge request redox-os/relibc!222
2019-06-12 09:18:09 +00:00
Jason Hansel a5409ecd36 Fix out-of-bounds error in strsignal 2019-06-10 10:25:59 -04:00
Peter Limkilde Svendsen 626c713021 Formatting 2019-05-30 18:35:16 +02:00
Peter Limkilde Svendsen 02d1a7fe6f Implement posix_memalign 2019-05-30 18:28:15 +02:00
Peter Limkilde Svendsen 7a48107080 Run fmt 2019-05-23 21:48:43 +02:00
Peter Limkilde Svendsen dcff3fd836 Use y_from_x naming for functions 2019-05-23 21:40:06 +02:00
Peter Limkilde Svendsen fe4a3ae2b4 Refactor for consistency 2019-05-23 21:33:20 +02:00
Peter Limkilde Svendsen b2a9cdf930 Implement lcong48() and seed48() 2019-05-23 20:36:13 +02:00
Peter Limkilde Svendsen 767cf86b38 Refer to newer standard (with correct half-open output intervals) 2019-05-22 21:09:26 +02:00
Peter Limkilde Svendsen 13108776ae Implement erand48(), jrand48() and nrand48() 2019-05-22 18:48:19 +02:00
jD91mZM2 dab6530fb4 Merge branch 'valloc_pagesize' into 'master'
Make valloc() get page size through sysconf(), add tests

See merge request redox-os/relibc!216
2019-05-12 14:52:56 +00:00
jD91mZM2 f1b88d9ea0 Merge branch 'lcg48' into 'master'
Implement LCG pseudorandom number functions

See merge request redox-os/relibc!213
2019-05-12 14:50:18 +00:00
Peter Limkilde Svendsen 45860e9256 Implement LCG pseudorandom number functions 2019-05-12 14:50:18 +00:00
jD91mZM2 06ab5b7de2 Merge branch 'memrchr' into 'master'
Add memrchr()

See merge request redox-os/relibc!214
2019-05-12 14:13:22 +00:00
jD91mZM2 f3363af54d Merge branch 'housekeeping' into 'master'
Spring cleanup

See merge request redox-os/relibc!217
2019-05-12 14:11:24 +00:00
Mateusz Mikuła 5dd9c042d6 Update rust-toolchain 2019-05-11 22:34:14 +02:00
Mateusz Mikuła 7597c082e7 Fix Clippy warnings 2019-05-11 22:34:13 +02:00
Jeremy Soller 20a2355bc4 Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2019-05-11 10:05:45 -06:00
Jeremy Soller 2606266c3f If the prefix is recompiled, clzsi2 does not have to be removed. 2019-05-11 10:05:38 -06:00
Mateusz Mikuła 21a6701528 Rename __assert to __assert_fail
This makes relibc more compatible with other libc implementations
2019-05-11 13:50:36 +02:00
Mateusz Mikuła d62db7b1b9 Add memrchr() 2019-05-11 13:49:46 +02:00
Mateusz Mikuła 30f6a9c323 Cargo fmt 2019-05-11 13:48:03 +02:00
Peter Limkilde Svendsen f8cf25d76c Fix inaccurate comment 2019-05-11 11:44:36 +02:00
jD91mZM2 15aa52a8e9 Fix the CI; Disregard last commit
The race condition didn't trigger when I tested it, so I assumed I had
solved it...
2019-05-11 08:55:11 +02:00
jD91mZM2 123031dcfe Fix race condition in parallel Makefile
Some recipes require the headers, but they don't explicitly say
so. Parallel make (-j`nproc`) might start compiling the libs when the
headers aren't done yet.
2019-05-11 08:04:03 +02:00
Peter Limkilde Svendsen 54c5423f35 Avoid call to memalign() 2019-05-09 23:40:12 +02:00
Peter Limkilde Svendsen 8beb10b1bd Get page size through sysconf() 2019-05-08 23:20:30 +02:00
Peter Limkilde Svendsen f13bd7fdd1 Add tests for valloc 2019-05-08 22:08:13 +02:00
jD91mZM2 3be13d672f Fix the GitLab CI for Redox OS (finally!) 2019-05-08 17:14:10 +02:00
Jeremy Soller cfc541019c Add socketpair on Linux with stub on Redox 2019-04-28 19:12:54 -06:00
Jeremy Soller 75cb7033c7 Fix use of timeout in epoll_pwait on redox 2019-04-28 13:33:17 -06:00
Jeremy Soller d2cb0959f3 Fix redox epoll timeout 2019-04-28 13:10:34 -06:00
Jeremy Soller 6a9d070115 Fix time path, use c_str macro 2019-04-28 12:56:00 -06:00
Jeremy Soller 61dea7f52b Add all 3 epoll_ctl ops 2019-04-28 11:30:14 -06:00
Jeremy Soller 16083a6020 Remove epoll_ctl debug message 2019-04-28 11:27:52 -06:00
Jeremy Soller 8efa7a3ed8 Fixes for epoll on Redox 2019-04-28 11:27:01 -06:00
Jeremy Soller 3a5a7b3378 Support for native relibc compilation of tests 2019-04-28 11:00:27 -06:00
Jeremy Soller d6d01e5614 Allow custom sysroot to be specified 2019-04-28 10:49:44 -06:00
Jeremy Soller e6e31dd3b4 Format 2019-04-28 10:29:20 -06:00
Jeremy Soller f8fe67e7ba Merge remote-tracking branch 'origin/epoll' 2019-04-28 10:28:27 -06:00
Jeremy Soller 10fdea88f2 Bring in changes that were accidently lost 2019-04-28 10:26:10 -06:00
Jeremy Soller 54fb8b9b2b Fix select on regular files 2019-04-28 10:07:42 -06:00
Jeremy Soller ba711deb0d Convert select example to use pipes 2019-04-28 09:27:07 -06:00
Jeremy Soller 378ea3ac0e signal test is no longer expected 2019-04-28 09:14:05 -06:00
Jeremy Soller b399e87ef8 Add epoll test 2019-04-28 09:13:47 -06:00
Jeremy Soller dd9328bd41 Add pipe2 2019-04-28 09:13:24 -06:00
Jeremy Soller 68c4e95b6d Merge branch 'epoll' 2019-04-28 09:10:52 -06:00
Jeremy Soller c9a8674c61 Update pthreads-emb 2019-04-28 07:50:04 -06:00
Jeremy Soller 89b4fa80af Merge branch 'jD91mZM2/epoll' into 'epoll'
Add completely untested redox epoll implementation

See merge request redox-os/relibc!211
2019-04-28 13:18:50 +00:00
jD91mZM2 4c8f51ace9 Avoid allocations in redox epoll 2019-04-28 14:51:42 +02:00
Jeremy Soller be765f879d Merge branch 'master' into 'master'
Implement rand_r(), strnlen_s(), tempnam(), tmpnam()

See merge request redox-os/relibc!210
2019-04-28 12:18:50 +00:00
jD91mZM2 488981f9ec Add completely untested redox epoll implementation 2019-04-28 08:20:49 +02:00
Jeremy Soller 6d857f8db7 C flavored Rust doesn't taste good 2019-04-27 20:23:32 -06:00
Jeremy Soller 125e0e08da Add timegm 2019-04-27 19:58:41 -06:00
Jeremy Soller 5a34907033 Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2019-04-27 19:57:35 -06:00
Alex Lyon 68d3c5f1b1 Format code 2019-04-26 20:40:22 -07:00
Alex Lyon 3584edf199 stdio: implement tempnam() and tmpnam() 2019-04-26 20:39:03 -07:00
Alex Lyon 5bbce37789 string: add strnlen_s() 2019-04-26 20:36:37 -07:00
Alex Lyon 67af78d0eb stdlib: make rand()/rand_r() generate from [0, RAND_MAX] 2019-04-26 13:13:25 -07:00
Alex Lyon 13a10ce7af stdlib: implement rand_r() using XorShiftRng 2019-04-25 19:35:32 -07:00
Jeremy Soller 6a16275817 Fix warning, format makefile, and update depends 2019-04-24 19:50:57 -06:00
Jeremy Soller 6074616857 Merge branch 'strerror_r' into 'master'
Handle zero len for strerror_r

See merge request redox-os/relibc!209
2019-04-24 17:19:40 +00:00
Mateusz Mikuła 1ebd8a3d72 Handle zero length for strerror_r 2019-04-24 17:42:28 +02:00
jD91mZM2 87ba8f8a08 Merge branch '140-bufferedvalist-index-may-read-out-of-bounds' into 'master'
Resolve "BufferedVaList::index may read out of bounds"

Closes #140

See merge request redox-os/relibc!208
2019-04-23 18:36:00 +00:00
jD91mZM2 8fca7bcbc1 More printf tests and corner cases 2019-04-23 08:15:58 +02:00
jD91mZM2 0a0aec502b Fix #140 2019-04-23 07:34:06 +02:00
jD91mZM2 40d01d9d57 Convert printf internals to iterator 2019-04-22 16:25:29 +02:00
jD91mZM2 c2c8806f04 Merge branch 'malloc_errno' into 'master'
Set errno in alloc functions and add further tests

See merge request redox-os/relibc!205
2019-04-22 11:16:13 +00:00
Peter Limkilde Svendsen 912385b501 Set errno in alloc functions and add further tests 2019-04-22 11:16:13 +00:00
Jeremy Soller 7bde036031 Remove va_list submodule, format 2019-04-21 15:45:55 -06:00
Jeremy Soller b2cc25dd38 Fix missing import 2019-04-21 15:28:19 -06:00
jD91mZM2 6d4ac9dba8 Finally, get rid of all rust warnings
Just a small step along the way to reduce the massive wall of spam
every time you compile.

This was done partly automagically with `cargo fix`. The rest was me
deleting or commenting out a bunch of variables. Hope nothing was
important...
2019-04-21 21:12:16 +02:00
jD91mZM2 3a3fd3da39 Use the memchr crate
https://github.com/BurntSushi/rust-memchr is supposed to be a whole
lot faster :)
2019-04-21 19:09:37 +02:00
Dan Robertson fa94f1b6d5 Use core::ffi::VaList 2019-04-21 17:46:22 +02:00
jD91mZM2 29e1c780aa Comment out or fix 2 failing tests 2019-04-21 17:46:22 +02:00
jD91mZM2 601cb43f6c Merge branch 'strerror_r' into 'master'
Add POSIX strerror_r

See merge request redox-os/relibc!207
2019-04-21 15:06:17 +00:00
jD91mZM2 78d52c6e9f Merge branch 'whiletofor' into 'master'
Changed while loops to for

See merge request redox-os/relibc!206
2019-04-21 15:04:10 +00:00
Jeremy Soller 83f89912e0 Do not copy kernel-allocated TLS 2019-04-20 10:36:18 -06:00
Mateusz Mikuła c68a0d5678 Add POSIX strerror_r 2019-04-19 17:59:56 +02:00
Michal Z 89ca696f8e Changed while loops to for
Changed while loops to for - https://gitlab.redox-os.org/redox-os/relibc/issues/128
2019-04-15 18:24:46 +02:00
Jeremy Soller b9e03cbaed Implement __tls_get_addr 2019-04-14 19:09:10 -06:00
Jeremy Soller 30aef27c76 Correctly set up TLS on Redox and other fixes for pthread_clone 2019-04-14 19:08:58 -06:00
Jeremy Soller 7fe0beb916 Add DTPMOD64 2019-04-14 13:21:07 -06:00
Jeremy Soller 5a005864a8 Fix compilation on redox 2019-04-14 13:18:57 -06:00
Jeremy Soller 361f32b63c ld_so: significant refactor to prepare for pthread_create support of TLS 2019-04-14 13:17:07 -06:00
Jeremy Soller 9f5e5f24dc Correctly set tcb pointer to the end of TLS 2019-04-14 10:44:25 -06:00
Jeremy Soller 47baf499bf Fix TLS offsets 2019-04-14 08:40:03 -06:00
Jeremy Soller cb9e779ca1 Install ld_so 2019-04-13 21:39:08 -06:00
Jeremy Soller b2cc8f6d26 Fix compilation on Redox 2019-04-13 21:32:51 -06:00
Jeremy Soller 27cebdd688 Build librelibc without incremental support, gc-sections for ld.so 2019-04-13 21:15:38 -06:00
Jeremy Soller ba50c94c3f Improve TLS support 2019-04-13 21:15:01 -06:00
Jeremy Soller 63cb2f3454 ld.so: Add auxv support, get ld_library_path from env 2019-04-13 21:14:52 -06:00
Jeremy Soller 084b69b361 Add ld_so executable 2019-04-13 12:17:38 -06:00
Jeremy Soller d5eb1e2732 Add dl-tls.h, required for shared libraries 2019-04-12 09:30:02 -06:00
Jeremy Soller d9ec8b4ab0 Do not link to standard libraries when making libc.so... 2019-04-11 21:02:01 -06:00
Jeremy Soller 2b56f2882b Add libc.so, remove compiler_builtins 2019-04-11 21:00:39 -06:00
Jeremy Soller e5529dc883 Update pthreads-emb 2019-04-11 20:31:11 -06:00
Jeremy Soller cf800b5282 Add shared object for openlibm and pthreads-emb 2019-04-11 20:10:08 -06:00
Jeremy Soller 2fdca9bd0a Work around definition of O_NOFOLLOW, and add target for only building and installing headers 2019-04-07 10:11:05 -06:00
Jeremy Soller f4fccc6d19 Update rust 2019-04-07 08:47:51 -06:00
Jeremy Soller 73dda0f32c Add missing cast 2019-04-06 21:38:59 -06:00
Jeremy Soller f2b86e985c Ensure that getpeername and getsockname return a sockaddr of family AF_INET 2019-04-06 21:34:56 -06:00
Jeremy Soller 588f032f75 Rename can be done with O_PATH 2019-04-06 20:47:20 -06:00
Jeremy Soller 54b6c8f025 Update pthreads-emb 2019-04-04 19:59:06 -06:00
Jeremy Soller 862c76b25f Correct error for unknown protocol type in socket 2019-04-01 20:35:15 -06:00
Jeremy Soller f4c036c3aa Fix returning incorrect ai_socktype from getaddrinfo 2019-04-01 20:34:53 -06:00
Jeremy Soller 42d40da973 Map stacks based on provided size. 2019-03-31 15:04:37 -06:00
Jeremy Soller 17372b4f69 Fix thread starting before pte_osThreadStart 2019-03-30 16:18:07 -06:00
jD91mZM2 3f98962054 Fix bug in scanf where EOF would be ignored 2019-03-28 17:57:13 +01:00
Jeremy Soller 6548aad36d Use next_byte function in all places in scanf 2019-03-27 21:32:02 -06:00
Jeremy Soller d13fb3f42b Fix panic in sigaction 2019-03-27 21:31:18 -06:00
Jeremy Soller bee72373be Fix panic not producing output 2019-03-27 21:28:39 -06:00
Jeremy Soller 5dca9843dc Fix use of trace macro when errno is imported 2019-03-27 20:57:12 -06:00
Jeremy Soller 65aeda1f59 Use AF_INET6 instead of PF_INET6 in test 2019-03-27 20:56:59 -06:00
Jeremy Soller a88ec09131 Prevent override of panic from relibc 2019-03-27 20:56:23 -06:00
Jeremy Soller 229ca66726 Merge branch 'usleep' into 'master'
Fix usleep

Closes #144

See merge request redox-os/relibc!204
2019-03-25 13:06:46 +00:00
Mateusz Mikuła e01d1ce11b Fix usleep 2019-03-25 13:36:48 +01:00
Jeremy Soller 7a1e2a6269 Merge branch 'new-toolchain' into 'master'
Support use of new cross compiler

See merge request redox-os/relibc!203
2019-03-17 02:28:01 +00:00
Jeremy Soller 0e667c5f25 Remove .travis.yml 2019-03-16 20:20:43 -06:00
Jeremy Soller 6f12bb6a32 Install tar before attempting to use it 2019-03-16 20:18:34 -06:00
Jeremy Soller 59653ee290 Support use of new cross compiler 2019-03-16 20:16:00 -06:00
Jeremy Soller cee4449f7c Replace make calls with MAKE variable 2019-03-16 18:54:11 -06:00
Jeremy Soller 5715fb7ba6 Work on switching to epoll as backend for select and poll 2019-03-10 13:03:00 -06:00
Jeremy Soller cdbeda1ca0 Merge branch 'patch-2' into 'master'
Fix conditional compilation of sys/mman.h

See merge request redox-os/relibc!201
2019-03-05 02:08:01 +00:00
jD91mZM2 640c6d41a7 Merge branch 'aarch64-prep' into 'master'
Aarch64 prep redux

See merge request redox-os/relibc!202
2019-03-04 09:48:26 +00:00
Robin Randhawa 9443eef518 Add wint_t definition to stddef.h
Without this the relibc tests would break. With this the relibc tests
pass and formerly breaking builds (such as uutils -> onig_sys) pass.
2019-03-03 21:50:13 +00:00
Robin Randhawa 23de2ca7ca Remove redundant wchar_t and win_t definitions
Typically with libc implementations, wchar_t and co are either defined
entirely by the libc or, under libc's arrangement, by headers supplied
by the compiler.

Things like dlmalloc in relibc need these definitions from relibc itself
and that's already already furnished by relibc's stddef.h.

These additional definitions here are redundant and collide with
compiler headers - for example: onig_sys (something that uutils depends
on) breaks. Instead, this patch makes the compiler headers define
things appropriately.
2019-03-03 21:50:04 +00:00
Robin Randhawa f9f752d74c aarch64-prep: Dummy auxv.h
For AArch64, the ring crate depends on the presence of this header and a definition
of getauxval.
2019-03-03 21:49:52 +00:00
Robin Randhawa 17bed54103 aarch64: Fix incorrect init/fini stack manipulation
The pre-index operator ('!') was missing at the end of the stp
instruction.

As a result, the stack pointer wasn't updated after the
store of the 64-bit pair and the stored values were basically lost when
follow on code used the stack for later store ops.
2019-03-03 21:49:46 +00:00
Angelo Bulfone 31fc29e70c Fix conditional compilation of sys/mman.h 2019-03-03 21:14:45 +00:00
jD91mZM2 269b8a1d3e Merge branch 'cleanup' into 'master'
tests: Macro based error handling

See merge request redox-os/relibc!195
2019-03-03 15:19:19 +00:00
jD91mZM2 37c976945a Merge branch 'implement-swab' into 'master'
Implement swab

See merge request redox-os/relibc!187
2019-02-28 08:23:11 +00:00
lmiskiew 5eb2a8f7bd Implement swab 2019-02-28 08:23:11 +00:00
jD91mZM2 30a0f70d73 Merge branch 'wcsrchr' into 'master'
implements wcsrchr from wchar.h

See merge request redox-os/relibc!197
2019-02-28 08:21:55 +00:00
jD91mZM2 fe905ed13c Merge branch 'calloc_overflow_check' into 'master'
add calloc integer overflow check

See merge request redox-os/relibc!188
2019-02-28 08:20:11 +00:00
jD91mZM2 71f8fb32e3 Merge branch 'patch-1' into 'master'
Change LONG_BIT definition, fixes #148

Closes #148

See merge request redox-os/relibc!198
2019-02-28 08:18:29 +00:00
Paul Sajna e93129b165 Change LONG_BIT definition, fixes #148 2019-02-28 07:42:19 +00:00
emturner 4ed6dca61d implements wcsrchr from wchar.h 2019-02-25 22:53:11 +00:00
Tibor Nagy fa2c6d29db tests: Rewrite libgen tests based on ctype (nice table layout), fix error handling of sleep tests 2019-02-25 19:32:20 +01:00
Tibor Nagy efd6947d8e tests: Fix function-like macros
Turns the results of these macros from compound to regular statements using the old `do { ... } while(0)` trick. Must have for function-like macros.
2019-02-25 14:13:02 +01:00
Tibor Nagy 96182ce8ad tests: Fix expected outputs 2019-02-24 22:19:07 +01:00
Tibor Nagy a92be000fb tests: Even more work on error handling
realpath: Fixing undefined behaviour in the second test. If the call fails the resolved_name argument cannot be used for error checking because its state is undefined by SUSv2.
pipe: Changing the order of close and write error handling code. Errors in close could overwrite errno after write errors, returning incorrect error messages.
gmtime: Removed duplicate checks
Other fixes for fseek, rename, mktime, putwchar
2019-02-24 22:02:11 +01:00
Tibor Nagy 2d027f0771 tests: More work on error handling 2019-02-24 00:46:26 +01:00
Jeremy Soller 76503d8943 Add epoll constants 2019-02-23 08:39:06 -07:00
Jeremy Soller f3ba7e8d8e Merge branch 'wcscspn' into 'master'
Implements wcscspn function from wchar.h

See merge request redox-os/relibc!196
2019-02-23 00:33:11 +00:00
emturner ec3488c7b0 implements wcscspn from wchar.h 2019-02-22 23:18:21 +00:00
Tibor Nagy 0c539d6e4e tests: Fix expected outputs 2019-02-22 13:28:18 +01:00
Tibor Nagy 513f4ba53c tests: Documentation for test_helpers.h, more refactoring 2019-02-22 13:19:38 +01:00
Jeremy Soller 887d89c2bb Add epoll (WIP) 2019-02-21 20:40:03 -07:00
Jeremy Soller 74d0b24939 Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2019-02-21 19:43:07 -07:00
Jeremy Soller 5690c6dcdf Add trace for select and poll 2019-02-21 19:42:58 -07:00
Tibor Nagy 9a0ea6ff34 tests: More refactoring, add helper header to every test, override exit for better error reporting 2019-02-21 21:13:28 +01:00
Tibor Nagy 6266d29242 tests: Fix expected outputs 2019-02-21 17:46:18 +01:00
Tibor Nagy 64acf45c40 tests: Add helper macros for easier error handling and reporting 2019-02-21 17:35:24 +01:00
Tibor Nagy f60c95d2ca tests: Work on more thorough error handling 2019-02-21 16:15:49 +01:00
Tibor Nagy d1a424c002 tests: Replace returns with exits in the main functions
This will allow us to redefine the exit function.

For example:
```
#define exit(code) { \
    fprintf(stderr, "%s:%d: exit(%s) in function ‘%s’\n",
        __FILE__, __LINE__, #code, __func__); \
    _exit(code); \
}
```
2019-02-21 12:15:06 +01:00
Jeremy Soller f19e029468 Merge branch 'cleanup' into 'master'
General test cleanups

See merge request redox-os/relibc!193
2019-02-20 22:34:52 +00:00
Jeremy Soller 20aeb15fc7 Merge branch 'path-separator' into 'master'
unistd: Generate correct C defines for PATH_SEPARATOR

See merge request redox-os/relibc!194
2019-02-20 22:32:13 +00:00
Tibor Nagy 27a3f2ab77 unistd: Generate correct C defines for PATH_SEPARATOR 2019-02-20 22:11:25 +01:00
Tibor Nagy 4381bb2a22 tests: Remove redundant return statements
When the execution reaches the end of the main functions, they implicitly return a successful status.
2019-02-20 21:09:03 +01:00
Tibor Nagy c19cc8b731 tests: Portability fixes, replaced 0/1/-1 return codes with macros 2019-02-20 20:20:07 +01:00
Tibor Nagy ff874c87d7 tests: Fix function signatures 2019-02-20 19:27:18 +01:00
Jeremy Soller 97592716fb Merge branch 'pedantic' into 'master'
tests: set C11, enable pedantic warnings, fix GCC and Clang warnings

See merge request redox-os/relibc!192
2019-02-20 16:01:50 +00:00
Tibor Nagy 7ee59d2fdb tests: set C11, enable pedantic warnings, fix GCC and Clang warnings 2019-02-20 15:04:47 +01:00
Jeremy Soller 1af4eb7ec0 Merge branch 'ctype' into 'master'
ctype: Implement _tolower, _toupper

See merge request redox-os/relibc!191
2019-02-20 13:19:36 +00:00
Tibor Nagy d38a1d0da3 ctype: Implement _tolower, _toupper 2019-02-20 11:49:06 +01:00
Jeremy Soller 73c368ddab Use correct open flags 2019-02-19 19:29:19 -07:00
Jeremy Soller 264659b634 Merge branch 'ctype' into 'master'
ctype: Add tests for toascii, tolower, toupper

See merge request redox-os/relibc!190
2019-02-19 21:59:14 +00:00
Tibor Nagy 1eb22b2cb2 ctype: Add tests for toascii, tolower, toupper 2019-02-19 20:54:05 +01:00
Jeremy Soller 514b31cf28 Merge branch 'ctype' into 'master'
ctype: Fix iscntrl, isgraph, ispunct, make tests exhaustive

See merge request redox-os/relibc!189
2019-02-19 19:09:27 +00:00
Tibor Nagy 5fac72298f ctype: Fix iscntrl, isgraph, ispunct, make tests exhaustive
iscntrl: Didn't handle the EOF macro correctly
isgraph: Didn't handle '~' (tilde) correctly
ispunct: Several issues
2019-02-19 19:53:54 +01:00
Jeremy Soller 38da5552e8 getaddrinfo: support for setting port from service argument (numeric only) 2019-02-02 14:20:26 -07:00
Peter Limkilde Svendsen 7aa0fbdf93 Include stdint.h in test 2019-02-02 16:51:38 +01:00
Peter Limkilde Svendsen 8b7453edf2 Add test of calloc with overflow 2019-02-02 16:41:09 +01:00
Peter Limkilde Svendsen c54db6f008 Add integer overflow check to calloc 2019-02-02 15:52:39 +01:00
Jeremy Soller d2502056a8 Cleanup termios and ioctls and add tcflush 2019-01-27 19:19:50 -07:00
Jeremy Soller 602f015e93 Implement fpathconf and pathconf 2019-01-27 18:53:57 -07:00
Jeremy Soller 0dd801da03 Implement ttyname by adding fpath function to Sys. Remove realpath function and use fpath internally 2019-01-27 17:10:55 -07:00
Jeremy Soller 42f212e678 Verify current system before continuing. 2019-01-27 15:53:09 -07:00
Jeremy Soller 47235d44e7 Fix change of sockaddr member sa_data on Redox 2019-01-21 20:38:31 -07:00
Jeremy Soller c59f268fcd Implement getaddrinfo (somewhat) 2019-01-21 20:36:56 -07:00
Jeremy Soller f3c858c151 Build includes in parallel 2019-01-20 20:17:04 -07:00
Jeremy Soller f25c494a73 Show hint information 2019-01-20 20:12:58 -07:00
Jeremy Soller 0f50a40b3f Update redox_syscall 2019-01-20 19:38:38 -07:00
Jeremy Soller aa3c7da128 Switch to using syscall-instruction 2019-01-20 09:46:21 -07:00
Jeremy Soller eaa031c21c Fix ioctl on redox 2019-01-18 15:39:49 -07:00
Jeremy Soller a88933386b Implement termios functions using ioctl 2019-01-17 20:46:12 -07:00
Jeremy Soller 047deceed0 Move hostent functions to separate file 2019-01-17 20:45:25 -07:00
Jeremy Soller d0261ebb35 Move db to crate root 2019-01-17 19:56:51 -07:00
Jeremy Soller 09340bd0f2 Add setpgrp 2019-01-15 21:14:55 -07:00
Jeremy Soller 22ca2e5f7b Export group struct 2019-01-15 21:08:08 -07:00
Jeremy Soller 1a0d363caa Redox support for some minimal ioctl's 2019-01-15 20:50:17 -07:00
Jeremy Soller 74dd5091f3 Add empty netinet_ip 2019-01-15 20:49:35 -07:00
Jeremy Soller b35a4f6372 Add in_systm.h 2019-01-15 20:49:15 -07:00
Jeremy Soller c71088e768 Cleanup and format 2019-01-14 21:07:24 -07:00
Jeremy Soller 8dabff129a Begin work on getnameinfo 2019-01-14 19:26:35 -07:00
Jeremy Soller c57ac53d28 Reduce warnings 2019-01-14 19:26:18 -07:00
Jeremy Soller b3dda7519d Update openlibm 2019-01-14 14:22:24 -07:00
Jeremy Soller 2e260a6b29 Add _SC_PAGE_SIZE, use sysconf to provide getpagesize 2019-01-13 19:48:06 -07:00
Jeremy Soller f35f65c2b8 Update pthreads-emb 2019-01-13 17:00:39 -07:00
Jeremy Soller 594e53c6f1 addrinfo stub 2019-01-13 14:37:20 -07:00
Jeremy Soller 87f2ab95bb Fix redox compilation 2019-01-13 14:36:35 -07:00
Jeremy Soller 8e9d65cb46 Add support for pthreads to Linux 2019-01-13 14:17:29 -07:00
Jeremy Soller 52669688bf Fix issue of strcasecmp not showing up 2019-01-13 14:17:05 -07:00
Jeremy Soller 434cad49ce Add sysconf 2019-01-13 14:16:51 -07:00
Jeremy Soller 5b969f2bae Add pthread_sigmask 2019-01-13 10:56:09 -07:00
Jeremy Soller 89fca557f3 Remove old pthread module 2019-01-13 10:56:00 -07:00
Jeremy Soller 6c0c6dd71b Fix missing negative flags in netdb.h, add NI_MAXHOST and NI_MAXSERV 2019-01-13 10:34:17 -07:00
Jeremy Soller 018ff409f1 Add gai_strerror 2019-01-13 10:24:30 -07:00
Jeremy Soller 543f32eb50 Add nameinfo defines 2019-01-13 10:24:17 -07:00
Jeremy Soller 97312c9ae2 Fix addrinfo structure 2019-01-13 10:13:25 -07:00
Jeremy Soller 84fcb1b906 Add addrinfo constants 2019-01-13 09:58:03 -07:00
Jeremy Soller aa069b3e0b Add netinet/tcp.h 2019-01-13 09:31:25 -07:00
Jeremy Soller cea5101cba Implement shm_ functions and add MAP_FIXED 2019-01-13 09:31:04 -07:00
Jeremy Soller 5b779448ab Add IOV_MAX 2019-01-13 09:30:37 -07:00
Jeremy Soller 33b539e4c1 Fix export of O_ACCMODE 2019-01-13 09:30:27 -07:00
Jeremy Soller 0c5abf0361 Combine all libraries into libc.a, call pthread_init and pthread_terminate in libc 2019-01-07 19:11:30 -07:00
Jeremy Soller aefb4fb116 Improvements for dlfcn 2019-01-06 16:28:22 -07:00
Jeremy Soller c41c20a943 Allow for static CStr 2019-01-06 14:40:01 -07:00
Jeremy Soller dc4aa9cf0b Use typedef for Dl_info 2019-01-06 12:53:43 -07:00
Jeremy Soller 53874213fa Add dladdr 2019-01-06 12:48:36 -07:00
Jeremy Soller 46020f466f Add dlfcn, fixes for glib and gstreamer 2019-01-06 07:30:42 -07:00
Jeremy Soller 9a0c12888f Use better verbiage for iovec 2019-01-05 13:24:02 -07:00
Jeremy Soller 7ac3dfaa49 Implement sys_uio, define sockaddr_storage 2019-01-05 13:10:20 -07:00
Jeremy Soller eef2f4d1f8 Add more netinet/in.h definitions 2019-01-05 12:01:24 -07:00
Jeremy Soller 2ba67f2fe2 Add getlogin stub 2019-01-05 10:12:33 -07:00
Jeremy Soller 961d1304ab Add sigismember 2019-01-05 09:40:08 -07:00
Jeremy Soller bd956e5fe4 Force little endian for reals 2019-01-01 07:35:13 -07:00
Jeremy Soller 775ec444be Add mprotect 2018-12-31 21:04:45 -07:00
Jeremy Soller c514b0b705 Fix semaphore deadlocks 2018-12-30 08:29:57 -07:00
Jeremy Soller c9e48bf141 Use locking in dlmalloc 2018-12-29 20:11:34 -07:00
Jeremy Soller e93ead5a8f Fix double lock in pte 2018-12-29 19:40:21 -07:00
Jeremy Soller 62b83190bf Fix incorrect variable name 2018-12-29 10:03:11 -07:00
Jeremy Soller e7896f6c48 Fix panic in fread 2018-12-29 10:02:36 -07:00
Jeremy Soller 0aaa7264db Fix signal support 2018-12-29 08:20:27 -07:00
Jeremy Soller 083642fb17 Enable getitimer, setitimer, and sigprocmask 2018-12-28 21:47:49 -07:00
Jeremy Soller 5cb92284f2 Update fmap support 2018-12-28 15:46:38 -07:00
Jeremy Soller 51b093b598 Use 4096 as Linux page size for now 2018-12-26 19:57:08 -07:00
Jeremy Soller 7aa789575a Add shutdown, listen, and getpagesize 2018-12-26 19:26:38 -07:00
jD91mZM2 a321545fd0 Merge branch 'aarch64-unknown-redox' into 'master'
aarch64: Fix typo in a jmp_buf preprocessor conditional

See merge request redox-os/relibc!186
2018-12-23 10:52:46 +00:00
Robin Randhawa 0842d6504b aarch64: Fix typo in a jmp_buf preprocessor conditional 2018-12-23 16:04:35 +05:30
Jeremy Soller 09135f5bd1 Merge branch 'netdb-mutable' into 'master'
netdb: Return mutable structs in the getter functions

See merge request redox-os/relibc!185
2018-12-19 21:17:12 +00:00
Tibor Nagy 51245d69e3 netdb: Return mutable structs in the getter functions 2018-12-18 21:13:32 +01:00
Jeremy Soller 42545713a7 Merge branch 'fwrite-division-by-zero' into 'master'
Fix panic in fwrite

See merge request redox-os/relibc!184
2018-12-17 01:37:12 +00:00
lmiskiew 5b6b11cb65 Fix panic in fwrite 2018-12-17 02:01:36 +01:00
Jeremy Soller f04ac7343a Update pthreads-emb 2018-12-14 15:52:03 -07:00
Jeremy Soller a8f3608f3c Fix stdlib div functions, add _Exit 2018-12-14 13:41:22 -07:00
Jeremy Soller 89832b3ac8 Add lldiv 2018-12-14 13:20:56 -07:00
Jeremy Soller e6c866a92d Undefine complex in fenv.h 2018-12-14 12:50:23 -07:00
Jeremy Soller 74af56d71b Add statvfs and strtold 2018-12-14 12:00:21 -07:00
Jeremy Soller 0d2332d368 Add more special redox functions 2018-12-13 15:26:03 -07:00
Jeremy Soller c6d42dd9e3 Use openlibm's fenv.h 2018-12-13 15:25:47 -07:00
Jeremy Soller 4e741f5583 Add redox_fpath function 2018-12-13 14:46:27 -07:00
Jeremy Soller f7b3abc1b6 Add more wchar definitions 2018-12-13 08:11:49 -07:00
Jeremy Soller 1c1da7dfcb Implement more wchar functions 2018-12-12 20:45:17 -07:00
Jeremy Soller df1c7404eb Update pthreads-emb 2018-12-11 21:02:19 -07:00
Jeremy Soller ae115ac6ff Run pre-init array before _init 2018-12-11 21:01:10 -07:00
Jeremy Soller e764fedba5 Remove unnecessary extern C function 2018-12-11 09:17:33 -07:00
Jeremy Soller 4a4e641b23 Update pthreads-emb 2018-12-11 08:02:47 -07:00
Jeremy Soller 756a0d2edc Initialize pthreads if it is linked 2018-12-09 19:59:33 -07:00
Jeremy Soller 1becb8c43a Enable sys/mman 2018-12-09 16:24:23 -07:00
Jeremy Soller f9b836d23e Add more pte functions 2018-12-09 15:28:45 -07:00
Jeremy Soller 90bf583d28 Better patch for missing M_PI constants 2018-12-09 14:43:23 -07:00
Jeremy Soller ee40035c4b Add asprintf 2018-12-09 12:45:04 -07:00
Jeremy Soller 63b079c231 Include alloca.h in stdlib.h 2018-12-09 11:53:41 -07:00
Jeremy Soller be035f8862 Copy pthreads-emb files on install 2018-12-09 11:29:51 -07:00
Jeremy Soller 8aae8e1564 Add PTE
Add sys_timeb header
2018-12-09 11:27:44 -07:00
Jeremy Soller fc9e3923f6 drop DIR pointers again 2018-12-02 21:05:37 -07:00
Jeremy Soller de429a8df6 Fix overflow issues in Redox getdents 2018-12-02 21:04:07 -07:00
Jeremy Soller e8377d259a Mutable argv 2018-12-02 20:14:33 -07:00
Jeremy Soller 925d9f6bbf WIP: fflush all files when null is passed 2018-12-02 16:45:29 -07:00
Jeremy Soller 05f17794e4 Return correct error code from access 2018-12-02 15:26:37 -07:00
Jeremy Soller 7049359c25 Hack around closedir crashing 2018-12-02 14:27:02 -07:00
Jeremy Soller 594bcd75d4 Add closedir to dirent test 2018-12-02 13:20:33 -07:00
Jeremy Soller a39f170ed3 Reenable grp header (for git) 2018-12-02 12:35:38 -07:00
Jeremy Soller 4ced856b39 Fix fseeko not flushing write buffer 2018-12-02 12:04:15 -07:00
Jeremy Soller 62b0b0d508 Add rustcflags to makefile 2018-12-02 10:24:16 -07:00
Jeremy Soller 7dbd57f913 Fix putenv crash 2018-12-02 10:23:17 -07:00
Jeremy Soller fe57754c34 Do not cast usize to isize in strncpy 2018-12-02 08:16:38 -07:00
Jeremy Soller 3075b8b69f Replace gethostname syscall with uname 2018-12-02 08:04:53 -07:00
Jeremy Soller 52fd4d7e83 Clippy fixes 2018-12-02 08:04:53 -07:00
Jeremy Soller 28dab8ece8 Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2018-12-01 08:55:05 -07:00
Jeremy Soller 9325183b21 Fix strcat 2018-12-01 08:55:02 -07:00
Jeremy Soller ca75bbc1c9 Merge branch 'isspace' into 'master'
ctype: fix isspace to test all space class characters

See merge request redox-os/relibc!182
2018-11-28 21:09:14 +00:00
Tibor Nagy 8d05067ac7 ctype: fix isspace to test all space class characters 2018-11-28 20:33:02 +01:00
Jeremy Soller d66afa4586 Do not return mutable pointer from strsignal 2018-11-27 20:54:37 -07:00
Jeremy Soller 35bcf93160 Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2018-11-27 10:07:47 -07:00
Jeremy Soller 0a44d4543f Override CC for aarch64 redox 2018-11-27 10:07:44 -07:00
Jeremy Soller 950b4526c7 - Disable output of empty header files
- Remove incorrect header styles
- Use export.replace where header style was previously needed
- Check compilation of tests using system gcc
2018-11-26 21:35:02 -07:00
Jeremy Soller 4bb16e01b2 Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2018-11-26 20:29:32 -07:00
Jeremy Soller 37cd503c88 Cleanups of redox pal 2018-11-26 20:29:27 -07:00
Jeremy Soller 1a8af993e6 Fix invalid inline ASM 2018-11-26 16:01:20 -07:00
Jeremy Soller 34edeaf066 Update dependencies 2018-11-26 15:48:40 -07:00
Jeremy Soller ee2a7685e6 Revert "Update compiler_builtins and redox_syscall"
This reverts commit d6a5b39505.
2018-11-26 15:45:35 -07:00
Jeremy Soller 583eaa498d Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2018-11-26 15:43:29 -07:00
Jeremy Soller d6a5b39505 Update compiler_builtins and redox_syscall 2018-11-26 15:43:24 -07:00
Jeremy Soller 809f665a8a Update compiler_builtins 2018-11-26 15:43:15 -07:00
Jeremy Soller 15eed4daf1 Update core_io 2018-11-26 14:33:55 -07:00
Jeremy Soller d4e42fd9e0 Merge branch 'type' into 'master'
Some type signature fixes found using script in #111

See merge request redox-os/relibc!181
2018-11-26 13:13:43 +00:00
Ian Douglas Scott f5f561424a Correct return value of regerror 2018-11-25 21:24:32 -08:00
Ian Douglas Scott fc0b7b9111 'strtoull' and 'strtoll' type signatures 2018-11-25 21:17:25 -08:00
Ian Douglas Scott fdd966629d Some type signature fixes found using script in #111 2018-11-25 20:58:02 -08:00
Jeremy Soller de0339ee93 Fix issue with open flag overflow 2018-11-25 19:34:24 -07:00
Jeremy Soller a614c40273 Fix definition of protocol families 2018-11-25 16:45:19 -07:00
Jeremy Soller 6180222760 Format 2018-11-25 16:44:01 -07:00
Jeremy Soller e0daa157b9 Add protocol families 2018-11-25 16:43:45 -07:00
Jeremy Soller 5c4c49a9d1 Add getdelim and getline 2018-11-25 16:39:14 -07:00
Jeremy Soller 96cc56a0b5 Add readlink and symlink 2018-11-25 14:56:36 -07:00
Jeremy Soller d6a1796122 Format 2018-11-25 14:38:33 -07:00
Jeremy Soller d818a8d10e Add pwrite 2018-11-25 14:38:12 -07:00
Jeremy Soller 8a042a220d Implement pread, add more poll constants 2018-11-25 14:34:18 -07:00
Jeremy Soller 869eb160bd Add poll 2018-11-25 13:04:38 -07:00
Jeremy Soller 7398fae8b6 Re-add removed comments 2018-11-25 11:01:19 -07:00
Jeremy Soller 0ac16556bc Format 2018-11-25 10:34:42 -07:00
Jeremy Soller a5279b648f Fix warnings 2018-11-25 10:34:02 -07:00
Jeremy Soller 52493a1ec3 Add popen/pclose 2018-11-25 10:33:50 -07:00
Jeremy Soller de43271204 Merge branch 'uname' into 'master'
Implement uname for Redox

See merge request redox-os/relibc!178
2018-11-25 15:25:48 +00:00
Jeremy Soller a613154191 Merge branch 'alloca' into 'master'
Implement alloca.h

See merge request redox-os/relibc!180
2018-11-25 15:24:56 +00:00
Tibor Nagy 55eb8f2779 Implement alloca.h 2018-11-23 21:31:09 +01:00
Jeremy Soller 9790289aec Add execlp 2018-11-22 20:43:04 -07:00
Jeremy Soller 3cc215caeb Add freading, fwriting, and stdio_ext.h header 2018-11-22 19:24:48 -07:00
Jeremy Soller b4f36bce17 Add more stdio_ext functions 2018-11-22 19:09:46 -07:00
Jeremy Soller 632f9f18e5 fpending 2018-11-22 18:43:45 -07:00
Jeremy Soller 9b0c74b935 Fix ioctl being defined on redox, add cxa_atexit for gcc 2018-11-18 10:35:33 -07:00
Tibor Nagy 012a9b2eb3 Implement uname for Redox 2018-11-18 18:23:47 +01:00
Jeremy Soller 02c8355c13 Update openlibm 2018-11-18 08:58:35 -07:00
Jeremy Soller 4c9173433e Merge branch 'macos_fixes' into 'master'
Make relibc buildable on macOS (not for macOS)

See merge request redox-os/relibc!179
2018-11-17 23:47:52 +00:00
jD91mZM2 1c92751a73 Don't rely on integer wrapping in ctype
Don't rely on integer wrapping in ctype and fix strcasecmp on
non-alphabetic characters
2018-11-17 20:26:43 +01:00
Alexander Theißen 484a05e8b3 Remove unnecessary escape from include.sh
The older bash version of macOS does not understand this escape
and actually creates directories with "\" in their name. After this
change it actually works with both versions.
2018-11-17 20:17:35 +01:00
Alexander Theißen e102c234c1 Properly export CC variable in Makefile
We cannot use ?= because CC is set by default to "cc". Therefore
CC was never set. In addition we need to export the variable
in order to have the rust cc crate pick it up. Otherwise it is
only used by openlibm where it is explicitly passed.
2018-11-17 20:17:35 +01:00
Jeremy Soller 44f84f406f Force byte order to little endian, for gcc 2018-11-17 09:19:35 -07:00
Jeremy Soller e32fc12308 Weak linkage for getopt and fnmatch 2018-11-17 08:40:39 -07:00
Jeremy Soller c6f2b30738 Add netdb bits to include hostent.h_addr 2018-11-17 08:16:37 -07:00
Jeremy Soller 8c5b237963 Rename intmaxdiv_t to imaxdiv_t to match standard 2018-11-17 07:40:30 -07:00
Jeremy Soller e7f7c4ea61 Fix incorrect nul 2018-11-16 21:32:03 -07:00
Jeremy Soller a6642bc753 Fix missing separator 2018-11-16 21:16:08 -07:00
Jeremy Soller a29aa9f599 Add execvp 2018-11-16 21:07:24 -07:00
Jeremy Soller dd65d0c0c8 Fix missing nul 2018-11-16 20:37:37 -07:00
Jeremy Soller 861602bbcc Add umask 2018-11-16 19:49:47 -07:00
jD91mZM2 0684fb6e4c Bump posix-regex version 2018-11-14 20:52:12 +01:00
jD91mZM2 d252838496 Re-use posix-regex matcher in fnmatch 2018-11-14 14:19:48 +01:00
Jeremy Soller 81dc144241 Abandon overriding cargo flags, for now 2018-11-13 21:03:14 -07:00
Jeremy Soller f1c970beef Fix override of CARGOFLAGS when using target 2018-11-13 21:00:05 -07:00
Jeremy Soller 8a972542be Allow override of cargoflags 2018-11-13 20:56:59 -07:00
Jeremy Soller 2b3ae4d8b8 Add configuration for compiling with xargo 2018-11-11 08:10:37 -07:00
Jeremy Soller c36ee7237b Allow override of cargo 2018-11-11 08:03:04 -07:00
Jeremy Soller bf111188e1 Reduce warnings for redox 2018-11-10 07:54:27 -07:00
Jeremy Soller ebffc977b2 Reduce warnings 2018-11-10 07:52:45 -07:00
Jeremy Soller 131dcac554 Update serde_json 2018-11-09 18:31:35 -07:00
Jeremy Soller 4963ca3a95 Fix compile on redox 2018-11-07 20:26:27 -07:00
Jeremy Soller 39b999ccea Update to new rust-toolchain 2018-11-07 20:25:21 -07:00
Jeremy Soller d88f4053ea Merge branch 'header-guards-fix' into 'master'
Fix include guards in regex and utime

See merge request redox-os/relibc!176
2018-11-06 12:45:36 +00:00
Michal Z 0396460c84 Fix include guards in regex and utime
The include_guard in both regex and utime was "_TEMPLATE_H", this meant that including both wasn't possible.
Their header guards should be consistent with the header files as well.
Changed _TEMPLATE_H to _REGEX_H and _UTIME_H in /regex/cbindgen.toml and /utime/cbindgen.toml respectively.
2018-11-06 11:27:11 +01:00
jD91mZM2 75bac011e4 Merge branch 'MaikuZ/libgen' into 'master'
Implement libgen.h

See merge request redox-os/relibc!175
2018-11-05 20:33:54 +00:00
Michal Z a7b71a311d Implement libgen.h
Implemented the following calls according to http://pubs.opengroup.org/onlinepubs/7908799/xsh/libgen.h.html
- char* basename(char*)
- char* dirname(char*)

Added test suit for the implemented calls.

Issue: https://gitlab.redox-os.org/redox-os/relibc/issues/134
2018-11-05 17:49:14 +01:00
jD91mZM2 571b4d4976 Fix getdents on redox 2018-11-01 10:58:01 +01:00
Jeremy Soller 09bd4bc375 Update cbindgen 2018-10-29 19:27:47 -06:00
Jeremy Soller 51b2e630b9 Merge branch 'optind-reset' into 'master'
Handle getopt reinitialization

See merge request redox-os/relibc!174
2018-10-28 19:36:25 +00:00
Tibor Nagy f97f93c48d Handle getopt reinitialization 2018-10-28 19:59:08 +01:00
Jeremy Soller 740f57738c Merge branch 'cpp-extern' into 'master'
Disable symbol mangling for C++

See merge request redox-os/relibc!173
2018-10-28 13:13:51 +00:00
Tibor Nagy d4308c8a9b Disable symbol mangling for C++ 2018-10-28 13:24:34 +01:00
Jeremy Soller 6f4b8db7d8 Merge branch 'assert-duke32' into 'master'
Fix assert when used as an expression

See merge request redox-os/relibc!172
2018-10-27 17:58:58 +00:00
Tibor Nagy e7f251fdb0 Fix assert when used as an expression
Based on what musl does.
2018-10-27 17:40:24 +02:00
jD91mZM2 bfa068df88 Fix strcasecmp return value 2018-10-17 21:26:16 +02:00
Jeremy Soller 3c2121d4e0 Do not require prefix for hex 2018-10-16 18:03:21 -06:00
jD91mZM2 460f57b37f Disallow execve on non-executable interpreted files 2018-10-15 17:36:41 +02:00
jD91mZM2 75c5c04bee Implement a proper mutex type for future usage 2018-10-15 15:24:14 +02:00
jD91mZM2 23fe526c55 Fix feof and ferror 2018-10-14 15:57:42 +02:00
jD91mZM2 057d23908a Merge branch 'bugfix/netdb-gethostent' into 'master'
Don't drop the host aliases pointer vector in `gethostent`

Closes #130

See merge request redox-os/relibc!170
2018-10-13 15:02:23 +00:00
jD91mZM2 edb95246d4 Fix bug in strncasecmp 2018-10-13 16:55:21 +02:00
Jeremy Soller e4d87a101a Merge branch 'printf' into 'master'
Implement almost all of printf

See merge request redox-os/relibc!171
2018-10-13 14:14:27 +00:00
jD91mZM2 63882684b2 Implement almost all of printf 2018-10-13 14:20:54 +02:00
Benedikt Rascher-Friesenhausen 49259d3f01 Don't drop the host aliases pointer vector in gethostent
There are pointers to this vector in `HOST_ENTRY` so we must keep it around for
as long as `HOST_ENTRY` exists.
2018-10-11 20:59:54 +02:00
jD91mZM2 b517629371 Fix timeradd
wow i am stupid for writing this code
2018-10-11 19:52:54 +02:00
jD91mZM2 1f3154b45c Invoke constructors and destructors
Huge thanks to @xtibor for both discovering that this was still an issue, and also providing information with how to fix it
2018-10-11 16:59:49 +02:00
jD91mZM2 116cbda8d2 Merge branch 'test-ctor-dtor' into 'master'
Add tests for constructors and destructors

See merge request redox-os/relibc!169
2018-10-10 14:06:41 +00:00
Tibor Nagy aee3f68117 Add tests for constructors and destructors 2018-10-09 20:32:27 +02:00
jD91mZM2 f516ff72d8 Merge branch 'regoff_t' into 'master'
Move regoff_t to regex.h

See merge request redox-os/relibc!168
2018-10-09 14:49:53 +00:00
jD91mZM2 0469c0c2c6 Add tests for memcmp and fix a teeny tiny bug 2018-10-09 16:47:57 +02:00
Tibor Nagy 0f5fa8c9d4 Move regoff_t to regex.h 2018-10-09 16:43:34 +02:00
jD91mZM2 3f4fbf9084 Merge branch 'feature/optimise-memcmp' into 'master'
Optimise `memcmp` for speed

See merge request redox-os/relibc!167
2018-10-09 14:20:06 +00:00
Benedikt Rascher-Friesenhausen 8e2b7c11b4 Replace i32 with c_int in memcmp
As per the comments from jD91mZM2 on the merge request.
2018-10-07 17:40:30 +02:00
jD91mZM2 91675b5bc8 realpath on redox: don't forget the nul terminator 2018-10-07 15:12:41 +02:00
jD91mZM2 fba3bf5161 Merge branch 'assert' into 'master'
Make assert more hygienic

See merge request redox-os/relibc!166
2018-10-07 12:50:56 +00:00
jD91mZM2 758f681590 Implement scandir 2018-10-07 14:43:54 +02:00
jD91mZM2 3c8cb95b80 Cleanup strcasecmp 2018-10-07 13:02:05 +02:00
jD91mZM2 0de7d30656 Fix S_IS*
For some reason, C handles `==` before `&`.
So `a & b == c` is the same thing as `a & (b == c)`.
2018-10-07 13:01:59 +02:00
jD91mZM2 028378b8bf Fix double close
Accidentally made file references not count as references and therefore also close the fd. My bad.
2018-10-07 10:54:37 +02:00
jD91mZM2 418a960f3b Implement realpath 2018-10-07 10:32:51 +02:00
Benedikt Rascher-Friesenhausen e10a346356 Optimise memcmp for speed
I saw that in other parts of the `string` module iterations over `usize` were
used to increase iteration speed.  In this patch I apply the same logic to
`memcmp`.  With this change I measured a 7x speedup for `memcmp` on a ~1MB
buffer (comparing two buffers with the same content) on my machine (i7-7500U),
but I did not do any real world benchmarking for the change.  The increase in
speed comes with the tradeoff of both increased complexity and larger generated
assembly code for the function.

I tested the correctness of the implementation by generating two randomly filled
buffers and comparing the `memcmp` result of the old implementation against this
new one.

I ran the tests and currently currently three of them fail:
  - netdb (fails to run)
  - stdio/rename (fails to verify)
  - unistd/pipe (fails to verify)

They do so though regardless of this change, so I don't think they are related.
2018-10-07 10:25:19 +02:00
jD91mZM2 26d629674a Implement strcasestr 2018-10-06 17:37:50 +02:00
jD91mZM2 9d56ce42c6 Implement timer* macros, and GNU's getopt_long 2018-10-06 16:46:35 +02:00
Tibor Nagy 614b2f5103 Make assert more hygienic 2018-10-06 14:55:06 +02:00
jD91mZM2 baddbb98d5 Don't reinvent the wheel in strings.h 2018-10-05 19:33:41 +02:00
jD91mZM2 1acc2a1a32 Initial regex.h implementation 2018-10-05 18:07:43 +02:00
jD91mZM2 dfa3845c33 Make fread/fwrite retry their respective operations 2018-10-02 18:47:42 +02:00
jD91mZM2 6dcc8ee8d9 Implement strtof 2018-10-02 18:47:42 +02:00
Jeremy Soller aec6a48ca4 Merge branch 'termios-baudrate' into 'master'
Add termios baud rate functions

See merge request redox-os/relibc!165
2018-09-29 21:27:31 +00:00
Tibor Nagy db4452e98b Add termios baud rate functions 2018-09-29 22:52:12 +02:00
jD91mZM2 b22d386177 Re-add EOF to bits header
cbindgen can't handle negative numbers, see https://github.com/eqrion/cbindgen/issues/205
2018-09-29 20:02:37 +02:00
jD91mZM2 dd711f4dee Fix bug in fread
Bug discovered by @xTibor. Test and input data provided by him.
2018-09-29 15:04:58 +02:00
jD91mZM2 0451fac66c Delete RawFile in favor of File 2018-09-26 19:40:39 +02:00
jD91mZM2 d365813c90 Merge branch 'core-io' into 'master'
Rewrite IO to use core-io library

See merge request redox-os/relibc!164
2018-09-26 16:56:29 +00:00
jD91mZM2 4f187efc9b Change BUFSIZ type to work with cbindgen 2018-09-26 18:44:04 +02:00
jD91mZM2 243ce18ecd Implement ftell 2018-09-26 17:48:46 +02:00
jD91mZM2 21559bb503 Fix redox compilation 2018-09-26 16:40:23 +02:00
jD91mZM2 afc1ff134a Rewrite IO to use core-io library 2018-09-26 16:13:09 +02:00
Jeremy Soller aff35892be Add fs module 2018-09-24 21:40:40 -06:00
Jeremy Soller 7f14fcdee0 Remove c_str functions, replace with CStr 2018-09-24 21:08:29 -06:00
Jeremy Soller ef9fee5a2b Prepare for use of Write trait by renaming Write to WriteByte 2018-09-24 20:31:06 -06:00
Jeremy Soller 9eef8d7e2d Add core_io 2018-09-24 20:19:37 -06:00
Jeremy Soller b309cd832d Add getopt and machine/endian.h 2018-09-24 14:45:36 -07:00
jD91mZM2 d659377b24 VERY basic crti/crtn 2018-09-23 21:30:13 +02:00
jD91mZM2 6d99915154 Use RAII for file locking in stdio 2018-09-23 20:40:48 +02:00
Jeremy Soller 7e4a60f78b Fix possible deadlocks 2018-09-23 11:58:09 -06:00
jD91mZM2 658dc34d30 A few I/O related fixes 2018-09-23 17:28:42 +02:00
jD91mZM2 1e9dbfdf62 Use cbitset crate 2018-09-22 17:26:58 +02:00
jD91mZM2 2a8bc8331b Fix select return value 2018-09-22 11:12:31 +02:00
Tom Almeida b43299642b Fix buffering issue with large output through stdio 2018-09-21 15:21:39 +02:00
jD91mZM2 29b4c19d6e fixup! Untested fix for pwd.h on redox 2018-09-21 13:13:17 +02:00
jD91mZM2 64acfbb8e3 Format 2018-09-21 08:04:38 +02:00
jD91mZM2 9e9b850b90 Untested fix for pwd.h on redox 2018-09-21 08:04:06 +02:00
Jeremy Soller a0b4e21bbb Comment out SO_ERROR so it is not used 2018-09-20 15:41:59 -07:00
Jeremy Soller a567197b54 enable getsockopt and setsockopt 2018-09-20 14:39:58 -07:00
Jeremy Soller 9dbf49fdcd Format and add O_CLOEXEC where appropriate 2018-09-18 19:52:47 -06:00
jD91mZM2 2aa7597a2b Fix network problem with netdb on redox 2018-09-18 19:14:28 +02:00
Jeremy Soller 043ecf2cf9 Replace a println with a trace 2018-09-18 08:53:37 -06:00
Jeremy Soller 290ecb3e46 - fsync when tracing
- clean up trace macro some
2018-09-18 08:49:44 -06:00
Jeremy Soller 60f00508d3 Restore errno if trace_expr is successful 2018-09-18 08:34:06 -06:00
jD91mZM2 10a7944aef Avoid duplicate code 2018-09-18 08:08:55 +02:00
Jeremy Soller c2f4c1dbc9 Add trace macro and feature 2018-09-17 21:29:40 -06:00
Jeremy Soller 28f4da526d Require all target when building sysroot 2018-09-17 20:28:17 -06:00
Jeremy Soller 2cc5db9de6 Fix Linux compilation 2018-09-17 20:27:59 -06:00
Jeremy Soller 23098b694e Add print, eprint, eprintln, and fix println macros 2018-09-17 15:02:00 -06:00
Jeremy Soller 35bdab7690 Remove protocol check from socket 2018-09-17 15:01:31 -06:00
Jeremy Soller 13cd7d5a5f Oops, extra nul 2018-09-17 10:57:22 -06:00
jD91mZM2 d0a4f2f845 Delete a bunch of leftover constants 2018-09-17 18:44:33 +02:00
Jeremy Soller 76959416bb Add missing open flags 2018-09-17 09:59:41 -06:00
Jeremy Soller 716ea87bb4 Format 2018-09-17 09:46:47 -06:00
Jeremy Soller f3a832ad12 Fixes for select on Redox 2018-09-17 09:46:40 -06:00
Jeremy Soller dfb07e473a Comment out functions not implemented by Redox 2018-09-15 12:31:40 -06:00
Jeremy Soller f661d5d1c0 Fix use of uninitialized memory 2018-09-15 11:14:51 -06:00
Jeremy Soller 9d24e61548 Use alloc_aligned and free functions in platform for global allocator 2018-09-15 11:14:34 -06:00
Jeremy Soller 706a8de7a0 Call _init and _fini 2018-09-15 11:14:05 -06:00
jD91mZM2 882b86e282 Revert 'fix netdb on names with spaces', just ignore invalid lines 2018-09-05 19:24:10 +02:00
jD91mZM2 30d6f079c5 Add missing dirent macros (fixes #129) 2018-09-05 17:39:40 +02:00
jD91mZM2 49ccf364c2 Fix netdb getservbyname on names with spaces 2018-09-05 17:38:59 +02:00
jD91mZM2 eb6ddac1eb Unify gmtime and localtime code
Apparently gmtime was already implemented when I made localtime, so we had two different things written from scratch. We decided in the relibc channel of the Redox OS Mattermost chat to use my code, as it is more extensively tested and perhaps is clearer in how it works.
2018-09-05 15:52:25 +02:00
Tom Almeida 9cb594dca1 Merge branch 'Tommoa:master' into 'master'
Add contribution guidelines/tutorial

See merge request redox-os/relibc!162
2018-09-05 13:03:46 +00:00
Tom Almeida 92e1127b64 Add contribution guidelines/tutorial 2018-09-05 13:03:46 +00:00
jD91mZM2 59d74e194d Fix CI 2018-09-04 15:31:43 +02:00
jD91mZM2 eb2fe7934c Merge branch 'master' into 'master'
Updated url, implemented missing functions in header/arpa_inet/mod.rs

See merge request redox-os/relibc!161
2018-09-04 12:28:13 +00:00
thedarkula e688d9c4d1 Updated url, implemented missing functions in header/arpa_inet/mod.rs 2018-09-04 02:59:59 +01:00
jD91mZM2 50c03f289f Support shebangs in redox execve 2018-09-02 11:15:38 +02:00
jD91mZM2 077e922cc6 fixup! Delete duplicate types 2018-09-02 08:20:19 +02:00
jD91mZM2 26f953e11f Run fmt.sh 2018-09-02 08:17:52 +02:00
jD91mZM2 6fe3e05ea0 Delete duplicate types
Now that we use cbindgen differently :D
2018-09-02 08:17:15 +02:00
jD91mZM2 dbe18b92f0 Merge branch 'netdb' into 'master'
Netdb

See merge request redox-os/relibc!156
2018-09-01 14:00:18 +00:00
Paul Sajna 07eb658a8a Netdb 2018-09-01 14:00:18 +00:00
Jeremy Soller 3dbf9f872a Allow use of custom CC for compiling tests 2018-08-27 14:54:53 -06:00
Jeremy Soller 28912d84d9 Further fixes to tests makefile 2018-08-27 13:29:44 -06:00
Jeremy Soller 82b9715f41 Fix makefile for tests, add sysroot target 2018-08-27 13:02:13 -06:00
Jeremy Soller 70eda382d3 Merge branch 'pal' into 'master'
Intense refactor

See merge request redox-os/relibc!159
2018-08-27 15:27:58 +00:00
Jeremy Soller 0258fb3f5e Fix header path 2018-08-27 08:47:16 -06:00
Jeremy Soller b52c822150 Update Redox module to use CStr 2018-08-27 08:44:42 -06:00
Jeremy Soller c911facca6 Make pal functions take cstr 2018-08-27 08:33:12 -06:00
Jeremy Soller 16373257b0 format 2018-08-27 07:12:37 -06:00
Jeremy Soller 8f5470fd27 Reduce warnings 2018-08-27 07:12:24 -06:00
Jeremy Soller bab4e2896a Format 2018-08-27 06:35:30 -06:00
Jeremy Soller 7ab700315d Fix warnings and add c_str 2018-08-26 15:15:29 -06:00
Jeremy Soller 6418f893e4 Fix headers with directories 2018-08-26 12:40:19 -06:00
Jeremy Soller 124e118f9f Fix makefile 2018-08-26 12:35:41 -06:00
Jeremy Soller ed00ddfb54 Fix remaining issues, move setjmp into relibc crate, move start logic into relibc 2018-08-26 12:28:27 -06:00
Jeremy Soller c63c930e4a Make it compile 2018-08-26 12:10:02 -06:00
Jeremy Soller 277b9abcd5 Fix build, mostly 2018-08-26 08:56:02 -06:00
Jeremy Soller c20ce5ffed Large reorganization of headers (WIP) 2018-08-26 08:11:35 -06:00
Jeremy Soller ff32c8cbbd Remove stat and lstat, which can be replaced with open and fstat 2018-08-25 10:13:58 -06:00
Jeremy Soller 34f5f57213 Fix signal and socket pal implementations on Redox 2018-08-25 09:21:08 -06:00
Jeremy Soller d1dabccdce Fix missing modules in Redox platform 2018-08-25 09:14:02 -06:00
Jeremy Soller 165f099c6b Update Redox platform to pal 2018-08-25 09:07:35 -06:00
Jeremy Soller 729709a8e6 Update all modules to new Pal mechanism 2018-08-25 08:42:57 -06:00
Jeremy Soller e6f163823c WIP: platform abstraction layer 2018-08-24 20:13:07 -06:00
Jeremy Soller c25ce6a5f3 Include stddef.h in sys/types.h 2018-08-18 08:27:40 -06:00
Jeremy Soller f1df1f9f0b Fix issue with stdio.h bits file not having FILE defined 2018-08-18 08:22:16 -06:00
Jeremy Soller 83cb46afd8 Fix path to crt0.o and libc.a 2018-08-18 08:15:14 -06:00
Jeremy Soller 2e8cb6b363 Fix signature of unsetenv 2018-08-17 20:07:00 -06:00
Jeremy Soller 4e3b6732d5 Default to release for make 2018-08-17 18:41:16 -06:00
jD91mZM2 128209788c Finish up fexec migration 2018-08-13 14:46:59 +02:00
jD91mZM2 66d7aa8553 Revert 'Fix off by one error' because it introduces one
Turns out, it's just redox not having a NULL pointer here. Linux does.
2018-08-13 11:37:29 +02:00
jD91mZM2 d5f85906cb Fix off-by-one error :| 2018-08-12 21:50:22 +02:00
jD91mZM2 1c4e8852dd Migrate to new FEXEC system call 2018-08-12 20:35:45 +02:00
jD91mZM2 07563de231 Implement setenv/unsetenv 2018-08-12 07:43:23 +02:00
jD91mZM2 232a3311df Add SIGABRT to redox 2018-08-10 08:33:11 +02:00
jD91mZM2 b10fa984f3 Implement strtod 2018-08-09 16:35:49 +02:00
jD91mZM2 face6f07f3 Implement mmap 2018-08-09 10:54:44 +02:00
Tom Almeida 3aa52e88a7 Fix issues with _IONBF and reading 2018-08-09 02:51:37 +08:00
Tom Almeida d5a9cd6953 Add tests to make sure setvbuf works. 2018-08-09 02:08:53 +08:00
Tom Almeida 540395c015 Fix _IONBF crashing when reading 2018-08-09 02:07:19 +08:00
Tom Almeida a1ebe321d6 Ensure that _IONBF would be respected when writing 2018-08-09 01:38:57 +08:00
jD91mZM2 40c3d28a41 fixup! Fix a few ffmpeg issues 2018-08-08 19:29:02 +02:00
jD91mZM2 b0546336c7 Fix a few ffmpeg issues 2018-08-08 19:28:13 +02:00
Tom Almeida d219d57acb Fix an issue where _IONBF would cause an overflow error 2018-08-09 00:49:57 +08:00
jD91mZM2 deee825a1c Implement llabs 2018-08-08 16:25:10 +02:00
jD91mZM2 b26213731c Don't forget to lock stdout when printfing 2018-08-08 13:25:26 +02:00
jD91mZM2 23a8855e50 Fix garbage env pointer to main on redox 2018-08-08 11:01:16 +02:00
jD91mZM2 40a7380a58 Fix snprintf and make strftime use a counting writer 2018-08-07 21:31:05 +02:00
jD91mZM2 d39a66c351 Fix waitpid -1 on redox 2018-08-07 15:01:07 +02:00
jD91mZM2 3bb3a3e322 Fix strcpy 2018-08-07 11:35:23 +02:00
jD91mZM2 f6ca7d7c2d Add S_ISSOCK and fix str(c)spn 2018-08-05 21:49:45 +02:00
jD91mZM2 b20307dca0 Implement fnmatch.h 2018-08-05 19:50:49 +02:00
jD91mZM2 b5adee798d Move scanf unit tests to normal C tests 2018-08-05 09:53:07 +02:00
jD91mZM2 442a7bbedc Fix getcwd with a NULL argument 2018-08-04 08:42:47 +02:00
jD91mZM2 ba8bd8c4e8 Add the last few things for bash to compile :D 2018-08-03 11:18:52 +02:00
jD91mZM2 44599a032e Kind of get bash to compile
Doesn't link yet due to "multiple definitions of malloc", because some are supplied by some library of bash itself. Really odd.
2018-08-02 14:37:57 +02:00
jD91mZM2 9c57c222f6 Fix strcasecmp 2018-07-31 07:37:19 +02:00
jD91mZM2 daf65c7a46 Implement access 2018-07-30 21:08:44 +02:00
jD91mZM2 ce53ac7e13 Fix inttypes a little 2018-07-30 12:32:03 +02:00
jD91mZM2 2a303c4b60 Implement sys/file.h 2018-07-30 10:04:58 +02:00
jD91mZM2 d3e4fa71a5 Implement sys/select.h
I really really wish I could actually test this on redox. All I know is: it compiles
2018-07-29 17:26:54 +02:00
Jeremy Soller bc7f7356b9 Fix redox futimens fd type 2018-07-29 07:22:41 -06:00
Jeremy Soller a9fcb973f6 Implement utimes and utime
Format
2018-07-29 07:18:44 -06:00
jD91mZM2 3eb7b99799 Move test binaries to tests/bins/ 2018-07-29 10:04:11 +02:00
jD91mZM2 f82b48b839 Implement sys/times.h on linux 2018-07-29 09:23:56 +02:00
jD91mZM2 e7e9d57db5 Implement a dummy sgtty 2018-07-29 07:55:19 +02:00
jD91mZM2 65cbd40fce Remove an accidentally committed binary. Again. Sigh. 2018-07-29 07:19:23 +02:00
jD91mZM2 4a42983d13 Make sigset_t be a long because bash needs that to compile 2018-07-28 17:18:53 +02:00
jD91mZM2 7524a83d82 fixup! sigemptyset and sigaddset 2018-07-28 15:33:06 +02:00
jD91mZM2 892ce75eb4 sigemptyset and sigaddset 2018-07-28 14:10:57 +02:00
jD91mZM2 6da2639dfa Fix leaking uninitialized elements and missing free 2018-07-28 08:22:21 +02:00
jD91mZM2 3c88056f9d Implement getrusage on linux 2018-07-27 19:54:30 +02:00
jD91mZM2 193328952d Alias memory.h to string.h 2018-07-27 18:27:51 +02:00
jD91mZM2 fc910d4157 Merge branch 'fix-parallel-builds' into 'master'
Turn the libc and libm rules into 'order-only' prequisites

Closes #127

See merge request redox-os/relibc!158
2018-07-27 16:02:49 +00:00
Robin Randhawa cb046c78e4 Turn the libc and libm rules into 'order-only' prequisites
These prerequisites are GNU Make terminology.

This change forces the libc rule to be executed first so that the headers that
the libm rule needs are available. The original setup was using 'normal'
prerequisites which occasionally resulted in bizarre build breakage,
especially on multi-core build hosts. Seen often on my 8-way SMP build
host.

Note that this doesn't impede parallelisation of each rule indepent of
the other. It just serializes the rules themselves.

This fixes: https://gitlab.redox-os.org/redox-os/relibc/issues/127
2018-07-27 16:51:15 +01:00
jD91mZM2 f6b364845e Implement pwd.h 2018-07-27 15:15:56 +02:00
jD91mZM2 1b40f2d463 Implement setitimer/getitimer/alarm/ualarm 2018-07-27 08:22:17 +02:00
jD91mZM2 8b48b6959c fixup! Implement isatty 2018-07-26 14:32:10 +02:00
jD91mZM2 2bf426b0fb Implement isatty 2018-07-26 14:19:20 +02:00
jD91mZM2 7ff6940edd Implement futimens 2018-07-26 13:26:54 +02:00
jD91mZM2 a0f2baff12 Implement gettimeofday 2018-07-26 10:07:33 +02:00
jD91mZM2 83949290c9 Implement dirent.h 2018-07-26 09:16:22 +02:00
jD91mZM2 dec5e0a019 Add missing sockaddr_in to platform/src/types.rs 2018-07-25 14:39:28 +02:00
jD91mZM2 e749d23030 Solve stdin/out/err UB in a better way 2018-07-25 14:29:14 +02:00
jD91mZM2 992e50ef0f Fix a few things with openssl 2018-07-25 14:04:36 +02:00
jD91mZM2 0e48937991 Merge branch 'tmpfile' into 'master'
Implement tmpfile

See merge request redox-os/relibc!154
2018-07-25 06:32:19 +00:00
stratact 42811717da Remove unneeded reference 2018-07-24 23:22:00 -07:00
stratact 5f6309d87c Implement tmpfile (squashed) 2018-07-24 23:14:18 -07:00
jD91mZM2 8021ade2a9 Move stat test out of expected tests 2018-07-23 21:41:19 +02:00
jD91mZM2 dc427272af fixup! Fix stat stack corruption and link test 2018-07-23 21:21:15 +02:00
jD91mZM2 5697ac0f84 Fix stat stack corruption and link test 2018-07-23 11:26:18 +02:00
jD91mZM2 86a38b47d1 Fix broken exec test 2018-07-22 19:57:59 +02:00
jD91mZM2 ecd8aca6d6 Basic signal support 2018-07-22 17:04:13 +02:00
jD91mZM2 7b8e7feb3d Run fmt.sh 2018-07-22 11:33:01 +02:00
jD91mZM2 67d5976622 Clean up tests 2018-07-22 11:24:50 +02:00
jD91mZM2 e9484e4d60 Ignore *all* target directories 2018-07-22 10:21:14 +02:00
jD91mZM2 27e8174e10 Combine mktemp and mkostemps logic 2018-07-22 10:17:09 +02:00
jD91mZM2 e4a89ae645 Merge branch 'mkstemp' into 'master'
Implement `mkstemp` and `mkostemps`

See merge request redox-os/relibc!152
2018-07-22 07:19:22 +00:00
stratact c788f7ed26 Add expected tests 2018-07-22 00:01:43 -07:00
stratact 6fa1f60830 Implement mkstemp and mkostemps (squashed) 2018-07-21 10:25:19 -07:00
jD91mZM2 7d43d45e56 Merge branch 'arpa_inet' into 'master'
implement arpainet

See merge request redox-os/relibc!153
2018-07-19 16:02:51 +00:00
Paul Sajna 0550a7b9db implement arpainet 2018-07-19 16:02:51 +00:00
jD91mZM2 233e679c08 Make inner platform functions private once more 2018-07-18 10:04:17 +02:00
jD91mZM2 ff9ef98f47 Move gethostname to platform 2018-07-18 10:02:42 +02:00
jD91mZM2 0a57c617c7 Remove a useless comment 2018-07-18 08:07:00 +02:00
jD91mZM2 5b3e09ee16 fixup! strcoll as strcmp because no locale 2018-07-17 18:35:54 +02:00
jD91mZM2 878208485c strcoll as strcmp because no locale 2018-07-17 17:44:38 +02:00
jD91mZM2 482bd9c5f1 fmt.sh 2018-07-17 17:24:22 +02:00
jD91mZM2 b83d1c7ff0 strftime :D 2018-07-17 16:47:33 +02:00
Jeremy Soller 37b6cd942c Fix pipe 2018-07-14 12:29:18 -06:00
jD91mZM2 515d041153 Hehe make environment tests work for everybody 2018-07-14 19:53:56 +02:00
jD91mZM2 75145ab92b Pass envp to main 2018-07-14 19:48:10 +02:00
jD91mZM2 019011f029 WIP env support 2018-07-14 18:03:22 +02:00
Jeremy Soller dc443a8cc3 Format 2018-07-13 09:53:44 -06:00
Jeremy Soller 4c4ce80fcd Fix warnings 2018-07-13 09:52:53 -06:00
Jeremy Soller 52e02286f2 Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2018-07-13 09:24:42 -06:00
Jeremy Soller 4718796c2b Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2018-07-13 09:23:13 -06:00
jD91mZM2 9cb0881cc4 Alias wbstowcs and wbtowc to their correct functions 2018-07-13 15:01:13 +02:00
jD91mZM2 5f098c89c3 Add more tests for mktime and localtime 2018-07-13 10:16:42 +02:00
jD91mZM2 a9ea2ef64e Fixup time & support negative & mktime 2018-07-13 09:13:46 +02:00
Jeremy Soller c2cdb451f5 Add system 2018-07-12 20:00:41 -06:00
jD91mZM2 758b437170 Run fmt.sh 2018-07-12 21:40:44 +02:00
jD91mZM2 b7e11afd2f Add localtime and ctime functions
I have NO IDEA if these are correct. Implementation was 'inspired by' https://github.com/rust-lang-deprecated/time/commit/4ca23fb14ddf44fd90609fec6a2fb1efcedb8ea3. Pretty darn certain that negative values won't work
2018-07-12 21:39:53 +02:00
jD91mZM2 a7cc95cd90 Comment out #[no_mangle] on unimplemented functions
This stops configure scripts from identifying them as valid
2018-07-12 21:39:53 +02:00
Jeremy Soller b8cab5f0be Fix missing stdint.h in signal.h 2018-07-12 11:12:41 -06:00
Jeremy Soller b7eb7a43e0 Update lock file 2018-07-12 09:50:00 -06:00
Jeremy Soller 463c9f386c Fix issue with RUSAGE constants not being in C headers if negative 2018-07-12 09:49:53 -06:00
Jeremy Soller 9c27110de1 Add rusage constants 2018-07-12 09:09:30 -06:00
Jeremy Soller 6e56734224 Fix environ signature 2018-07-12 09:00:58 -06:00
Jeremy Soller 99fa77535a Add pathconf variables 2018-07-12 09:00:23 -06:00
Jeremy Soller 9fc785dcc6 Add stack_chk functionality 2018-07-12 07:40:53 -06:00
Jeremy Soller 6c11a18240 Go back to patched ralloc 2018-07-11 09:59:28 -06:00
jD91mZM2 5f4ebaaabf Fix broken ralloc submodule & fmt.sh 2018-07-11 17:13:38 +02:00
jD91mZM2 55e618d8c0 Add the last socket functions on linux; leave unimplemented on redox 2018-07-11 12:49:50 +02:00
jD91mZM2 6d923cbd0b Implement getpeername and getsockname 2018-07-11 11:43:38 +02:00
jD91mZM2 30d91b82b2 Run fmt.sh 2018-07-08 08:51:15 +02:00
jD91mZM2 d3f6985ee9 Add a few things necessary for openssl (not all) 2018-07-08 08:44:23 +02:00
jD91mZM2 587ee32a30 Merge branch 'style-tag' into 'master'
Use style = Tag everywhere possible

See merge request redox-os/relibc!151
2018-07-08 06:38:45 +00:00
jD91mZM2 985a83ee69 Use style = Tag everywhere possible 2018-07-06 17:02:23 +02:00
jD91mZM2 53f634f579 Fix inttypes 2018-07-06 17:01:52 +02:00
jD91mZM2 eaf7338946 Add aliases for compatibility 2018-07-06 13:39:07 +02:00
Jeremy Soller 919ae09d2f Fix compilation on Redox 2018-07-04 10:16:34 -06:00
Jeremy Soller 3361b05911 Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2018-07-04 10:12:32 -06:00
Jeremy Soller ea5f8d59de Add dlmalloc 2018-07-04 10:10:34 -06:00
jD91mZM2 e206400d19 Move exec* back to platform
This undos a workaround. Jeremy moved the ralloc stuff to platform and suddenly this seems to work again. I don't know what is different from when I tried this before and now, but I don't really care
2018-07-04 09:29:34 +02:00
Jeremy Soller 3ef9599af5 Update ralloc 2018-07-03 21:18:23 -06:00
Jeremy Soller 42abc98a99 Cleanup allocation functions 2018-07-03 19:40:47 -06:00
Jeremy Soller b6b34a7026 Ralloc fixes and fixes for Redox execution 2018-07-03 19:07:07 -06:00
Jeremy Soller 7e6e1b164c Align stack on x86_64 2018-07-03 11:31:05 -06:00
jD91mZM2 6a0928edfd Use relibc to build openlibm 2018-07-03 19:01:24 +02:00
jD91mZM2 9c169a186f Run fmt.sh 2018-07-03 09:33:41 +02:00
jD91mZM2 aff5380723 Merge branch 'master' into 'master'
Fixing some things in stdio

See merge request redox-os/relibc!136
2018-07-03 07:21:02 +00:00
Tom Almeida 53a03cb0ba Made sure errors were properly handled by printf 2018-07-03 14:50:38 +08:00
Tom Almeida 8bc07abd05 Fix freopen.stdout. There was a trailing space 2018-07-03 14:42:31 +08:00
Tom Almeida ebe1ed15f8 Fix fgets 2018-07-03 14:34:40 +08:00
Tom Almeida bf2973e857 Ensure we correctly insert null character in gets 2018-07-03 12:50:04 +08:00
Tom Almeida d7a0f3d526 Ensure gets stops on newline or bufchar 2018-07-03 12:36:41 +08:00
Tom Almeida bf6db91993 Actually remove stdlib from stdio. This should have been done with wchar being put in, but I messed something up 2018-07-03 12:24:51 +08:00
Tom Almeida 72177be0fa Add a working implementation of gets 2018-07-03 12:14:30 +08:00
Tom Almeida 7277286efd Implement Drop for FILE, so we flush when the process exits 2018-07-03 10:05:12 +08:00
Tom Almeida 81107f8cd1 Don't reset read/write every time we check if we can read or write 2018-07-03 10:01:48 +08:00
Tom Almeida e9cecfead3 Return -1 for error in printf 2018-07-03 09:48:21 +08:00
Tom Almeida 0d61f9f4fd Make sure we can actually write before writing anything when using printf 2018-07-03 09:13:48 +08:00
Tom Almeida da664d4919 Merged relibc with branch 2018-07-03 08:39:04 +08:00
jD91mZM2 30ec8aa2c9 Add redox to CI 2018-07-02 10:35:40 +02:00
jD91mZM2 07dbc6bd76 Fix no_std on redox
Apparently a root-level cfg does not go well with a root-level no_std
2018-07-02 08:53:13 +02:00
jD91mZM2 17778ba1b4 Remove missing rustfmt.toml options 2018-07-02 07:42:33 +02:00
jD91mZM2 9c01673422 Use no_std in inttypes (whoops) 2018-07-01 21:00:03 +02:00
Stephan Vedder cc210361d6 wchar support 2018-07-01 20:59:37 +02:00
jD91mZM2 fb09b03acf Fix compilation on redox 2018-07-01 17:55:24 +02:00
Jeremy Soller 396a6dbb90 Merge branch 'mggmuggins/ci' into 'master'
Stage and Cache build

See merge request redox-os/relibc!150
2018-06-30 21:59:01 +00:00
SamwiseFilmore b911a76de4 Stage and Cache build 2018-06-30 21:01:12 +00:00
jD91mZM2 0567f699a2 Merge branch 'master' into 'master'
Workaround compilation errors

See merge request redox-os/relibc!149
2018-06-30 14:14:04 +00:00
jD91mZM2 541fbcf57c Use ptr::null over 0 2018-06-30 12:19:39 +02:00
jD91mZM2 1fd9a5f249 Moooore fixes :| 2018-06-30 12:15:51 +02:00
Tom Almeida 05b4b76426 Fix some issues 2018-06-30 17:49:34 +08:00
Tom Almeida 10a9081b66 Made sure that something that's unsafe is actually marked as unsafe 2018-06-30 17:47:30 +08:00
Tom Almeida 18418254b9 Made sure lazy_static works with no_std 2018-06-30 17:37:26 +08:00
Tom Almeida 8075447fad Changed FILE to use a vector as a buffer instead of raw pointers. This allows us to remove the large majority of unsafe blocks from the code 2018-06-30 17:37:26 +08:00
Tom Almeida 57f7de1e6d Changed FILE to use a vector as a buffer instead of raw pointers. This allows us to remove the large majority of unsafe blocks from the code 2018-06-30 17:33:02 +08:00
Tom Almeida 4c65f14f9a Fixed some issues with temporary files and moved some raw pointers to Option<&T>s 2018-06-30 17:26:39 +08:00
Tom Almeida 71fa4026f5 Changed FILE to use a vector as a buffer instead of raw pointers. This allows us to remove the large majority of unsafe blocks from the code 2018-06-30 17:26:35 +08:00
Tom Almeida a2dc22123f Merge branch 'master' into 'master'
# Conflicts:
#   src/stdio/src/default.rs
2018-06-30 09:19:54 +00:00
jD91mZM2 2f6467bce6 Fix test warning 2018-06-30 09:26:46 +02:00
jD91mZM2 674d4e3695 Preallocate because why not 2018-06-30 09:25:05 +02:00
jD91mZM2 234632d319 Workaround compilation errors 2018-06-30 09:19:06 +02:00
Jeremy Soller 29a626cd7c Merge branch 'unistd' into 'master'
Exec Functions (again) (again)

See merge request redox-os/relibc!144
2018-06-28 19:24:04 +00:00
Paul Sajna 5c5e237042 Exec Functions (again) (again) 2018-06-28 19:24:04 +00:00
Jeremy Soller da992bff56 Merge branch 'master' into 'master'
Fix off-by-one error and remove utf8 check in mktemp

See merge request redox-os/relibc!148
2018-06-28 11:36:02 +00:00
jD91mZM2 8e7cd11bc0 Fix CI 2018-06-28 08:31:34 +02:00
jD91mZM2 2c0f9ce747 Fix off-by-one error and remove utf8 check in mktemp 2018-06-28 08:03:17 +02:00
Jeremy Soller e4be43f617 Adjust list of expected binaries 2018-06-27 15:12:14 -06:00
Jeremy Soller 2e3eda4612 Add more expected files 2018-06-27 15:08:29 -06:00
Jeremy Soller cf6c8093ab Update expected output 2018-06-27 15:06:19 -06:00
Jeremy Soller 1f1665fd58 Merge branch 'master' into 'master'
Add the few last things to get gcc_complete working

See merge request redox-os/relibc!146
2018-06-27 21:02:30 +00:00
Jeremy Soller abbf0c9609 Add mktemp test binary to gitingore 2018-06-27 14:33:47 -06:00
Jeremy Soller 2dbe7ebee0 Update ralloc 2018-06-27 14:33:03 -06:00
Jeremy Soller b5da8aa35c Merge branch 'mggmuggins/ci' into 'master'
Add Gitlab CI

See merge request redox-os/relibc!140
2018-06-27 20:31:11 +00:00
Jeremy Soller 6939ca7d7a Merge branch 'mktemp' into 'master'
implement mktemp

See merge request redox-os/relibc!145
2018-06-27 20:22:12 +00:00
Paul Sajna 776491bae9 implement mktemp 2018-06-27 20:22:12 +00:00
jD91mZM2 a6ffd2cc46 Update inttypes to match the revert of ints 2018-06-27 08:08:14 +02:00
jD91mZM2 cbc3723c66 Fix signal not being linked correctly 2018-06-26 17:16:56 +02:00
jD91mZM2 727324fd73 Apparently cbindgen works on constants 2018-06-26 16:57:56 +02:00
jD91mZM2 9de73d0e5b Add uname and gethostname 2018-06-26 16:41:19 +02:00
jD91mZM2 844e244851 Use both Tag and Type 2018-06-26 16:05:02 +02:00
jD91mZM2 3927b0ab44 Revert int definitions 2018-06-26 14:10:20 +02:00
jD91mZM2 5fc1459eb9 signal: Make constants visible from C 2018-06-26 11:23:22 +02:00
jD91mZM2 0776de1ae6 Fix inttypes 2018-06-26 11:10:44 +02:00
jD91mZM2 257040e164 Fix a few stat-related things 2018-06-26 10:47:48 +02:00
jD91mZM2 ad324a0e4d Use global_asm for setjmp instead 2018-06-26 10:21:44 +02:00
jD91mZM2 feed73ffcc inttypes 2018-06-26 09:51:07 +02:00
jD91mZM2 5537817594 Export libm as well 2018-06-26 08:35:27 +02:00
jD91mZM2 441bf9f00b Add the few last things to get gcc_complete working 2018-06-25 11:43:44 +02:00
Jeremy Soller a63e6b3dd8 Merge branch 'master' into 'master'
Revert openlibm install script

See merge request redox-os/relibc!143
2018-06-24 18:50:40 +00:00
jD91mZM2 320eb0ecd0 Revert openlibm install script
Turns out that this only worked because I didn't clean before rebuilding, so it still had access to the old files. Sorry.
2018-06-24 20:19:06 +02:00
Jeremy Soller f265d7c5be Fix linking issues with lang items 2018-06-24 09:56:08 -06:00
Jeremy Soller 878f466b67 Update to new ralloc, new panic implementation, new compiler-builtins 2018-06-24 09:50:15 -06:00
Jeremy Soller be0aed56bc Merge branch 'master' into 'master'
Fix openlibm & fenv and add more integer types

See merge request redox-os/relibc!141
2018-06-24 13:18:34 +00:00
jD91mZM2 72e9525828 Add U?INT([0-9]+)_LEAST([0-9]+)_MIN/MAX macros 2018-06-24 14:27:42 +02:00
jD91mZM2 3e67314b97 Fix openlibm & fenv and add more integer types 2018-06-24 14:12:24 +02:00
SamwiseFilmore 59f1b37be8 Fix dumb mistake 2018-06-24 00:51:37 +00:00
SamwiseFilmore 382c6efb39 Add Gitlab CI 2018-06-24 00:48:54 +00:00
Jeremy Soller 7f0908eb8e Merge branch 'master' into 'master'
Reuse musl's setjmp implementation

See merge request redox-os/relibc!139
2018-06-23 17:46:01 +00:00
jD91mZM2 2283243d95 Replace setjmp lib.rs with empty file 2018-06-23 17:38:15 +02:00
jD91mZM2 4e99b55417 Implement basic setjmp using musl's awesome existing code 2018-06-23 17:38:10 +02:00
Jeremy Soller 6e67d30486 Merge branch 'master' into 'master'
Install openlibm from Makefile

See merge request redox-os/relibc!138
2018-06-23 08:33:27 +00:00
jD91mZM2 829bc64ad6 Remove unused import from test 2018-06-23 07:54:36 +02:00
Tom Almeida 7e731e0b01 Made sure lazy_static works with no_std 2018-06-23 13:08:28 +08:00
jD91mZM2 5945de62cb Install openlibm from Makefile 2018-06-23 06:54:23 +02:00
Tom Almeida c7bdd31a18 Merged relibc (#311db758) with branch 2018-06-23 05:13:02 +08:00
Tom Almeida 6bc28203ca Changed FILE to use a vector as a buffer instead of raw pointers. This allows us to remove the large majority of unsafe blocks from the code 2018-06-23 05:01:43 +08:00
jD91mZM2 12ce441f5c Use static mut over UnsafeCell 2018-06-22 22:40:30 +02:00
Tom Almeida b5529c9b71 Fixed some issues with temporary files and moved some raw pointers to Option<&T>s 2018-06-23 04:28:03 +08:00
Tom Almeida 5921f00e90 Changed FILE to use a vector as a buffer instead of raw pointers. This allows us to remove the large majority of unsafe blocks from the code 2018-06-23 04:28:00 +08:00
Jeremy Soller 8fd77a4b13 Merge branch 'master' into 'master'
Fix undefined behavior

See merge request redox-os/relibc!137
2018-06-22 20:07:31 +00:00
Tom Almeida 43a3c5677a Merged relibc (20/06/2018) with branch 2018-06-23 03:49:19 +08:00
Tom Almeida 50bfebfe3e Fixed some issues with temporary files and moved some raw pointers to Option<&T>s 2018-06-23 03:44:33 +08:00
Tom Almeida 90c6937f17 Changed FILE to use a vector as a buffer instead of raw pointers. This allows us to remove the large majority of unsafe blocks from the code 2018-06-23 03:44:30 +08:00
jD91mZM2 ea24699798 Fix undefined behavior
Transmuting from an immutable to a mutable reference is undefined
behavior in Rust, with the exception of UnsafeCell which tells the
optimizer to not draw too many conclusions. Sadly UnsafeCell::get cannot
yet be used in statics (see https://github.com/rust-lang/rust/issues/51718),
so this works around that by making the statics into functions and
making C macros to call those.
2018-06-22 21:17:44 +02:00
jD91mZM2 3034114c14 Fix broken comment 2018-06-22 15:02:34 +02:00
Jeremy Soller ccb74c6efc Merge branch 'master' into 'master'
Add empty locale functions

See merge request redox-os/relibc!135
2018-06-22 12:59:10 +00:00
jD91mZM2 0a3c8abe95 Fix setlocale return value 2018-06-22 14:54:16 +02:00
jD91mZM2 996445a6a3 Add empty locale functions 2018-06-22 14:54:10 +02:00
Jeremy Soller 05f7371e46 Merge branch 'master' into 'master'
Add scanf

See merge request redox-os/relibc!134
2018-06-21 16:58:41 +00:00
jD91mZM2 91221645c5 Add *scanf to header 2018-06-21 18:52:41 +02:00
jD91mZM2 5936c7a76e Add scanf 2018-06-21 17:16:56 +02:00
Tom Almeida 77b160c70d Fixed some issues with temporary files and moved some raw pointers to Option<&T>s 2018-06-21 09:33:21 +08:00
Jeremy Soller 6f8fff4b1c Merge branch 'sys_wait_macros' into 'master'
sys_wait: implement C macros properly

See merge request redox-os/relibc!133
2018-06-20 18:43:34 +00:00
Jasen Borisov 06a8d5d89d sys_wait: implement C macros properly
Remove the broken Rust functions and instead provide C macros in a
`include/bits` header. The C macros were taken from musl.
2018-06-20 19:40:38 +01:00
Tom Almeida 454ce67d45 Changed FILE to use a vector as a buffer instead of raw pointers. This allows us to remove the large majority of unsafe blocks from the code 2018-06-21 00:20:21 +08:00
Jeremy Soller 895e250564 Add aligned_alloc 2018-06-20 09:53:27 -06:00
Jeremy Soller 9d38494435 Fix missing strtol, strtoul 2018-06-20 09:44:09 -06:00
Jeremy Soller 1b653c4e60 Update ralloc, fix invalid c++ names 2018-06-20 08:48:56 -06:00
Jeremy Soller 009ceec188 Merge branch 'sys_wait_fix' into 'master'
Fix compilation error in `sys_wait`

See merge request redox-os/relibc!132
2018-06-14 20:09:46 +00:00
Jasen Borisov 326078a578 Fix compilation error in sys_wait 2018-06-14 20:15:25 +01:00
Jeremy Soller c5552cbb39 Merge branch 'fix-81' into 'master'
Add `sys_wait` functions (Fixes #81)

Closes #81

See merge request redox-os/relibc!131
2018-06-14 13:45:32 +00:00
stratact 3fa220237d Add sys_wait functions (Fixes #81) 2018-06-14 05:08:55 -07:00
Jeremy Soller a573549df8 Update links to gitlab 2018-06-12 12:30:45 -06:00
Jeremy Soller fd05aca991 Update README.md 2018-05-24 15:00:40 -06:00
Jeremy Soller 1f9f7ce6c8 Merge pull request #127 from stratact/master
Update `platform::rawfile`
2018-05-24 14:36:06 -06:00
stratact 3aa01b6907 Remove pointless cast 2018-05-24 13:27:24 -07:00
stratact a7a415603f Fix stupid mistake 2018-05-24 13:04:58 -07:00
stratact 16c51a297d Use the right C types from platform::types 2018-05-24 12:29:59 -07:00
Jeremy Soller f0227e737e Merge pull request #128 from ids1024/lifetime
Make functions taking raw pointer return &'a instead of &'static
2018-05-24 12:44:19 -06:00
Jeremy Soller aead6d8fd0 Merge pull request #129 from ids1024/cstr
Simplify cstr_from_bytes_with_nul_unchecked()
2018-05-24 12:43:48 -06:00
Ian Douglas Scott 5bcf1d42ff Simplify cstr_from_bytes_with_nul_unchecked()
The original implementation is modified from the `Cstr` method, but the
complexity there exists because it is trying to convert to the DST `Cstr`.
2018-05-24 11:27:35 -07:00
Ian Douglas Scott cbd0d0473c Make functions taking raw pointer return &'a instead of &'static
This is technically more correct, and matches the pointer methods in the
standard library.
2018-05-24 11:13:55 -07:00
stratact b389e4831d Have open() and dup() match -1 for Err instead of 0 2018-05-24 10:33:15 -07:00
stratact 9daae71c2a Use the super module instead of sys 2018-05-23 19:35:28 -07:00
stratact bb9d0e4aa1 Implement RawFile::from_raw_fd() 2018-05-23 13:14:42 -07:00
stratact 285d1b05c4 Implement RawFile::open() and add *_raw_df() convenience methods 2018-05-23 11:05:43 -07:00
stratact 7ca5fac214 Implement RawFile::dup() completely 2018-05-23 08:00:53 -07:00
Jeremy Soller 3311a700e0 Merge pull request #126 from ProgVal/update-ralloc
Update ralloc. Closes GH-83.
2018-05-20 07:27:15 -06:00
Valentin Lorentz 0b6d6549f1 Update ralloc. Closes GH-83. 2018-05-20 14:13:36 +02:00
Jeremy Soller ed12713aa8 Update gitignore for tests 2018-05-15 18:35:29 -06:00
Jeremy Soller c647fdfed3 Merge pull request #116 from matijaskala/patch-1
Add optimized version of memchr
2018-05-15 18:33:31 -06:00
Jeremy Soller 8eec109cc0 Merge pull request #120 from Majora320/master
Implement clock() and add CLOCK_* constants
2018-05-15 18:32:29 -06:00
Jeremy Soller c8d4ea3ee6 Merge pull request #123 from Arcterus/qsort-real
stdlib: implement qsort() as an introsort
2018-05-15 18:31:50 -06:00
Jeremy Soller 4fb4790890 Merge pull request #122 from Arcterus/qsort
Fix a bug in printf()
2018-05-15 18:31:21 -06:00
Matija Skala 9bbb070104 Add optimized version of memchr 2018-05-15 21:06:17 +02:00
Alex Lyon f5ded007c6 stdlib: recurse into the smaller partition when sorting 2018-05-13 16:16:48 -07:00
Alex Lyon 4d3ac1c0dc stdlib: save stack space by looping in introsort_helper() 2018-05-13 03:29:53 -07:00
Alex Lyon b15aa83a8a stdlib: move insertion sort from introsort() into a separate function 2018-05-13 03:15:16 -07:00
Alex Lyon aa21e5fc3f stdlib: implement qsort() as an introsort 2018-05-13 03:07:00 -07:00
Jeremy Soller 6e8e6ad5d2 Merge pull request #121 from Arcterus/strtoul
stdlib: implement strtoul() and strtol() using a macro
2018-05-12 06:24:18 -06:00
Alex Lyon 0cabecd5b5 stdio, string, platform: fix a bug in printf() involving chars
Because we were previously converting the bytes in the format
string into Rust's char type and then printing that using the
format machinery, byte values that were not valid single-byte
UTF-8 characters failed to print correctly.  I found this while
trying to implement qsort() because the output of my test program
was mysteriously incorrect despite it working when I used glibc.
2018-05-11 23:09:12 -07:00
Moses Miller d14d0b5965 Fix various formatting issues 2018-05-11 22:01:51 -07:00
Moses Miller 766e00c69e Implement conversion of nanoseconds to clocks in terms of CLOCKS_PER_SEC 2018-05-11 17:22:01 -07:00
Moses Miller 3d1a66f270 Add CLOCKS_PER_SEC 2018-05-11 16:26:56 -07:00
Moses Miller 9d8758006d Change 1000000 to 1_000_000 2018-05-11 11:41:18 -07:00
Alex Lyon 1bcc40c08f stdlib: manually fix formatting 2018-05-11 09:31:58 -07:00
Alex Lyon 7647db27c0 stdlib: implement strtoul() and strtol() using a macro 2018-05-11 01:48:27 -07:00
Moses Miller 56458e5e4c Condense 5 lines into 1 2018-05-10 20:48:13 -07:00
Moses Miller 1ecd5f8f21 Implement clock() and add CLOCK_* constants 2018-05-10 20:31:35 -07:00
Jeremy Soller 018f950851 Merge branch 'master' of https://github.com/jeizsm/relibc 2018-04-26 20:14:53 -06:00
Jeremy Soller 08091ab2a9 Merge branch 'stat' of https://github.com/sajattack/relibc 2018-04-26 20:12:57 -06:00
Marat Safin ff37adeeba add asctime
Signed-off-by: Marat Safin <jeizsm@gmail.com>
2018-04-19 07:59:58 +03:00
Jeremy Soller 43e6cad33f Merge pull request #112 from jeizsm/master
add gmtime and difftime
2018-04-17 10:07:12 -06:00
Marat Safin 8015878a73 use static variable for gmtime 2018-04-15 08:56:09 +03:00
Marat Safin 2b21dca567 add gmtime and difftime 2018-04-14 09:01:04 +03:00
Jeremy Soller 93e2e16077 Merge pull request #118 from dlrobertson/fix_ci
ci: Ensure that the correct compiler is installed
2018-04-08 12:16:01 -06:00
Dan Robertson 6a4220458c ci: Ensure that the correct compiler is installed
Ensure that a compiler is installed when the aarch64 CI build is run.
2018-04-08 13:52:34 +00:00
Jeremy Soller 722732b616 Merge pull request #114 from HermannDppes/format
Run ./fmt.sh
2018-04-04 16:07:37 -06:00
Hermann Döppes dc769fd977 Run ./fmt.sh 2018-04-04 22:52:06 +02:00
Jeremy Soller 3f627b1b40 Remove asserts 2018-04-03 19:52:50 -06:00
Jeremy Soller 5b1e11d1b1 Fix minimum alignment for malloc_inner 2018-04-03 19:52:34 -06:00
Jeremy Soller 62fbff93bc Clean up malloc 2018-04-03 19:51:50 -06:00
Jeremy Soller 742339ca9e Hacky version of memalign 2018-04-03 19:45:36 -06:00
Jeremy Soller dabd8dc6a2 Move memory handling into string, do not use compiler_builtins for memory handling 2018-03-27 21:28:48 -06:00
Jeremy Soller 79d05d7eda Build variadic functions as part of relibc 2018-03-27 21:13:11 -06:00
Jeremy Soller b849165438 Fix MAX_C macros 2018-03-27 20:33:04 -06:00
Jeremy Soller ea804582b9 Rename sys header crates, add mman constants 2018-03-27 20:25:42 -06:00
Jeremy Soller afdc80629f Fix Makefile spurious rebuilds
Add mem* functions to stdio
Add constant int functions
2018-03-27 20:14:22 -06:00
Paul Sajna 92493a55b9 fix harderer 2018-03-26 21:23:36 -07:00
Paul Sajna bc0763f3ef fmt 2018-03-26 21:17:14 -07:00
Paul Sajna 14957bb8dc fix harder 2018-03-26 21:14:38 -07:00
Jeremy Soller 6999363916 Create build directory if necessary in openlibm target 2018-03-26 20:41:02 -06:00
Jeremy Soller 78c8c2171b Add install target 2018-03-26 20:13:45 -06:00
Jeremy Soller 8c218b1608 Build crt0 as object file 2018-03-26 20:06:46 -06:00
Jeremy Soller d071522bc5 Add libm to phony 2018-03-26 19:59:42 -06:00
Jeremy Soller adcd0c9900 Only update libcrt0.a if there is a source change 2018-03-26 19:49:21 -06:00
Jeremy Soller e1abe80992 Fix CI 2018-03-26 19:34:45 -06:00
Jeremy Soller 6abd64ae16 Disable cargo cache 2018-03-26 19:13:49 -06:00
Jeremy Soller 47ee733afa Complete Makefile 2018-03-26 19:12:20 -06:00
Jeremy Soller ae137dbc03 Prepare for cross compiled openlibm 2018-03-26 18:50:51 -06:00
Jeremy Soller d9e4622f83 Add Makefile (WIP) 2018-03-26 18:38:29 -06:00
Jeremy Soller f0b41aa57e Merge pull request #104 from dlrobertson/rename
stdio: Implement rename
2018-03-26 18:22:22 -06:00
Jeremy Soller e39d2d61fa Merge branch 'master' into rename 2018-03-26 18:22:13 -06:00
Paul Sajna c7e9ec8ae2 fix 2018-03-26 16:47:12 -07:00
Paul Sajna c7ad4d3997 Merge branch 'stat' of github.com:sajattack/relibc into stat 2018-03-26 15:48:06 -07:00
Paul Sajna cafb76abdd mkfifo and constants 2018-03-26 15:47:36 -07:00
Paul 6d11736603 Merge branch 'master' into stat 2018-03-26 15:34:43 -07:00
Jeremy Soller bbf5c34ce8 Merge pull request #108 from mmstick/kill
Implement kill() and killpg()
2018-03-25 18:56:09 -06:00
Michael Aaron Murphy 43e95a9b92 Implement kill() and killpg() 2018-03-25 14:40:44 -04:00
Dan Robertson 57a17cb05f stdio: Implement rename 2018-03-25 14:41:42 +00:00
Paul Sajna 35dbc8d351 minor fixes 2018-03-23 13:37:56 -07:00
Paul Sajna 304473b68f Implement fstat, stat, lstat 2018-03-23 13:27:41 -07:00
Jeremy Soller 5f9170d861 Merge pull request #105 from jeizsm/master
add clock_gettime and time
2018-03-23 08:48:01 -06:00
Marat Safin 58b2b64183 add clock_gettime and time 2018-03-23 16:57:33 +03:00
Paul Sajna 29a6d24309 chmod and fchmod 2018-03-22 17:41:19 -07:00
Jeremy Soller 66fa211a05 Merge pull request #85 from Tommoa/master
Added functions for stdio.h
2018-03-22 10:07:57 -06:00
Tom Almeida 97e165d8c7 Merge branch 'master' into master 2018-03-22 12:49:55 +08:00
Tom Almeida e1b20ed368 Fixed getopt passing the wrong argument to stdio functions 2018-03-22 12:43:05 +08:00
Jeremy Soller e5849526a0 Update lock file 2018-03-21 21:16:21 -06:00
Jeremy Soller fcf1104ea5 Merge pull request #102 from sajattack/rand
implement rand and srand using the rand crate
2018-03-21 21:15:30 -06:00
Jeremy Soller 0ec7d0bc57 Merge branch 'master' into rand 2018-03-21 21:14:35 -06:00
Paul Sajna 5f243a21f7 Merge branch 'rand' of github.com:sajattack/relibc into rand 2018-03-21 20:13:27 -07:00
Jeremy Soller e34d32aefe Update gitignore 2018-03-21 21:12:58 -06:00
Paul Sajna cdc6209ff4 fix comment 2018-03-21 20:12:22 -07:00
Jeremy Soller 26b533c978 Merge branch 'master' into rand 2018-03-21 21:08:33 -06:00
Jeremy Soller ae097074ec Merge branch 'master' into master 2018-03-21 20:59:14 -06:00
Jeremy Soller 77b7a98d4e Merge pull request #97 from Arcterus/master
unistd: add a preliminary implementation of getopt()
2018-03-21 20:55:43 -06:00
Paul Sajna cc5a4e92ce fmt 2018-03-20 19:45:45 -07:00
Paul Sajna a24f537a38 test 2018-03-20 19:44:49 -07:00
Paul Sajna 4db812d34d implement rand and srand 2018-03-20 19:31:58 -07:00
Tom Almeida 19705ccc87 Merged master into master 2018-03-20 23:48:07 +08:00
Tom Almeida dbc3e413cc Fixed clearerr actually doing nothing 2018-03-20 23:43:42 +08:00
Alex Lyon 2751d457bf unistd: use .is_null() for pointers 2018-03-19 15:05:38 -07:00
Alex Lyon 42a6693a0b unistd: fix off-by-one in getopt() 2018-03-19 14:50:41 -07:00
Alex Lyon af78348d4a unistd: add a preliminary implementation of getopt() 2018-03-19 14:50:41 -07:00
Tom Almeida 90aec2076e Merge branch 'master' into master 2018-03-19 14:29:58 +08:00
Jeremy Soller edead8e085 Merge pull request #98 from jeizsm/master
refactor nanosleep
2018-03-18 16:40:30 -06:00
Jeremy Soller 045a510ce5 Merge pull request #92 from tdbgamer/feature/strtok
Implement strtok
2018-03-18 16:37:06 -06:00
Jeremy Soller ca61b4cb63 Merge pull request #100 from jrraymond/bsearch
implement bsearch
2018-03-18 16:36:24 -06:00
Justin Raymond d3583e11d2 fix c99 mode 2018-03-18 17:58:29 -04:00
Justin Raymond a0c76f7ce5 bsearch 2018-03-18 17:11:43 -04:00
Marat Safin 31516989c0 refactor nanosleep 2018-03-18 12:29:38 +03:00
Timothy Bess 3a89f66cfd * simplify strtok implementation 2018-03-18 00:05:13 -04:00
Jeremy Soller 5cec358a45 Merge pull request #86 from dlrobertson/add_headers
Add some of the basics for netinet/in.h and sys/socket.h
2018-03-17 18:11:46 -06:00
Jeremy Soller befca562df Merge pull request #95 from ids1024/travis
Use build matrix on Travis CI
2018-03-17 18:11:16 -06:00
Ian Douglas Scott b7d68895b0 Use build matrix on Travis CI
This makes it easy to see which target failed to build.
2018-03-17 16:00:54 -07:00
Timothy Bess 06de920be6 * remove unnecessary assignments 2018-03-17 12:58:10 -04:00
Tom Almeida d8139238e7 Merged master with branch 2018-03-18 00:22:08 +08:00
Tom Almeida c24d1e2b36 Removed all function pointers in FILE, moved internal functions to be member functions of FILE, made relevant *mut FILEs into &mut FILE and made suitable functions safe again 2018-03-18 00:20:21 +08:00
Tom Almeida d7965f2598 Made it so that AtomicBool exports as volatile char 2018-03-18 00:19:08 +08:00
Tom Almeida 25501b3640 Changed redox lseek to have the same function signature as the linux version 2018-03-18 00:18:14 +08:00
Tom Almeida b33c3a8e4f Merge branch 'master' into master 2018-03-18 00:06:59 +08:00
Jeremy Soller 362849f0f6 Merge pull request #91 from tdbgamer/master
Issue #89: Fix return types on string functions
2018-03-17 07:04:52 -06:00
Timothy Bess e91891625f * add strtok_r 2018-03-17 03:56:40 -04:00
Timothy Bess 898cf98ccc * fix test case a bit
* remove unnecessary cast
2018-03-17 03:06:59 -04:00
Timothy Bess f60fafe8fb * create basic strtok
* add test and expected output
2018-03-17 02:58:08 -04:00
Timothy Bess bebbd35e1a Issue #89
* fix return types
* fix type casts on returns
2018-03-17 00:50:22 -04:00
Tom Almeida 2cb0a994b8 Merge branch 'master' into master 2018-03-16 23:26:11 +08:00
Tom Almeida 659d3d1042 Changed object type of function pointers from Option<*const (Fn(...))> to Option<fn(...)> for readability 2018-03-16 23:14:43 +08:00
Jeremy Soller d75535974a Merge pull request #74 from sajattack/wait
wait and waitpid
2018-03-16 09:03:35 -06:00
Tom Almeida 81d96c214a Ran formatting for freopen() 2018-03-16 20:47:32 +08:00
Tom Almeida 8d40424020 Added freopen() and relevant tests 2018-03-16 20:24:40 +08:00
Paul Sajna 2610fdd126 Merge branch 'wait' of github.com:sajattack/relibc into wait 2018-03-15 16:22:23 -07:00
Paul Sajna c568ca2932 test cleanup 2018-03-15 16:18:35 -07:00
Jeremy Soller b2b7804f5b Merge branch 'master' into wait 2018-03-15 15:51:29 -06:00
Paul Sajna cdfde8c0d4 more requested changes 2018-03-15 11:55:37 -07:00
Dan Robertson 16e82636fb Add basic structures for netinet/in.h crate
Add the basic structures for the netinet/in.h header.
2018-03-15 17:34:30 +00:00
Dan Robertson 01081729c8 Add structures and stub fns for sys/socket.h
Add some of the basic structures and stub functions for sys/socket.h
2018-03-15 17:34:30 +00:00
Tom Almeida 41b96fede3 Added a different internal function for redox 2018-03-15 15:57:19 +08:00
Tom Almeida c4c8b73903 Formatted stdio files 2018-03-15 15:34:39 +08:00
Tom Almeida 8648fd39c4 Added some constants in linux for file modes in the new branch 2018-03-15 15:32:46 +08:00
Tom Almeida b0492eba84 Added some tests for stdio 2018-03-15 15:28:14 +08:00
Tom Almeida 7f2b720962 Implemented stdio functions 2018-03-15 15:27:07 +08:00
Tom Almeida 046ce1468e Removed an unused import from printf 2018-03-15 15:23:38 +08:00
Tom Almeida e73678d8ad Added a FileReader struct 2018-03-15 15:22:18 +08:00
Tom Almeida f20878c592 Added lseek to syscalls 2018-03-15 15:21:52 +08:00
Tom Almeida aa8b14e107 Added some constants in linux for file modes 2018-03-15 15:21:02 +08:00
Jeremy Soller a1baf1c92d Merge pull request #75 from azymohliad/master
Implement strstr() and strpbrk() from string.h
2018-03-14 21:22:59 -06:00
Jeremy Soller b419e150d1 Merge pull request #84 from dlrobertson/fixup_signal
Update cbindgen and fix issues with signal
2018-03-14 20:23:08 -06:00
Dan Robertson f1d802dc1e signal: sigaction struct should not be a typedef
The sigaction struct should not be a typedef, but the sigset_t struct
should be a typedef.
2018-03-15 01:07:44 +00:00
Dan Robertson 6d110ef0cb Use a sys module for OS specific information
Update cbindgen to parse modules with a path attribute and revert the
following commits:
 - 996fad7092.
 - cfe98ab3b2.
2018-03-15 00:53:35 +00:00
Paul Sajna 52acce0d34 handle the null case 2018-03-14 12:37:24 -07:00
Jeremy Soller 54c0e501e3 Merge pull request #82 from Tommoa/master
Actual working tests on strspn and strcspn
2018-03-13 21:02:04 -06:00
Tom Almeida b2d01a67f2 Actual working tests on strspn and strcspn 2018-03-14 10:55:01 +08:00
Jeremy Soller cfe98ab3b2 Fix constants in signal.h 2018-03-13 19:58:52 -06:00
Andrii Zymohliad cd2312fd56 Merge remote-tracking branch 'upstream/master' 2018-03-14 09:55:59 +08:00
Jeremy Soller d6e210b1fd Merge branch 'signal' of https://github.com/dlrobertson/relibc into dlrobertson-signal 2018-03-13 19:54:49 -06:00
Jeremy Soller 996fad7092 Fix fcntl header constants 2018-03-13 19:52:15 -06:00
Jeremy Soller 1d6115fd09 Update cbindgen and lock file 2018-03-13 19:41:31 -06:00
Jeremy Soller b09435f17d Merge pull request #78 from Tommoa/master
Yet another fix for strcspn and strspn.
2018-03-13 19:39:08 -06:00
Tom Almeida d3c2e99ed7 Merge branch 'master' into master 2018-03-14 08:56:52 +08:00
Tom Almeida d058390b75 The erroneous use came back! 2018-03-14 08:56:18 +08:00
Tom Almeida 122f6cfef5 Merge branch 'master' of github.com:Tommoa/relibc 2018-03-14 08:54:10 +08:00
Tom Almeida 9d46fa4d8c Missed having both loops look at themselves. I'm not sure how long this has been here. 2018-03-14 08:48:56 +08:00
Jeremy Soller 010e171071 Merge pull request #80 from dlrobertson/master
Add the no_mangle attribute to fns
2018-03-13 18:28:09 -06:00
Andrii Zymohliad 40efea056b Reimplement strpbrk() using strcspn() 2018-03-14 08:06:51 +08:00
Paul Sajna 2fd2a9c520 Merge branch 'wait' of github.com:sajattack/relibc into wait 2018-03-13 16:55:32 -07:00
Paul Sajna d177b8e974 requested change 2018-03-13 16:55:16 -07:00
Dan Robertson d3e44da527 Add the no_mangle attribute to fns
Add the no_mangle attribute to functions without it.
2018-03-13 23:27:32 +00:00
Tom Almeida ca82b6df5b remove erroneous import in string 2018-03-14 01:03:48 +08:00
Tom Almeida d6a7942ec4 Change the type of byteset from [u8] to [usize] in strcspn and strspn. Hopefully this is the last bug in these! 2018-03-14 01:01:23 +08:00
Jeremy Soller 1e661cdbef Merge branch 'master' into wait 2018-03-13 07:11:35 -06:00
Jeremy Soller 8d0308d3ce Merge branch 'master' into master 2018-03-12 21:59:06 -06:00
Jeremy Soller 13b7119994 Merge pull request #77 from dlrobertson/add_extern_crate
Add missing extern crate statements
2018-03-12 21:56:12 -06:00
Jeremy Soller dd847cc67e Return with 0 in all tests 2018-03-12 21:55:46 -06:00
Dan Robertson ef8a64c101 Add missing extern crate statements
Add missing extern crate statements.
2018-03-13 02:17:32 +00:00
Andrii Zymohliad c4620be999 Prettify strpbrk and strstr tests 2018-03-12 18:22:39 +08:00
Andrii Zymohliad 1e969afd43 Implement strpbrk(), add strpbrk test 2018-03-12 18:01:12 +08:00
Andrii Zymohliad a1de0ef8a1 Implement strstr(), add strstr test 2018-03-12 14:55:02 +08:00
Paul Sajna 211f95155a fmt 2018-03-11 21:24:06 -07:00
Paul Sajna b35abd1065 test and fixes 2018-03-11 21:20:59 -07:00
Paul Sajna 224cf04cf3 Merge branch 'master' of github.com:redox-os/relibc into wait 2018-03-11 20:28:39 -07:00
Jeremy Soller 7912332137 Mark sys_time functions no_mangle 2018-03-11 21:26:21 -06:00
Jeremy Soller 3e354aed04 Merge branch 'fix_includes' of https://github.com/dlrobertson/relibc into dlrobertson-fix_includes 2018-03-11 21:22:07 -06:00
Jeremy Soller 232e364f60 Remove warnings, build openlibm without stack protector 2018-03-11 21:20:56 -06:00
Jeremy Soller 477e8eb4e0 Exit run, expected, or verify on error in loop 2018-03-11 21:11:08 -06:00
Jeremy Soller 41e552b696 Only expect output for a whitelist of binaries 2018-03-11 21:04:53 -06:00
Jeremy Soller 7c13ec153e Update expects 2018-03-11 21:00:53 -06:00
Jeremy Soller ee13ed44d3 Merge pull request #69 from sajattack/stat
stat is now autogenerated correctly
2018-03-11 20:38:20 -06:00
Dan Robertson cc5669939e Fix include in resource.h and add SIZE_MAX
The rusage struct makes use of the timeval structure. Make sure to
include sys/time.h so that the type is known.

Add SIZE_MAX to stdint.h

sys/resource expects the defined structures to not be defined with a
typedef.
2018-03-12 02:38:07 +00:00
Jeremy Soller 7c305c5c0d Merge branch 'master' into stat 2018-03-11 19:31:59 -06:00
Paul Sajna c5dd3f8706 Update Cargo.lock 2018-03-11 17:01:25 -07:00
Paul Sajna ccb29cfa2c wait and waitpid 2018-03-11 16:50:46 -07:00
Dan Robertson 50eab4369d Add signal.h
Create stubs for signal.h
2018-03-11 21:36:02 +00:00
Jeremy Soller 1b1ff5c750 Merge pull request #66 from w0xel/master
Add implementation for a64l
2018-03-11 13:11:06 -06:00
Paul Sajna ca57f30425 Update cbindgen 2018-03-11 12:06:46 -07:00
Paul Sajna a000f1a2c0 fmt 2018-03-11 11:26:35 -07:00
Paul Sajna bc98f6a029 git rm include/sys/stat.h 2018-03-11 11:22:10 -07:00
Paul Sajna 76c4520cea stat is now autogenerated correctly 2018-03-11 11:19:56 -07:00
Jeremy Soller 4f5e978634 Merge pull request #68 from Tommoa/master
Fixed strcspn and strspn
2018-03-11 11:09:55 -06:00
Tom Almeida 1f9f9f7d55 Made an error in the logic of strcspn and strspn that would cause a bit shift much too large 2018-03-11 23:53:15 +08:00
Sebastian Würl 55bd1adae0 stdlib: cleaner raw pointer handling in a64l 2018-03-11 13:23:36 +01:00
Sebastian Würl d4d808fcc8 Add implementation for a64l 2018-03-11 11:55:22 +01:00
Jeremy Soller 8028c35172 Merge pull request #65 from dlrobertson/add_more_crates
Add more crates for missing headers
2018-03-10 21:52:30 -07:00
Jeremy Soller 089b41da23 Merge pull request #62 from jrraymond/strrchr
implement strrchr
2018-03-10 21:51:21 -07:00
Jeremy Soller c2a76870b5 Merge pull request #63 from Tommoa/master
Implemented fputc, fputs, and puts
2018-03-10 21:50:09 -07:00
Dan Robertson 3699b53ba2 float: Add crate for float.h
Add a crate with stubbed functions for the float.h header.
2018-03-10 21:16:55 +00:00
Dan Robertson f29e6b00d7 fenv: Add crate for fenv.h
Add a crate for building out stub functions and structures for the fenv
header.
2018-03-10 21:16:54 +00:00
Dan Robertson ca7f3a00e6 wait: Add crate for sys/wait.h
Add the basics of sys/wait.h so that we get a bit closer to being able
to compile libc-test.
2018-03-10 21:16:54 +00:00
Dan Robertson c6f16547ff resource: Add crate for sys/resource.h
Add the basics of sys/resource.h so that work can begin on sys/wait.h
2018-03-10 19:14:20 +00:00
Dan Robertson 2f718d40d6 mman: mman.h should be located at sys/mman.h
- Update target location of mman.h to sys/mman.h
 - Add more types to sys/type.h
2018-03-10 19:14:16 +00:00
Justin Raymond 63ee4de162 Update lib.rs 2018-03-10 12:39:30 -05:00
Justin Raymond 23a409204f Update .gitignore 2018-03-10 12:36:42 -05:00
Tom Almeida 49be92f87f ran fmt.sh cause I'm an idiot 2018-03-11 00:39:43 +08:00
Tom Almeida 8374fcb4be implemented fputc, fputs, and puts 2018-03-11 00:33:00 +08:00
Justin Raymond a1e62baad7 Merge branch 'master' into strrchr 2018-03-10 11:11:46 -05:00
Justin Raymond 826cf0c61c implement strrchr 2018-03-10 11:10:19 -05:00
Jeremy Soller ffeefb2a8e Merge pull request #61 from Tommoa/master
Add implementations of strspn, strcspn and strchr
2018-03-10 09:03:32 -07:00
Tom Almeida d0bf830ca7 fixed a logic error in strchr 2018-03-10 23:09:10 +08:00
Tom Almeida b0f8e31b63 ran fmt.sh 2018-03-10 23:01:49 +08:00
Tom Almeida 87ec6dfacb Fixed unused variable in memchr 2018-03-10 22:59:24 +08:00
Tom Almeida 18283feac1 Added implementations of strchr, strcspn and strspn 2018-03-10 22:58:35 +08:00
Jeremy Soller b52a1d612d Merge pull request #59 from Tommoa/master
Add implementations of memchr and memccpy
2018-03-10 07:03:40 -07:00
Jeremy Soller a227338a72 Merge pull request #58 from dlrobertson/sprintf
Add implementations of sprintf and snprintf
2018-03-10 07:00:22 -07:00
Tom Almeida a2a7efa946 Update .gitignore 2018-03-10 21:52:37 +08:00
Tom Almeida d214817c87 readability update in lib.rs 2018-03-10 21:52:06 +08:00
Jeremy Soller 0ee34fe836 Merge branch 'master' into sprintf 2018-03-10 06:46:17 -07:00
Jeremy Soller 639ea0919f Merge pull request #56 from Arcterus/master
string: address performance concerns for strncmp()
2018-03-10 06:43:22 -07:00
Tom Almeida 774856f9b2 Update lib.rs 2018-03-10 21:37:01 +08:00
Tom Almeida 3470882df6 Fixed incorrect return of memccpy 2018-03-10 17:12:05 +08:00
Tom Almeida b013f5f0ed Fixed mem test 2018-03-10 17:05:56 +08:00
Tom Almeida 4f601f4896 Added memchr and memccpy to string 2018-03-10 16:59:53 +08:00
Alex Lyon cfc1014c6e string: fix a couple minor issues in strncmp() 2018-03-09 20:54:42 -08:00
Alex Lyon 50f79e9a0e string: address performance concerns for strncmp() 2018-03-09 20:54:42 -08:00
Dan Robertson 75920d2c12 Add implementations of sprintf and snprintf
Add implementations of sprintf and snprintf so that we can get a bit
closer to compiling libc-test.
2018-03-10 02:33:03 +00:00
Jeremy Soller 3890ec58f0 Merge pull request #49 from sajattack/time
Add time and sys/time
2018-03-09 18:11:51 -07:00
Jeremy Soller 4d67145aa1 Merge pull request #54 from MggMuggins/master
Update README.md
2018-03-09 13:52:46 -07:00
MggMuggins 06a6922cde Merge branch 'master' of https://github.com/redox-os/relibc 2018-03-09 12:41:25 -06:00
MggMuggins d7aa9c44f9 Add Documentation 2018-03-09 12:38:37 -06:00
Paul 7108d0164e Merge branch 'master' into time 2018-03-09 08:37:40 -08:00
Paul Sajna 7e40d8c87b fmt 2018-03-09 07:51:15 -08:00
Paul Sajna 23bb883797 update nanosleep 2018-03-09 07:49:37 -08:00
Jeremy Soller 11043129f2 Merge pull request #52 from dlrobertson/aarch64
Aarch64: Merge the final components
2018-03-09 08:24:37 -07:00
Dan Robertson c2ae141df3 Aarch64: Merge the final components
Merge the final components for Aarch64 support into master.
2018-03-09 14:20:42 +00:00
Paul 031fc5da27 Update Makefile 2018-03-09 05:58:55 -08:00
Paul 5632d96016 Merge branch 'master' into time 2018-03-09 05:52:29 -08:00
Jeremy Soller 77c0a5b430 Merge pull request #47 from sajattack/unistd
implement setid functions and unlink
2018-03-09 06:50:04 -07:00
Paul 4d12c408fd Merge branch 'master' into time 2018-03-09 05:49:37 -08:00
Paul cdf298ba3a Merge branch 'master' into unistd 2018-03-09 05:48:22 -08:00
Jeremy Soller dd0e6187db Merge pull request #50 from Arcterus/master
Preliminary implementation of strtol()
2018-03-09 06:45:39 -07:00
Jeremy Soller b7ac90fd9f Merge branch 'master' into master 2018-03-09 06:45:17 -07:00
Jeremy Soller 580dcd3c08 Merge pull request #48 from sajattack/stat
correction to include guard of stat
2018-03-09 06:43:12 -07:00
Paul Sajna b11c079d69 Makefile fix 2018-03-09 05:34:58 -08:00
Paul Sajna 3c198a3a40 fmt 2018-03-09 05:19:25 -08:00
Paul Sajna 4d4ab1a75f fix and test 2018-03-09 05:18:21 -08:00
Paul Sajna 161d93466c fixes and tests 2018-03-09 04:48:34 -08:00
Paul Sajna e99857d125 sleep and usleep 2018-03-09 03:42:42 -08:00
Alex Lyon dec7ecd06b tests: fix Makefile 2018-03-09 03:37:30 -08:00
Paul Sajna 7e19ce23bd nanosleep 2018-03-09 03:26:45 -08:00
Alex Lyon 9325a29a74 stdlib: make rustfmt happy with strtol() 2018-03-09 03:21:18 -08:00
Alex Lyon f5b1f872a0 stdlib: implement preliminary version of strtol() 2018-03-09 03:07:16 -08:00
Alex Lyon a7e71717cb stdio: add support for %o to printf() 2018-03-09 02:51:50 -08:00
Paul Sajna 083aa0ed55 fmt 2018-03-09 02:47:22 -08:00
Paul Sajna 72909b3f4c add time and sys/time 2018-03-09 02:46:14 -08:00
Paul Sajna 1c1a48b648 fix formatting 2018-03-09 00:56:02 -08:00
Paul Sajna b9a2dfded4 correction to include guard of stat 2018-03-09 00:52:34 -08:00
Paul Sajna a7fba79be7 implement setid functions and unlink 2018-03-09 00:28:46 -08:00
Jeremy Soller e676440e1f Merge pull request #46 from dlrobertson/aarch64
Aarch64: Update syscall usage
2018-03-08 21:26:04 -07:00
Jeremy Soller 89259475ab Merge branch 'master' into aarch64 2018-03-08 21:25:28 -07:00
Jeremy Soller 54655a4e3b Add verification makefile rule 2018-03-08 21:22:17 -07:00
Dan Robertson f83ff041cc Aarch64: Update syscall usage
Don't use syscalls that are non-existent on Aarch64 linux boxes. The
FORK and RMDIR syscalls are no longer present and the CLONE and UNLINKAT
syscalls are used instead.
2018-03-09 04:19:22 +00:00
Jeremy Soller 85766a41ff Expected output 2018-03-08 21:14:46 -07:00
Jeremy Soller 4da873ae79 Merge pull request #43 from MggMuggins/master
Imp va_arg for fcntl; fcntl test
2018-03-08 21:07:39 -07:00
Jeremy Soller 76e53e86fa Merge pull request #45 from redox-os/atof
Implement atof
2018-03-08 21:00:38 -07:00
Jeremy Soller a95a034219 Fix issues by adding support for floating point values in va_list 2018-03-08 20:54:46 -07:00
Jeremy Soller 56e304a2af Fix format 2018-03-08 20:20:21 -07:00
Jeremy Soller 0e766c6b53 Implement atof 2018-03-08 20:17:45 -07:00
Jeremy Soller 96358469a4 Merge branch 'master' into master 2018-03-08 20:17:08 -07:00
MggMuggins c291632492 Imp va_arg for fcntl; fcntl test 2018-03-08 20:56:50 -06:00
Paul Sajna 799c8828c2 mkdir and rmdir 2018-03-08 19:45:16 -07:00
Jeremy Soller 231d7a023a Merge pull request #42 from dlrobertson/use_va_list
fcntl: open should use a va_list
2018-03-08 19:32:34 -07:00
Jeremy Soller 7b3fc9191a Merge pull request #40 from MggMuggins/master
Implement fcntl
2018-03-08 19:24:54 -07:00
Dan Robertson e306e3f855 fcntl: open should use a va_list
The current implementation of open requires the user to pass all three
args to the function. It should use a va_list and allow a user to
provide only the filename and flags.
2018-03-09 02:24:25 +00:00
MggMuggins 0cb3a893a1 Fix compile on redox 2018-03-08 20:19:55 -06:00
Jeremy Soller fb173dc787 Move travis instructions into ci.sh 2018-03-08 19:14:10 -07:00
MggMuggins 14c8125108 Implement fcntl
No tests written yet! See #36
2018-03-08 19:55:35 -06:00
Jeremy Soller 620a459d93 Merge pull request #39 from Arcterus/master
string: fix out of bounds bug in strncmp
2018-03-08 18:34:27 -07:00
Alex Lyon 332ae13af5 string: fix out of bounds bug in strncmp 2018-03-08 17:18:38 -08:00
Jeremy Soller dbe73d4bab Merge pull request #35 from sajattack/patch-1
Add build badge to README
2018-03-08 17:47:28 -07:00
Jeremy Soller d0c9c46ff9 Merge pull request #38 from MggMuggins/master
ctype: tests and reorganize
2018-03-08 17:47:01 -07:00
SamwiseFilmore 46fe488e05 Merge branch 'master' into master 2018-03-08 18:31:14 -06:00
MggMuggins 6ced871d9a ctype: tests and reorganize
Wrote tests for the functions implemented in 40558b2 and maybe made that
test a little more comprehensible.

Also made sure that fmt.sh and test.sh were being executed by bash all
the time (compatibility with other shells).
2018-03-08 18:25:11 -06:00
Paul bb376ff3fb Add build badge to README 2018-03-08 15:27:44 -08:00
Jeremy Soller 284cc4eece Fix formatting 2018-03-08 16:21:04 -07:00
Jeremy Soller cd4082bf9f Fix build harder 2018-03-08 16:09:28 -07:00
Jeremy Soller 07c3ce02be Fix build 2018-03-08 15:52:48 -07:00
Jeremy Soller af78f4819a Merge branch 'master' of github.com:redox-os/relibc 2018-03-08 15:43:23 -07:00
Jeremy Soller 4198055d4a Fix tests 2018-03-08 15:43:17 -07:00
Jeremy Soller 8adf1c3de0 Merge pull request #34 from MggMuggins/master
Finish ctype impls
2018-03-08 15:39:05 -07:00
MggMuggins 42de0a0a46 Merge branch 'master' of https://github.com/redox-os/relibc 2018-03-08 16:29:58 -06:00
MggMuggins 40558b2608 Finish ctype impls; Solve #31 2018-03-08 16:16:51 -06:00
Jeremy Soller cfbe27490f Remove allocation, fix pipe example 2018-03-08 15:00:17 -07:00
Jeremy Soller 0bcabc2163 Merge remote-tracking branch 'sajattack/unistd' 2018-03-08 14:53:07 -07:00
Jeremy Soller 18961114e2 Simplify perror 2018-03-08 14:51:22 -07:00
Jeremy Soller c6a31f709b Merge remote-tracking branch 'sajattack/master' 2018-03-08 14:47:03 -07:00
Jeremy Soller e1a8b288fb Update README.md 2018-03-08 14:32:06 -07:00
Jeremy Soller 38ed9ccb22 Update README.md 2018-03-08 14:31:55 -07:00
Paul Sajna 12833a5a5c add test and fork 2018-03-08 12:25:14 -08:00
Paul Sajna 22fb6c5bf0 copy strerror implementation into perror 2018-03-08 11:20:13 -08:00
Paul Sajna 6304595a1d Merge branch 'master' of github.com:redox-os/relibc 2018-03-08 11:07:51 -08:00
Jeremy Soller 8812c2148f Merge pull request #33 from dlrobertson/stub_wctype
Create crate and stubs for wctype
2018-03-08 10:07:14 -07:00
Dan Robertson a6a16cf233 Create crate and stubs for wctype
Create the wctype crate and stub functions with the unimplemented macro.
2018-03-08 16:03:45 +00:00
Jeremy Soller 013dff2aaf Merge pull request #29 from dlrobertson/add_functions
Add ctype functions and atoi/atol
2018-03-08 07:34:14 -07:00
Paul Sajna 33f1033e0e implement pipe and read 2018-03-07 23:30:10 -08:00
Dan Robertson ec288a1b53 Add ctype functions and atoi/atol
Add ctype functions
  - isalnum
  - isalpha
  - isascii
  - isdigit
  - islower
  - isspace
  - isupper
Add stdlib functions
  - atoi
  - atol
Fix some warnings
Make a fmt run
2018-03-08 05:26:40 +00:00
Paul Sajna 838c364ed5 Merge branch 'unistd' 2018-03-07 20:58:48 -08:00
Paul Sajna 3b7149612f implement perror 2018-03-07 20:57:51 -08:00
Jeremy Soller 1127c36ceb Add strerror to error test 2018-03-07 21:01:48 -07:00
Jeremy Soller b7b49d5801 Implement strerror 2018-03-07 21:00:26 -07:00
Paul Sajna f6db153ea5 Merge branch 'master' of github.com:redox-os/relibc 2018-03-07 19:46:41 -08:00
Jeremy Soller f01c669771 Remove thread local from errno, for now 2018-03-07 20:37:22 -07:00
Jeremy Soller 85b80d0fe5 Fix errno.h, add -no-pie to tests Makefile 2018-03-07 20:31:18 -07:00
Paul Sajna 95424b3c69 Merge branch 'master' of github.com:redox-os/relibc 2018-03-07 18:47:21 -08:00
Jeremy Soller 851e4d399f Fix errno.h definition 2018-03-07 19:46:23 -07:00
Paul Sajna ffd9176cdf forgot to commit the makefile 2018-03-07 18:45:03 -08:00
Jeremy Soller 633b5474db Merge pull request #27 from sajattack/master
add test for errno
2018-03-07 19:40:46 -07:00
Jeremy Soller 7e725a803e Merge pull request #26 from Arcterus/master
Implement several more string functions and add errno
2018-03-07 19:40:09 -07:00
Paul Sajna 93ddcca294 add test for errno 2018-03-07 18:36:18 -08:00
Alex Lyon 629c20f097 string: ensure resulting string has NUL byte 2018-03-07 17:52:37 -08:00
Alex Lyon 3e1b945e99 Add errno crate and set errno in strndup 2018-03-07 17:38:43 -08:00
Jeremy Soller 89a9e01676 Create README.md 2018-03-07 17:29:54 -07:00
Jeremy Soller ba515d83df Create LICENSE 2018-03-07 17:29:33 -07:00
Alex Lyon ee824f3b19 string: implement strndup and strnlen 2018-03-07 15:59:58 -08:00
Alex Lyon 9f39456dbd string: implement strcat, strcmp, strcpy, and strdup 2018-03-07 14:06:30 -08:00
Jeremy Soller 3224fa24c8 Merge pull request #23 from Arcterus/master
string: implement strncat, strncmp, and strncpy
2018-03-07 06:15:21 -07:00
Alex Lyon 114ee16c21 string: implement strncat, strncmp, and strncpy 2018-03-07 05:04:40 -08:00
Jeremy Soller 1198ad3ae7 Format vsnprintf 2018-03-06 22:02:30 -07:00
Jeremy Soller ff0cebca87 Implement more stdio functions 2018-03-06 21:47:39 -07:00
Jeremy Soller bf41415c8b Use Rust nightly, disable email notifications 2018-03-06 21:25:10 -07:00
Jeremy Soller b14ee3ed39 Fix build, add Wall 2018-03-06 21:23:36 -07:00
Jeremy Soller 853fdaad75 Merge branch 'master' of github.com:redox-os/relibc 2018-03-06 21:16:14 -07:00
Jeremy Soller a1ce114cd4 Convert errors and set errno 2018-03-06 21:15:38 -07:00
Jeremy Soller 6afdf3fabf Merge pull request #21 from sajattack/patch-1
Test if the redox version compiles too
2018-03-06 21:08:09 -07:00
Paul 8f513f809b Test if it compiles for redox too 2018-03-06 20:06:47 -08:00
Jeremy Soller cf03233e66 Fix linux build 2018-03-06 20:44:21 -07:00
Jeremy Soller b768e44678 Merge pull request #19 from sajattack/redox-fixes
redox fixes
2018-03-06 20:42:35 -07:00
Jeremy Soller 1dd2f61d76 Merge pull request #20 from dlrobertson/add_ci
Add test.sh and fmt.sh to travis.yml
2018-03-06 20:40:13 -07:00
Paul Sajna 05d316b3a5 redox fixes 2018-03-06 19:28:02 -08:00
Dan Robertson 628c68abe3 Add test.sh and fmt.sh to travis.yml
Do not accept unformatted code.
2018-03-07 03:15:24 +00:00
Jeremy Soller 98b2fba518 Merge pull request #18 from dlrobertson/aarch64
Finalize Aarch64 support
2018-03-06 20:03:47 -07:00
Dan Robertson 40b6a9c5cc Finalize Aarch64 support
Update platform support for linux to avoid the use of syscalls not
supported by Aarch64.
  - link, chown, and open should use fchownat and linkat with fd
    set to AT_FDCWD.
  - use dup3 with the 3rd arg set to 0 instead of dup2.
2018-03-07 02:56:08 +00:00
Jeremy Soller 543526cb85 Move crt0 and platform into src folder
Add cargo fmt script
2018-03-06 19:55:11 -07:00
Jeremy Soller 6bca112340 Merge pull request #16 from dlrobertson/fixes_and_nits
Fix platform
2018-03-06 19:30:13 -07:00
Dan Robertson 846e495944 Get rustfmt passing on core relibc code
- Add a rustfmt config
 - Get the current code passing the formatter
2018-03-07 01:52:50 +00:00
Dan Robertson 2096b85115 Fix platform
- Add cfg to extern crate sc. It is not used by redox.
 - Fix bad syntax in brk implementation for redox
 - nits
   - style: update brk implementation for linux
   - style: no space between not operator and ptr.is_null
   - style: should be a space around = in module path
2018-03-07 01:52:50 +00:00
Jeremy Soller a808dfe39c Merge pull request #14 from sajattack/unistd
implement some unistd
2018-03-05 19:31:08 -07:00
Paul Sajna 44e6c334e6 unwrap_or(-1) 2018-03-05 14:57:04 -08:00
Paul Sajna 151d873aba link 2018-03-04 22:34:47 -08:00
Paul Sajna 3a07bc27c2 getid functions 2018-03-04 22:11:59 -08:00
Jeremy Soller d4308b4c5d Update rust toolchain and lock file 2018-03-04 18:01:28 -07:00
Paul Sajna 2636b6f5b1 ftruncate test 2018-03-04 16:41:53 -08:00
Paul Sajna 5cc52e4b19 tests 2018-03-04 16:34:46 -08:00
Paul Sajna fc92d95b35 this [u8] to c_char* is probably wrong 2018-03-04 09:42:57 -08:00
Paul Sajna 95ed0b59bd getcwd 2018-03-04 09:35:38 -08:00
Paul Sajna b5192437c3 ftruncate 2018-03-04 09:24:33 -08:00
Paul Sajna 3ad7c62601 fsync and some tweaks 2018-03-04 09:16:56 -08:00
Paul Sajna 9de89e037a fchdir 2018-03-04 09:03:46 -08:00
Paul Sajna 95e74373fe fchown 2018-03-04 08:49:40 -08:00
Paul Sajna 8b1222c3fb brk 2018-03-04 08:41:37 -08:00
Paul Sajna c96040187f chown 2018-03-04 08:32:47 -08:00
Paul Sajna aa4f7ed3a5 Merge branch 'platform' into unistd 2018-03-04 08:21:52 -08:00
Paul Sajna 6b89b4620b Merge branch 'master' of github.com:redox-os/relibc into platform 2018-03-04 08:09:48 -08:00
Paul Sajna 4b1a1568bf add rawfile.rs 2018-03-04 08:09:13 -08:00
Jeremy Soller 8283f130d6 Merge pull request #10 from sajattack/semaphore
build semaphore header
2018-03-04 09:06:30 -07:00
Paul Sajna 0157f7fcea Merge branch 'semaphore' into platform 2018-03-04 08:03:01 -08:00
Paul Sajna 608a6fcfad merge 2018-03-04 08:02:41 -08:00
Paul Sajna e08ffa6474 merge 2018-03-04 07:57:39 -08:00
Paul Sajna 25b9ac206b remove timedwait 2018-03-04 07:50:49 -08:00
Paul ae4b64c491 missing curlyboi 2018-03-04 07:41:07 -08:00
Paul 4d506e6981 Merge branch 'master' into unistd 2018-03-04 07:39:51 -08:00
Paul Sajna 7a38acada9 Merge branch 'semaphore' of github.com:sajattack/relibc into semaphore 2018-03-04 07:34:47 -08:00
Paul Sajna 0a245a386e comment out sem_open 2018-03-04 07:34:27 -08:00
Paul Sajna caa89878d6 merge 2018-03-04 07:33:38 -08:00
Jeremy Soller 5002dd720f Add mman to lib.rs 2018-03-04 08:31:43 -07:00
Jeremy Soller 07c897e558 Clean up gcc line 2018-03-04 08:29:19 -07:00
Jeremy Soller 18c6701841 Disable stack protector 2018-03-04 08:27:20 -07:00
Jeremy Soller 654ca47351 Fix atexit_funcs call in exit 2018-03-04 08:15:26 -07:00
Jeremy Soller 7a7b3efe3a Merge branch 'master' of github.com:redox-os/relibc 2018-03-04 08:12:38 -07:00
Jeremy Soller 866d952924 Support building for Redox 2018-03-04 08:10:42 -07:00
Paul Sajna d9d7440a7f implement some unistd 2018-03-04 06:53:30 -08:00
Paul Sajna 8860109efc add stuff from old newlib to todo 2018-03-04 06:53:30 -08:00
Paul Sajna 432c3ad397 add mman to main Cargo.toml 2018-03-04 06:53:30 -08:00
Paul Sajna de29e16024 remove mman from todo 2018-03-04 06:53:30 -08:00
Paul Sajna 16cf6e0267 build mman header 2018-03-04 06:53:30 -08:00
Paul 0e423aae4d Merge branch 'master' into semaphore 2018-03-04 06:46:27 -08:00
Paul Sajna 21abb75ccc Merge branch 'semaphore' of github.com:sajattack/relibc into semaphore 2018-03-04 06:45:13 -08:00
Paul Sajna 7fcad36826 add semaphore to main Cargo.toml 2018-03-04 06:43:41 -08:00
Paul Sajna 2e1d29203d build semaphore header 2018-03-04 06:43:41 -08:00
Paul Sajna d25b1d2fa4 implement some unistd 2018-03-04 06:37:45 -08:00
Jeremy Soller 9f5db313ce Merge pull request #13 from sajattack/oldlib
add stuff from old newlib to todo
2018-03-04 07:36:00 -07:00
Jeremy Soller 50af0031c3 Merge pull request #9 from sajattack/mman
build mman header
2018-03-04 07:35:28 -07:00
Jeremy Soller 4f5d65e7a6 Merge pull request #12 from sajattack/atexit
fix atexit
2018-03-04 06:17:25 -07:00
Paul Sajna 460d7fb2c3 add stuff from old newlib to todo 2018-03-04 05:08:32 -08:00
Paul Sajna ef9545cf71 missing parens 2018-03-04 04:43:05 -08:00
Paul Sajna cdf5cb2d56 fix atexit 2018-03-04 04:34:22 -08:00
Jeremy Soller e2695b2380 Merge pull request #11 from dlrobertson/aarch64
Start on support for aarch64
2018-03-03 23:00:30 -07:00
Paul Sajna 01e519aa24 add semaphore to main Cargo.toml 2018-03-03 21:56:46 -08:00
Jeremy Soller 1a572d91b0 Merge pull request #8 from sajattack/fix-options
Fix options
2018-03-03 22:56:09 -07:00
Paul Sajna 09116f83f7 add mman to main Cargo.toml 2018-03-03 21:55:24 -08:00
Dan Robertson d9d2ec1992 Start on support for aarch64
- Add aarch64 support
   - crt0 - add support to _start
   - platform - aarch64 does not have the open syscall. Instead most
     libc implementations use openat() with AT_FDCWD
 - Use sc instead of syscall. sc is the maintained fork of syscall.
2018-03-04 05:10:31 +00:00
Paul Sajna 3210d52eee Merge branch 'fix-options' into semaphore 2018-03-03 21:10:11 -08:00
Paul Sajna 6cf4b3bf82 build semaphore header 2018-03-03 21:07:40 -08:00
Paul Sajna 2acf7e6915 remove mman from todo 2018-03-03 20:58:58 -08:00
Paul Sajna ba1a9543c8 build mman header 2018-03-03 20:57:29 -08:00
Paul Sajna ee6ffbe73e fix Options 2018-03-03 20:55:32 -08:00
Paul Sajna eea3f0ede6 Merge branch 'master' of github.com:redox-os/relibc 2018-03-03 20:07:33 -08:00
Jeremy Soller a6dfd7145f Merge pull request #6 from sajattack/master
wrap all function parameters in Options
2018-03-03 21:04:12 -07:00
Paul Sajna f4d8fd3186 Merge branch 'master' of github.com:redox-os/relibc 2018-03-03 19:58:12 -08:00
Jeremy Soller 352f485649 Build grp header 2018-03-03 20:52:10 -07:00
Jeremy Soller a9f2e9a9a7 Add template 2018-03-03 20:48:37 -07:00
Paul Sajna 2b16a3693e wrap all function parameters in Options 2018-03-03 19:42:29 -08:00
Paul Sajna 533cb67681 fix Options 2018-03-03 19:33:34 -08:00
Jeremy Soller c4b88cc1e6 Build ctype with header 2018-03-03 20:33:19 -07:00
Jeremy Soller 083fd72e66 Reorganize 2018-03-03 20:24:40 -07:00
Jeremy Soller 388d8ed8cf Merge stdlib 2018-03-03 20:17:46 -07:00
Jeremy Soller 9a423140bc Merge string 2018-03-03 20:17:08 -07:00
Jeremy Soller 800a3a7a47 Merge stdio files 2018-03-03 20:13:52 -07:00
Jeremy Soller 3855e4c4b9 Merge branch 'master' of https://github.com/sajattack/relibc into sajattack-master 2018-03-03 20:06:27 -07:00
Jeremy Soller 64b2970cf4 make it possible to printf to any fmt::Write implementer 2018-03-03 19:57:18 -07:00
Jeremy Soller 5520526bef Implement printf (very simple version) 2018-03-03 19:47:01 -07:00
Jeremy Soller bf987098dc Use openlibm 2018-03-03 17:56:53 -07:00
Paul Sajna 341bc1b938 parameter names 2018-03-03 16:49:01 -08:00
Jeremy Soller 172517e4f8 Add all stdlib functions 2018-03-03 17:44:09 -07:00
Jeremy Soller f5ef0af883 Implement malloc/free with ralloc 2018-03-03 16:54:58 -07:00
Jeremy Soller e30dec7124 WIP: stdio.h 2018-03-03 15:15:50 -07:00
Jeremy Soller 2aff4d41dd Implement argument handling, add string.h 2018-03-03 14:55:54 -07:00
Jeremy Soller 78e421cb72 Implement some functions on Linux 2018-03-03 14:31:28 -07:00
Paul Sajna 457d3972f7 merge with origin, put unistd back the way it was 2018-03-03 12:28:59 -08:00
Jeremy Soller 9fb0b77d89 Include sys/types in fctnl and unistd 2018-03-03 13:10:21 -07:00
Jeremy Soller d64dba1c1e Use patched cbindgen, implement stdbool and stdint 2018-03-03 13:05:43 -07:00
Jeremy Soller a9aae80ae0 WIP: Define common types 2018-03-03 10:08:16 -07:00
Jeremy Soller d337caafe6 Remove std from outputted libc.a 2018-03-03 09:19:25 -07:00
Jeremy Soller d20e3f69e1 no_std 2018-03-03 08:51:14 -07:00
Jeremy Soller a01ff6baf8 Add overarching staticlib 2018-03-03 08:44:18 -07:00
Jeremy Soller 7251cbec76 Add definitions for unistd 2018-03-03 08:33:19 -07:00
Jeremy Soller b720d0181f Add fcntl 2018-03-03 08:25:53 -07:00
Jeremy Soller 858ad52cf6 Finish function definitions for unistd 2018-03-03 08:04:16 -07:00
Paul Sajna 1a298045b6 #[no_mangle] 2018-03-02 21:27:35 -08:00
Paul Sajna e57a314acf rustfmt 2018-03-02 18:24:40 -08:00
Paul Sajna 7da98c514a wctype.h skeleton 2018-03-02 18:15:13 -08:00
Paul Sajna bd91a5a11e wchar.h skeleton 2018-03-02 18:08:35 -08:00
Paul Sajna 28b72a667c grp.h skeleton 2018-03-02 17:51:39 -08:00
Paul Sajna b8a5b9b551 aio.h skeleton 2018-03-02 17:40:35 -08:00
Paul Sajna 7f29a7127c ctype.h skeleton 2018-03-02 17:36:23 -08:00
Paul Sajna 3ccd24c50e mman 2018-03-02 17:30:20 -08:00
Paul Sajna ae49c54d60 stdio.h skeleton 2018-03-02 17:23:28 -08:00
Paul Sajna c1d1be4d61 semaphore.h skeleton 2018-03-02 17:07:17 -08:00
Paul Sajna e39ff9d5a3 add string.h skeleton 2018-03-02 16:59:44 -08:00
Paul Sajna aef8c1442d pthread skeleton 2018-03-02 16:55:13 -08:00
Paul Sajna af548fd1bc add bindgen post-processing script, use it for unistd and stdlib.h 2018-03-02 14:50:13 -08:00
Jeremy Soller b2b120bbc1 Add many more functions 2018-03-01 21:02:52 -07:00
Jeremy Soller 3267409c57 Add very basic example 2018-03-01 20:26:40 -07:00
1603 changed files with 100284 additions and 92804 deletions
+7
View File
@@ -0,0 +1,7 @@
[**.c]
indent_size = 4
indent_style = space
[**.yml]
indent_size = 4
indent_style = space
+10 -10
View File
@@ -1,11 +1,11 @@
target/
sysroot/
# Local settings folder for Visual Studio Code
.vscode/
# Local settings folder for Jetbrains products (RustRover, IntelliJ, CLion)
.idea/
# Local settings folder for Visual Studio Professional
.vs/
# Local settings folder for the devcontainer extension that most IDEs support.
.devcontainer/
prefix/
sysroot/
**/target/
.gdb_history
*.patch
*.swp
*.swo
/.vim
.vscode/
+56 -11
View File
@@ -1,42 +1,87 @@
image: "redoxos/redoxer:latest"
variables:
GIT_SUBMODULE_STRATEGY: recursive
workflow:
rules:
- if: '$CI_COMMIT_BRANCH == "main" && $CI_PROJECT_NAMESPACE == "redox-os"'
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"'
- if: '$CI_COMMIT_BRANCH == "master" && $CI_PROJECT_NAMESPACE == "redox-os"'
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"'
stages:
- build
- cross-build
- test
- build
- cross-build
- test
before_script:
cargo install cbindgen
fmt:
stage: build
needs: []
script:
- rustup component add rustfmt
- CHECK_ONLY=1 ./fmt.sh
- rustup component add rustfmt-preview
- ./fmt.sh -- --check
clippy:
stage: build
needs: []
# TODO: remove when passed
allow_failure: true
script:
- ./check.sh --clippy
linux:
stage: build
script:
- rustup component add clippy
- ./check.sh --host
# - ./check.sh --host --clippy
x86_64:
stage: build
script:
- rustup component add rustfmt
- ./check.sh
- ./check.sh --arch=x86_64
i586:
stage: cross-build
script:
- ./check.sh --arch=i586
# - ./check.sh --arch=i586 --clippy
aarch64:
stage: cross-build
image: "redoxos/redoxer:aarch64"
script:
- ./check.sh --arch=aarch64
# - ./check.sh --arch=aarch64 --clippy
riscv64gc:
stage: cross-build
script:
- ./check.sh --arch=riscv64gc
# - ./check.sh --arch=riscv64gc --clippy
boot:
test:linux:
stage: test
needs: [linux]
script:
- timeout -s KILL 9m ./check.sh --test
- ./check.sh --host --test
test:x86_64:
stage: test
needs: [x86_64]
script:
# timeout: https://gitlab.redox-os.org/redox-os/relibc/-/issues/238
- timeout -s KILL 9m ./check.sh --arch=x86_64 --test
test:aarch64:
stage: test
needs: [aarch64]
image: "redoxos/redoxer:aarch64"
# many issues that not exist in x86_64, and lack of interest to fix so far
allow_failure: true
when: manual
script:
- timeout -s KILL 9m ./check.sh --arch=aarch64 --test
#TODO: Enable more arch once dynamic linker working
-92
View File
@@ -1,92 +0,0 @@
<!-- Thank you for taking the time to submit an issue! By following these comments and filling out the sections below, you can help the developers get the necessary information to fix your issue. Please provide a single issue per report. You can also preview this report before submitting it. Feel free to modify/remove sections to fit the nature of your issue. -->
<!-- Please search to check that your issue has not been created already. By preventing duplicate issues, you can help keep the repository organized. If your current issue has already been created and is still unresolved, you can contribute by commenting there. -->
<!-- Replace the empty checkbox [ ] below with a checked one [x] if you have already searched for your issue. -->
- [ ] I agree that I have searched opened and closed issues to prevent duplicates.
--------------------
## Description
<!-- Briefly summarize/describe the issue that you are experiencing below. -->
Replace me
## Environment info
<!-- To understand where your issue originates, please include some relevant information about your environment. -->
<!-- If you are using a pre-built release of Redox, please specify the release version below. -->
- Redox OS Release:
0.0.0 Remove me
<!-- If you have built Redox OS yourself, please provide the following information: -->
- Operating system:
Replace me
- `uname -a`:
`Replace me`
- `rustc -V`:
`Replace me`
- `git rev-parse HEAD`:
`Replace me`
<!-- Depending on your issue, additional information about your environment (network config, package versions, dependencies, etc.) can also help. You can list that below. -->
- Replace me:
Replace me
## Steps to reproduce
<!-- If possible, please list the steps to reproduce ("trigger") your issue below. Being detailed definitely helps speed up bug fixes. -->
1. Replace me
2. Replace me
3. ...
## Behavior
<!-- It may seem obvious to know what to expect, but isolating the behavior from everything else simplifies the development process. Remember to provide a single issue in this report. You can use the References section below to link your issues together. -->
<!-- Describe the behavior you expect your steps should yield (i.e., correct behavior). -->
- **Expected behavior**:
Replace me
<!-- Describe the behavior you observed when running your steps (i.e., buggy behavior). -->
- **Actual behavior**:
Replace me
<!-- **Logs?** Posting a log can help developers find your particular issue more easily. Please wrap your code in code blocks using triple back-ticks ``` to increase readability. -->
```
Replace me
```
<!-- **Solution?** Have a solution in mind? Propose your solution below. -->
- **Proposed solution**:
Replace me
<!-- **Screenshots?** Make it easier to get your point across with screenshots. You can drag & drop or paste your images below. -->
## Optional references
<!-- If you have found issues or pull requests that are related to or blocking this issue, please link them below. See https://help.github.com/articles/autolinked-references-and-urls/ for more options. You can also link related code snippets by providing the permalink. See https://help.github.com/articles/creating-a-permanent-link-to-a-code-snippet/ for more information. -->
Related to:
- #0000 Remove me
- Replace me
- ...
Blocked by:
- #0000 Remove me
- ...
## Optional extras
<!-- If you have other relevant information not found in other sections, you can include it below. -->
Replace me
<!-- **Code?** Awesome! You can also create a pull request with a reference to this issue. -->
<!-- **Files?** Attach your relevant files by dragging & dropping or pasting them below. -->
<!-- You also can preview your report before submitting it. Thanks for contributing to Redox! -->
@@ -1,25 +0,0 @@
**Problem**: [describe the problem you try to solve with this PR.]
**Solution**: [describe carefully what you change by this PR.]
**Changes introduced by this pull request**:
- [...]
- [...]
- [...]
**Drawbacks**: [if any, describe the drawbacks of this pull request.]
**TODOs**: [what is not done yet.]
**Fixes**: [what issues this fixes.]
**State**: [the state of this PR, e.g. WIP, ready, etc.]
**Blocking/related**: [issues or PRs blocking or being related to this issue.]
**Other**: [optional: for other relevant information that should be known or cannot be described in the other fields.]
------
_The above template is not necessary for smaller PRs._
+7
View File
@@ -0,0 +1,7 @@
[submodule "openlibm"]
path = openlibm
url = https://gitlab.redox-os.org/redox-os/openlibm.git
branch = master
[submodule "src/dlmalloc-rs"]
path = dlmalloc-rs
url = https://gitlab.redox-os.org/redox-os/dlmalloc-rs.git
+123
View File
@@ -0,0 +1,123 @@
# Contributing
## Table of contents
1. [What to do](#what-to-do)
2. [Code style](#code-style)
3. [Sending merge requests](#sending-merge-requests)
4. [Writing tests](#writing-tests)
5. [Running tests](#running-tests)
Maintaining a libc is tough work, and we'd love some help!
## What to do
For now, we are still trying to get full libc compatibility before we move on to
any optimisation.
- We currently have a number of unimplemented functions. Search for
`unimplemented!()` and hop right in!
- If you notice any missing functionality, feel free to add it in
## Code style
We have a `rustfmt.toml` in the root directory of relibc. Please run `./fmt.sh`
before sending in any merge requests as it will automatically format your code.
With regards to general style:
### Where applicable, prefer using references to raw pointers
This is most obvious when looking at `stdio` functions. If raw pointers were
used instead of references, then the resulting code would be significantly
uglier. Instead try to check for pointer being valid with `pointer::as_ref()`
and `pointer::as_mut()` and then immediately use those references instead.
Internal functions should always take references.
### Use the c types exposed in our platform module instead of Rust's inbuilt integer types
This is so we can guarantee that everything works across platforms. While it is
generally accepted these days that an `int` has 32 bits (which matches against
an `i32`), some platforms have `int` as having 16 bits, and others have long as
being 32 bits instead of 64. If you use the types in platform, then we can
guarantee that your code will "just work" should we port relibc to a different
architecture.
### Use our internal functions
If you need to use a C string, don't reinvent the wheel. We have functions in
the platform module that convert C strings to Rust slices.
We also have structures that wrap files, wrap writable strings, and wrap various
other commonly used things that you should use instead of rolling your own.
## Sending merge requests
If you have sent us a merge request, first of all, thanks for taking your time
to help us!
The first thing to note is that we do most of our development on our
[GitLab server](https://gitlab.redox-os.org/redox-os/relibc), and as such it is
possible that none of the maintainers will see your merge request if it is
opened on GitHub.
In your merge request, please put in the description:
- What functions (if any) have been implemented or changed
- The rationale behind your merge request (e.g. why you thought this change was
required. If you are just implementing some functions, you can ignore this)
- Any issues that are related to the merge request
We have CI attached to our GitLab instance, so all merge requests are checked to
make sure that they are tested before they are merged. Please write tests for
the functions that you add/change and test locally on your own machine
***before*** submitting a merge request.
## Writing tests
Every function that gets written needs to have a test in C in order to make sure
it works as intended. Here are a few guidelines for writing good tests.
### Ensure that any literals you have are mapped to variables instead of being directly passed to a function.
Sometimes compilers take literals put into libc functions and run them
internally during compilation, which can cause some false positives. All tests
are compiled with `-fno-builtin`, which theoretically solves this issue, but
just in case, it'd be a good idea to map inputs to variables.
```c
#include "string.h"
#include "stdio.h"
int main(void) {
// Don't do this
printf("%d\n", strcspn("Hello", "Hi"));
// Do this
char *first = "Hello";
char *second = "Hi";
printf("%d\n", strcspn(first, second));
}
```
### Ensure your tests cover every section of code.
What happens if a string in `strcmp()` is shorter than the other string? What
happens if the first argument to `strcspn()` is longer than the second string?
In order to make sure that all functions work as expected, we ask that any tests
cover as much of the code that you have written as possible.
## Running tests
Running tests is an important part in trying to find bugs. Before opening a
merge request, we ask that you test on your own machine to make sure there are
no regressions.
You can run tests with `make test` in the root directory of relibc to compile
relibc, compile the tests and run them. This *will* print a lot of output to
stdout, so be warned!
You can test against verified correct output with `make verify` in the tests
directory. You will need to manually create the correct output and put it in the
tests/expected directory. Running any `make` commands in the tests directory
will ***not*** rebuild relibc, so you'll need to go back to the root directory
if you need to rebuild relibc.
Generated
+270 -2555
View File
File diff suppressed because it is too large Load Diff
+143 -145
View File
@@ -1,155 +1,153 @@
[package]
name = "relibc"
version = "0.2.5+rb0.3.1"
authors = ["Jeremy Soller <jackpot51@gmail.com>", "vasilito <adminpupkin@gmail.com>"]
edition = "2024"
[lib]
name = "relibc"
crate-type = ["staticlib"]
[workspace]
resolver = "2"
members = [
"audiod",
"config",
"daemon",
"dhcpd",
"dhcpv6d",
"netdiag",
"init",
"initfs",
"initfs/tools",
"ipcd",
"logd",
"netstack",
"ptyd",
"ramfs",
"redbear-ufw",
"randd",
"scheme-utils",
"zerod",
"drivers/common",
"drivers/executor",
"drivers/acpid",
"drivers/hwd",
"drivers/pcid",
"drivers/pcid-spawner",
"drivers/rtcd",
"drivers/vboxd",
"drivers/inputd",
"drivers/virtio-core",
"drivers/audio/ac97d",
"drivers/audio/ihdad",
"drivers/audio/sb16d",
"drivers/graphics/console-draw",
"drivers/graphics/fbbootlogd",
"drivers/graphics/driver-graphics",
"drivers/graphics/fbcond",
"drivers/graphics/graphics-ipc",
"drivers/graphics/ihdgd",
"drivers/graphics/vesad",
"drivers/graphics/virtio-gpud",
"drivers/input/ps2d",
"drivers/input/usbhidd",
"drivers/net/driver-network",
"drivers/net/e1000d",
"drivers/net/ixgbed",
"drivers/net/rtl8139d",
"drivers/net/rtl8168d",
"drivers/net/virtio-netd",
"drivers/redoxerd",
"drivers/storage/ahcid",
"drivers/storage/bcm2835-sdhcid",
"drivers/storage/driver-block",
"drivers/storage/ided",
"drivers/storage/lived", # TODO: not really a driver...
"drivers/storage/nvmed",
"drivers/storage/usbscsid",
"drivers/storage/virtio-blkd",
"drivers/usb/xhcid",
"drivers/usb/usbctl",
"drivers/usb/usbhubd",
"drivers/usb/ucsid",
"drivers/i2c/i2c-interface",
"drivers/i2c/i2cd",
"drivers/i2c/amd-mp2-i2cd",
"drivers/i2c/dw-acpi-i2cd",
"drivers/i2c/intel-lpss-i2cd",
"drivers/gpio/gpiod",
"drivers/gpio/intel-gpiod",
"drivers/gpio/i2c-gpio-expanderd",
"drivers/input/i2c-hidd",
"drivers/input/intel-thc-hidd",
"drivers/acpi-resource",
"src/crt0",
"src/crti",
"src/crtn",
"redox-rt",
"ld_so",
"generic-rt",
]
# Bootstrap needs it's own profile configuration
exclude = ["bootstrap"]
# Low-level Redox OS crates should be kept in sync using workspace dependencies
# Remember to also update bootstrap dependencies, those are not in the workspace
[workspace.dependencies]
acpi = { git = "https://gitlab.redox-os.org/redox-os/acpi.git", branch = "redox-6.x" }
anyhow = "1"
bitflags = "2"
clap = "4"
drm = "0.15.0"
drm-sys = "0.8.1"
edid = "0.3.0" #TODO: edid is abandoned, fork it and maintain?
fdt = "0.1.5"
libc = "0.2.181"
log = "0.4"
libredox = { path = "../libredox", default-features = true }
orbclient = "0.3.51"
parking_lot = { git = "https://github.com/Amanieu/parking_lot.git", rev = "0.12.3", default-features = false }
pico-args = "0.5"
plain = "0.2.3"
ransid = "0.4"
redox_event = "0.4.8"
redox-ioctl = { path = "../relibc/redox-ioctl" }
redox-log = { git = "https://gitlab.redox-os.org/redox-os/redox-log.git" }
redox-rt = { path = "../relibc/redox-rt", default-features = false }
redox-scheme = { path = "../redox-scheme" }
redox_syscall = { path = "../syscall", features = ["std"] }
redox_termios = "0.1.3"
ron = "0.8.1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
slab = "0.4.9"
smallvec = "1"
spin = "0.10"
static_assertions = "1.1.0"
thiserror = "2"
toml = "1"
[workspace.lints.rust]
missing_docs = "allow" #TODO: set to deny when all public functions are documented
exclude = ["tests", "dlmalloc-rs"]
[workspace.lints.clippy]
missing_safety_doc = "warn" #TODO: set to deny when all safety documentation is completed
borrow_as_ptr = "deny"
cast_lossless = "warn" # TODO review occurrences
cast_possible_truncation = "allow" # TODO review occurrences
cast_possible_wrap = "allow" # TODO review occurrences
cast_precision_loss = "allow" # TODO review occurrences
cast_ptr_alignment = "allow" # TODO review occurrences
cast_sign_loss = "allow" # TODO review occurrences
ignored_unit_patterns = "deny"
implicit_clone = "deny"
manual_let_else = "deny"
missing_errors_doc = "allow" # TODO review occurrences
missing_panics_doc = "allow" # TODO review occurrences
missing_safety_doc = "allow" # TODO review occurrences
mut_from_ref = "deny"
precedence = "deny"
ptr_as_ptr = "warn" # TODO review occurrences
ptr_cast_constness = "warn" # TODO review occurrences
ptr_offset_by_literal = "deny"
ref_as_ptr = "warn" # TODO review occurrences
type_complexity = "allow" # TODO review occurrences
upper_case_acronyms = "allow" # TODO review occurrences
zero_ptr = "deny" # must allow on public constants due to cbindgen issue
[workspace.lints.rust]
dangling_pointers_from_temporaries = "deny"
dead_code = "allow" # TODO review occuurences
deprecated = "deny"
improper_ctypes_definitions = "deny"
internal_features = "allow" # core_intrinsics and lang_items
irrefutable_let_patterns = "deny"
mismatched_lifetime_syntaxes = "deny"
non_camel_case_types = "allow" # needed for most POSIX type names
non_snake_case = "allow" # TODO review occuurences
non_upper_case_globals = "allow" # TODO review occuurences
unexpected_cfgs = "deny"
unpredictable_function_pointer_comparisons = "deny"
unreachable_code = "allow" # TODO review occuurences
unsafe_op_in_unsafe_fn = "deny"
unused_imports = "deny"
unused_must_use = "deny"
unused_mut = "deny"
unused_unsafe = "deny"
unused_variables = "allow" # TODO review occurrences (too many for now)
[lints]
workspace = true
[workspace.dependencies]
bitflags = "2"
ioslice = { version = "0.6", default-features = false }
plain = "0.2"
redox-path = "0.4.0"
redox_protocols = { package = "libredox", path = "../libredox", default-features = false, features = ["protocol"] }
redox_syscall = { path = "../syscall" }
[build-dependencies]
cc = "1"
[dependencies]
bitflags.workspace = true
arrayvec = { version = "0.7.6", default-features = false }
cbitset = "0.2"
posix-regex = { version = "0.1.4", features = ["no_std"] }
rand = { version = "0.10", default-features = false }
rand_xorshift = "0.5"
rand_jitter = "0.6"
memchr = { version = "2.2.0", default-features = false }
plain.workspace = true
unicode-width = "0.1"
__libc_only_for_layout_checks = { package = "libc", version = "0.2.149", optional = true }
md5-crypto = { package = "md-5", version = "0.10.6", default-features = false }
sha-crypt = { version = "0.5", default-features = false }
base64ct = { version = "1.6", default-features = false, features = ["alloc"] }
bcrypt-pbkdf = { version = "0.10", default-features = false, features = [
"alloc",
] }
scrypt = { version = "0.11", default-features = false, features = ["simple"] }
pbkdf2 = { version = "0.12", features = ["sha2"] }
sha2 = { version = "0.10", default-features = false }
generic-rt = { path = "generic-rt" }
chrono-tz = { version = "0.10", default-features = false }
chrono = { version = "0.4", default-features = false, features = ["alloc"] }
libm = "0.2"
log = "0.4"
spin = "0.9.8"
argon2 = "0.5.3"
[dependencies.dlmalloc]
path = "dlmalloc-rs"
default-features = false
features = ["c_api"]
[dependencies.object]
version = "0.36.7"
git = "https://gitlab.redox-os.org/andypython/object"
default-features = false
features = ["elf", "read_core"]
[target.'cfg(target_os = "linux")'.dependencies]
sc = "0.2.7"
[target.'cfg(target_os = "redox")'.dependencies]
redox_syscall.workspace = true
redox-rt = { path = "redox-rt" }
redox-path.workspace = true
redox_event = { version = "0.4.8", default-features = false, features = ["redox_syscall"] }
ioslice.workspace = true
redox-ioctl = { path = "redox-ioctl" }
redox_protocols.workspace = true
[features]
# to enable trace level, take out this `no_trace`
default = ["check_against_libc_crate", "no_trace"]
check_against_libc_crate = ["__libc_only_for_layout_checks"]
math_libm = []
no_trace = ["log/release_max_level_debug"]
# for very verbose activity beyond trace level
trace_tls = []
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
[patch.crates-io]
# Red Bear OS Phase I: s2idle / Modern Standby support.
# The [patch.crates-io] replaces the upstream gitlab.redox-os.org
# redox_syscall (which lacks the new AcpiVerb::EnterS2Idle /
# ExitS2Idle variants) with the local fork at
# local/sources/syscall/ (a sibling directory of base/, both
# under local/sources/). The local fork is the upstream
# gitlab.redox-os.org/redox-os/syscall @ 79cb6d9 with our
# Red Bear OS P1 commit (cfa7f0c) on top. The version field
# stays at upstream 0.8.1 — periodic rebase via
# 'git fetch upstream && git rebase upstream/master' is the
# workflow when upstream changes. Hardware-agnostic — works
# for any platform with Modern Standby firmware (Dell, HP,
# Lenovo, LG Gram, etc.).
cc-11 = { git = "https://github.com/tea/cc-rs", branch = "riscv-abi-arch-fix", package = "cc" }
redox_syscall = { path = "../syscall" }
libredox = { path = "../libredox" }
redox-scheme = { path = "../redox-scheme" }
[patch."https://gitlab.redox-os.org/redox-os/relibc.git"]
#redox-ioctl = { path = "../../relibc/source/redox-ioctl" }
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2017 Redox OS
Copyright (c) 2018 Redox OS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+215 -105
View File
@@ -1,119 +1,229 @@
TARGET ?= x86_64-unknown-redox
LINKER ?= $(shell redoxer env which $(shell redoxer env printenv LD))
BOARD ?=
BUILD_TYPE ?= release
BUILD_FLAGS ?= --release
CARGO ?= redoxer
CARGO_HOST ?= env -u CARGO -u RUSTFLAGS cargo
include config.mk
SRC_DIR ?= $(CURDIR)
BUILD_DIR ?= $(shell pwd)/target/$(TARGET)/build
DESTDIR ?= ./sysroot
SYSROOT ?= $(shell pwd)/target/$(TARGET)/sysroot
TARGET_DIR = $(BUILD_DIR)/$(TARGET)/$(BUILD_TYPE)
BUILD_FLAGS += --target-dir $(BUILD_DIR)
CARGO?=cargo
CARGO_TEST?=$(CARGO)
CARGO_COMMON_FLAGS=-Z build-std=core,alloc,compiler_builtins
CARGOFLAGS?=$(CARGO_COMMON_FLAGS)
CC_WRAPPER?=
RUSTCFLAGS?=
LINKFLAGS?=-lgcc
USE_RUST_LIBM?=
TESTBIN?=
export OBJCOPY?=objcopy
INITFS_BINS = init logd ramfs randd zerod \
acpid fbbootlogd fbcond hwd inputd lived \
pcid pcid-spawner rtcd vesad
INITFS_DRIVERS_BINS = nvmed virtio-blkd virtio-gpud
BASE_BINS = inputd pcid pcid-spawner redoxerd audiod dhcpd ipcd ptyd netstack
DRIVERS_BINS = e1000d ihdad ihdgd ixgbed rtl8139d rtl8168d \
usbctl usbhidd usbhubd usbscsid virtio-netd xhcid
ifneq (,$(filter i586-unknown-redox i686-unknown-redox x86_64-unknown-redox,$(TARGET)))
INITFS_BINS += ps2d
INITFS_DRIVERS_BINS += ahcid ided
DRIVERS_BINS += ac97d sb16d vboxd
export CARGO_TARGET_DIR?=$(shell pwd)/target
BUILD?=$(CARGO_TARGET_DIR)/$(TARGET)
CARGOFLAGS+=--target=$(TARGET)
EXCEPT_MATH=-not -name "math"
FEATURE_MATH=
ifneq ($(USE_RUST_LIBM),)
FEATURE_MATH=--features math_libm
EXCEPT_MATH=
endif
ifeq ($(TARGET),aarch64-unknown-redox)
ifeq ($(BOARD),raspi3b)
INITFS_BINS += bcm2835-sdhcid
endif
TARGET_HEADERS?=$(BUILD)/include
export CFLAGS=-I$(TARGET_HEADERS)
PROFILE?=release
HEADERS_UNPARSED=$(shell find src/header -mindepth 1 -maxdepth 1 -type d -not -name "_*" $(EXCEPT_MATH) -printf "%f\n")
HEADERS_DEPS=$(shell find src/header -type f \( -name "cbindgen.toml" -o -name "*.rs" \))
#HEADERS=$(patsubst %,%.h,$(subst _,/,$(HEADERS_UNPARSED)))
SRC=\
Cargo.* \
$(shell find src/ redox-rt/src/ ld_so/src/ redox-ioctl/src/ include/ -type f)
BUILTINS_VERSION=0.1.70
.PHONY: all clean fmt install install-libs install-headers install-tests libs headers submodules test
all: | headers libs
headers: $(HEADERS_DEPS)
rm -rf $(TARGET_HEADERS)
mkdir -p $(TARGET_HEADERS)
cp -r include/* $(TARGET_HEADERS)
ifeq ($(USE_RUST_LIBM),)
cp "openlibm/include"/*.h $(TARGET_HEADERS)
cp "openlibm/src"/*.h $(TARGET_HEADERS)
endif
INITFS_CARGO_ARGS = $(foreach bin,$(INITFS_BINS),-p $(bin))
INITFS_DRIVERS_CARGO_ARGS = $(foreach bin,$(INITFS_DRIVERS_BINS),-p $(bin))
BASE_CARGO_ARGS = $(foreach bin,$(BASE_BINS),-p $(bin))
DRIVERS_CARGO_ARGS = $(foreach bin,$(DRIVERS_BINS),-p $(bin))
.PHONY: all base install install-base test
all: base
install: install-base
@set -e ; \
for header in $(HEADERS_UNPARSED); do \
if test -f "src/header/$$header/cbindgen.toml"; then \
echo -e "\033[0;36;49mWriting Header $$header\033[0m"; \
out=`echo "$$header" | sed 's/_/\//g'`; \
out="$(TARGET_HEADERS)/$$out.h"; \
cat "src/header/$$header/cbindgen.toml" cbindgen.globdefs.toml \
| cbindgen "src/header/$$header/mod.rs" --config=/dev/stdin --output "$$out"; \
fi \
done; echo -e "\033[0;36;49mAll headers written\033[0m";
clean:
rm -rf $(SRC_DIR)/target $(SRC_DIR)/sysroot $(SYSROOT) $(TARGET_DIR)
$(CARGO) clean
$(MAKE) -C tests clean
rm -rf sysroot
# test if booting
test: all
$(MAKE) install
redoxer exec --folder ./sysroot/:/ true
check:
$(CARGO) check
# test with interactive gui
test-gui: all
$(MAKE) install
redoxer exec --gui --folder ./sysroot/:/ ion
fmt:
./fmt.sh
# -----------------------------------------------------------------------------
# base
# -----------------------------------------------------------------------------
$(SYSROOT)/bin/redoxfs:
REDOXER_SYSROOT=$(SYSROOT) redoxer pkg redoxfs
install-headers: headers libs
mkdir -pv "$(DESTDIR)/include"
cp -rv "$(TARGET_HEADERS)"/* "$(DESTDIR)/include"
base:
@mkdir -pv "$(BUILD_DIR)"
# Build daemons and drivers
CARGO_PROFILE_RELEASE_OPT_LEVEL=s CARGO_PROFILE_RELEASE_PANIC=abort \
$(CARGO) build $(BUILD_FLAGS) \
--manifest-path "$(SRC_DIR)/Cargo.toml" \
$(BASE_CARGO_ARGS) $(DRIVERS_CARGO_ARGS)
# Build initfs daemons and drivers
# FIXME fix whatever issue (feature unification?) causes most logs to be omitted
# if this is merged with the above build command.
CARGO_PROFILE_RELEASE_OPT_LEVEL=s CARGO_PROFILE_RELEASE_PANIC=abort \
$(CARGO) build $(BUILD_FLAGS) \
--manifest-path "$(SRC_DIR)/Cargo.toml" \
$(INITFS_CARGO_ARGS) $(INITFS_DRIVERS_CARGO_ARGS)
# Build bootstrap
cd "$(SRC_DIR)/bootstrap" && $(CARGO) rustc $(BUILD_FLAGS) \
-- -Ctarget-feature=+crt-static -Clinker="$(LINKER)"
libs: \
$(BUILD)/$(PROFILE)/libc.a \
$(BUILD)/$(PROFILE)/libc.so \
$(BUILD)/$(PROFILE)/crt0.o \
$(BUILD)/$(PROFILE)/crti.o \
$(BUILD)/$(PROFILE)/crtn.o \
$(BUILD)/$(PROFILE)/ld.so
install-base: base $(SYSROOT)/bin/redoxfs
@mkdir -pv "$(DESTDIR)/usr/bin" "$(DESTDIR)/usr/lib/drivers"
@mkdir -pv "$(DESTDIR)/usr/lib/init.d/" "$(DESTDIR)/usr/lib/pcid.d"
# Distribute binaries
@for bin in $(BASE_BINS); do \
cp -v "$(TARGET_DIR)/$$bin" "$(DESTDIR)/usr/bin"; \
done
@for bin in $(DRIVERS_BINS); do \
cp -v "$(TARGET_DIR)/$$bin" "$(DESTDIR)/usr/lib/drivers"; \
done
# Copy configurations
@cp -v "$(SRC_DIR)/init.d"/* "$(DESTDIR)/usr/lib/init.d/"
@find "$(SRC_DIR)/drivers" -maxdepth 3 -type f -name 'config.toml' | while read -r conf; do \
driver=$$(basename "$$(dirname "$$conf")"); \
cp -v "$$conf" "$(DESTDIR)/usr/lib/pcid.d/$$driver.toml"; \
install-libs: headers libs
mkdir -pv "$(DESTDIR)/lib"
cp -v "$(BUILD)/$(PROFILE)/libc.a" "$(DESTDIR)/lib"
cp -v "$(BUILD)/$(PROFILE)/libc.so" "$(DESTDIR)/lib"
ln -vnfs libc.so "$(DESTDIR)/lib/libc.so.6"
cp -v "$(BUILD)/$(PROFILE)/crt0.o" "$(DESTDIR)/lib"
ln -vnfs crt0.o "$(DESTDIR)/lib/crt1.o"
ln -vnfs crt0.o "$(DESTDIR)/lib/Scrt1.o"
cp -v "$(BUILD)/$(PROFILE)/crti.o" "$(DESTDIR)/lib"
cp -v "$(BUILD)/$(PROFILE)/crtn.o" "$(DESTDIR)/lib"
cp -v "$(BUILD)/$(PROFILE)/ld.so" "$(DESTDIR)/$(LD_SO_PATH)"
ifeq ($(USE_RUST_LIBM),)
cp -v "$(BUILD)/openlibm/libopenlibm.a" "$(DESTDIR)/lib/libm.a"
else
$(AR) -rcs "$(DESTDIR)/lib/libm.a"
endif
# Empty libraries for dl, pthread, and rt
$(AR) -rcs "$(DESTDIR)/lib/libdl.a"
$(AR) -rcs "$(DESTDIR)/lib/libpthread.a"
$(AR) -rcs "$(DESTDIR)/lib/librt.a"
install-tests: tests
$(MAKE) -C tests
mkdir -p "$(DESTDIR)/relibc-tests"
cp -vr tests/build_$(TARGET)/* "$(DESTDIR)/relibc-tests/"
install: install-headers install-libs
submodules:
git submodule sync
git submodule update --init --recursive
sysroot:
@mkdir -p $@
.PHONY: sysroot/$(TARGET)
sysroot/$(TARGET): | sysroot
rm -rf $@
rm -rf $@.partial
mkdir -p $@.partial
$(MAKE) install DESTDIR=$(shell pwd)/$@.partial
mv $@.partial $@
touch $@
test: sysroot/$(TARGET)
# TODO: Fix SIGILL when running cargo test
# $(CARGO_TEST) test
$(MAKE) -C tests run
test-once: sysroot/$(TARGET)
$(MAKE) -C tests run-once TESTBIN=$(TESTBIN)
$(BUILD)/$(PROFILE)/libc.so: $(BUILD)/$(PROFILE)/libc.a
$(CC) -nostdlib \
-shared \
-Wl,--gc-sections \
-Wl,-z,pack-relative-relocs \
-Wl,--sort-common \
-Wl,--whole-archive $^ -Wl,--no-whole-archive \
-Wl,-soname,libc.so.6 \
$(LINKFLAGS) \
-o $@
$(BUILD)/$(PROFILE)/ld.so: $(BUILD)/$(PROFILE)/ld_so.o $(BUILD)/$(PROFILE)/libc.a
# TODO: merge ld.so with libc.so: --dynamic-list=dynamic-list-file
$(LD) --shared -Bsymbolic --no-relax -T ld_so/ld_script/$(TARGET).ld --gc-sections $^ -o $@
$(BUILD)/$(PROFILE)/libc.a: $(BUILD)/$(PROFILE)/librelibc.a $(BUILD)/openlibm/libopenlibm.a
echo "create $@" > "$@.mri"
for lib in $^; do\
echo "addlib $$lib" >> "$@.mri"; \
done
echo "save" >> "$@.mri"
echo "end" >> "$@.mri"
$(AR) -M < "$@.mri"
rm -rf "$(BUILD_DIR)/initfs"
# Distribute initfs binaries
@mkdir -pv "$(BUILD_DIR)/initfs/bin" "$(BUILD_DIR)/initfs/lib/drivers"
for bin in $(INITFS_BINS); do \
cp -v "$(TARGET_DIR)/$$bin" "$(BUILD_DIR)/initfs/bin"; \
done
for bin in $(INITFS_DRIVERS_BINS); do \
cp -v "$(TARGET_DIR)/$$bin" "$(BUILD_DIR)/initfs/lib/drivers"; \
done
cp "$(SYSROOT)/bin/redoxfs" "$(BUILD_DIR)/initfs/bin"
# Copy initfs config files
@mkdir -p "$(BUILD_DIR)/initfs/lib/init.d" "$(BUILD_DIR)/initfs/lib/pcid.d"
cp "$(SRC_DIR)/init.initfs.d"/* "$(BUILD_DIR)/initfs/lib/init.d/"
cp "$(SRC_DIR)/drivers/initfs.toml" "$(BUILD_DIR)/initfs/lib/pcid.d/initfs.toml"
# Build initfs
$(CARGO_HOST) run --manifest-path "$(SRC_DIR)/initfs/tools/Cargo.toml" --bin redox-initfs-ar -- \
"$(BUILD_DIR)/initfs" "$(TARGET_DIR)/bootstrap" -o "$(BUILD_DIR)/initfs.img"
# Distribute initfs
@mkdir -pv "$(DESTDIR)/usr/lib/boot"
cp -v "$(BUILD_DIR)/initfs.img" "$(DESTDIR)/usr/lib/boot/initfs"
# Debug targets
$(BUILD)/debug/librelibc.a: $(SRC)
$(CARGO) rustc $(CARGOFLAGS) $(FEATURE_MATH) -- --emit link=$@ -g -C debug-assertions=no $(RUSTCFLAGS)
./renamesyms.sh "$@" "$(BUILD)/debug/deps/"
./stripcore.sh "$@"
touch $@
$(BUILD)/debug/crt0.o: $(SRC)
$(CARGO) rustc --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
touch $@
$(BUILD)/debug/crti.o: $(SRC)
$(CARGO) rustc --manifest-path src/crti/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
touch $@
$(BUILD)/debug/crtn.o: $(SRC)
$(CARGO) rustc --manifest-path src/crtn/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
touch $@
$(BUILD)/debug/ld_so.o: $(SRC)
$(CARGO) rustc --manifest-path ld_so/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort -g -C debug-assertions=no $(RUSTCFLAGS)
touch $@
# Release targets
$(BUILD)/release/librelibc.a: $(SRC)
$(CARGO) rustc --release $(CARGOFLAGS) $(FEATURE_MATH) -- --emit link=$@ $(RUSTCFLAGS)
@# TODO: Better to only allow a certain whitelisted set of symbols? Perhaps
@# use some cbindgen hook, specify them manually, or grep for #[unsafe(no_mangle)].
./renamesyms.sh "$@" "$(BUILD)/release/deps/"
./stripcore.sh "$@"
touch $@
$(BUILD)/release/crt0.o: $(SRC)
$(CARGO) rustc --release --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
touch $@
$(BUILD)/release/crti.o: $(SRC)
$(CARGO) rustc --release --manifest-path src/crti/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
touch $@
$(BUILD)/release/crtn.o: $(SRC)
$(CARGO) rustc --release --manifest-path src/crtn/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
touch $@
$(BUILD)/release/ld_so.o: $(SRC)
$(CARGO) rustc --release --manifest-path ld_so/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
touch $@
# Other targets
$(BUILD)/openlibm: openlibm
rm -rf $@ $@.partial
mkdir -p $(BUILD)
cp -r $< $@.partial
mv $@.partial $@
touch $@
ifeq ($(USE_RUST_LIBM),)
$(BUILD)/openlibm/libopenlibm.a: $(BUILD)/openlibm $(BUILD)/$(PROFILE)/librelibc.a
$(MAKE) -s AR=$(AR) CC="$(CC_WRAPPER) $(CC)" LD=$(LD) CPPFLAGS="$(CPPFLAGS) -fno-stack-protector -I$(shell pwd)/include -I$(TARGET_HEADERS)" -C $< libopenlibm.a
./renamesyms.sh "$@" "$(BUILD)/release/deps/"
else
$(BUILD)/openlibm/libopenlibm.a:
mkdir -p "$(BUILD)/openlibm"
$(AR) -rcs "$(BUILD)/openlibm/libopenlibm.a"
endif
+160 -30
View File
@@ -1,43 +1,173 @@
# Base
# Redox C Library (relibc)
Repository containing various system daemons, that are considered fundamental for the OS.
relibc is a portable C standard library written in Rust and is under heavy development, this library contains the following items:
You can see what each component does in the following list:
- C, Linux, BSD functions and extensions
- POSIX compatibility layer
- Interfaces for system components
- audiod : Daemon used to process the sound drivers audio
- bootstrap : First code that the kernel executes, responsible for spawning the init daemon
- daemon : Redox daemon library
- drivers
- init : Daemon used to start most system components and programs
- initfs : Filesystem with the necessary system components to run RedoxFS
- ipcd : Daemon used for inter-process communication
- logd : Daemon used to log system components and daemons
- netstack : Daemon used for networking
- ptyd : Daemon used for pseudo-terminal
- ramfs : RAM filesystem
- randd : Daemon used for random number generation
- zerod : Daemon used to discard all writes and fill read buffers with zero
The motivation for this project is twofold: Reduce issues that the Redox developers were having with [newlib](https://sourceware.org/newlib/), and create a more stable and safe alternative to C standard libraries written in C. It is mainly designed to be used under Redox, as an alternative to newlib, but it also supports Linux via the [sc](https://crates.io/crates/sc) crate.
## How To Contribute
Currently Redox and Linux are supported.
To learn how to contribute you need to read the following document:
## `redox-rt`
- [CONTRIBUTING.md](https://gitlab.redox-os.org/redox-os/redox/-/blob/master/CONTRIBUTING.md)
`redox-rt` is a runtime library that provides much of the code that enables POSIX on Redox, like `fork`, `exec`, signal handling, etc.
Relibc uses it as backend in `src/platform/redox`, and it's intended to eventually be usable independently, without relibc.
If you want to contribute to drivers read its [README](drivers/README.md)
## Repository Layout
## Development
- `include` - Header files (mostly macros and variadic functions `cbindgen` can't generate)
- `src` - Source files
- `src/c` - C code
- `src/crt0` - Runtime code
- `src/crti` - Runtime code
- `src/crtn` - Runtime code
- `src/header` - Header files implementation
- `src/header/*` - Each folder has a `cbindgen.toml` file, it generates a C-to-Rust interface and header files
- `src/ld_so` - Dynamic loader code
- `src/platform` - Platform-specific and common code
- `src/platform/redox` - Redox-specific code
- `src/platform/linux` - Linux-specific code
- `src/pthread` - pthread implementation
- `src/sync` - Synchronization primitives
- `tests` - C tests (each MR needs to give success in all of them)
To learn how to do development with these system components inside the Redox build system you need to read the [Build System](https://doc.redox-os.org/book/build-system-reference.html) and [Coding and Building](https://doc.redox-os.org/book/coding-and-building.html) pages.
## Download the sources
### How To Build
To download the relibc sources run the following command:
It is recommended to build this system component via the Redox build system, you can learn how to do it on the [Building Redox](https://doc.redox-os.org/book/podman-build.html) page.
```sh
git clone --recursive https://gitlab.redox-os.org/redox-os/relibc
```
To build and test outside the build system, [install redoxer](https://doc.redox-os.org/book/ci.html) then use `check.sh` script to build or test:
- `./check.sh` - Check build for x86_64
- `./check.sh --arch=ARCH` - Check build for specific ARCH (`aarch64`, `i586`, `riscv64gc`)
- `./check.sh --all` - Check build for all ARCH
- `./check.sh --test` - Check the base system boots up on x86_64
## Build Instructions
You can also use `make install` to inspect the content on `./sysroot`, or `make test-gui` to test booting with orbital interactively.
To build relibc out of the Redox build system, do the following steps:
### Dependencies
- Install `cbindgen`
```sh
cargo install cbindgen
```
#### Install the `expect` tool
- Debian, Ubuntu and PopOS:
```sh
sudo apt install expect
```
- Fedora:
```sh
sudo dnf install expect
```
- Arch Linux:
```sh
sudo pacman -S expect
```
### Build Relibc
To build the relibc library objects, run the following command:
```sh
make all
```
- Clean old library objects and tests
```sh
make clean
```
## Build relibc inside the Redox build system
Inside of your Redox build system, run:
```sh
make prefix
```
If you need to rebuild `relibc` for testing a Cookbook recipe, run:
```sh
touch relibc
make prefix r.recipe-name
```
Touching (changing the "last modified time" of) the `relibc` folder is needed to trigger recompilation for `make prefix`. Replace `recipe-name` with your desired recipe name.
Note: Do not edit `relibc` inside `prefix` folder! Do your work on `relibc` folder directly inside your Redox build system instead.
## Tests
Relibc has a test suite that also runs every time a new commit get pushed. You can see `.gitlab-ci.yml` to see how it's being executed. That being said, `./check.sh` is the recommended way to run tests. Here's few examples:
+ `./check.sh` - Run build, without running the test
+ `./check.sh --test` - Run all tests in x86_64 Redox using Redoxer
+ `./check.sh --test --host` - Run all tests in host (Linux)
+ `./check.sh --test --arch=aarch64` - Run all tests in specified arch
- Arch can be `x86_64`, `aarch64`, `i586`, or `riscv64gc`
+ `./check.sh --test=stdio/printf` - Run a single test
- Can be combined with `--host` or `--arch`
- Will run statically linked test in Linux, dynamically linked in Redox
Couple of notes:
- Relibc and its tests will rebuild if files are changed, however switching between arch or host requires you to run `make clean`
- Redoxer is needed to run tests for Redox without `--host`. You can install it using `cargo install redoxer`
- Tests can hang, the test runner can anticipate this, assuming the kernel doesn't hang too.
## Issues
#### I'm building for my own platform which I run, and am getting `x86_64-linux-gnu-ar: command not found` (or similar)
The Makefile expects GNU compiler tools prefixed with the platform specifier, as would be present when you installed a cross compiler. Since you are building for your own platform, some Linux distributions (like Manjaro) don't install/symlink the prefixed executables.
An easy fix would be to replace the corresponding lines in `config.mk`, e.g.
```diff
ifeq ($(TARGET),x86_64-unknown-linux-gnu)
- export CC=x86_64-linux-gnu-gcc
- export LD=x86_64-linux-gnu-ld
- export AR=x86_64-linux-gnu-ar
- export NM=x86_64-linux-gnu-nm
+ export CC=gcc
+ export LD=ld
+ export AR=ar
+ export NM=nm
export OBJCOPY=objcopy
export CPPFLAGS=
LD_SO_PATH=lib/ld64.so.1
endif
```
## Contributing
Before starting to contribute, read [this](CONTRIBUTING.md) document.
## Supported OSes
- Redox OS
- Linux
## Supported architectures
- i586 (Intel/AMD)
- x86_64 (Intel/AMD)
- aarch64 (ARM64)
- riscv64gc (RISC-V)
## Funding - _Unix-style Signals and Process Management_
This project is funded through [NGI Zero Core](https://nlnet.nl/core), a fund established by [NLnet](https://nlnet.nl) with financial support from the European Commission's [Next Generation Internet](https://ngi.eu) program. Learn more at the [NLnet project page](https://nlnet.nl/project/RedoxOS-Signals).
[<img src="https://nlnet.nl/logo/banner.png" alt="NLnet foundation logo" width="20%" />](https://nlnet.nl)
[<img src="https://nlnet.nl/image/logos/NGI0_tag.svg" alt="NGI Zero Logo" width="20%" />](https://nlnet.nl/core)
-19
View File
@@ -1,19 +0,0 @@
[package]
name = "audiod"
description = "Sound daemon"
version = "0.1.0"
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
edition = "2021"
[dependencies]
daemon = { path = "../daemon" }
redox_syscall = { workspace = true, features = ["std"] }
libc.workspace = true
libredox = { workspace = true, features = ["mkns"] }
redox-scheme.workspace = true
scheme-utils = { path = "../scheme-utils" }
anyhow.workspace = true
ioslice = "0.6.0"
[lints]
workspace = true
-94
View File
@@ -1,94 +0,0 @@
//! The audio daemon for RedoxOS.
use std::mem::MaybeUninit;
use std::ptr::addr_of_mut;
use std::sync::{Arc, Mutex};
use std::{mem, process, slice, thread};
use anyhow::Context;
use ioslice::IoSlice;
use libredox::flag;
use libredox::{error::Result, Fd};
use redox_scheme::Socket;
use scheme_utils::ReadinessBased;
use daemon::SchemeDaemon;
use self::scheme::AudioScheme;
mod scheme;
extern "C" fn sigusr_handler(_sig: usize) {}
fn thread(scheme: Arc<Mutex<AudioScheme>>, pid: usize, hw_file: Fd) -> Result<()> {
loop {
let buffer = scheme.lock().unwrap().buffer();
let buffer_u8 = unsafe {
slice::from_raw_parts(buffer.as_ptr() as *const u8, mem::size_of_val(&buffer))
};
// Wake up the scheme thread
libredox::call::kill(pid, libredox::flag::SIGUSR1 as u32)?;
hw_file.write(&buffer_u8)?;
}
}
fn daemon(daemon: SchemeDaemon) -> anyhow::Result<()> {
// Handle signals from the hw thread
let new_sigaction = unsafe {
let mut sigaction = MaybeUninit::<libc::sigaction>::uninit();
addr_of_mut!((*sigaction.as_mut_ptr()).sa_flags).write(0);
libc::sigemptyset(addr_of_mut!((*sigaction.as_mut_ptr()).sa_mask));
addr_of_mut!((*sigaction.as_mut_ptr()).sa_sigaction).write(sigusr_handler as usize);
sigaction.assume_init()
};
libredox::call::sigaction(flag::SIGUSR1, Some(&new_sigaction), None)?;
let pid = libredox::call::getpid()?;
let hw_file = Fd::open("/scheme/audiohw", flag::O_WRONLY | flag::O_CLOEXEC, 0)?;
let socket = Socket::create().context("failed to create scheme")?;
let scheme = Arc::new(Mutex::new(AudioScheme::new()));
let _ = daemon.ready_sync_scheme(&socket, &mut *scheme.lock().unwrap());
// Enter a constrained namespace
let ns = libredox::call::mkns(&[
IoSlice::new(b"memory"),
IoSlice::new(b"rand"), // for HashMap
])
.context("failed to make namespace")?;
libredox::call::setns(ns).context("failed to set namespace")?;
// Spawn a thread to mix and send audio data
let scheme_thread = scheme.clone();
let _thread = thread::spawn(move || thread(scheme_thread, pid, hw_file));
let mut readiness = ReadinessBased::new(&socket, 16);
loop {
readiness.read_and_process_requests(&mut *scheme.lock().unwrap())?;
readiness.poll_all_requests(&mut *scheme.lock().unwrap())?;
readiness.write_responses()?;
}
}
fn main() {
SchemeDaemon::new(inner);
}
fn inner(x: SchemeDaemon) -> ! {
match daemon(x) {
Ok(()) => {
process::exit(0);
}
Err(err) => {
eprintln!("audiod: {}", err);
process::exit(1);
}
}
}
-177
View File
@@ -1,177 +0,0 @@
use redox_scheme::{CallerCtx, OpenResult};
use scheme_utils::HandleMap;
use std::collections::VecDeque;
use std::str;
use syscall::error::{Error, Result, EACCES, EBADF, EINVAL, ENOENT, EWOULDBLOCK};
use redox_scheme::scheme::SchemeSync;
use syscall::schemev2::NewFdFlags;
// The strict buffer size of the audiohw: driver
const HW_BUFFER_SIZE: usize = 512;
// The desired buffer size of each handle
const HANDLE_BUFFER_SIZE: usize = 4096;
enum Handle {
Audio { buffer: VecDeque<(i16, i16)> },
// TODO: move volume to audiohw:?
// TODO: Use SYS_CALL to handle this better?
Volume,
SchemeRoot,
}
pub struct AudioScheme {
handles: HandleMap<Handle>,
volume: i32,
}
impl AudioScheme {
pub fn new() -> Self {
AudioScheme {
handles: HandleMap::new(),
volume: 50,
}
}
pub fn buffer(&mut self) -> [(i16, i16); HW_BUFFER_SIZE] {
let mut mix_buffer = [(0i16, 0i16); HW_BUFFER_SIZE];
// Multiply each sample by the cube of volume divided by 100
// This mimics natural perception of loudness
let volume_factor = ((self.volume as f32) / 100.0).powi(3);
for (_id, handle) in self.handles.iter_mut() {
match handle {
Handle::Audio { ref mut buffer } => {
let mut i = 0;
while i < mix_buffer.len() {
if let Some(sample) = buffer.pop_front() {
let left = (sample.0 as f32 * volume_factor) as i16;
let right = (sample.1 as f32 * volume_factor) as i16;
mix_buffer[i].0 = mix_buffer[i].0.saturating_add(left);
mix_buffer[i].1 = mix_buffer[i].1.saturating_add(right);
} else {
break;
}
i += 1;
}
}
_ => (),
}
}
mix_buffer
}
}
impl SchemeSync for AudioScheme {
fn scheme_root(&mut self) -> Result<usize> {
Ok(self.handles.insert(Handle::SchemeRoot))
}
fn openat(
&mut self,
dirfd: usize,
path: &str,
_flags: usize,
_fcntl_flags: u32,
_ctx: &CallerCtx,
) -> Result<OpenResult> {
if !matches!(self.handles.get(dirfd)?, Handle::SchemeRoot) {
return Err(Error::new(EACCES));
}
let (handle, flags) = match path.trim_matches('/') {
"" => (
Handle::Audio {
buffer: VecDeque::new(),
},
NewFdFlags::empty(),
),
"volume" => (Handle::Volume, NewFdFlags::POSITIONED),
_ => return Err(Error::new(ENOENT)),
};
let id = self.handles.insert(handle);
Ok(OpenResult::ThisScheme { number: id, flags })
}
fn read(
&mut self,
id: usize,
buf: &mut [u8],
off: u64,
_flags: u32,
_ctx: &CallerCtx,
) -> Result<usize> {
//TODO: check flags for readable
match self.handles.get_mut(id)? {
Handle::Audio { buffer: _ } => {
//TODO: audio input?
Err(Error::new(EBADF))
}
Handle::Volume => {
let Ok(off) = usize::try_from(off) else {
return Ok(0);
};
//TODO: should we allocate every time?
let bytes = format!("{}", self.volume).into_bytes();
let src = bytes.get(off..).unwrap_or(&[]);
let len = src.len().min(buf.len());
buf[..len].copy_from_slice(&src[..len]);
Ok(len)
}
Handle::SchemeRoot => Err(Error::new(EBADF)),
}
}
fn write(
&mut self,
id: usize,
buf: &[u8],
offset: u64,
_flags: u32,
_ctx: &CallerCtx,
) -> Result<usize> {
//TODO: check flags for writable
match self.handles.get_mut(id)? {
Handle::Audio { ref mut buffer } => {
if buffer.len() >= HANDLE_BUFFER_SIZE {
Err(Error::new(EWOULDBLOCK))
} else {
let mut i = 0;
while i + 4 <= buf.len() {
buffer.push_back((
(buf[i] as i16) | ((buf[i + 1] as i16) << 8),
(buf[i + 2] as i16) | ((buf[i + 3] as i16) << 8),
));
i += 4;
}
Ok(i)
}
}
Handle::Volume => {
//TODO: support other offsets?
if offset == 0 {
let value = str::from_utf8(buf)
.map_err(|_| Error::new(EINVAL))?
.trim()
.parse::<i32>()
.map_err(|_| Error::new(EINVAL))?;
if value >= 0 && value <= 100 {
self.volume = value;
Ok(buf.len())
} else {
Err(Error::new(EINVAL))
}
} else {
// EOF
Ok(0)
}
}
Handle::SchemeRoot => Err(Error::new(EBADF)),
}
}
}
-3
View File
@@ -1,3 +0,0 @@
[unstable]
build-std = ["core", "alloc", "compiler_builtins"]
build-std-features = ["compiler-builtins-mem"]
-233
View File
@@ -1,233 +0,0 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "arrayvec"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56"
[[package]]
name = "bitflags"
version = "2.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8"
[[package]]
name = "bootstrap"
version = "0.0.0"
dependencies = [
"arrayvec",
"hashbrown",
"libredox",
"linked_list_allocator",
"log",
"plain",
"redox-initfs",
"redox-path",
"redox-rt",
"redox-scheme",
"redox_syscall",
"slab",
]
[[package]]
name = "foldhash"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]]
name = "generic-rt"
version = "0.1.0"
[[package]]
name = "goblin"
version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17582616a7718cca54cec18e534a76c7c4aec11a8b9a85695712f262fd15a4c8"
dependencies = [
"log",
"plain",
"scroll",
]
[[package]]
name = "hashbrown"
version = "0.15.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
dependencies = [
"foldhash",
]
[[package]]
name = "ioslice"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e571352c8a3b89074d12e3ee5173ffe162159105352aaaf1fc5764da747e31b"
[[package]]
name = "libc"
version = "0.2.186"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
[[package]]
name = "libredox"
version = "0.1.18+rb0.3.0"
dependencies = [
"bitflags",
"libc",
"plain",
"redox_syscall",
]
[[package]]
name = "linked_list_allocator"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b23ac50abb8261cb38c6e2a7192d3302e0836dac1628f6a93b82b4fad185897"
dependencies = [
"spinning_top",
]
[[package]]
name = "lock_api"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
dependencies = [
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad"
[[package]]
name = "plain"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
[[package]]
name = "proc-macro2"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368"
dependencies = [
"proc-macro2",
]
[[package]]
name = "redox-initfs"
version = "0.2.0"
dependencies = [
"plain",
]
[[package]]
name = "redox-path"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "436d45c2b6a5b159d43da708e62b25be3a4a3d5550d654b72216ade4c4bfd717"
[[package]]
name = "redox-rt"
version = "0.1.0"
dependencies = [
"bitflags",
"generic-rt",
"goblin",
"ioslice",
"libredox",
"plain",
"redox-path",
"redox_syscall",
]
[[package]]
name = "redox-scheme"
version = "0.11.2+rb0.3.0"
dependencies = [
"libredox",
"redox_syscall",
]
[[package]]
name = "redox_syscall"
version = "0.9.0+rb0.3.0"
dependencies = [
"bitflags",
]
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "scroll"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1257cd4248b4132760d6524d6dda4e053bc648c9070b960929bf50cfb1e7add"
dependencies = [
"scroll_derive",
]
[[package]]
name = "scroll_derive"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed76efe62313ab6610570951494bdaa81568026e0318eaa55f167de70eeea67d"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "slab"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
[[package]]
name = "spinning_top"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0"
dependencies = [
"lock_api",
]
[[package]]
name = "syn"
version = "2.0.118"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
-46
View File
@@ -1,46 +0,0 @@
[package]
name = "bootstrap"
description = "Userspace bootstrapper"
version = "0.0.0"
authors = ["4lDO2 <4lDO2@protonmail.com>"]
edition = "2024"
license = "MIT"
[workspace.dependencies]
libredox = { path = "../../libredox", default-features = false, features = ["base", "protocol", "redox_syscall"] }
redox_syscall = { path = "../../syscall" }
redox-scheme = { path = "../../redox-scheme", default-features = false }
[workspace]
[dependencies]
hashbrown = { version = "0.15", default-features = false, features = [
"inline-more",
"default-hasher",
] }
linked_list_allocator = "0.10"
libredox = { workspace = true }
log = { version = "0.4", default-features = false }
plain = "0.2"
redox-initfs = { path = "../initfs", default-features = false }
redox_syscall = { workspace = true }
redox-scheme = { workspace = true }
redox-path = "0.3.1"
slab = { version = "0.4.9", default-features = false }
arrayvec = { version = "0.7.6", default-features = false }
[target.'cfg(target_os = "redox")'.dependencies]
redox-rt = { path = "../../relibc/redox-rt", default-features = false }
[profile.release]
panic = "abort"
lto = "fat"
opt-level = "s"
[profile.dev]
panic = "abort"
opt-level = "s"
[patch.crates-io]
redox_syscall = { path = "../../syscall" }
libredox = { path = "../../libredox" }
-14
View File
@@ -1,14 +0,0 @@
use std::env;
fn main() {
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let mut arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
if arch == "x86" {
arch = "i586".to_owned();
}
println!("cargo::rustc-link-arg=-z");
println!("cargo::rustc-link-arg=max-page-size=4096");
println!("cargo::rustc-link-arg=-T");
println!("cargo::rustc-link-arg={manifest_dir}/src/{arch}.ld");
}
-55
View File
@@ -1,55 +0,0 @@
ENTRY(_start)
OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
SECTIONS {
. = 4096 + 4096; /* Reserved for the null page and the initfs header prepended by redox-initfs-ar */
__initfs_header = . - 4096;
. += SIZEOF_HEADERS;
. = ALIGN(4096);
.text : {
__text_start = .;
*(.text*)
. = ALIGN(4096);
__text_end = .;
}
.rodata : {
__rodata_start = .;
*(.rodata*)
}
.data.rel.ro : {
*(.data.rel.ro*)
}
.got : {
*(.got)
}
.got.plt : {
*(.got.plt)
. = ALIGN(4096);
__rodata_end = .;
}
.data : {
__data_start = .;
*(.data*)
. = ALIGN(4096);
__data_end = .;
*(.tbss*)
. = ALIGN(4096);
*(.tdata*)
. = ALIGN(4096);
__bss_start = .;
*(.bss*)
. = ALIGN(4096);
__bss_end = .;
}
/DISCARD/ : {
*(.comment*)
*(.eh_frame*)
*(.gcc_except_table*)
*(.note*)
*(.rel.eh_frame*)
}
}
-53
View File
@@ -1,53 +0,0 @@
use core::mem;
use syscall::{data::Map, flag::MapFlags, number::SYS_FMAP};
pub const USERMODE_END: usize = 0x0000_8000_0000_0000;
pub const STACK_START: usize = USERMODE_END - syscall::KERNEL_METADATA_SIZE - STACK_SIZE;
const STACK_SIZE: usize = 64 * 1024; // 64 KiB
static MAP: Map = Map {
offset: 0,
size: STACK_SIZE,
flags: MapFlags::PROT_READ
.union(MapFlags::PROT_WRITE)
.union(MapFlags::MAP_PRIVATE)
.union(MapFlags::MAP_FIXED_NOREPLACE),
address: STACK_START, // highest possible user address
};
core::arch::global_asm!(
"
.globl _start
_start:
// Setup a stack.
ldr x8, ={number}
ldr x0, ={fd}
ldr x1, ={map} // pointer to Map struct
ldr x2, ={map_size} // size of Map struct
svc 0
// Failure if return value is zero
cbz x0, 1f
// Failure if return value is negative
tbnz x0, 63, 1f
// Set up stack frame
mov sp, x0
add sp, sp, #{stack_size}
mov fp, sp
// Stack has the same alignment as `size`.
bl start
// `start` must never return.
// failure, emit undefined instruction
1:
udf #0
",
fd = const usize::MAX, // dummy fd indicates anonymous map
map = sym MAP,
map_size = const mem::size_of::<Map>(),
number = const SYS_FMAP,
stack_size = const STACK_SIZE,
);
-364
View File
@@ -1,364 +0,0 @@
use alloc::string::ToString;
use alloc::sync::Arc;
use alloc::vec::Vec;
use core::ffi::CStr;
use core::str::FromStr;
use hashbrown::HashMap;
use redox_scheme::Socket;
use syscall::CallFlags;
use syscall::data::{GlobalSchemes, KernelSchemeInfo};
use syscall::flag::{O_CLOEXEC, O_RDONLY, O_STAT};
use syscall::{EINTR, Error};
use redox_rt::proc::*;
use crate::KernelSchemeMap;
struct Logger;
impl log::Log for Logger {
fn enabled(&self, metadata: &log::Metadata) -> bool {
metadata.level() <= log::max_level()
}
fn log(&self, record: &log::Record) {
let file = record.file().unwrap_or("");
let line = record.line().unwrap_or(0);
let level = record.level();
let msg = record.args();
let _ = libredox::call::write(
1,
alloc::format!("[{file}:{line} {level}] {msg}\n").as_bytes(),
);
}
fn flush(&self) {}
}
const KERNEL_METADATA_BASE: usize = crate::arch::USERMODE_END - syscall::KERNEL_METADATA_SIZE;
pub fn main() -> ! {
let mut cursor = KERNEL_METADATA_BASE;
let kernel_scheme_infos = unsafe {
let base_ptr = cursor as *const u8;
let infos_len = *(base_ptr as *const usize);
let infos_ptr = base_ptr.add(core::mem::size_of::<usize>()) as *const KernelSchemeInfo;
let slice = core::slice::from_raw_parts(infos_ptr, infos_len);
cursor += core::mem::size_of::<usize>() // kernel scheme number size
+ infos_len // kernel scheme number
* core::mem::size_of::<KernelSchemeInfo>();
slice
};
let scheme_creation_cap = unsafe {
let base_ptr = cursor as *const u8;
FdGuard::new(*(base_ptr as *const usize))
};
let mut kernel_schemes = KernelSchemeMap::new(kernel_scheme_infos);
let auth = kernel_schemes
.0
.remove(&GlobalSchemes::Proc)
.expect("failed to get proc fd");
let this_thr_fd = auth
.dup(b"cur-context")
.expect("failed to open open_via_dup")
.to_upper()
.unwrap();
let this_thr_fd = unsafe { redox_rt::initialize_freestanding(this_thr_fd) };
let mut env_bytes = [0_u8; 4096];
let mut envs = {
let fd = FdGuard::new(
libredox::call::openat(
kernel_schemes
.get(GlobalSchemes::Sys)
.expect("failed to get sys fd")
.as_raw_fd(),
"env",
(O_RDONLY | O_CLOEXEC) as i32,
0,
)
.expect("bootstrap: failed to open env"),
);
let bytes_read = fd
.read(&mut env_bytes)
.expect("bootstrap: failed to read env");
if bytes_read >= env_bytes.len() {
// TODO: Handle this, we can allocate as much as we want in theory.
panic!("env is too large");
}
let env_bytes = &mut env_bytes[..bytes_read];
env_bytes
.split(|&c| c == b'\n')
.filter(|var| !var.is_empty())
.filter(|var| !var.starts_with(b"INITFS_"))
.collect::<Vec<_>>()
};
envs.push(b"RUST_BACKTRACE=1");
//envs.push(b"LD_DEBUG=all");
envs.push(b"LD_LIBRARY_PATH=/scheme/initfs/lib");
log::set_max_level(log::LevelFilter::Warn);
if let Some(log_env) = envs
.iter()
.find_map(|var| var.strip_prefix(b"BOOTSTRAP_LOG_LEVEL="))
{
if let Ok(Ok(log_level)) = str::from_utf8(&log_env).map(|s| log::LevelFilter::from_str(s)) {
log::set_max_level(log_level);
}
}
let _ = log::set_logger(&Logger);
unsafe extern "C" {
// The linker script will define this as the location of the initfs header.
static __initfs_header: u8;
// The linker script will define this as the end of the executable (excluding initfs).
static __bss_end: u8;
}
let initfs_start = core::ptr::addr_of!(__initfs_header);
let initfs_length = unsafe {
(*(core::ptr::addr_of!(__initfs_header) as *const redox_initfs::types::Header))
.initfs_size
.get() as usize
};
let (scheme_creation_cap, auth, kernel_schemes, initfs_fd) = spawn(
"initfs daemon",
auth,
&this_thr_fd,
scheme_creation_cap,
kernel_schemes,
false,
|write_fd, socket, _, _| unsafe {
crate::initfs::run(
core::slice::from_raw_parts(initfs_start, initfs_length),
write_fd,
socket,
);
},
);
// Unmap initfs data as only the initfs scheme implementation needs it.
unsafe {
let executable_end = core::ptr::addr_of!(__bss_end)
.add(core::ptr::addr_of!(__bss_end).align_offset(syscall::PAGE_SIZE));
syscall::funmap(
executable_end as usize,
initfs_length.next_multiple_of(syscall::PAGE_SIZE)
- (executable_end.offset_from(initfs_start) as usize),
)
.unwrap();
}
let (scheme_creation_cap, auth, kernel_schemes, proc_fd) = spawn(
"process manager",
auth,
&this_thr_fd,
scheme_creation_cap,
kernel_schemes,
true,
|write_fd, socket, auth, mut kernel_schemes| {
let event = kernel_schemes
.0
.remove(&GlobalSchemes::Event)
.expect("failed to get event fd");
drop(kernel_schemes);
crate::procmgr::run(write_fd, socket, auth, event)
},
);
let scheme_creation_cap_dup = scheme_creation_cap
.dup(b"")
.expect("failed to dup scheme creation cap");
let (_, _, _, initns_fd) = spawn(
"init namespace manager",
auth,
&this_thr_fd,
scheme_creation_cap,
kernel_schemes,
false,
|write_fd, socket, _, kernel_schemes| {
let mut schemes = HashMap::default();
for (scheme, fd) in kernel_schemes.0.into_iter() {
schemes.insert(scheme.as_str().to_string(), Arc::new(fd));
}
schemes.insert(
"proc".to_string(),
// A bit dirty, but necessary as the parent process still needs access to it. Rust
// doesn't know that the fd got cloned by fork.
Arc::new(FdGuard::new(proc_fd.as_raw_fd())),
);
schemes.insert("initfs".to_string(), Arc::new(initfs_fd));
crate::initnsmgr::run(write_fd, socket, schemes, scheme_creation_cap_dup)
},
);
let (init_proc_fd, init_thr_fd) = unsafe { make_init(proc_fd.take()) };
// from this point, this_thr_fd is no longer valid
const CWD: &[u8] = b"/scheme/initfs";
let cwd_fd = FdGuard::new(
libredox::call::openat(initns_fd.as_raw_fd(), "/scheme/initfs", O_STAT as i32, 0)
.expect("failed to open cwd fd"),
)
.to_upper()
.unwrap();
let extrainfo = ExtraInfo {
cwd: Some(CWD),
sigprocmask: 0,
sigignmask: 0,
umask: redox_rt::sys::get_umask(),
thr_fd: init_thr_fd.as_raw_fd(),
proc_fd: init_proc_fd.as_raw_fd(),
ns_fd: Some(initns_fd.take()),
cwd_fd: Some(cwd_fd.as_raw_fd()),
};
let path = "/scheme/initfs/bin/init";
let image_file = FdGuard::new(
libredox::call::openat(extrainfo.ns_fd.unwrap(), path, (O_RDONLY | O_CLOEXEC) as i32, 0)
.expect("failed to open init"),
)
.to_upper()
.unwrap();
let exe_path = alloc::format!("/scheme/initfs{}", path);
let FexecResult::Interp {
path: interp_path,
interp_override,
} = fexec_impl(
image_file,
init_thr_fd,
init_proc_fd,
exe_path.as_bytes(),
&[exe_path.as_bytes()],
&envs,
&extrainfo,
None,
)
.map_err(|e| {
let _ = libredox::call::write(1, alloc::format!("fexec_impl failed: {}\n", e).as_bytes());
e
})
.expect("failed to execute init");
// According to elf(5), PT_INTERP requires that the interpreter path be
// null-terminated. Violating this should therefore give the "format error" ENOEXEC.
let interp_cstr = CStr::from_bytes_with_nul(&interp_path).expect("interpreter not valid C str");
let interp_file = FdGuard::new(
libredox::call::openat(
extrainfo.ns_fd.unwrap(), // initns, not initfs!
interp_cstr.to_str().expect("interpreter not UTF-8"),
(O_RDONLY | O_CLOEXEC) as i32,
0,
)
.expect("failed to open dynamic linker"),
)
.to_upper()
.unwrap();
fexec_impl(
interp_file,
init_thr_fd,
init_proc_fd,
exe_path.as_bytes(),
&[exe_path.as_bytes()],
&envs,
&extrainfo,
Some(interp_override),
)
.expect("failed to execute init");
unreachable!()
}
pub(crate) fn spawn(
name: &str,
auth: FdGuard,
this_thr_fd: &FdGuardUpper,
scheme_creation_cap: FdGuard,
kernel_schemes: KernelSchemeMap,
nonblock: bool,
inner: impl FnOnce(FdGuard, Socket, FdGuard, KernelSchemeMap) -> !,
) -> (FdGuard, FdGuard, KernelSchemeMap, FdGuard) {
let read = FdGuard::new(
libredox::call::openat(
kernel_schemes
.get(GlobalSchemes::Pipe)
.expect("failed to get pipe fd")
.as_raw_fd(),
"",
O_CLOEXEC as i32,
0,
)
.expect("failed to open sync read pipe"),
);
// The write pipe will not inherit O_CLOEXEC, but is closed by the daemon later.
let write = FdGuard::new(
libredox::call::dup(read.as_raw_fd(), b"write").expect("failed to open sync write pipe"),
);
match fork_impl(&ForkArgs::Init {
this_thr_fd,
auth: &auth,
}) {
Err(err) => {
panic!("Failed to fork in order to start {name}: {err}");
}
// Continue serving the scheme as the child.
Ok(0) => {
let _ = libredox::call::write(1, b"SP:0\n");
drop(read);
let _ = libredox::call::write(1, b"SP:1\n");
let socket = Socket::create_inner(scheme_creation_cap.as_raw_fd(), nonblock)
.expect("failed to open proc scheme socket");
let _ = libredox::call::write(1, b"SP:2\n");
drop(scheme_creation_cap);
let _ = libredox::call::write(1, b"SP:3\n");
inner(write, socket, auth, kernel_schemes)
}
// Return in order to execute init, as the parent.
Ok(_) => {
drop(write);
let mut new_fd = usize::MAX;
let fd_bytes = unsafe {
core::slice::from_raw_parts_mut(
core::slice::from_mut(&mut new_fd).as_mut_ptr() as *mut u8,
core::mem::size_of::<usize>(),
)
};
loop {
match syscall::call_ro(
read.as_raw_fd(),
fd_bytes,
CallFlags::FD | CallFlags::FD_UPPER,
&[],
) {
Err(Error { errno: EINTR }) => continue,
_ => break,
}
}
(
scheme_creation_cap,
auth,
kernel_schemes,
FdGuard::new(new_fd),
)
}
}
}
-55
View File
@@ -1,55 +0,0 @@
ENTRY(_start)
OUTPUT_FORMAT(elf32-i386)
SECTIONS {
. = 4096 + 4096; /* Reserved for the null page and the initfs header prepended by redox-initfs-ar */
__initfs_header = . - 4096;
. += SIZEOF_HEADERS;
. = ALIGN(4096);
.text : {
__text_start = .;
*(.text*)
. = ALIGN(4096);
__text_end = .;
}
.rodata : {
__rodata_start = .;
*(.rodata*)
}
.data.rel.ro : {
*(.data.rel.ro*)
}
.got : {
*(.got)
}
.got.plt : {
*(.got.plt)
. = ALIGN(4096);
__rodata_end = .;
}
.data : {
__data_start = .;
*(.data*)
. = ALIGN(4096);
__data_end = .;
*(.tbss*)
. = ALIGN(4096);
*(.tdata*)
. = ALIGN(4096);
__bss_start = .;
*(.bss*)
. = ALIGN(4096);
__bss_end = .;
}
/DISCARD/ : {
*(.comment*)
*(.eh_frame*)
*(.gcc_except_table*)
*(.note*)
*(.rel.eh_frame*)
}
}
-55
View File
@@ -1,55 +0,0 @@
ENTRY(_start)
OUTPUT_FORMAT(elf32-i386)
SECTIONS {
. = 4096 + 4096; /* Reserved for the null page and the initfs header prepended by redox-initfs-ar */
__initfs_header = . - 4096;
. += SIZEOF_HEADERS;
. = ALIGN(4096);
.text : {
__text_start = .;
*(.text*)
. = ALIGN(4096);
__text_end = .;
}
.rodata : {
__rodata_start = .;
*(.rodata*)
}
.data.rel.ro : {
*(.data.rel.ro*)
}
.got : {
*(.got)
}
.got.plt : {
*(.got.plt)
. = ALIGN(4096);
__rodata_end = .;
}
.data : {
__data_start = .;
*(.data*)
. = ALIGN(4096);
__data_end = .;
*(.tbss*)
. = ALIGN(4096);
*(.tdata*)
. = ALIGN(4096);
__bss_start = .;
*(.bss*)
. = ALIGN(4096);
__bss_end = .;
}
/DISCARD/ : {
*(.comment*)
*(.eh_frame*)
*(.gcc_except_table*)
*(.note*)
*(.rel.eh_frame*)
}
}
-49
View File
@@ -1,49 +0,0 @@
use core::mem;
use syscall::{data::Map, flag::MapFlags, number::SYS_FMAP};
const STACK_SIZE: usize = 64 * 1024; // 64 KiB
pub const USERMODE_END: usize = 0x8000_0000;
pub const STACK_START: usize = USERMODE_END - syscall::KERNEL_METADATA_SIZE - STACK_SIZE;
static MAP: Map = Map {
offset: 0,
size: STACK_SIZE,
flags: MapFlags::PROT_READ
.union(MapFlags::PROT_WRITE)
.union(MapFlags::MAP_PRIVATE)
.union(MapFlags::MAP_FIXED_NOREPLACE),
address: STACK_START, // highest possible user address
};
core::arch::global_asm!(
"
.globl _start
_start:
# Setup a stack.
mov eax, {number}
mov ebx, {fd}
mov ecx, offset {map} # pointer to Map struct
mov edx, {map_size} # size of Map struct
int 0x80
# Test for success (nonzero value).
cmp eax, 0
jg 1f
# (failure)
ud2
1:
# Subtract 16 since all instructions seem to hate non-canonical ESP values :)
lea esp, [eax+{stack_size}-16]
mov ebp, esp
# Stack has the same alignment as `size`.
call start
# `start` must never return.
ud2
",
fd = const usize::MAX, // dummy fd indicates anonymous map
map = sym MAP,
map_size = const mem::size_of::<Map>(),
number = const SYS_FMAP,
stack_size = const STACK_SIZE,
);
-543
View File
@@ -1,543 +0,0 @@
use core::convert::TryFrom;
#[allow(deprecated)]
use core::hash::{BuildHasherDefault, SipHasher};
use core::str;
use alloc::string::String;
use hashbrown::HashMap;
use redox_initfs::{InitFs, Inode, InodeDir, InodeKind, InodeStruct, types::Timespec};
use redox_rt::proc::FdGuard;
use redox_scheme::{
CallerCtx, OpenResult, RequestKind,
scheme::{SchemeState, SchemeSync},
};
use redox_scheme::{SignalBehavior, Socket};
use syscall::PAGE_SIZE;
use syscall::data::Stat;
use syscall::dirent::DirEntry;
use syscall::dirent::DirentBuf;
use syscall::dirent::DirentKind;
use syscall::error::*;
use syscall::flag::*;
use syscall::schemev2::NewFdFlags;
enum Handle {
Node(Node),
SchemeRoot,
}
impl Handle {
fn as_node(&self) -> Result<&Node> {
match self {
Handle::Node(n) => Ok(n),
_ => Err(Error::new(EBADF)),
}
}
fn as_node_mut(&mut self) -> Result<&mut Node> {
match self {
Handle::Node(n) => Ok(n),
_ => Err(Error::new(EBADF)),
}
}
}
struct Node {
inode: Inode,
// TODO: Any better way to implement fpath? Or maybe work around it, e.g. by giving paths such
// as `initfs:__inodes__/<inode>`?
filename: String,
}
pub struct InitFsScheme {
#[allow(deprecated)]
handles: HashMap<usize, Handle, BuildHasherDefault<SipHasher>>,
next_id: usize,
fs: InitFs<'static>,
}
impl InitFsScheme {
pub fn new(bytes: &'static [u8]) -> Self {
Self {
handles: HashMap::default(),
next_id: 0,
fs: InitFs::new(bytes, Some(PAGE_SIZE.try_into().unwrap()))
.expect("failed to parse initfs"),
}
}
fn get_inode(fs: &InitFs<'static>, inode: Inode) -> Result<InodeStruct<'static>> {
fs.get_inode(inode).ok_or_else(|| Error::new(EIO))
}
fn next_id(&mut self) -> usize {
assert_ne!(self.next_id, usize::MAX, "usize overflow in initfs scheme");
self.next_id += 1;
self.next_id
}
}
struct Iter {
dir: InodeDir<'static>,
idx: u32,
}
impl Iterator for Iter {
type Item = Result<redox_initfs::Entry<'static>>;
fn next(&mut self) -> Option<Self::Item> {
let entry = self.dir.get_entry(self.idx).map_err(|_| Error::new(EIO));
self.idx += 1;
entry.transpose()
}
fn size_hint(&self) -> (usize, Option<usize>) {
match self.dir.entry_count().ok() {
Some(size) => {
let size =
usize::try_from(size).expect("expected u32 to be convertible into usize");
(size, Some(size))
}
None => (0, None),
}
}
}
fn inode_len(inode: InodeStruct<'static>) -> Result<usize> {
Ok(match inode.kind() {
InodeKind::File(file) => file.data().map_err(|_| Error::new(EIO))?.len(),
InodeKind::Dir(dir) => (Iter { dir, idx: 0 }).fold(0, |len, entry| {
len + entry
.and_then(|entry| entry.name().map_err(|_| Error::new(EIO)))
.map_or(0, |name| name.len() + 1)
}),
InodeKind::Link(link) => link.data().map_err(|_| Error::new(EIO))?.len(),
InodeKind::Unknown => return Err(Error::new(EIO)),
})
}
impl SchemeSync for InitFsScheme {
fn openat(
&mut self,
dirfd: usize,
path: &str,
flags: usize,
_fcntl_flags: u32,
_ctx: &CallerCtx,
) -> Result<OpenResult> {
if !matches!(
self.handles.get(&dirfd).ok_or(Error::new(EBADF))?,
Handle::SchemeRoot
) {
return Err(Error::new(EACCES));
}
let mut components = path
// trim leading and trailing slash
.trim_matches('/')
// divide into components
.split('/')
// filter out double slashes (e.g. /usr//bin/...)
.filter(|c| !c.is_empty());
let mut current_inode = InitFs::ROOT_INODE;
while let Some(component) = components.next() {
match component {
"." => continue,
".." => {
let _ = components.next_back();
continue;
}
_ => (),
}
let current_inode_struct = Self::get_inode(&self.fs, current_inode)?;
let dir = match current_inode_struct.kind() {
InodeKind::Dir(dir) => dir,
// TODO: Support symlinks in other position than xopen target
InodeKind::Link(_) => {
return Err(Error::new(EOPNOTSUPP));
}
// If we still have more components in the path, and the file tree for that
// particular branch is not all directories except the last, then that file cannot
// exist.
InodeKind::File(_) | InodeKind::Unknown => return Err(Error::new(ENOENT)),
};
let mut entries = Iter { dir, idx: 0 };
current_inode = loop {
let entry_res = match entries.next() {
Some(e) => e,
None => return Err(Error::new(ENOENT)),
};
let entry = entry_res?;
let name = entry.name().map_err(|_| Error::new(EIO))?;
if name == component.as_bytes() {
break entry.inode();
}
};
}
// xopen target is link -- return EXDEV so that the file is opened as a link.
// TODO: Maybe follow initfs-local symlinks here? Would be faster
let is_link = matches!(
Self::get_inode(&self.fs, current_inode)?.kind(),
InodeKind::Link(_)
);
let o_stat_nofollow = flags & O_STAT != 0 && flags & O_NOFOLLOW != 0;
let o_symlink = flags & O_SYMLINK != 0;
if is_link && !o_stat_nofollow && !o_symlink {
return Err(Error::new(EXDEV));
}
let id = self.next_id();
let old = self.handles.insert(
id,
Handle::Node(Node {
inode: current_inode,
filename: path.into(),
}),
);
assert!(old.is_none());
Ok(OpenResult::ThisScheme {
number: id,
flags: NewFdFlags::POSITIONED,
})
}
fn read(
&mut self,
id: usize,
buffer: &mut [u8],
offset: u64,
_fcntl_flags: u32,
_ctx: &CallerCtx,
) -> Result<usize> {
let Ok(offset) = usize::try_from(offset) else {
return Ok(0);
};
let handle = self
.handles
.get_mut(&id)
.ok_or(Error::new(EBADF))?
.as_node_mut()?;
match Self::get_inode(&self.fs, handle.inode)?.kind() {
InodeKind::File(file) => {
let data = file.data().map_err(|_| Error::new(EIO))?;
let src_buf = &data[core::cmp::min(offset, data.len())..];
let to_copy = core::cmp::min(src_buf.len(), buffer.len());
buffer[..to_copy].copy_from_slice(&src_buf[..to_copy]);
Ok(to_copy)
}
InodeKind::Dir(_) => Err(Error::new(EISDIR)),
InodeKind::Link(link) => {
let link_data = link.data().map_err(|_| Error::new(EIO))?;
let src_buf = &link_data[core::cmp::min(offset, link_data.len())..];
let to_copy = core::cmp::min(src_buf.len(), buffer.len());
buffer[..to_copy].copy_from_slice(&src_buf[..to_copy]);
Ok(to_copy)
}
InodeKind::Unknown => Err(Error::new(EIO)),
}
}
fn getdents<'buf>(
&mut self,
id: usize,
mut buf: DirentBuf<&'buf mut [u8]>,
opaque_offset: u64,
) -> Result<DirentBuf<&'buf mut [u8]>> {
let Ok(offset) = u32::try_from(opaque_offset) else {
return Ok(buf);
};
let handle = self.handles.get(&id).ok_or(Error::new(EBADF))?.as_node()?;
let InodeKind::Dir(dir) = Self::get_inode(&self.fs, handle.inode)?.kind() else {
return Err(Error::new(ENOTDIR));
};
let iter = Iter { dir, idx: offset };
for (index, entry) in iter.enumerate() {
let entry = entry?;
buf.entry(DirEntry {
// TODO: Add getter
//inode: entry.inode(),
inode: 0,
name: entry
.name()
.ok()
.and_then(|utf8| core::str::from_utf8(utf8).ok())
.ok_or(Error::new(EIO))?,
next_opaque_id: index as u64 + 1,
kind: DirentKind::Unspecified,
})?;
}
Ok(buf)
}
fn fsize(&mut self, id: usize, _ctx: &CallerCtx) -> Result<u64> {
let handle = self
.handles
.get_mut(&id)
.ok_or(Error::new(EBADF))?
.as_node_mut()?;
Ok(inode_len(Self::get_inode(&self.fs, handle.inode)?)? as u64)
}
fn fcntl(&mut self, id: usize, _cmd: usize, _arg: usize, _ctx: &CallerCtx) -> Result<usize> {
let _handle = self.handles.get(&id).ok_or(Error::new(EBADF))?.as_node()?;
Ok(0)
}
fn fpath(&mut self, id: usize, buf: &mut [u8], _ctx: &CallerCtx) -> Result<usize> {
let handle = self.handles.get(&id).ok_or(Error::new(EBADF))?.as_node()?;
// TODO: Copy scheme part in kernel
let scheme_path = b"/scheme/initfs";
let scheme_bytes = core::cmp::min(scheme_path.len(), buf.len());
buf[..scheme_bytes].copy_from_slice(&scheme_path[..scheme_bytes]);
let source = handle.filename.as_bytes();
let path_bytes = core::cmp::min(buf.len() - scheme_bytes, source.len());
buf[scheme_bytes..scheme_bytes + path_bytes].copy_from_slice(&source[..path_bytes]);
Ok(scheme_bytes + path_bytes)
}
fn fstat(&mut self, id: usize, stat: &mut Stat, _ctx: &CallerCtx) -> Result<()> {
let handle = self.handles.get(&id).ok_or(Error::new(EBADF))?.as_node()?;
let Timespec { sec, nsec } = self.fs.image_creation_time();
let inode = Self::get_inode(&self.fs, handle.inode)?;
stat.st_ino = inode.id();
stat.st_mode = inode.mode()
| match inode.kind() {
InodeKind::Dir(_) => MODE_DIR,
InodeKind::File(_) => MODE_FILE,
InodeKind::Link(_) => MODE_SYMLINK,
_ => 0,
};
stat.st_uid = 0;
stat.st_gid = 0;
stat.st_size = u64::try_from(inode_len(inode)?).unwrap_or(u64::MAX);
stat.st_ctime = sec.get();
stat.st_ctime_nsec = nsec.get();
stat.st_mtime = sec.get();
stat.st_mtime_nsec = nsec.get();
Ok(())
}
fn fsync(&mut self, id: usize, _ctx: &CallerCtx) -> Result<()> {
if !self.handles.contains_key(&id) {
return Err(Error::new(EBADF));
}
Ok(())
}
fn mmap_prep(
&mut self,
id: usize,
offset: u64,
size: usize,
flags: MapFlags,
_ctx: &CallerCtx,
) -> syscall::Result<usize> {
let handle = self.handles.get(&id).ok_or(Error::new(EBADF))?;
let Handle::Node(node) = handle else {
return Err(Error::new(EBADF));
};
let data = match Self::get_inode(&self.fs, node.inode)?.kind() {
InodeKind::File(file) => file.data().map_err(|_| Error::new(EIO))?,
InodeKind::Dir(_) => return Err(Error::new(EISDIR)),
InodeKind::Link(_) => return Err(Error::new(ELOOP)),
InodeKind::Unknown => return Err(Error::new(EIO)),
};
if flags.contains(MapFlags::PROT_WRITE) {
return Err(Error::new(EPERM));
}
let Some(last_addr) = offset.checked_add(size as u64) else {
return Err(Error::new(EINVAL));
};
if last_addr > data.len().next_multiple_of(PAGE_SIZE) as u64 {
return Err(Error::new(EINVAL));
}
Ok(data.as_ptr() as usize)
}
}
pub fn run(bytes: &'static [u8], sync_pipe: FdGuard, socket: Socket) -> ! {
log::info!("bootstrap: starting initfs scheme");
let mut state = SchemeState::new();
let mut scheme = InitFsScheme::new(bytes);
// send open-capability to bootstrap
let new_id = scheme.next_id();
scheme.handles.insert(new_id, Handle::SchemeRoot);
let cap_fd = socket
.create_this_scheme_fd(0, new_id, 0, 0)
.expect("failed to issue initfs root fd");
let _ = syscall::call_rw(
sync_pipe.as_raw_fd(),
&mut cap_fd.to_ne_bytes(),
CallFlags::FD,
&[],
);
drop(sync_pipe);
loop {
let Some(req) = socket
.next_request(SignalBehavior::Restart)
.expect("bootstrap: failed to read scheme request from kernel")
else {
break;
};
match req.kind() {
RequestKind::Call(req) => {
let resp = req.handle_sync(&mut scheme, &mut state);
if !socket
.write_response(resp, SignalBehavior::Restart)
.expect("bootstrap: failed to write scheme response to kernel")
{
break;
}
}
RequestKind::OnClose { id } => {
scheme.handles.remove(&id);
}
_ => (),
}
}
unreachable!()
}
// TODO: Restructure bootstrap so it calls into relibc, or a split-off derivative without the C
// parts, such as "redox-rt".
#[unsafe(no_mangle)]
pub unsafe extern "C" fn redox_read_v1(fd: usize, ptr: *mut u8, len: usize) -> isize {
Error::mux(syscall::read(fd, unsafe {
core::slice::from_raw_parts_mut(ptr, len)
})) as isize
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn redox_write_v1(fd: usize, ptr: *const u8, len: usize) -> isize {
Error::mux(syscall::write(fd, unsafe {
core::slice::from_raw_parts(ptr, len)
})) as isize
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn redox_openat_v1(
fd: usize,
buf: *const u8,
path_len: usize,
flags: u32,
fcntl_flags: u32,
) -> isize {
let path = unsafe { core::slice::from_raw_parts(buf, path_len) };
let path_str = match core::str::from_utf8(path) {
Ok(s) => s,
Err(_) => return -(syscall::EINVAL as isize),
};
Error::mux(syscall::openat(fd, path_str, flags as usize, fcntl_flags as usize)) as isize
}
#[unsafe(no_mangle)]
pub unsafe fn redox_dup_v1(fd: usize, buf: *const u8, len: usize) -> isize {
Error::mux(syscall::dup(fd, unsafe {
core::slice::from_raw_parts(buf, len)
})) as isize
}
#[unsafe(no_mangle)]
pub extern "C" fn redox_close_v1(fd: usize) -> isize {
Error::mux(syscall::close(fd)) as isize
}
#[unsafe(no_mangle)]
pub extern "C" fn redox_fcntl_v0(fd: usize, cmd: usize, arg: usize) -> isize {
Error::mux(syscall::fcntl(fd, cmd, arg)) as isize
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn redox_strerror_v1(
dst: *mut u8,
dst_len: *mut usize,
error: u32,
) -> isize {
let msg = match error {
x if x == syscall::EPERM as u32 => "Operation not permitted",
x if x == syscall::ENOENT as u32 => "No such file or directory",
x if x == syscall::EINTR as u32 => "Interrupted system call",
x if x == syscall::EIO as u32 => "I/O error",
x if x == syscall::EBADF as u32 => "Bad file descriptor",
x if x == syscall::EAGAIN as u32 => "Resource temporarily unavailable",
x if x == syscall::ENOMEM as u32 => "Cannot allocate memory",
x if x == syscall::EACCES as u32 => "Permission denied",
x if x == syscall::EFAULT as u32 => "Bad address",
x if x == syscall::EBUSY as u32 => "Device or resource busy",
x if x == syscall::EEXIST as u32 => "File exists",
x if x == syscall::ENOTDIR as u32 => "Not a directory",
x if x == syscall::EISDIR as u32 => "Is a directory",
x if x == syscall::EINVAL as u32 => "Invalid argument",
x if x == syscall::ENOSYS as u32 => "Function not implemented",
x if x == syscall::ENOTEMPTY as u32 => "Directory not empty",
_ => "Unknown error",
};
let msg_bytes = msg.as_bytes();
unsafe {
let avail = *dst_len;
let copy_len = avail.min(msg_bytes.len());
core::ptr::copy_nonoverlapping(msg_bytes.as_ptr(), dst, copy_len);
*dst_len = copy_len;
copy_len as isize
}
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn redox_sys_call_v0(
fd: usize,
payload: *mut u8,
payload_len: usize,
flags: usize,
metadata: *const u64,
metadata_len: usize,
) -> isize {
let flags = CallFlags::from_bits_retain(flags);
let metadata = unsafe { core::slice::from_raw_parts(metadata, metadata_len) };
let result = if flags.contains(CallFlags::READ) {
let payload = unsafe { core::slice::from_raw_parts_mut(payload, payload_len) };
if flags.contains(CallFlags::WRITE) {
syscall::call_rw(fd, payload, flags, metadata)
} else {
syscall::call_ro(fd, payload, flags, metadata)
}
} else {
let payload = unsafe { core::slice::from_raw_parts(payload, payload_len) };
syscall::call_wo(fd, payload, flags, metadata)
};
Error::mux(result) as isize
}
-558
View File
@@ -1,558 +0,0 @@
use alloc::rc::Rc;
use alloc::string::{String, ToString};
use alloc::sync::Arc;
use alloc::vec::Vec;
use core::cell::RefCell;
use core::fmt::Debug;
use core::mem;
use hashbrown::HashMap;
use libredox::protocol::{NsDup, NsPermissions};
use log::{error, warn};
use redox_path::RedoxPath;
use redox_path::RedoxScheme;
use redox_rt::proc::FdGuard;
use redox_scheme::{
CallerCtx, OpenResult, RequestKind, Response, SendFdRequest, SignalBehavior, Socket,
scheme::{SchemeState, SchemeSync},
};
use syscall::Stat;
use syscall::dirent::{DirEntry, DirentBuf, DirentKind};
use syscall::{CallFlags, FobtainFdFlags, error::*, schemev2::NewFdFlags};
#[derive(Debug, Clone)]
struct Namespace {
schemes: HashMap<String, Arc<FdGuard>>,
}
impl Namespace {
fn fork(&self, buf: &[u8]) -> Result<Self> {
let mut schemes = HashMap::new();
let mut cursor = 0;
while cursor < buf.len() {
let len = read_num::<usize>(&buf[cursor..])?;
cursor += mem::size_of::<usize>();
let name = String::from_utf8(Vec::from(&buf[cursor..cursor + len]))
.map_err(|_| Error::new(EINVAL))?;
cursor += len;
if name.ends_with('*') {
let prefix = &name[..name.len() - 1];
for (registered_name, fd) in &self.schemes {
if registered_name.starts_with(prefix) {
schemes.insert(registered_name.clone(), fd.clone());
}
}
} else {
let Some(fd) = self.schemes.get(&name) else {
warn!("Scheme {} not found in namespace", name);
continue;
};
schemes.insert(name, fd.clone());
}
}
Ok(Self { schemes })
}
fn get_scheme_fd(&self, scheme: &str) -> Option<&Arc<FdGuard>> {
self.schemes.get(scheme)
}
fn remove_scheme(&mut self, scheme: &str) -> Option<()> {
self.schemes.remove(scheme).map(|_| ())
}
}
#[derive(Debug, Clone)]
struct NamespaceAccess {
namespace: Rc<RefCell<Namespace>>,
permission: NsPermissions,
}
impl NamespaceAccess {
fn has_permission(&self, permission: NsPermissions) -> bool {
self.permission.contains(permission)
}
}
#[derive(Debug, Clone)]
struct SchemeRegister {
target_namespace: Rc<RefCell<Namespace>>,
scheme_name: String,
}
impl SchemeRegister {
fn register(&self, fd: FdGuard) -> Result<()> {
let mut ns = self.target_namespace.borrow_mut();
if ns.schemes.contains_key(&self.scheme_name) {
return Err(Error::new(EEXIST));
}
ns.schemes.insert(self.scheme_name.clone(), Arc::new(fd));
Ok(())
}
}
#[derive(Debug, Clone)]
enum Handle {
Access(NamespaceAccess),
Register(SchemeRegister),
List(NamespaceAccess),
}
pub struct NamespaceScheme<'sock> {
socket: &'sock Socket,
handles: HashMap<usize, Handle>,
root_namespace: Namespace,
next_id: usize,
scheme_creation_cap: FdGuard,
}
const HIGH_PERMISSIONS: NsPermissions = NsPermissions::SCHEME_CREATE;
impl<'sock> NamespaceScheme<'sock> {
pub fn new(
socket: &'sock Socket,
schemes: HashMap<String, Arc<FdGuard>>,
scheme_creation_cap: FdGuard,
) -> Self {
Self {
socket,
handles: HashMap::new(),
root_namespace: Namespace { schemes },
next_id: 0,
scheme_creation_cap,
}
}
fn add_namespace(&mut self, id: usize, schemes: Namespace, permission: NsPermissions) {
let handle = Handle::Access(NamespaceAccess {
namespace: Rc::new(RefCell::new(schemes)),
permission,
});
self.handles.insert(id, handle);
}
fn get_ns_access(&self, id: usize) -> Option<&NamespaceAccess> {
let handle = self.handles.get(&id);
match handle {
Some(Handle::Access(access)) => Some(access),
_ => None,
}
}
fn open_namespace_resource(
&self,
ns_access: &NamespaceAccess,
reference: &str,
_flags: usize,
_fcntl_flags: u32,
_ctx: &CallerCtx,
) -> Result<usize> {
match reference {
"scheme-creation-cap" => {
if !ns_access.has_permission(NsPermissions::SCHEME_CREATE) {
error!("Permission denied to get scheme creation capability");
return Err(Error::new(EACCES));
}
Ok(libredox::call::dup(self.scheme_creation_cap.as_raw_fd(), &[])?)
}
_ => {
error!("Unknown special reference: {}", reference);
return Err(Error::new(EINVAL));
}
}
}
fn open_scheme_resource(
&self,
ns: &Namespace,
scheme: &str,
reference: &str,
flags: usize,
fcntl_flags: u32,
ctx: &CallerCtx,
) -> Result<usize> {
let Some(cap_fd) = ns.get_scheme_fd(scheme) else {
log::info!("Scheme {:?} not found in namespace", scheme);
return Err(Error::new(ENODEV));
};
let scheme_fd = syscall::openat(
cap_fd.as_raw_fd(),
reference,
flags,
fcntl_flags as usize,
)?;
Ok(scheme_fd)
}
fn fork_namespace(&mut self, namespace: Rc<RefCell<Namespace>>, names: &[u8]) -> Result<usize> {
let new_id = self.next_id;
let new_namespace = namespace.borrow().fork(names).map_err(|e| {
error!("Failed to fork namespace {}: {}", new_id, e);
e
})?;
self.add_namespace(
new_id,
new_namespace,
NsPermissions::all().difference(HIGH_PERMISSIONS),
);
self.next_id += 1;
Ok(new_id)
}
fn shrink_permissions(
&mut self,
mut ns: NamespaceAccess,
permission: NsPermissions,
) -> Result<usize> {
ns.permission = ns.permission.intersection(permission);
let next_id = self.next_id;
self.handles.insert(next_id, Handle::Access(ns));
self.next_id += 1;
Ok(next_id)
}
}
impl<'sock> SchemeSync for NamespaceScheme<'sock> {
fn openat(
&mut self,
fd: usize,
path: &str,
flags: usize,
fcntl_flags: u32,
ctx: &CallerCtx,
) -> Result<OpenResult> {
let ns_access = {
let handle = self.handles.get(&fd);
match handle {
Some(Handle::Access(access)) => Some(access),
_ => None,
}
}
.ok_or_else(|| {
error!("Namespace with ID {} not found", fd);
Error::new(ENOENT)
})?;
let redox_path = RedoxPath::from_absolute(path).ok_or(Error::new(EINVAL))?;
let (scheme, reference) = redox_path.as_parts().ok_or(Error::new(EINVAL))?;
let res_fd = match scheme.as_ref() {
"namespace" => self.open_namespace_resource(
ns_access,
reference.as_ref(),
flags,
fcntl_flags,
ctx,
)?,
"" => {
if !ns_access.has_permission(NsPermissions::LIST) {
error!("Permission denied to list schemes in namespace {}", fd);
return Err(Error::new(EACCES));
}
let new_id = self.next_id;
self.next_id += 1;
self.handles.insert(new_id, Handle::List(ns_access.clone()));
return Ok(OpenResult::ThisScheme {
number: new_id,
flags: NewFdFlags::empty(),
});
}
_ => self.open_scheme_resource(
&ns_access.namespace.borrow(),
scheme.as_ref(),
reference.as_ref(),
flags,
fcntl_flags,
ctx,
)?,
};
Ok(OpenResult::OtherScheme { fd: res_fd })
}
fn dup(&mut self, id: usize, buf: &[u8], _ctx: &CallerCtx) -> Result<OpenResult> {
let ns_access = self.get_ns_access(id).ok_or_else(|| {
error!("Namespace with ID {} not found", id);
Error::new(ENOENT)
})?;
let raw_kind = read_num::<usize>(buf)?;
let Some(kind) = NsDup::try_from_raw(raw_kind) else {
error!("Unknown dup kind: {}", raw_kind);
return Err(Error::new(EINVAL));
};
let payload = &buf[mem::size_of::<NsDup>()..];
let new_id = match kind {
NsDup::ForkNs => {
let ns = ns_access.namespace.clone();
let _ = ns_access;
self.fork_namespace(ns, payload)?
}
NsDup::ShrinkPermissions => self.shrink_permissions(
ns_access.clone(),
NsPermissions::from_bits_truncate(read_num::<usize>(payload)?),
)?,
NsDup::IssueRegister => {
let name = core::str::from_utf8(payload).map_err(|_| Error::new(EINVAL))?;
let scheme_name = RedoxScheme::new(name).ok_or_else(|| {
error!("Invalid scheme name: {}", name);
Error::new(EINVAL)
})?;
if !ns_access.has_permission(NsPermissions::INSERT) {
error!(
"Permission denied to issue register capability for namespace {}",
id
);
return Err(Error::new(EACCES));
}
let new_id = self.next_id;
let register_cap = Handle::Register(SchemeRegister {
target_namespace: ns_access.namespace.clone(),
scheme_name: scheme_name.as_ref().to_string(),
});
self.handles.insert(new_id, register_cap);
self.next_id += 1;
new_id
}
};
Ok(OpenResult::ThisScheme {
number: new_id,
flags: NewFdFlags::empty(),
})
}
fn unlinkat(&mut self, fd: usize, path: &str, flags: usize, ctx: &CallerCtx) -> Result<()> {
let ns_access = self.get_ns_access(fd).ok_or_else(|| {
error!("Namespace with ID {} not found", fd);
Error::new(ENOENT)
})?;
let mut ns = ns_access.namespace.borrow_mut();
let redox_path = RedoxPath::from_absolute(path).ok_or(Error::new(EINVAL))?;
let (scheme, reference) = redox_path.as_parts().ok_or(Error::new(EINVAL))?;
if reference.as_ref().is_empty() {
if !ns_access.has_permission(NsPermissions::DELETE) {
error!("Permission denied to remove scheme for namespace {}", fd);
return Err(Error::new(EACCES));
}
match ns.remove_scheme(scheme.as_ref()) {
Some(_) => return Ok(()),
None => {
error!("Scheme {} not found in namespace", scheme);
return Err(Error::new(ENODEV));
}
}
}
let Some(cap_fd) = ns.get_scheme_fd(scheme.as_ref()) else {
error!("Scheme {} not found in namespace", scheme);
return Err(Error::new(ENODEV));
};
syscall::unlinkat(cap_fd.as_raw_fd(), reference, flags)?;
Ok(())
}
fn on_close(&mut self, id: usize) {
self.handles.remove(&id);
}
fn on_sendfd(&mut self, sendfd_request: &SendFdRequest) -> Result<usize> {
let namespace_id = sendfd_request.id();
let num_fds = sendfd_request.num_fds();
let handle = self.handles.get(&namespace_id).ok_or_else(|| {
error!("Namespace with ID {} not found", namespace_id);
Error::new(ENOENT)
})?;
let Handle::Register(register_cap) = handle else {
error!(
"Handle with ID {} is not a register capability",
namespace_id
);
return Err(Error::new(EACCES));
};
if num_fds == 0 {
return Ok(0);
}
if num_fds > 1 {
error!("Can only send one fd at a time");
return Err(Error::new(EINVAL));
}
let mut new_fd = usize::MAX;
if let Err(e) = sendfd_request.obtain_fd(
&self.socket,
FobtainFdFlags::UPPER_TBL,
core::slice::from_mut(&mut new_fd),
) {
error!("on_sendfd: obtain_fd failed with error: {:?}", e);
return Err(e);
}
register_cap.register(FdGuard::new(new_fd))?;
Ok(num_fds)
}
fn getdents<'buf>(
&mut self,
id: usize,
mut buf: DirentBuf<&'buf mut [u8]>,
opaque_offset: u64,
) -> Result<DirentBuf<&'buf mut [u8]>> {
let Handle::List(ns_access) = self.handles.get(&id).ok_or(Error::new(EBADF))? else {
return Err(Error::new(ENOTDIR));
};
if !ns_access.has_permission(NsPermissions::LIST) {
return Err(Error::new(EACCES));
}
let ns = ns_access.namespace.borrow();
let opaque_offset = opaque_offset as usize;
for (i, (name, _)) in ns.schemes.iter().enumerate().skip(opaque_offset) {
if name.is_empty() {
continue;
}
if let Err(err) = buf.entry(DirEntry {
kind: DirentKind::Unspecified,
name: &name.clone(),
inode: 0,
next_opaque_id: i as u64 + 1,
}) {
if err.errno == EINVAL && i > opaque_offset {
// POSIX allows partial result of getdents
break;
} else {
return Err(err);
}
}
}
Ok(buf)
}
fn fstat(&mut self, id: usize, stat: &mut Stat, _ctx: &CallerCtx) -> Result<()> {
let resource_stat = match self.handles.get(&id).ok_or(Error::new(EBADF))? {
Handle::List(_) => Stat {
st_mode: 0o444 | syscall::MODE_DIR,
st_uid: 0,
st_gid: 0,
st_size: 0,
..Default::default()
},
Handle::Access(_) | Handle::Register(_) => Stat {
st_mode: 0o666 | syscall::MODE_FILE,
st_uid: 0,
st_gid: 0,
st_size: 0,
..Default::default()
},
};
*stat = resource_stat;
Ok(())
}
}
trait NumFromBytes: Sized + Debug {
fn from_le_bytes_slice(buffer: &[u8]) -> Result<Self, Error>;
}
macro_rules! num_from_bytes_impl {
($($t:ty),*) => {
$(
impl NumFromBytes for $t {
fn from_le_bytes_slice(buffer: &[u8]) -> Result<Self, Error> {
let size = mem::size_of::<Self>();
let buffer_slice = buffer.get(..size).and_then(|s| s.try_into().ok());
if let Some(slice) = buffer_slice {
Ok(Self::from_le_bytes(slice))
} else {
error!(
"read_num: buffer is too short to read num of size {} (buffer len: {})",
size, buffer.len()
);
Err(Error::new(EINVAL))
}
}
}
)*
};
}
num_from_bytes_impl!(usize);
fn read_num<T>(buffer: &[u8]) -> Result<T, Error>
where
T: NumFromBytes,
{
T::from_le_bytes_slice(buffer)
}
pub fn run(
sync_pipe: FdGuard,
socket: Socket,
schemes: HashMap<String, Arc<FdGuard>>,
scheme_creation_cap: FdGuard,
) -> ! {
let mut state = SchemeState::new();
let mut scheme = NamespaceScheme::new(&socket, schemes, scheme_creation_cap);
// send namespace fd to bootstrap
let new_id = scheme.next_id;
scheme.add_namespace(new_id, scheme.root_namespace.clone(), NsPermissions::all());
scheme.next_id += 1;
let cap_fd = scheme
.socket
.create_this_scheme_fd(0, new_id, 0, 0)
.expect("nsmgr: failed to create namespace fd");
let _ = syscall::call_wo(
sync_pipe.as_raw_fd(),
&cap_fd.to_ne_bytes(),
CallFlags::FD,
&[],
);
drop(sync_pipe);
log::info!("bootstrap: namespace scheme start!");
loop {
let Some(req) = socket
.next_request(SignalBehavior::Restart)
.expect("bootstrap: failed to read scheme request from kernel")
else {
break;
};
match req.kind() {
RequestKind::Call(req) => {
let resp = req.handle_sync(&mut scheme, &mut state);
if !socket
.write_response(resp, SignalBehavior::Restart)
.expect("bootstrap: failed to write scheme response to kernel")
{
break;
}
}
RequestKind::OnClose { id } => scheme.on_close(id),
RequestKind::SendFd(sendfd_request) => {
let result = scheme.on_sendfd(&sendfd_request);
let resp = Response::new(result, sendfd_request);
if !socket
.write_response(resp, SignalBehavior::Restart)
.expect("bootstrap: failed to write scheme response to kernel")
{
break;
}
}
_ => (),
}
}
unreachable!()
}
-170
View File
@@ -1,170 +0,0 @@
#![no_std]
#![no_main]
#![allow(internal_features)]
#![feature(core_intrinsics, str_from_raw_parts, never_type)]
#[cfg(target_arch = "aarch64")]
#[path = "aarch64.rs"]
pub mod arch;
#[cfg(target_arch = "x86")]
#[path = "i686.rs"]
pub mod arch;
#[cfg(target_arch = "x86_64")]
#[path = "x86_64.rs"]
pub mod arch;
#[cfg(target_arch = "riscv64")]
#[path = "riscv64.rs"]
pub mod arch;
pub mod exec;
pub mod initfs;
pub mod initnsmgr;
pub mod procmgr;
pub mod start;
extern crate alloc;
use core::cell::UnsafeCell;
use alloc::collections::btree_map::BTreeMap;
use redox_rt::proc::FdGuard;
use syscall::data::Map;
use syscall::data::{GlobalSchemes, KernelSchemeInfo};
use syscall::flag::MapFlags;
#[panic_handler]
fn panic_handler(info: &core::panic::PanicInfo) -> ! {
use core::fmt::Write;
// Try fd 1 first (opened in start()). If that fails, open a fresh debug handle.
struct Writer {
fd: usize,
}
impl Write for Writer {
fn write_str(&mut self, s: &str) -> core::fmt::Result {
// Try writing to our fd. If it fails and we're on fd 1,
// attempt to open a fresh debug handle.
if libredox::call::write(self.fd, s.as_bytes()).is_ok() {
return Ok(());
}
if self.fd == 1 {
let debug_root =
syscall::UPPER_FDTBL_TAG + syscall::data::GlobalSchemes::Debug as usize;
if let Ok(new_fd) =
libredox::call::openat(debug_root, "", syscall::O_WRONLY as i32, 0)
{
self.fd = new_fd;
let _ = libredox::call::write(self.fd, s.as_bytes());
}
}
Ok(()) // Always succeed so writeln! continues formatting
}
}
let _ = writeln!(Writer { fd: 1 }, "{}", info);
core::intrinsics::abort();
}
const HEAP_OFF: usize = arch::USERMODE_END / 2;
struct Allocator;
#[global_allocator]
static ALLOCATOR: Allocator = Allocator;
struct AllocStateInner {
heap: Option<linked_list_allocator::Heap>,
heap_top: usize,
}
struct AllocState(UnsafeCell<AllocStateInner>);
unsafe impl Send for AllocState {}
unsafe impl Sync for AllocState {}
static ALLOC_STATE: AllocState = AllocState(UnsafeCell::new(AllocStateInner {
heap: None,
heap_top: HEAP_OFF + SIZE,
}));
const SIZE: usize = 1024 * 1024;
const HEAP_INCREASE_BY: usize = SIZE;
unsafe impl alloc::alloc::GlobalAlloc for Allocator {
unsafe fn alloc(&self, layout: core::alloc::Layout) -> *mut u8 {
let state = unsafe { &mut (*ALLOC_STATE.0.get()) };
let heap = state.heap.get_or_insert_with(|| {
state.heap_top = HEAP_OFF + SIZE;
let _ = unsafe {
syscall::fmap(
!0,
&Map {
offset: 0,
size: SIZE,
address: HEAP_OFF,
flags: MapFlags::PROT_WRITE
| MapFlags::PROT_READ
| MapFlags::MAP_PRIVATE
| MapFlags::MAP_FIXED_NOREPLACE,
},
)
}
.expect("failed to map initial heap");
unsafe { linked_list_allocator::Heap::new(HEAP_OFF as *mut u8, SIZE) }
});
match heap.allocate_first_fit(layout) {
Ok(p) => p.as_ptr(),
Err(_) => {
if layout.size() > HEAP_INCREASE_BY || layout.align() > 4096 {
return core::ptr::null_mut();
}
let _ = unsafe {
syscall::fmap(
!0,
&Map {
offset: 0,
size: HEAP_INCREASE_BY,
address: state.heap_top,
flags: MapFlags::PROT_WRITE
| MapFlags::PROT_READ
| MapFlags::MAP_PRIVATE
| MapFlags::MAP_FIXED_NOREPLACE,
},
)
}
.expect("failed to extend heap");
unsafe { heap.extend(HEAP_INCREASE_BY) };
state.heap_top += HEAP_INCREASE_BY;
return unsafe { self.alloc(layout) };
}
}
}
unsafe fn dealloc(&self, ptr: *mut u8, layout: core::alloc::Layout) {
unsafe {
(&mut *ALLOC_STATE.0.get())
.heap
.as_mut()
.unwrap()
.deallocate(core::ptr::NonNull::new(ptr).unwrap(), layout)
}
}
}
pub struct KernelSchemeMap(BTreeMap<GlobalSchemes, FdGuard>);
impl KernelSchemeMap {
fn new(kernel_scheme_infos: &[KernelSchemeInfo]) -> Self {
let mut map = BTreeMap::new();
for info in kernel_scheme_infos {
if let Some(scheme_id) = GlobalSchemes::try_from_raw(info.scheme_id) {
map.insert(scheme_id, FdGuard::new(info.fd));
}
}
Self(map)
}
fn get(&self, scheme: GlobalSchemes) -> Option<&FdGuard> {
self.0.get(&scheme)
}
}
File diff suppressed because it is too large Load Diff
-52
View File
@@ -1,52 +0,0 @@
ENTRY(_start)
OUTPUT_FORMAT(elf64-littleriscv)
SECTIONS {
. = 4096 + 4096; /* Reserved for the null page and the initfs header prepended by redox-initfs-ar */
__initfs_header = . - 4096;
. += SIZEOF_HEADERS;
. = ALIGN(4096);
.text : {
__text_start = .;
*(.text*)
. = ALIGN(4096);
__text_end = .;
}
.rodata : {
__rodata_start = .;
*(.rodata*)
}
.data.rel.ro : {
*(.data.rel.ro*)
}
.got : {
*(.got)
}
.got.plt : {
*(.got.plt)
. = ALIGN(4096);
__rodata_end = .;
}
.data : {
__data_start = .;
*(.data*)
*(.sdata*)
. = ALIGN(4096);
__data_end = .;
__bss_start = .;
*(.bss*)
*(.sbss*)
. = ALIGN(4096);
__bss_end = .;
}
/DISCARD/ : {
*(.comment*)
*(.eh_frame*)
*(.gcc_except_table*)
*(.note*)
*(.rel.eh_frame*)
}
}
-47
View File
@@ -1,47 +0,0 @@
use core::mem;
use syscall::{data::Map, flag::MapFlags, number::SYS_FMAP};
const STACK_SIZE: usize = 64 * 1024; // 64 KiB
pub const USERMODE_END: usize = 1 << 38; // Assuming Sv39
pub const STACK_START: usize = USERMODE_END - syscall::KERNEL_METADATA_SIZE - STACK_SIZE;
static MAP: Map = Map {
offset: 0,
size: STACK_SIZE,
flags: MapFlags::PROT_READ
.union(MapFlags::PROT_WRITE)
.union(MapFlags::MAP_PRIVATE)
.union(MapFlags::MAP_FIXED_NOREPLACE),
address: STACK_START, // highest possible user address
};
core::arch::global_asm!(
"
.globl _start
_start:
# Setup a stack.
li a7, {number}
li a0, {fd}
la a1, {map} # pointer to Map struct
li a2, {map_size} # size of Map struct
ecall
# Test for success (nonzero value).
bne a0, x0, 2f
# (failure)
unimp
2:
li sp, {stack_size}
add sp, sp, a0
mv fp, x0
jal start
# `start` must never return.
unimp
",
fd = const usize::MAX, // dummy fd indicates anonymous map
map = sym MAP,
map_size = const mem::size_of::<Map>(),
number = const SYS_FMAP,
stack_size = const STACK_SIZE,
);
-98
View File
@@ -1,98 +0,0 @@
use syscall::flag::MapFlags;
mod offsets {
unsafe extern "C" {
static __text_start: u8;
static __text_end: u8;
static __rodata_start: u8;
static __rodata_end: u8;
static __data_start: u8;
static __bss_end: u8;
}
pub fn text() -> (usize, usize) {
unsafe {
(
&__text_start as *const u8 as usize,
&__text_end as *const u8 as usize,
)
}
}
pub fn rodata() -> (usize, usize) {
unsafe {
(
&__rodata_start as *const u8 as usize,
&__rodata_end as *const u8 as usize,
)
}
}
pub fn data_and_bss() -> (usize, usize) {
unsafe {
(
&__data_start as *const u8 as usize,
&__bss_end as *const u8 as usize,
)
}
}
}
fn dbg(msg: &[u8]) {
let _ = libredox::call::write(1, msg);
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn start() -> ! {
let (text_start, text_end) = offsets::text();
let (rodata_start, rodata_end) = offsets::rodata();
let (data_start, data_end) = offsets::data_and_bss();
let debug_fd = syscall::UPPER_FDTBL_TAG + syscall::data::GlobalSchemes::Debug as usize;
let _ = libredox::call::openat(debug_fd, "", syscall::O_RDONLY as i32, 0);
let _ = libredox::call::openat(debug_fd, "", syscall::O_WRONLY as i32, 0);
let _ = libredox::call::openat(debug_fd, "", syscall::O_WRONLY as i32, 0);
dbg(b"BS:0\n");
unsafe {
let _ = syscall::mprotect(4096, 4096, MapFlags::PROT_READ | MapFlags::MAP_PRIVATE)
.expect("mprotect failed for initfs header page");
dbg(b"BS:1\n");
let _ = syscall::mprotect(
text_start,
text_end - text_start,
MapFlags::PROT_READ | MapFlags::PROT_EXEC | MapFlags::MAP_PRIVATE,
)
.expect("mprotect failed for .text");
dbg(b"BS:2\n");
let _ = syscall::mprotect(
rodata_start,
rodata_end - rodata_start,
MapFlags::PROT_READ | MapFlags::MAP_PRIVATE,
)
.expect("mprotect failed for .rodata");
dbg(b"BS:3\n");
let _ = syscall::mprotect(
data_start,
data_end - data_start,
MapFlags::PROT_READ | MapFlags::PROT_WRITE | MapFlags::MAP_PRIVATE,
)
.expect("mprotect failed for .data/.bss");
dbg(b"BS:4\n");
let _ = syscall::mprotect(
data_end,
crate::arch::STACK_START - data_end,
MapFlags::PROT_READ | MapFlags::MAP_PRIVATE,
)
.expect("mprotect failed for rest of memory");
}
dbg(b"BS:5\n");
crate::exec::main();
}
-55
View File
@@ -1,55 +0,0 @@
ENTRY(_start)
OUTPUT_FORMAT(elf64-x86-64)
SECTIONS {
. = 4096 + 4096; /* Reserved for the null page and the initfs header prepended by redox-initfs-ar */
__initfs_header = . - 4096;
. += SIZEOF_HEADERS;
. = ALIGN(4096);
.text : {
__text_start = .;
*(.text*)
. = ALIGN(4096);
__text_end = .;
}
.rodata : {
__rodata_start = .;
*(.rodata*)
}
.data.rel.ro : {
*(.data.rel.ro*)
}
.got : {
*(.got)
}
.got.plt : {
*(.got.plt)
. = ALIGN(4096);
__rodata_end = .;
}
.data : {
__data_start = .;
*(.data*)
. = ALIGN(4096);
__data_end = .;
*(.tbss*)
. = ALIGN(4096);
*(.tdata*)
. = ALIGN(4096);
__bss_start = .;
*(.bss*)
. = ALIGN(4096);
__bss_end = .;
}
/DISCARD/ : {
*(.comment*)
*(.eh_frame*)
*(.gcc_except_table*)
*(.note*)
*(.rel.eh_frame*)
}
}
-49
View File
@@ -1,49 +0,0 @@
use core::mem;
use syscall::{data::Map, flag::MapFlags, number::SYS_FMAP};
const STACK_SIZE: usize = 64 * 1024; // 64 KiB
pub const USERMODE_END: usize = 0x0000_8000_0000_0000;
pub const STACK_START: usize = USERMODE_END - syscall::KERNEL_METADATA_SIZE - STACK_SIZE;
static MAP: Map = Map {
offset: 0,
size: STACK_SIZE,
flags: MapFlags::PROT_READ
.union(MapFlags::PROT_WRITE)
.union(MapFlags::MAP_PRIVATE)
.union(MapFlags::MAP_FIXED_NOREPLACE),
address: STACK_START, // highest possible user address
};
core::arch::global_asm!(
"
.globl _start
_start:
# Setup a stack.
mov rax, {number}
mov rdi, {fd}
mov rsi, offset {map} # pointer to Map struct
mov rdx, {map_size} # size of Map struct
syscall
# Test for success (nonzero value).
cmp rax, 0
jg 1f
# (failure)
ud2
1:
# Subtract 16 since all instructions seem to hate non-canonical RSP values :)
lea rsp, [rax+{stack_size}-16]
mov rbp, rsp
# Stack has the same alignment as `size`.
call start
# `start` must never return.
ud2
",
fd = const usize::MAX, // dummy fd indicates anonymous map
map = sym MAP,
map_size = const mem::size_of::<Map>(),
number = const SYS_FMAP,
stack_size = const STACK_SIZE,
);
+30
View File
@@ -0,0 +1,30 @@
extern crate cc;
use std::{env, fs};
fn main() {
let _crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
let target = env::var("TARGET").unwrap();
println!("cargo:rerun-if-changed=src/c");
let mut cc_builder = &mut cc::Build::new();
cc_builder = cc_builder.flag("-nostdinc").flag("-nostdlib");
if target.starts_with("aarch64") {
cc_builder = cc_builder.flag("-mno-outline-atomics")
}
cc_builder
.flag("-fno-stack-protector")
.flag("-Wno-expansion-to-defined")
.files(
fs::read_dir("src/c")
.expect("src/c directory missing")
.map(|res| res.expect("read_dir error").path()),
)
.compile("relibc_c");
println!("cargo:rustc-link-lib=static=relibc_c");
}
+25
View File
@@ -0,0 +1,25 @@
# needs a leading newline
[defines]
"target_os=redox" = "__redox__"
"target_os=linux" = "__linux__"
"target_pointer_width=64" = "__LP64__"
"target_pointer_width=32" = "__ILP32__"
"target_arch=x86" = "__i386__"
"target_arch=x86_64" = "__x86_64__"
"target_arch=aarch64" = "__aarch64__"
# This is not exact. It should be `defined(__riscv) && defined(__LP64__)`, or `defined(__riscv) && __riscv_xlen==64`
# This will do however, as long as we only support riscv64 and not riscv32
"target_arch=riscv64" = "__riscv"
# XXX: silences a warning
"feature = no_std" = "__relibc__"
"feature = ip6" = "__ip6__"
# Ensure attributes are passed down from Rust
# <features.h> must be included where attributes are used in relibc
[fn]
must_use = "__nodiscard"
deprecated = "__deprecated"
deprecated_with_note = "__deprecatedNote({})"
no_return = "__noreturn"
+73 -16
View File
@@ -8,10 +8,14 @@ show_help() {
echo "Usage: $(basename "$0") [OPTIONS]"
echo ""
echo "Description:"
echo " Wrapper for redoxer to run checks or tests on Redox OS targets."
echo " Wrapper for Makefile / Cargo to run checks or tests on Redox OS targets."
echo ""
echo "Options:"
echo " --test Run 'cargo test' instead of 'cargo check'"
echo " --test Run 'make test' instead of 'make all'"
echo " --test= Run single 'make test'"
echo " --cargo Run 'cargo check' / 'cargo test' instead"
echo " (note: cargo test is currently not maintained for relibc)"
echo " --host Run the command on host (linux) target"
echo " --all-target Run the command on all supported Redox architectures"
echo " --target=<target> Override the target architecture (e.g., i586-unknown-redox)"
echo " --arch=<arch> Override the target architecture using arch (e.g., i586)"
@@ -21,14 +25,15 @@ show_help() {
for t in "${SUPPORTED_TARGETS[@]}"; do
echo " - $t"
done
echo " - $(uname -m)-unknown-linux-gnu"
echo ""
echo "Environment:"
echo " TARGET Sets the default target (overridden by --target)"
}
if ! command -v redoxer &> /dev/null; then
echo "Error: 'redoxer' CLI not found."
echo "Please install it: cargo install redoxer"
if ! command -v cbindgen &> /dev/null; then
echo "Error: 'cbindgen' CLI not found."
echo "Please install it: cargo install cbindgen"
exit 1
fi
@@ -41,14 +46,35 @@ SUPPORTED_TARGETS=(
CURRENT_TARGET="${TARGET:-x86_64-unknown-redox}"
CHECK_ALL=false
CMD_ACTION="all"
CMD_ACTION="make"
CARGO_ACTION="check"
MAKE_ACTION="all"
TEST_BIN=""
IS_HOST=0
while [[ $# -gt 0 ]]; do
case "$1" in
--all-target)
CHECK_ALL=true
;;
--test)
CMD_ACTION="test"
MAKE_ACTION="test"
CARGO_ACTION="test"
;;
--test=*)
TEST_BIN="${1#*=}"
MAKE_ACTION="test-once"
;;
--cargo)
CMD_ACTION="cargo"
;;
--clippy)
CMD_ACTION="cargo"
CARGO_ACTION="clippy"
;;
--host)
CURRENT_TARGET="$(uname -m)-unknown-linux-gnu"
IS_HOST=1
;;
--target=*)
CURRENT_TARGET="${1#*=}"
@@ -69,32 +95,63 @@ while [[ $# -gt 0 ]]; do
shift
done
if [ "$IS_HOST" -eq 0 ]; then
if ! command -v redoxer &> /dev/null; then
echo "Error: 'redoxer' CLI not found."
echo "Please install it: cargo install redoxer"
exit 1
fi
fi
run_redoxer() {
export TARGET=$1
redoxer toolchain || { echo -e "${RED}Fail: redoxer toolchain for: $target.${NC}" && exit 1; }
REDOXER_ENV="redoxer env"
if [ "$IS_HOST" -eq 0 ]; then
redoxer toolchain || { echo -e "${RED}Fail: redoxer toolchain for: $target.${NC}" && exit 1; }
export CARGO_TEST="redoxer"
export TEST_RUNNER="redoxer exec --folder ../../sysroot/$TARGET/:/usr --folder . --"
MAKE_ACTION="$MAKE_ACTION IS_REDOX=1"
else
REDOXER_ENV=""
fi
if [ "$TEST_BIN" != "" ]; then
if [ "$IS_HOST" -eq 0 ]; then
MAKE_ACTION="$MAKE_ACTION TESTBIN=bins_dynamic/$TEST_BIN"
else
MAKE_ACTION="$MAKE_ACTION TESTBIN=bins_static/$TEST_BIN"
fi
fi
if [ "$CMD_ACTION" == "make" ]; then
CMD_OPT="-j $(nproc) $MAKE_ACTION"
else
CMD_OPT="$CARGO_ACTION --target=$TARGET"
fi
echo "----------------------------------------"
echo "Running make $CMD_ACTION for: $TARGET"
if make "$CMD_ACTION"; then
echo "Running $REDOXER_ENV $CMD_ACTION $CMD_OPT for: $TARGET"
if $REDOXER_ENV $CMD_ACTION $CMD_OPT; then
return 0
else
echo -e "${RED}Fail: $CMD_ACTION $TARGET failed.${NC}"
echo -e "${RED}Fail: $CMD_ACTION $CMD_OPT for $TARGET failed.${NC}"
return 1
fi
}
if [ "$CHECK_ALL" = true ]; then
echo "Running $CMD_ACTION for all supported Redox targets..."
has_error=false
for target in "${SUPPORTED_TARGETS[@]}"; do
if ! run_redoxer "$target"; then
has_error=true
fi
done
echo "----------------------------------------"
if [ "$has_error" = true ]; then
echo -e "${RED}Summary: One or more targets failed.${NC}"
@@ -105,7 +162,7 @@ if [ "$CHECK_ALL" = true ]; then
fi
else
if run_redoxer "$CURRENT_TARGET"; then
echo -e "${GREEN}Success: $CMD_ACTION $CURRENT_TARGET passed.${NC}"
echo -e "${GREEN}Success: $CARGO_ACTION for $CURRENT_TARGET passed.${NC}"
exit 0
else
exit 1
+94
View File
@@ -0,0 +1,94 @@
ifndef TARGET
export TARGET:=$(shell rustc -Z unstable-options --print target-spec-json | grep llvm-target | cut -d '"' -f4)
endif
ifeq ($(TARGET),aarch64-unknown-linux-gnu)
export CC=aarch64-linux-gnu-gcc
export LD=aarch64-linux-gnu-ld
export AR=aarch64-linux-gnu-ar
export NM=aarch64-linux-gnu-nm
export OBJCOPY=aarch64-linux-gnu-objcopy
export CPPFLAGS=
LD_SO_PATH=lib/ld.so.1
endif
ifeq ($(TARGET),aarch64-unknown-linux-relibc)
export CC=aarch64-linux-relibc-gcc
export LD=aarch64-linux-relibc-ld
export AR=aarch64-linux-relibc-ar
export NM=aarch64-linux-relibc-nm
export OBJCOPY=aarch64-linux-relibc-objcopy
export CPPFLAGS=
LD_SO_PATH=lib/ld.so.1
endif
ifeq ($(TARGET),aarch64-unknown-redox)
export CC=aarch64-unknown-redox-gcc
export LD=aarch64-unknown-redox-ld
export AR=aarch64-unknown-redox-ar
export NM=aarch64-unknown-redox-nm
export OBJCOPY=aarch64-unknown-redox-objcopy
export CPPFLAGS=
LD_SO_PATH=lib/ld.so.1
endif
ifeq ($(TARGET),i586-unknown-redox)
export CC=i586-unknown-redox-gcc
export LD=i586-unknown-redox-ld
export AR=i586-unknown-redox-ar
export NM=i586-unknown-redox-nm
export OBJCOPY=i586-unknown-redox-objcopy
export CPPFLAGS=
LD_SO_PATH=lib/libc.so.1
endif
ifeq ($(TARGET),i686-unknown-redox)
export CC=i686-unknown-redox-gcc
export LD=i686-unknown-redox-ld
export AR=i686-unknown-redox-ar
export NM=i686-unknown-redox-nm
export OBJCOPY=i686-unknown-redox-objcopy
export CPPFLAGS=
LD_SO_PATH=lib/libc.so.1
endif
ifeq ($(TARGET),x86_64-unknown-linux-gnu)
export CC=x86_64-linux-gnu-gcc
export LD=x86_64-linux-gnu-ld
export AR=x86_64-linux-gnu-ar
export NM=x86_64-linux-gnu-nm
export OBJCOPY=objcopy
export CPPFLAGS=
LD_SO_PATH=lib/ld64.so.1
endif
ifeq ($(TARGET),x86_64-unknown-linux-relibc)
export CC=x86_64-linux-relibc-gcc
export LD=x86_64-linux-relibc-ld
export AR=x86_64-linux-relibc-ar
export NM=x86_64-linux-relibc-nm
export OBJCOPY=x86_64-linux-relibc-objcopy
export CPPFLAGS=
LD_SO_PATH=lib/ld64.so.1
endif
ifeq ($(TARGET),x86_64-unknown-redox)
export CC=x86_64-unknown-redox-gcc
export LD=x86_64-unknown-redox-ld
export AR=x86_64-unknown-redox-ar
export NM=x86_64-unknown-redox-nm
export OBJCOPY=x86_64-unknown-redox-objcopy
export CPPFLAGS=
LD_SO_PATH=lib/ld64.so.1
endif
ifeq ($(TARGET),riscv64gc-unknown-redox)
export CC=riscv64-unknown-redox-gcc
export LD=riscv64-unknown-redox-ld
export AR=riscv64-unknown-redox-ar
export NM=riscv64-unknown-redox-nm
export OBJCOPY=riscv64-unknown-redox-objcopy
export CPPFLAGS=-march=rv64gc -mabi=lp64d
LD_SO_PATH=lib/ld.so.1
endif
-10
View File
@@ -1,10 +0,0 @@
[package]
name = "config"
description = "Configuration override library"
version = "0.0.0"
edition = "2024"
[dependencies]
[lints]
workspace = true
-40
View File
@@ -1,40 +0,0 @@
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
use std::{fs, io};
pub fn config(name: &str) -> Result<Vec<PathBuf>, io::Error> {
config_for_dirs(&[
&Path::new("/usr/lib").join(format!("{name}.d")),
&Path::new("/etc").join(format!("{name}.d")),
])
}
pub fn config_for_initfs(name: &str) -> Result<Vec<PathBuf>, io::Error> {
config_for_dirs(&[
&Path::new("/scheme/initfs/lib").join(format!("{name}.d")),
&Path::new("/scheme/initfs/etc").join(format!("{name}.d")),
])
}
pub fn config_for_dirs(dirs: &[impl AsRef<Path>]) -> Result<Vec<PathBuf>, io::Error> {
// This must be a BTreeMap to iterate in sorted order.
let mut entries = BTreeMap::new();
for dir in dirs {
let dir = dir.as_ref();
if !dir.exists() {
// Skip non-existent dirs
continue;
}
for entry_res in fs::read_dir(&dir)? {
// This intentionally overwrites older entries with
// the same filename to allow overriding entries in
// one search dir with those in a later search dir.
let entry = entry_res?;
entries.insert(entry.file_name(), entry.path());
}
}
Ok(entries.into_values().collect())
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "daemon"
description = "Redox daemon library"
version = "0.0.0"
edition = "2024"
[dependencies]
libc.workspace = true
libredox.workspace = true
redox-scheme.workspace = true
redox_syscall.workspace = true
[lints]
workspace = true
-139
View File
@@ -1,139 +0,0 @@
//! A library for creating and managing daemons for RedoxOS.
#![feature(never_type)]
use std::io::{self, PipeWriter, Read, Write};
use std::os::fd::{AsRawFd, FromRawFd, OwnedFd, RawFd};
use std::os::unix::process::CommandExt;
use std::process::Command;
use libredox::Fd;
use redox_scheme::Socket;
use redox_scheme::scheme::{SchemeAsync, SchemeSync};
unsafe fn get_fd(var: &str) -> RawFd {
let fd: RawFd = std::env::var(var).unwrap().parse().unwrap();
if unsafe { libc::fcntl(fd, libc::F_SETFD, libc::FD_CLOEXEC) } == -1 {
panic!(
"daemon: failed to set CLOEXEC flag for {var} fd: {}",
io::Error::last_os_error()
);
}
fd
}
unsafe fn pass_fd(cmd: &mut Command, env: &str, fd: OwnedFd) {
cmd.env(env, format!("{}", fd.as_raw_fd()));
unsafe {
cmd.pre_exec(move || {
// Pass notify pipe to child
if libc::fcntl(fd.as_raw_fd(), libc::F_SETFD, 0) == -1 {
Err(io::Error::last_os_error())
} else {
Ok(())
}
});
}
}
/// A long running background process that handles requests.
#[must_use = "Daemon::ready must be called"]
pub struct Daemon {
write_pipe: PipeWriter,
}
impl Daemon {
/// Create a new daemon.
pub fn new(f: impl FnOnce(Daemon) -> !) -> ! {
let write_pipe = unsafe { io::PipeWriter::from_raw_fd(get_fd("INIT_NOTIFY")) };
f(Daemon { write_pipe })
}
/// Notify the process that the daemon is ready to accept requests.
///
/// BrokenPipe is tolerated: init may have already closed its read end
/// during the startup phase. The daemon is operational regardless of
/// init's readiness tracking state.
pub fn ready(mut self) {
match self.write_pipe.write_all(&[0]) {
Ok(()) => {}
Err(err) if err.kind() == io::ErrorKind::BrokenPipe => {}
Err(err) => {
eprintln!("daemon: failed to notify init of readiness: {err}");
}
}
}
/// Executes `Command` as a child process.
// FIXME remove once the service spawning of hwd and pcid-spawner is moved to init
#[deprecated]
pub fn spawn(mut cmd: Command) {
let (mut read_pipe, write_pipe) = io::pipe().unwrap();
unsafe { pass_fd(&mut cmd, "INIT_NOTIFY", write_pipe.into()) };
if let Err(err) = cmd.spawn() {
eprintln!("daemon: failed to execute {cmd:?}: {err}");
return;
}
let mut data = [0];
match read_pipe.read_exact(&mut data) {
Ok(()) => {}
Err(err) if err.kind() == io::ErrorKind::UnexpectedEof => {
eprintln!("daemon: {cmd:?} exited without notifying readiness");
}
Err(err) => {
eprintln!("daemon: failed to wait for {cmd:?}: {err}");
}
}
}
}
/// A long running background process that handles requests using schemes.
#[must_use = "SchemeDaemon::ready must be called"]
pub struct SchemeDaemon {
write_pipe: PipeWriter,
}
impl SchemeDaemon {
/// Create a new daemon for use with schemes.
pub fn new(f: impl FnOnce(SchemeDaemon) -> !) -> ! {
let write_pipe = unsafe { io::PipeWriter::from_raw_fd(get_fd("INIT_NOTIFY")) };
f(SchemeDaemon { write_pipe })
}
/// Notify the process that the scheme daemon is ready to accept requests.
pub fn ready_with_fd(self, cap_fd: Fd) -> syscall::Result<()> {
syscall::call_wo(
self.write_pipe.as_raw_fd() as usize,
&cap_fd.into_raw().to_ne_bytes(),
syscall::CallFlags::FD,
&[],
)?;
Ok(())
}
/// Notify the process that the synchronous scheme daemon is ready to accept requests.
pub fn ready_sync_scheme<S: SchemeSync>(
self,
socket: &Socket,
scheme: &mut S,
) -> syscall::Result<()> {
let cap_id = scheme.scheme_root()?;
let cap_fd = socket.create_this_scheme_fd(0, cap_id, 0, 0)?;
self.ready_with_fd(Fd::new(cap_fd))
}
/// Notify the process that the asynchronous scheme daemon is ready to accept requests.
pub fn ready_async_scheme<S: SchemeAsync>(
self,
socket: &Socket,
scheme: &mut S,
) -> syscall::Result<()> {
let cap_id = scheme.scheme_root()?;
let cap_fd = socket.create_this_scheme_fd(0, cap_id, 0, 0)?;
self.ready_with_fd(Fd::new(cap_fd))
}
}
-37
View File
@@ -1,37 +0,0 @@
#[repr(C, packed)]
pub struct Dhcp {
pub op: u8,
pub htype: u8,
pub hlen: u8,
pub hops: u8,
pub tid: u32,
pub secs: u16,
pub flags: u16,
pub ciaddr: [u8; 4],
pub yiaddr: [u8; 4],
pub siaddr: [u8; 4],
pub giaddr: [u8; 4],
pub chaddr: [u8; 16],
pub sname: [u8; 64],
pub file: [u8; 128],
pub magic: u32,
pub options: [u8; 308],
}
pub const DHCPDISCOVER: u8 = 1;
pub const DHCPOFFER: u8 = 2;
pub const DHCPREQUEST: u8 = 3;
pub const DHCPDECLINE: u8 = 4;
pub const DHCPACK: u8 = 5;
pub const DHCPNAK: u8 = 6;
pub const DHCPRELEASE: u8 = 7;
pub const OPT_SUBNET_MASK: u8 = 1;
pub const OPT_ROUTER: u8 = 3;
pub const OPT_DNS: u8 = 6;
pub const OPT_REQUESTED_IP: u8 = 50;
pub const OPT_LEASE_TIME: u8 = 51;
pub const OPT_MESSAGE_TYPE: u8 = 53;
pub const OPT_SERVER_ID: u8 = 54;
pub const OPT_PARAM_REQUEST: u8 = 55;
pub const OPT_END: u8 = 255;
-376
View File
@@ -1,376 +0,0 @@
use std::fs::{File, OpenOptions};
use std::io::{Read, Write};
use std::net::{SocketAddr, UdpSocket};
use std::time::Duration;
use std::{env, process, time};
use dhcp::{
Dhcp, DHCPACK, DHCPDISCOVER, DHCPNAK, DHCPOFFER, DHCPREQUEST, DHCPRELEASE,
OPT_DNS, OPT_LEASE_TIME, OPT_MESSAGE_TYPE, OPT_REQUESTED_IP, OPT_ROUTER,
OPT_SERVER_ID, OPT_SUBNET_MASK, OPT_END,
};
mod dhcp;
macro_rules! try_fmt {
($e:expr, $m:expr) => {
match $e {
Ok(ok) => ok,
Err(err) => return Err(format!("{}: {}", $m, err)),
}
};
}
fn get_cfg_value(path: &str) -> Result<String, String> {
let path = format!("/scheme/netcfg/{path}");
let mut file = File::open(&path).map_err(|_| format!("Can't open {path}"))?;
let mut result = String::new();
file.read_to_string(&mut result)
.map_err(|_| format!("Can't read {path}"))?;
Ok(result)
}
fn get_iface_cfg_value(iface: &str, cfg: &str) -> Result<String, String> {
let path = format!("ifaces/{iface}/{cfg}");
get_cfg_value(&path)
}
fn set_cfg_value(path: &str, value: &str) -> Result<(), String> {
let path = format!("/scheme/netcfg/{path}");
let mut file = OpenOptions::new()
.read(false)
.write(true)
.create(false)
.open(&path)
.map_err(|_| format!("Can't open {path}"))?;
file.write(value.as_bytes())
.map(|_| ())
.map_err(|_| format!("Can't write {value} to {path}"))?;
file.sync_data()
.map_err(|_| format!("Can't commit {value} to {path}"))
}
fn set_iface_cfg_value(iface: &str, cfg: &str, value: &str) -> Result<(), String> {
let path = format!("ifaces/{iface}/{cfg}");
set_cfg_value(&path, value)
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Default)]
struct MacAddr {
bytes: [u8; 6],
}
impl MacAddr {
fn from_str(string: &str) -> Self {
MacAddr::try_parse_with_delimeter(string, ':')
.or_else(|| MacAddr::try_parse_with_delimeter(string, '-'))
.unwrap_or_default()
}
fn try_parse_with_delimeter(string: &str, delimeter: char) -> Option<MacAddr> {
let mut addr = MacAddr::default();
let mut segments = 0;
for part in string.split(delimeter) {
if segments >= addr.bytes.len() {
return None;
}
addr.bytes[segments] = match u8::from_str_radix(part, 16) {
Ok(b) => b,
_ => return None,
};
segments += 1;
}
if segments == addr.bytes.len() {
Some(addr)
} else {
None
}
}
fn to_string(&self) -> String {
format!(
"{:>02X}-{:>02X}-{:>02X}-{:>02X}-{:>02X}-{:>02X}",
self.bytes[0],
self.bytes[1],
self.bytes[2],
self.bytes[3],
self.bytes[4],
self.bytes[5]
)
}
}
fn dhcp(iface: &str, verbose: bool) -> Result<(), String> {
let current_mac = MacAddr::from_str(get_iface_cfg_value(iface, "mac")?.trim());
let _current_ip = get_iface_cfg_value(iface, "addr/list")?
.lines()
.next()
.map(|l| l.to_owned())
.unwrap_or("0.0.0.0".to_string());
if verbose {
println!("DHCP: MAC: {} Starting", current_mac.to_string());
}
let tid = try_fmt!(
time::SystemTime::now().duration_since(time::UNIX_EPOCH),
"failed to get time"
).subsec_nanos();
let socket = try_fmt!(UdpSocket::bind(("0.0.0.0", 68)), "failed to bind udp");
try_fmt!(socket.connect(SocketAddr::from(([255, 255, 255, 255], 67))), "failed to connect");
try_fmt!(socket.set_read_timeout(Some(Duration::new(30, 0))), "failed to set read timeout");
try_fmt!(socket.set_write_timeout(Some(Duration::new(30, 0))), "failed to set write timeout");
let mut subnet_option: Option<[u8; 4]> = None;
let mut router_option: Option<[u8; 4]> = None;
let mut dns_option: Option<[u8; 4]> = None;
let mut server_id_option: Option<[u8; 4]> = None;
let mut lease_time_secs: u32 = 86400;
// DHCPDISCOVER
{
let mut discover = Dhcp::default();
init_dhcp_header(&mut discover, current_mac, tid);
let disc_opts: &[u8] = &[OPT_MESSAGE_TYPE, 1, DHCPDISCOVER, OPT_END];
discover.options[..disc_opts.len()].copy_from_slice(disc_opts);
try_fmt!(send_dhcp(&discover, &socket), "failed to send discover");
if verbose { println!("DHCP: Sent Discover"); }
}
// Recv DHCPOFFER
let mut offer_data = [0; 65536];
try_fmt!(socket.recv(&mut offer_data), "failed to receive offer");
let offer = unsafe { &*(offer_data.as_ptr() as *const Dhcp) };
if verbose { println!("DHCP: Offer IP: {:?}", offer.yiaddr); }
parse_options(&offer.options, &mut |code, data| {
match code {
OPT_SUBNET_MASK if data.len() == 4 && subnet_option.is_none() => {
subnet_option = Some([data[0], data[1], data[2], data[3]]);
}
OPT_ROUTER if data.len() == 4 && router_option.is_none() => {
router_option = Some([data[0], data[1], data[2], data[3]]);
}
OPT_DNS if data.len() == 4 && dns_option.is_none() => {
dns_option = Some([data[0], data[1], data[2], data[3]]);
}
OPT_LEASE_TIME if data.len() == 4 => {
lease_time_secs = u32::from_be_bytes([data[0], data[1], data[2], data[3]]);
}
OPT_SERVER_ID if data.len() == 4 && server_id_option.is_none() => {
server_id_option = Some([data[0], data[1], data[2], data[3]]);
}
_ => {}
}
});
let mask_len = compute_prefix_len(subnet_option);
let new_ips = format!(
"{}.{}.{}.{}/{}\n",
offer.yiaddr[0], offer.yiaddr[1], offer.yiaddr[2], offer.yiaddr[3], mask_len
);
try_fmt!(set_iface_cfg_value(iface, "addr/set", &new_ips), "failed to set ip");
apply_dhcp_config(iface, router_option, dns_option, verbose)?;
let server_id = server_id_option.unwrap_or([0, 0, 0, 0]);
// DHCPREQUEST
{
let mut request = Dhcp::default();
init_dhcp_header(&mut request, current_mac, tid);
let req_opts: &[u8] = &[
OPT_MESSAGE_TYPE, 1, DHCPREQUEST,
OPT_REQUESTED_IP, 4,
offer.yiaddr[0], offer.yiaddr[1], offer.yiaddr[2], offer.yiaddr[3],
OPT_SERVER_ID, 4, server_id[0], server_id[1], server_id[2], server_id[3],
OPT_END,
];
request.options[..req_opts.len()].copy_from_slice(req_opts);
try_fmt!(send_dhcp(&request, &socket), "failed to send request");
if verbose { println!("DHCP: Sent Request"); }
}
// Recv DHCPACK
let mut ack_data = [0; 65536];
try_fmt!(socket.recv(&mut ack_data), "failed to receive ack");
if verbose { println!("DHCP: lease acquired, {}s lease time", lease_time_secs); }
// RFC 2131 lease lifecycle: RENEW at T1, REBIND at T2
let t1 = Duration::from_secs(lease_time_secs as u64 / 2);
let t2 = Duration::from_secs((lease_time_secs as u64 * 7) / 8);
let now = time::Instant::now();
let t1_deadline = now + t1;
let mut remaining = t1_deadline.saturating_duration_since(time::Instant::now());
while remaining > Duration::ZERO {
std::thread::sleep(std::cmp::min(remaining, Duration::from_secs(60)));
remaining = t1_deadline.saturating_duration_since(time::Instant::now());
}
if verbose { println!("DHCP: entering RENEW state"); }
{
let mut renew = Dhcp::default();
init_dhcp_header(&mut renew, current_mac, tid.wrapping_add(1));
renew.ciaddr = offer.yiaddr;
let rn_opts: &[u8] = &[OPT_MESSAGE_TYPE, 1, DHCPREQUEST, OPT_END];
renew.options[..rn_opts.len()].copy_from_slice(rn_opts);
try_fmt!(send_dhcp(&renew, &socket), "failed to send renew");
}
socket.set_read_timeout(Some(t2.saturating_sub(t1))).ok();
match socket.recv(&mut ack_data) {
Ok(_) => {
let response = unsafe { &*(ack_data.as_ptr() as *const Dhcp) };
match get_message_type(&response.options) {
Some(DHCPACK) => { if verbose { println!("DHCP: renewed"); } }
Some(DHCPNAK) => {
if verbose { println!("DHCP: NAK, restarting"); }
return dhcp(iface, verbose);
}
_ => {}
}
}
Err(_) => {
if verbose { println!("DHCP: entering REBIND state"); }
let bind_socket = try_fmt!(UdpSocket::bind(("0.0.0.0", 68)), "failed to bind rebind");
try_fmt!(bind_socket.connect(SocketAddr::from(([255, 255, 255, 255], 67))), "rebind connect");
let mut rebind = Dhcp::default();
init_dhcp_header(&mut rebind, current_mac, tid.wrapping_add(2));
rebind.ciaddr = offer.yiaddr;
let rb_opts: &[u8] = &[OPT_MESSAGE_TYPE, 1, DHCPREQUEST, OPT_END];
rebind.options[..rb_opts.len()].copy_from_slice(rb_opts);
let _ = send_dhcp(&rebind, &bind_socket);
bind_socket.set_read_timeout(Some(Duration::from_secs(10))).ok();
if let Ok(_) = bind_socket.recv(&mut ack_data) {
if verbose { println!("DHCP: rebound"); }
} else {
if verbose { println!("DHCP: lease expired, restarting"); }
return dhcp(iface, verbose);
}
}
}
Ok(())
}
fn apply_dhcp_config(
iface: &str,
router: Option<[u8; 4]>,
dns: Option<[u8; 4]>,
verbose: bool,
) -> Result<(), String> {
if let Some(router) = router {
let route = format!("default via {}.{}.{}.{}", router[0], router[1], router[2], router[3]);
try_fmt!(set_cfg_value("route/add", &route), "failed to set route");
}
if let Some(mut dns) = dns {
if dns[0] == 127 {
dns = [9, 9, 9, 9];
if verbose { println!("DHCP: replaced loopback DNS with Quad9"); }
}
let ns = format!("{}.{}.{}.{}", dns[0], dns[1], dns[2], dns[3]);
try_fmt!(set_cfg_value("resolv/nameserver", &ns), "failed to set DNS");
}
Ok(())
}
fn compute_prefix_len(subnet: Option<[u8; 4]>) -> u32 {
let Some(subnet) = subnet else { return 24 };
let inverted: u32 = !u32::from_be_bytes(subnet);
inverted.leading_zeros()
}
fn parse_options(options: &[u8], cb: &mut dyn FnMut(u8, &[u8])) {
let mut i = 0;
while i < options.len() {
let code = options[i];
if code == 0 { i += 1; continue; }
if code == OPT_END { break; }
i += 1;
if i >= options.len() { break; }
let len = options[i] as usize;
i += 1;
if i + len > options.len() { break; }
cb(code, &options[i..i + len]);
i += len;
}
}
fn get_message_type(options: &[u8]) -> Option<u8> {
let mut msg_type = None;
parse_options(options, &mut |code, data| {
if code == OPT_MESSAGE_TYPE && data.len() == 1 {
msg_type = Some(data[0]);
}
});
msg_type
}
fn init_dhcp_header(pkt: &mut Dhcp, mac: MacAddr, tid: u32) {
*pkt = Dhcp::default();
pkt.op = 1;
pkt.htype = 1;
pkt.hlen = 6;
pkt.tid = tid;
pkt.flags = 0x8000u16.to_be();
pkt.chaddr[..6].copy_from_slice(&mac.bytes);
pkt.magic = 0x63825363u32.to_be();
}
fn send_dhcp(pkt: &Dhcp, socket: &UdpSocket) -> Result<(), String> {
let data = unsafe {
std::slice::from_raw_parts(pkt as *const Dhcp as *const u8, std::mem::size_of::<Dhcp>())
};
socket.send(data).map(|_| ()).map_err(|e| format!("send: {}", e))
}
impl Default for Dhcp {
fn default() -> Self {
Dhcp {
op: 0, htype: 0, hlen: 0, hops: 0, tid: 0, secs: 0, flags: 0,
ciaddr: [0; 4], yiaddr: [0; 4], siaddr: [0; 4], giaddr: [0; 4],
chaddr: [0; 16], sname: [0; 64], file: [0; 128], magic: 0,
options: [0; 308],
}
}
}
fn main() {
let mut verbose = false;
let iface = "eth0";
for arg in env::args().skip(1) {
match arg.as_ref() {
"-v" => verbose = true,
_ => (),
}
}
if let Err(err) = dhcp(iface, verbose) {
eprintln!("dhcpd: {err}");
process::exit(1);
}
}
#[cfg(test)]
mod test {
use super::MacAddr;
#[test]
fn from_str_test() {
let mac = MacAddr { bytes: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab] };
let empty_mac = MacAddr::default();
assert_eq!(mac, MacAddr::from_str("01:23:45:67:89:ab"));
assert_eq!(mac, MacAddr::from_str("1:23:45:67:89:ab"));
assert_eq!(mac, MacAddr::from_str("01:23:45:67:89:AB"));
assert_eq!(mac, MacAddr::from_str("01-23-45-67-89-ab"));
assert_eq!(empty_mac, MacAddr::from_str(""));
assert_eq!(empty_mac, MacAddr::from_str("01:23:45:67:89"));
assert_eq!(empty_mac, MacAddr::from_str("01:23:45:67:89:ab:cd"));
assert_eq!(empty_mac, MacAddr::from_str("x1:23:45:67:89:ab"));
assert_eq!(mac, MacAddr::from_str(&mac.to_string()));
}
}
-4
View File
@@ -1,4 +0,0 @@
[package]
name = "dhcpv6d"
version = "0.1.0"
edition = "2021"
-286
View File
@@ -1,286 +0,0 @@
//! dhcpv6d — DHCPv6 client daemon for Red Bear OS.
//!
//! Mirrors Linux 7.1's systemd-networkd `sd-dhcp6-client.c`.
//! Implements RFC 8415 state machine:
//! SOLICIT → ADVERTISE → REQUEST → REPLY
//!
//! Reference:
//! - `sd-dhcp6-client.c` — DHCPv6 client state machine
//! - RFC 8415 §17 — client behavior
//! - RFC 3315 — original DHCPv6 specification
use std::fs::{self, File, OpenOptions};
use std::io::{Read, Write};
use std::net::{SocketAddr, UdpSocket};
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use std::{env, process, time};
const DHCPV6_CLIENT_PORT: u16 = 546;
const DHCPV6_SERVER_PORT: u16 = 547;
const MULTICAST_ADDR: &str = "ff02::1:2";
const SOLICIT: u8 = 1;
const ADVERTISE: u8 = 2;
const REQUEST: u8 = 3;
const REPLY: u8 = 7;
const RELEASE: u8 = 8;
const INFO_REQUEST: u8 = 11;
const OPT_CLIENTID: u16 = 1;
const OPT_SERVERID: u16 = 2;
const OPT_IA_NA: u16 = 3;
const OPT_IAADDR: u16 = 5;
const OPT_ORO: u16 = 6;
const OPT_DNS: u16 = 23;
const OPT_DOMAIN: u16 = 24;
macro_rules! try_fmt {
($e:expr, $m:expr) => {
match $e {
Ok(ok) => ok,
Err(err) => return Err(format!("{}: {}", $m, err)),
}
};
}
fn set_cfg(path: &str, value: &str) -> Result<(), String> {
let full = format!("/scheme/netcfg/{path}");
let mut f = OpenOptions::new().write(true).create(false).open(&full)
.map_err(|_| format!("open {}", full))?;
f.write_all(value.as_bytes()).map_err(|_| format!("write {}", full))?;
f.sync_data().map_err(|_| "sync failed".into())
}
fn get_mac() -> Result<[u8; 6], String> {
let s = fs::read_to_string("/scheme/netcfg/ifaces/eth0/mac")
.map_err(|e| format!("read mac: {}", e))?;
let mut bytes = [0u8; 6];
for (i, part) in s.trim().split(&[':', '-'][..]).take(6).enumerate() {
bytes[i] = u8::from_str_radix(part, 16).map_err(|_| "bad mac".to_string())?;
}
Ok(bytes)
}
fn build_duid(mac: [u8; 6]) -> Vec<u8> {
let time = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap_or_default()
.as_secs() as u32;
let mut duid = vec![0u8; 14];
duid[0..2].copy_from_slice(&[0x00, 0x01]);
duid[2..4].copy_from_slice(&[0x00, 0x01]);
duid[4..8].copy_from_slice(&time.to_be_bytes());
duid[8..14].copy_from_slice(&mac);
duid
}
fn put_u16(buf: &mut Vec<u8>, val: u16) {
buf.extend_from_slice(&val.to_be_bytes());
}
fn put_u32(buf: &mut Vec<u8>, val: u32) {
buf.extend_from_slice(&val.to_be_bytes());
}
fn put_option(buf: &mut Vec<u8>, code: u16, data: &[u8]) {
put_u16(buf, code);
put_u16(buf, data.len() as u16);
buf.extend_from_slice(data);
}
struct Dhcp6Packet {
data: Vec<u8>,
}
impl Dhcp6Packet {
fn new(msg_type: u8, tid: [u8; 3], duid: &[u8]) -> Self {
let mut data = vec![msg_type];
data.extend_from_slice(&tid);
put_option(&mut data, OPT_CLIENTID, duid);
put_option(&mut data, OPT_ORO, &[0, OPT_DNS as u8, 0, OPT_DOMAIN as u8]);
Dhcp6Packet { data }
}
fn add_ia_na(&mut self, iaid: u32, t1: u32, t2: u32) {
let mut ia = Vec::new();
put_u32(&mut ia, iaid);
put_u32(&mut ia, t1);
put_u32(&mut ia, t2);
put_option(&mut self.data, OPT_IA_NA, &ia);
}
}
struct Dhcp6Reply {
msg_type: u8,
server_id: Option<Vec<u8>>,
addresses: Vec<([u8; 16], u32, u32)>,
dns_servers: Vec<[u8; 16]>,
domains: Vec<String>,
}
fn parse_reply(data: &[u8]) -> Result<Dhcp6Reply, String> {
if data.len() < 4 {
return Err("packet too short".into());
}
let msg_type = data[0];
let mut reply = Dhcp6Reply {
msg_type,
server_id: None,
addresses: Vec::new(),
dns_servers: Vec::new(),
domains: Vec::new(),
};
let mut pos = 4;
while pos + 4 <= data.len() {
let code = u16::from_be_bytes([data[pos], data[pos + 1]]);
let len = u16::from_be_bytes([data[pos + 2], data[pos + 3]]) as usize;
pos += 4;
if pos + len > data.len() {
break;
}
let opt_data = &data[pos..pos + len];
match code {
OPT_SERVERID => reply.server_id = Some(opt_data.to_vec()),
OPT_DNS => {
for chunk in opt_data.chunks(16) {
if chunk.len() == 16 {
let mut addr = [0u8; 16];
addr.copy_from_slice(chunk);
reply.dns_servers.push(addr);
}
}
}
OPT_IA_NA => {
if opt_data.len() >= 12 {
let t1 = u32::from_be_bytes([opt_data[4], opt_data[5], opt_data[6], opt_data[7]]);
let t2 = u32::from_be_bytes([opt_data[8], opt_data[9], opt_data[10], opt_data[11]]);
let mut inner = &opt_data[12..];
while inner.len() >= 4 {
let inner_code = u16::from_be_bytes([inner[0], inner[1]]);
let inner_len = u16::from_be_bytes([inner[2], inner[3]]) as usize;
inner = &inner[4..];
if inner.len() < inner_len { break; }
if inner_code == OPT_IAADDR && inner_len >= 24 {
let mut addr = [0u8; 16];
addr.copy_from_slice(&inner[..16]);
let pref = u32::from_be_bytes([inner[16], inner[17], inner[18], inner[19]]);
let valid = u32::from_be_bytes([inner[20], inner[21], inner[22], inner[23]]);
reply.addresses.push((addr, pref, valid));
}
inner = &inner[inner_len..];
}
}
}
_ => {}
}
pos += len;
}
Ok(reply)
}
fn main() {
let mut verbose = false;
for arg in env::args().skip(1) {
if arg == "-v" || arg == "--verbose" { verbose = true; }
}
if let Err(e) = run(verbose) {
eprintln!("dhcpv6d: {}", e);
process::exit(1);
}
}
fn run(verbose: bool) -> Result<(), String> {
let mac = get_mac()?;
let duid = build_duid(mac);
if verbose {
println!("dhcpv6d: DUID {:02x?}", duid);
}
let socket = try_fmt!(
UdpSocket::bind((MULTICAST_ADDR, DHCPV6_CLIENT_PORT)),
"bind"
);
try_fmt!(
socket.connect(SocketAddr::new(
MULTICAST_ADDR.parse().map_err(|_| "bad addr")?,
DHCPV6_SERVER_PORT,
)),
"connect"
);
try_fmt!(socket.set_read_timeout(Some(Duration::from_secs(5))), "timeout");
let tid = [
(mac[0] ^ mac[1]) as u8,
(mac[2] ^ mac[3]) as u8,
(mac[4] ^ mac[5]) as u8,
];
// SOLICIT
let mut solicit = Dhcp6Packet::new(SOLICIT, tid, &duid);
solicit.add_ia_na(1, 0, 0);
try_fmt!(socket.send(&solicit.data), "send solicit");
if verbose { println!("dhcpv6d: sent SOLICIT"); }
// Recv ADVERTISE
let mut buf = [0u8; 65536];
let n = try_fmt!(socket.recv(&mut buf), "recv advertise");
let adv = parse_reply(&buf[..n])?;
if verbose {
println!("dhcpv6d: received ADVERTISE, {} addresses", adv.addresses.len());
}
// REQUEST
let mut request = Dhcp6Packet::new(REQUEST, tid, &duid);
if let Some(ref sid) = adv.server_id {
put_option(&mut request.data, OPT_SERVERID, sid);
}
request.add_ia_na(1, 0, 0);
try_fmt!(socket.send(&request.data), "send request");
if verbose { println!("dhcpv6d: sent REQUEST"); }
// Recv REPLY
let n = try_fmt!(socket.recv(&mut buf), "recv reply");
let reply = parse_reply(&buf[..n])?;
if verbose {
println!("dhcpv6d: received REPLY, {} addresses", reply.addresses.len());
}
for (addr, pref, valid) in &reply.addresses {
let addr_str = format!(
"{:04x}:{:04x}:{:04x}:{:04x}:{:04x}:{:04x}:{:04x}:{:04x}",
u16::from_be_bytes([addr[0], addr[1]]),
u16::from_be_bytes([addr[2], addr[3]]),
u16::from_be_bytes([addr[4], addr[5]]),
u16::from_be_bytes([addr[6], addr[7]]),
u16::from_be_bytes([addr[8], addr[9]]),
u16::from_be_bytes([addr[10], addr[11]]),
u16::from_be_bytes([addr[12], addr[13]]),
u16::from_be_bytes([addr[14], addr[15]]),
);
let cidr = format!("{}/128\n", addr_str);
try_fmt!(set_cfg("ifaces/eth0/addr/set", &cidr), "set addr");
if verbose {
println!("dhcpv6d: configured {} (pref={}s valid={}s)", addr_str, pref, valid);
}
}
for dns in &reply.dns_servers {
let dns_str = format!(
"{:04x}:{:04x}:{:04x}:{:04x}:{:04x}:{:04x}:{:04x}:{:04x}",
u16::from_be_bytes([dns[0], dns[1]]),
u16::from_be_bytes([dns[2], dns[3]]),
u16::from_be_bytes([dns[4], dns[5]]),
u16::from_be_bytes([dns[6], dns[7]]),
u16::from_be_bytes([dns[8], dns[9]]),
u16::from_be_bytes([dns[10], dns[11]]),
u16::from_be_bytes([dns[12], dns[13]]),
u16::from_be_bytes([dns[14], dns[15]]),
);
try_fmt!(set_cfg("resolv/nameserver6", &dns_str), "set DNS");
if verbose { println!("dhcpv6d: DNS6 {}", dns_str); }
}
Ok(())
}
Submodule
+1
Submodule dlmalloc-rs added at 3b0ee3b467
-63
View File
@@ -1,63 +0,0 @@
# Community Hardware
This document tracks the devices from developers or community that need a driver.
This document was created because unfortunately we can't know the most sold device models of the world to measure our device porting priority, thus we will use our community data to measure our device priorities, if you find a "device model users" survey (similar to [Debian Popularity Contest](https://popcon.debian.org/) and [Steam Hardware/Software Survey](https://store.steampowered.com/hwsurvey/Steam-Hardware-Software-Survey-Welcome-to-Steam)), please comment.
If you want to contribute to this table, install [pciutils](https://mj.ucw.cz/sw/pciutils/) on your Linux or Unix-like distribution (it may have a package on your distribution), run the `lspci -v` command to see your hardware devices, their kernel drivers and give the results of these items on each device:
- The first field (each device has an unique name for this item)
- Kernel driver
- Kernel module
If you are unsure of what to do, you can talk with us on the [chat](https://doc.redox-os.org/book/chat.html).
## Template
You will use this template to insert your devices on the table.
```
| | | | No |
```
- Remove the `#` characters in the port numbers to avoid GitLab issues to be wrongly mentioned
## Devices
| **Device model** | **Kernel driver?** | **Kernel module?** | **There's a Redox driver?** |
|------------------|--------------------|--------------------|-----------------------------|
| Realtek RTL8821CE 802.11ac (Wi-Fi) | rtw_8821ce | rtw88_8821ce | No |
| Intel Ice Lake-LP SPI Controller | intel-spi | spi_intel_pci | No |
| Intel Ice Lake-LP SMBus Controller | i801_smbus | i2c_i801 | No |
| Intel Ice Lake-LP Smart Sound Technology Audio Controller | snd_hda_intel | snd_hda_intel, snd_sof_pci_intel_icl | No |
| Intel Ice Lake-LP Serial IO SPI Controller | intel-lpss | No | No |
| Intel Ice Lake-LP Serial IO UART Controller | intel-lpss | No | No |
| Intel Ice Lake-LP Serial IO I2C Controller | intel-lpss | No | No |
| Ice Lake-LP USB 3.1 xHCI Host Controller | xhci_hcd | No | No |
| Intel Processor Power and Thermal Controller | proc_thermal | processor_thermal_device_pci_legacy | No |
| Intel Device 8a02 | icl_uncore | No | No |
| Iris Plus Graphics G1 (Ice Lake) | i915 | i915 | No |
| Intel Corporation Raptor Lake-P 6p+8e cores Host Bridge/DRAM Controller | No | No | No |
| Intel Corporation Raptor Lake PCI Express 5.0 Graphics Port (PEG010) (prog-if 00 [Normal decode]) | pcieport | No | No |
| Intel Corporation Raptor Lake-P [UHD Graphics] (rev 04) (prog-if 00 [VGA controller]) | i915 | i915 | No |
| Intel Corporation Raptor Lake Dynamic Platform and Thermal Framework Processor Participant | proc_thermal_pci | processor_thermal_device_pci | No |
| Intel Corporation Raptor Lake PCIe 4.0 Graphics Port (prog-if 00 [Normal decode]) | pcieport | No | No |
| Intel Corporation Raptor Lake-P Thunderbolt 4 PCI Express Root Port 0 (prog-if 00 [Normal decode]) | pcieport | No | No |
| Intel Corporation GNA Scoring Accelerator module | No | No | No |
| Intel Corporation Raptor Lake-P Thunderbolt 4 USB Controller (prog-if 30 [XHCI]) | xhci_hcd | xhci_pci | No |
| Intel Corporation Raptor Lake-P Thunderbolt 4 NHI 0 (prog-if 40 [USB4 Host Interface]) | thunderbolt | thunderbolt | No |
| Intel Corporation Raptor Lake-P Thunderbolt 4 NHI 1 (prog-if 40 [USB4 Host Interface]) | thunderbolt | thunderbolt | No |
| Intel Corporation Alder Lake PCH USB 3.2 xHCI Host Controller (rev 01) (prog-if 30 [XHCI]) | xhci_hcd | xhci_pci | No |
| Intel Corporation Alder Lake PCH Shared SRAM (rev 01) | No | No | No |
| Intel Corporation Raptor Lake PCH CNVi WiFi (rev 01) | iwlwifi | iwlwifi | No |
| Intel Corporation Alder Lake PCH Serial IO I2C Controller #0 (rev 01) | intel-lpss | intel_lpss_pci | No |
| Intel Corporation Alder Lake PCH HECI Controller (rev 01) | mei_me | mei_me | No |
| Intel Corporation Device 51b8 (rev 01) (prog-if 00 [Normal decode]) | pcieport | No | No |
| Intel Corporation Alder Lake-P PCH PCIe Root Port 6 (rev 01) (prog-if 00 [Normal decode]) | pcieport | No | No |
| Intel Corporation Raptor Lake LPC/eSPI Controller (rev 01) | No | No | No |
| Intel Corporation Raptor Lake-P/U/H cAVS (rev 01) (prog-if 80) | sof-audio-pci-intel-tgl | snd_hda_intel, snd_sof_pci_intel_tgl | No |
| Intel Corporation Alder Lake PCH-P SMBus Host Controller | i801_smbus | i2c_i801 | No |
| Intel Corporation Alder Lake-P PCH SPI Controller (rev 01) | intel-spi | spi_intel_pci | No |
| NVIDIA Corporation GA107GLM [RTX A1000 6GB Laptop GPU] (rev a1) | nvidia | nouveau, nvidia_drm, nvidia | No |
| SK hynix Platinum P41/PC801 NVMe Solid State Drive (prog-if 02 [NVM Express]) | nvme | nvme | No |
| Realtek Semiconductor Co., Ltd. RTS5261 PCI Express Card Reader (rev 01) | rtsx_pci | rtsx_pci | No |
-160
View File
@@ -1,160 +0,0 @@
# Drivers
- [Libraries](#libraries)
- [Services](#services)
- [Hardware Interfaces](#hardware-interfaces)
- [Devices](#devices)
- [CPU](#cpu)
- [Controllers](#controllers)
- [Storage](#storage)
- [Graphics](#graphics)
- [Input](#input)
- [Sound](#sound)
- [Networking](#networking)
- [Virtualization](#virtualization)
- [System Interfaces](#system-interfaces)
- [System Calls](#system-calls)
- [Schemes](#schemes)
- [Contribution Details](#contribution-details)
## Libraries
- amlserde - Library to provide serialization/deserialization of the AML symbol table from ACPI
- common - Library with shared driver code
- executor - Library to run Rust futures and integrate the executor in an interrupt+queue model without a separated reactor thread
- [graphics/console-draw](graphics/console-draw/) - Library with shared terminal drawing code
- [graphics/driver-graphics](graphics/driver-graphics/) - Library with shared graphics code
- [graphics/graphics-ipc](graphics/graphics-ipc/) - Library with graphics IPC shared code
- [net/driver-network](net/driver-network/) - Library with shared networking code
- [storage/partitionlib](storage/partitionlib/) - Library with MBR and GPT code
- [storage/driver-block](storage/driver-block/) - Library with shared storage code
- virtio-core - VirtIO driver library
## Services
- [graphics/fbbootlogd](graphics/fbbootlogd/) - Daemon for boot log drawing
- [graphics/fbcond](graphics/fbcond/) - Terminal daemon
- hwd - Daemon that handle the ACPI and DeviceTree booting
- inputd - Multiplexes input from multiple input drivers and provides that to Orbital
- pcid-spawner - Daemon for PCI-based device driver spawn
- [storage/lived](storage/lived/) - Daemon for live disk
- redoxerd - Daemon that send/receive terminal text between the host system and QEMU
## Hardware Interfaces
- acpid - ACPI interface driver
- pcid - PCI and PCI Express driver
## Devices
### CPU
- rtcd - x86 Real Time Clock driver
### Controllers
- [usb/xhcid](usb/xhcid/) - xHCI USB controller driver
### Storage
- [storage/ahcid](storage/ahcid/) - AHCI (SATA) driver
- [storage/bcm2835-sdhcid](storage/bcm2835-sdhcid/) - BCM2835 storage driver
- [storage/ided](storage/ided/) - PATA (IDE) driver
- [storage/nvmed](storage/nvmed/) - NVMe driver
- [storage/virtio-blkd](storage/virtio-blkd/) - VirtIO block device driver
- [storage/usbscsid](storage/usbscsid/) - USB SCSI driver
### Graphics
- [graphics/ihdgd](graphics/ihdgd/) - Intel graphics driver
- [graphics/vesad](graphics/vesad/) - VESA video driver
- [graphics/virtio-gpud](graphics/virtio-gpud/) - VirtIO-GPU device driver
### Input
- [input/ps2d](input/ps2d/) - PS/2 interface driver
- [input/usbhidd](input/usbhidd/) - USB HID driver
- [usb/usbhubd](usb/usbhubd/) - USB Hub driver
- [usb/usbctl](usb/usbctl/) - TODO
### Sound
- [audio/ac97d](audio/ac97d/) - AC'97 codec driver
- [audio/ihdad](audio/ihdad/) - Intel HD Audio chipset driver
- [audio/sb16d](audio/sb16d/) - Sound Blaster sound card driver
### Networking
- [net/e1000d](net/e1000d/) - Intel Gigabit ethernet driver
- [net/ixgbed](net/ixgbed/) - Intel 10 Gigabit ethernet driver
- [net/rtl8139d](net/rtl8139d/), [net/rtl8168d](net/rtl8168d/) - Realtek ethernet drivers
- [net/virtio-netd](net/virtio-netd/) - VirtIO network device driver
### Virtualization
- vboxd - VirtualBox driver
Some drivers are work-in-progress and incomplete, read [this](https://gitlab.redox-os.org/redox-os/base/-/issues/56) tracking issue to verify.
## System Interfaces
This section explain the system interfaces used by drivers.
### System Calls
- `iopl` : system call that sets the I/O privilege level. x86 has four privilege rings (0/1/2/3), of which the kernel runs in ring 0 and userspace in ring 3. IOPL can only be changed by the kernel, for obvious security reasons, and therefore the Redox kernel needs root to set it. It is unique for each process. Processes with IOPL=3 can access I/O ports, and the kernel can access them as well.
### Schemes
- `/scheme/memory/physical` : Allows mapping physical memory frames to driver-accessible virtual memory pages, with various available memory types:
- `/scheme/memory/physical` : Default memory type (currently writeback)
- `/scheme/memory/physical@wb` Writeback cached memory
- `/scheme/memory/physical@uc` : Uncacheable memory
- `/scheme/memory/physical@wc` : Write-combining memory
- `/scheme/irq` : Allows getting events from interrupts. It is used primarily by listening for its file descriptors using the `/scheme/event` scheme.
## Contribution Details
### Driver Design
A device driver on Redox is an user-space daemon that use system calls and schemes to work, while operating systems with monolithic kernels drivers use internal kernel APIs instead of common program APIs.
If you want to port a driver from a monolithic operating system to Redox you will need to rewrite the driver with reverse enginnering of the code logic, because the logic is adapted to internal kernel APIs (it's a hard task if the device is complex, datasheets are much more easy).
### Write a Driver
Datasheets are preferable (much more easy depending on device complexity), when they are freely available. Be aware that datasheets are often provided under a [Non-Disclosure Agreement](https://en.wikipedia.org/wiki/Non-disclosure_agreement) from hardware vendors, which can affect the ability to create an MIT-licensed driver.
If datasheets aren't available you need to do reverse-engineering of BSD or Linux drivers (if you want use a Linux driver as reference for your Redox driver please ask in the [Chat](https://doc.redox-os.org/book/chat.html) before the implementation to know/satisfy the license requirements and not waste your time, also if you use a BSD driver not licensed as BSD as reference).
### Libraries
You should use the [redox-scheme](https://crates.io/crates/redox-scheme) and [redox_event](https://crates.io/crates/redox_event) libraries to create your drivers, you can also read the [example driver](https://gitlab.redox-os.org/redox-os/exampled) or read the code of other drivers with the same type of your device.
Before testing your changes be aware of [this](https://doc.redox-os.org/book/coding-and-building.html#how-to-update-initfs).
### References
If you want to reverse enginner the existing drivers, you can access the BSD code using these links:
- [FreeBSD drivers](https://github.com/freebsd/freebsd-src/tree/main/sys/dev)
- [NetBSD drivers](https://github.com/NetBSD/src/tree/trunk/sys/dev)
- [OpenBSD drivers](https://github.com/openbsd/src/tree/master/sys/dev)
## How To Contribute
To learn how to contribute to this system component you need to read the following document:
- [CONTRIBUTING.md](https://gitlab.redox-os.org/redox-os/redox/-/blob/master/CONTRIBUTING.md)
## Development
To learn how to do development with this system component inside the Redox build system you need to read the [Build System](https://doc.redox-os.org/book/build-system-reference.html) and [Coding and Building](https://doc.redox-os.org/book/coding-and-building.html) pages.
### How To Build
To build this system component you need to download the Redox build system, you can learn how to do it on the [Building Redox](https://doc.redox-os.org/book/podman-build.html) page.
This is necessary because they only work with cross-compilation to a Redox virtual machine or real hardware, but you can do some testing from Linux.
[Back to top](#drivers)
-13
View File
@@ -1,13 +0,0 @@
[package]
name = "acpi-resource"
description = "Shared ACPI resource template decoder"
version = "0.0.1"
authors = ["Red Bear OS"]
repository = "https://gitlab.redox-os.org/redox-os/drivers"
categories = ["hardware-support"]
license = "MIT/Apache-2.0"
edition = "2021"
[dependencies]
serde.workspace = true
thiserror.workspace = true
-688
View File
@@ -1,688 +0,0 @@
use serde::{Deserialize, Serialize};
use thiserror::Error;
const SMALL_IRQ: u8 = 0x20;
const SMALL_END_TAG: u8 = 0x78;
const LARGE_MEMORY32: u8 = 0x85;
const LARGE_FIXED_MEMORY32: u8 = 0x86;
const LARGE_ADDRESS32: u8 = 0x87;
const LARGE_EXTENDED_IRQ: u8 = 0x89;
const LARGE_ADDRESS64: u8 = 0x8A;
const LARGE_GPIO: u8 = 0x8C;
const LARGE_SERIAL_BUS: u8 = 0x8E;
const SERIAL_BUS_I2C: u8 = 1;
const I2C_TYPE_DATA_LEN: usize = 6;
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum InterruptTrigger {
Edge,
Level,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum InterruptPolarity {
ActiveHigh,
ActiveLow,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum AddressResourceType {
MemoryRange,
IoRange,
BusNumberRange,
Unknown(u8),
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ResourceSource {
pub index: u8,
pub source: String,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct IrqDescriptor {
pub interrupts: Vec<u8>,
pub triggering: InterruptTrigger,
pub polarity: InterruptPolarity,
pub shareable: bool,
pub wake_capable: bool,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExtendedIrqDescriptor {
pub producer_consumer: bool,
pub interrupts: Vec<u32>,
pub triggering: InterruptTrigger,
pub polarity: InterruptPolarity,
pub shareable: bool,
pub wake_capable: bool,
pub resource_source: Option<ResourceSource>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct GpioDescriptor {
pub revision_id: u8,
pub producer_consumer: bool,
pub pin_config: u8,
pub shareable: bool,
pub wake_capable: bool,
pub io_restriction: u8,
pub triggering: InterruptTrigger,
pub polarity: InterruptPolarity,
pub drive_strength: u16,
pub debounce_timeout: u16,
pub pins: Vec<u16>,
pub resource_source: Option<ResourceSource>,
pub vendor_data: Vec<u8>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct I2cSerialBusDescriptor {
pub revision_id: u8,
pub producer_consumer: bool,
pub slave_mode: bool,
pub connection_sharing: bool,
pub type_revision_id: u8,
pub access_mode_10bit: bool,
pub slave_address: u16,
pub connection_speed: u32,
pub resource_source: Option<ResourceSource>,
pub vendor_data: Vec<u8>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Memory32RangeDescriptor {
pub write_protect: bool,
pub minimum: u32,
pub maximum: u32,
pub alignment: u32,
pub address_length: u32,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct FixedMemory32Descriptor {
pub write_protect: bool,
pub address: u32,
pub address_length: u32,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Address32Descriptor {
pub resource_type: AddressResourceType,
pub producer_consumer: bool,
pub decode: bool,
pub min_address_fixed: bool,
pub max_address_fixed: bool,
pub specific_flags: u8,
pub granularity: u32,
pub minimum: u32,
pub maximum: u32,
pub translation_offset: u32,
pub address_length: u32,
pub resource_source: Option<ResourceSource>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Address64Descriptor {
pub resource_type: AddressResourceType,
pub producer_consumer: bool,
pub decode: bool,
pub min_address_fixed: bool,
pub max_address_fixed: bool,
pub specific_flags: u8,
pub granularity: u64,
pub minimum: u64,
pub maximum: u64,
pub translation_offset: u64,
pub address_length: u64,
pub resource_source: Option<ResourceSource>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum ResourceDescriptor {
Irq(IrqDescriptor),
ExtendedIrq(ExtendedIrqDescriptor),
GpioInt(GpioDescriptor),
GpioIo(GpioDescriptor),
I2cSerialBus(I2cSerialBusDescriptor),
Memory32Range(Memory32RangeDescriptor),
FixedMemory32(FixedMemory32Descriptor),
Address32(Address32Descriptor),
Address64(Address64Descriptor),
}
#[derive(Debug, Error, PartialEq, Eq)]
pub enum ResourceDecodeError {
#[error("descriptor at offset {offset} overruns the resource template")]
TruncatedDescriptor { offset: usize },
#[error("unsupported small descriptor length {length} for tag {tag:#04x} at offset {offset}")]
InvalidSmallLength {
offset: usize,
tag: u8,
length: usize,
},
#[error("descriptor {descriptor} at offset {offset} is shorter than {minimum} bytes")]
InvalidLargeLength {
offset: usize,
descriptor: &'static str,
minimum: usize,
},
#[error("descriptor {descriptor} at offset {offset} has an invalid internal offset")]
InvalidInternalOffset {
offset: usize,
descriptor: &'static str,
},
}
pub fn decode_resource_template(
bytes: &[u8],
) -> Result<Vec<ResourceDescriptor>, ResourceDecodeError> {
let mut resources = Vec::new();
let mut offset = 0usize;
while offset < bytes.len() {
let descriptor = *bytes
.get(offset)
.ok_or(ResourceDecodeError::TruncatedDescriptor { offset })?;
if descriptor & 0x80 == 0 {
let length = usize::from(descriptor & 0x07);
let end = offset + 1 + length;
let desc = bytes
.get(offset..end)
.ok_or(ResourceDecodeError::TruncatedDescriptor { offset })?;
let body = &desc[1..];
match descriptor & 0x78 {
SMALL_IRQ => resources.push(ResourceDescriptor::Irq(parse_irq(body, offset)?)),
SMALL_END_TAG => break,
_ => {}
}
offset = end;
continue;
}
let length = usize::from(read_u16(bytes, offset + 1)?);
let end = offset + 3 + length;
let desc = bytes
.get(offset..end)
.ok_or(ResourceDecodeError::TruncatedDescriptor { offset })?;
let body = &desc[3..];
match descriptor {
LARGE_MEMORY32 => resources.push(ResourceDescriptor::Memory32Range(parse_memory32(
body, offset,
)?)),
LARGE_FIXED_MEMORY32 => resources.push(ResourceDescriptor::FixedMemory32(
parse_fixed_memory32(body, offset)?,
)),
LARGE_ADDRESS32 => {
resources.push(ResourceDescriptor::Address32(parse_address32(
desc, body, offset,
)?));
}
LARGE_ADDRESS64 => {
resources.push(ResourceDescriptor::Address64(parse_address64(
desc, body, offset,
)?));
}
LARGE_EXTENDED_IRQ => resources.push(ResourceDescriptor::ExtendedIrq(
parse_extended_irq(desc, body, offset)?,
)),
LARGE_GPIO => {
let (is_interrupt, descriptor) = parse_gpio(desc, body, offset)?;
resources.push(if is_interrupt {
ResourceDescriptor::GpioInt(descriptor)
} else {
ResourceDescriptor::GpioIo(descriptor)
});
}
LARGE_SERIAL_BUS => {
if let Some(descriptor) = parse_i2c_serial_bus(desc, body, offset)? {
resources.push(ResourceDescriptor::I2cSerialBus(descriptor));
}
}
_ => {}
}
offset = end;
}
Ok(resources)
}
fn parse_irq(body: &[u8], offset: usize) -> Result<IrqDescriptor, ResourceDecodeError> {
if body.len() != 2 && body.len() != 3 {
return Err(ResourceDecodeError::InvalidSmallLength {
offset,
tag: SMALL_IRQ,
length: body.len(),
});
}
let mask = u16::from_le_bytes([body[0], body[1]]);
let flags = body.get(2).copied().unwrap_or(0);
let interrupts = (0..16)
.filter(|irq| mask & (1 << irq) != 0)
.map(|irq| irq as u8)
.collect();
Ok(IrqDescriptor {
interrupts,
triggering: if flags & 0x01 != 0 {
InterruptTrigger::Level
} else {
InterruptTrigger::Edge
},
polarity: if flags & 0x08 != 0 {
InterruptPolarity::ActiveLow
} else {
InterruptPolarity::ActiveHigh
},
shareable: flags & 0x10 != 0,
wake_capable: flags & 0x20 != 0,
})
}
fn parse_extended_irq(
desc: &[u8],
body: &[u8],
offset: usize,
) -> Result<ExtendedIrqDescriptor, ResourceDecodeError> {
ensure_length(body, 2, offset, "ExtendedIrq")?;
let flags = body[0];
let count = usize::from(body[1]);
let ints_len = count * 4;
ensure_length(body, 2 + ints_len, offset, "ExtendedIrq")?;
let interrupts = (0..count)
.map(|index| read_u32(body, 2 + index * 4))
.collect::<Result<Vec<_>, _>>()?;
let resource_source = if body.len() > 2 + ints_len {
Some(parse_source_inline(&body[2 + ints_len..]))
} else {
None
};
let _ = desc;
Ok(ExtendedIrqDescriptor {
producer_consumer: flags & 0x01 != 0,
triggering: if flags & 0x02 != 0 {
InterruptTrigger::Level
} else {
InterruptTrigger::Edge
},
polarity: if flags & 0x04 != 0 {
InterruptPolarity::ActiveLow
} else {
InterruptPolarity::ActiveHigh
},
shareable: flags & 0x08 != 0,
wake_capable: flags & 0x10 != 0,
interrupts,
resource_source,
})
}
fn parse_gpio(
desc: &[u8],
body: &[u8],
offset: usize,
) -> Result<(bool, GpioDescriptor), ResourceDecodeError> {
ensure_length(body, 20, offset, "Gpio")?;
let connection_type = body[1];
let flags = read_u16(body, 2)?;
let int_flags = read_u16(body, 4)?;
let pin_table_offset = usize::from(read_u16(body, 11)?);
let resource_source_index = body[13];
let resource_source_offset = usize::from(read_u16(body, 14)?);
let vendor_offset = usize::from(read_u16(body, 16)?);
let vendor_length = usize::from(read_u16(body, 18)?);
let pins_end = min_nonzero([resource_source_offset, vendor_offset, desc.len()]);
let pins = parse_u16_list(desc, pin_table_offset, pins_end, offset, "Gpio")?;
let resource_source = parse_source_absolute(
desc,
resource_source_offset,
min_nonzero([vendor_offset, desc.len()]),
resource_source_index,
offset,
"Gpio",
)?;
let vendor_data = parse_blob_absolute(desc, vendor_offset, vendor_length, offset, "Gpio")?;
Ok((
connection_type == 0,
GpioDescriptor {
revision_id: body[0],
producer_consumer: flags & 0x0001 != 0,
pin_config: body[6],
shareable: int_flags & 0x0008 != 0,
wake_capable: int_flags & 0x0010 != 0,
io_restriction: (int_flags & 0x0003) as u8,
triggering: if int_flags & 0x0001 != 0 {
InterruptTrigger::Level
} else {
InterruptTrigger::Edge
},
polarity: if int_flags & 0x0002 != 0 {
InterruptPolarity::ActiveLow
} else {
InterruptPolarity::ActiveHigh
},
drive_strength: read_u16(body, 7)?,
debounce_timeout: read_u16(body, 9)?,
pins,
resource_source,
vendor_data,
},
))
}
fn parse_i2c_serial_bus(
desc: &[u8],
body: &[u8],
offset: usize,
) -> Result<Option<I2cSerialBusDescriptor>, ResourceDecodeError> {
ensure_length(body, 15, offset, "SerialBus")?;
if body[2] != SERIAL_BUS_I2C {
return Ok(None);
}
let type_data_length = usize::from(read_u16(body, 7)?);
if type_data_length < I2C_TYPE_DATA_LEN {
return Err(ResourceDecodeError::InvalidLargeLength {
offset,
descriptor: "I2cSerialBus",
minimum: 15,
});
}
let vendor_length = type_data_length - I2C_TYPE_DATA_LEN;
let vendor_data = parse_blob_absolute(desc, 18, vendor_length, offset, "I2cSerialBus")?;
let resource_source = parse_source_absolute(
desc,
12 + type_data_length,
desc.len(),
body[1],
offset,
"I2cSerialBus",
)?;
Ok(Some(I2cSerialBusDescriptor {
revision_id: body[0],
producer_consumer: body[3] & 0x02 != 0,
slave_mode: body[3] & 0x01 != 0,
connection_sharing: body[3] & 0x04 != 0,
type_revision_id: body[6],
access_mode_10bit: read_u16(body, 4)? & 0x0001 != 0,
connection_speed: read_u32(body, 9)?,
slave_address: read_u16(body, 13)?,
resource_source,
vendor_data,
}))
}
fn parse_memory32(
body: &[u8],
offset: usize,
) -> Result<Memory32RangeDescriptor, ResourceDecodeError> {
ensure_length(body, 17, offset, "Memory32Range")?;
Ok(Memory32RangeDescriptor {
write_protect: body[0] & 0x01 != 0,
minimum: read_u32(body, 1)?,
maximum: read_u32(body, 5)?,
alignment: read_u32(body, 9)?,
address_length: read_u32(body, 13)?,
})
}
fn parse_fixed_memory32(
body: &[u8],
offset: usize,
) -> Result<FixedMemory32Descriptor, ResourceDecodeError> {
ensure_length(body, 9, offset, "FixedMemory32")?;
Ok(FixedMemory32Descriptor {
write_protect: body[0] & 0x01 != 0,
address: read_u32(body, 1)?,
address_length: read_u32(body, 5)?,
})
}
fn parse_address32(
desc: &[u8],
body: &[u8],
offset: usize,
) -> Result<Address32Descriptor, ResourceDecodeError> {
ensure_length(body, 23, offset, "Address32")?;
Ok(Address32Descriptor {
resource_type: parse_address_type(body[0]),
producer_consumer: body[1] & 0x01 != 0,
decode: body[1] & 0x02 != 0,
min_address_fixed: body[1] & 0x04 != 0,
max_address_fixed: body[1] & 0x08 != 0,
specific_flags: body[2],
granularity: read_u32(body, 3)?,
minimum: read_u32(body, 7)?,
maximum: read_u32(body, 11)?,
translation_offset: read_u32(body, 15)?,
address_length: read_u32(body, 19)?,
resource_source: if desc.len() > 26 {
parse_source_absolute(desc, 26, desc.len(), desc[26], offset, "Address32")?
} else {
None
},
})
}
fn parse_address64(
desc: &[u8],
body: &[u8],
offset: usize,
) -> Result<Address64Descriptor, ResourceDecodeError> {
ensure_length(body, 43, offset, "Address64")?;
Ok(Address64Descriptor {
resource_type: parse_address_type(body[0]),
producer_consumer: body[1] & 0x01 != 0,
decode: body[1] & 0x02 != 0,
min_address_fixed: body[1] & 0x04 != 0,
max_address_fixed: body[1] & 0x08 != 0,
specific_flags: body[2],
granularity: read_u64(body, 3)?,
minimum: read_u64(body, 11)?,
maximum: read_u64(body, 19)?,
translation_offset: read_u64(body, 27)?,
address_length: read_u64(body, 35)?,
resource_source: if desc.len() > 46 {
parse_source_absolute(desc, 46, desc.len(), desc[46], offset, "Address64")?
} else {
None
},
})
}
fn ensure_length(
body: &[u8],
minimum: usize,
offset: usize,
descriptor: &'static str,
) -> Result<(), ResourceDecodeError> {
if body.len() < minimum {
return Err(ResourceDecodeError::InvalidLargeLength {
offset,
descriptor,
minimum,
});
}
Ok(())
}
fn parse_source_inline(bytes: &[u8]) -> ResourceSource {
let index = bytes.first().copied().unwrap_or(0);
let source = bytes.get(1..).map(parse_nul_string).unwrap_or_default();
ResourceSource { index, source }
}
fn parse_source_absolute(
desc: &[u8],
start: usize,
end: usize,
index: u8,
offset: usize,
descriptor: &'static str,
) -> Result<Option<ResourceSource>, ResourceDecodeError> {
if start == 0 || start >= end || start > desc.len() {
return Ok(None);
}
let slice = desc
.get(start..end)
.ok_or(ResourceDecodeError::InvalidInternalOffset { offset, descriptor })?;
Ok(Some(ResourceSource {
index,
source: parse_nul_string(slice),
}))
}
fn parse_blob_absolute(
desc: &[u8],
start: usize,
length: usize,
offset: usize,
descriptor: &'static str,
) -> Result<Vec<u8>, ResourceDecodeError> {
if start == 0 || length == 0 {
return Ok(Vec::new());
}
let end = start + length;
Ok(desc
.get(start..end)
.ok_or(ResourceDecodeError::InvalidInternalOffset { offset, descriptor })?
.to_vec())
}
fn parse_u16_list(
desc: &[u8],
start: usize,
end: usize,
offset: usize,
descriptor: &'static str,
) -> Result<Vec<u16>, ResourceDecodeError> {
if start == 0 || start >= end || start > desc.len() {
return Ok(Vec::new());
}
let slice = desc
.get(start..end)
.ok_or(ResourceDecodeError::InvalidInternalOffset { offset, descriptor })?;
if slice.len() % 2 != 0 {
return Err(ResourceDecodeError::InvalidInternalOffset { offset, descriptor });
}
slice
.chunks_exact(2)
.map(|chunk| Ok(u16::from_le_bytes([chunk[0], chunk[1]])))
.collect()
}
fn parse_nul_string(bytes: &[u8]) -> String {
let end = bytes
.iter()
.position(|byte| *byte == 0)
.unwrap_or(bytes.len());
String::from_utf8_lossy(&bytes[..end]).to_string()
}
fn parse_address_type(value: u8) -> AddressResourceType {
match value {
0 => AddressResourceType::MemoryRange,
1 => AddressResourceType::IoRange,
2 => AddressResourceType::BusNumberRange,
other => AddressResourceType::Unknown(other),
}
}
fn read_u16(bytes: &[u8], offset: usize) -> Result<u16, ResourceDecodeError> {
let slice = bytes
.get(offset..offset + 2)
.ok_or(ResourceDecodeError::TruncatedDescriptor { offset })?;
Ok(u16::from_le_bytes([slice[0], slice[1]]))
}
fn read_u32(bytes: &[u8], offset: usize) -> Result<u32, ResourceDecodeError> {
let slice = bytes
.get(offset..offset + 4)
.ok_or(ResourceDecodeError::TruncatedDescriptor { offset })?;
Ok(u32::from_le_bytes([slice[0], slice[1], slice[2], slice[3]]))
}
fn read_u64(bytes: &[u8], offset: usize) -> Result<u64, ResourceDecodeError> {
let slice = bytes
.get(offset..offset + 8)
.ok_or(ResourceDecodeError::TruncatedDescriptor { offset })?;
Ok(u64::from_le_bytes([
slice[0], slice[1], slice[2], slice[3], slice[4], slice[5], slice[6], slice[7],
]))
}
fn min_nonzero<const N: usize>(values: [usize; N]) -> usize {
values
.into_iter()
.filter(|value| *value != 0)
.min()
.unwrap_or(0)
}
#[cfg(test)]
mod tests {
use super::{decode_resource_template, ResourceDescriptor};
#[test]
fn decodes_small_irq_descriptor() {
let resources = decode_resource_template(&[0x23, 0x0A, 0x00, 0x19, 0x79, 0x00]).unwrap();
assert!(matches!(
&resources[0],
ResourceDescriptor::Irq(descriptor)
if descriptor.interrupts == vec![1, 3]
&& descriptor.shareable
&& descriptor.wake_capable == false
));
}
#[test]
fn decodes_i2c_serial_bus_descriptor() {
let template = [
0x8E, 0x14, 0x00, 0x01, 0x02, 0x01, 0x02, 0x00, 0x00, 0x01, 0x06, 0x00, 0x80, 0x1A,
0x06, 0x00, 0x15, 0x00, b'I', b'2', b'C', b'0', 0x00, 0x79, 0x00,
];
let resources = decode_resource_template(&template).unwrap();
assert!(matches!(
&resources[0],
ResourceDescriptor::I2cSerialBus(descriptor)
if descriptor.connection_speed == 400_000
&& descriptor.slave_address == 0x15
&& descriptor.resource_source.as_ref().map(|source| source.source.as_str())
== Some("I2C0")
));
}
#[test]
fn decodes_gpio_interrupt_descriptor() {
let template = [
0x8C, 0x1B, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17,
0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x12, b'\\', b'_', b'S', b'B',
0x00, 0x79, 0x00,
];
let resources = decode_resource_template(&template).unwrap();
assert!(matches!(&resources[0], ResourceDescriptor::GpioInt(_)));
}
}
-33
View File
@@ -1,33 +0,0 @@
[package]
name = "acpid"
description = "ACPI daemon"
version = "0.1.0"
authors = ["4lDO2 <4lDO2@protonmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
acpi.workspace = true
arrayvec = "0.7.6"
log.workspace = true
num-derive = "0.3"
num-traits = "0.2"
parking_lot.workspace = true
plain.workspace = true
redox_syscall.workspace = true
redox_event.workspace = true
rustc-hash = "1.1.0"
thiserror.workspace = true
ron.workspace = true
serde.workspace = true
amlserde = { path = "../amlserde" }
common = { path = "../common" }
daemon = { path = "../../daemon" }
libredox.workspace = true
redox-scheme.workspace = true
scheme-utils = { path = "../../scheme-utils" }
[lints]
workspace = true
File diff suppressed because it is too large Load Diff
-128
View File
@@ -1,128 +0,0 @@
use std::ops::{Deref, DerefMut};
use common::io::Mmio;
// TODO: Only wrap with Mmio where there are hardware-registers. (Some of these structs seem to be
// ring buffer entries, which are not to be treated the same way).
pub struct DrhdPage {
virt: *mut Drhd,
}
impl DrhdPage {
pub fn map(base_phys: usize) -> syscall::Result<Self> {
assert_eq!(
base_phys % crate::acpi::PAGE_SIZE,
0,
"DRHD registers must be page-aligned"
);
// TODO: Uncachable? Can reads have side-effects?
let virt = unsafe {
common::physmap(
base_phys,
crate::acpi::PAGE_SIZE,
common::Prot::RO,
common::MemoryType::default(),
)?
} as *mut Drhd;
Ok(Self { virt })
}
}
impl Deref for DrhdPage {
type Target = Drhd;
fn deref(&self) -> &Self::Target {
unsafe { &*self.virt }
}
}
impl DerefMut for DrhdPage {
fn deref_mut(&mut self) -> &mut Self::Target {
unsafe { &mut *self.virt }
}
}
impl Drop for DrhdPage {
fn drop(&mut self) {
unsafe {
let _ = libredox::call::munmap(self.virt.cast(), crate::acpi::PAGE_SIZE);
}
}
}
#[repr(C, packed)]
pub struct DrhdFault {
pub sts: Mmio<u32>,
pub ctrl: Mmio<u32>,
pub data: Mmio<u32>,
pub addr: [Mmio<u32>; 2],
_rsv: [Mmio<u64>; 2],
pub log: Mmio<u64>,
}
#[repr(C, packed)]
pub struct DrhdProtectedMemory {
pub en: Mmio<u32>,
pub low_base: Mmio<u32>,
pub low_limit: Mmio<u32>,
pub high_base: Mmio<u64>,
pub high_limit: Mmio<u64>,
}
#[repr(C, packed)]
pub struct DrhdInvalidation {
pub queue_head: Mmio<u64>,
pub queue_tail: Mmio<u64>,
pub queue_addr: Mmio<u64>,
_rsv: Mmio<u32>,
pub cmpl_sts: Mmio<u32>,
pub cmpl_ctrl: Mmio<u32>,
pub cmpl_data: Mmio<u32>,
pub cmpl_addr: [Mmio<u32>; 2],
}
#[repr(C, packed)]
pub struct DrhdPageRequest {
pub queue_head: Mmio<u64>,
pub queue_tail: Mmio<u64>,
pub queue_addr: Mmio<u64>,
_rsv: Mmio<u32>,
pub sts: Mmio<u32>,
pub ctrl: Mmio<u32>,
pub data: Mmio<u32>,
pub addr: [Mmio<u32>; 2],
}
#[repr(C, packed)]
pub struct DrhdMtrrVariable {
pub base: Mmio<u64>,
pub mask: Mmio<u64>,
}
#[repr(C, packed)]
pub struct DrhdMtrr {
pub cap: Mmio<u64>,
pub def_type: Mmio<u64>,
pub fixed: [Mmio<u64>; 11],
pub variable: [DrhdMtrrVariable; 10],
}
#[repr(C, packed)]
pub struct Drhd {
pub version: Mmio<u32>,
_rsv: Mmio<u32>,
pub cap: Mmio<u64>,
pub ext_cap: Mmio<u64>,
pub gl_cmd: Mmio<u32>,
pub gl_sts: Mmio<u32>,
pub root_table: Mmio<u64>,
pub ctx_cmd: Mmio<u64>,
_rsv1: Mmio<u32>,
pub fault: DrhdFault,
_rsv2: Mmio<u32>,
pub pm: DrhdProtectedMemory,
pub invl: DrhdInvalidation,
_rsv3: Mmio<u64>,
pub intr_table: Mmio<u64>,
pub page_req: DrhdPageRequest,
pub mtrr: DrhdMtrr,
}
-557
View File
@@ -1,557 +0,0 @@
//! DMA Remapping Table -- `DMAR`. This is Intel's implementation of IOMMU functionality, known as
//! VT-d.
//!
//! Too understand what all of these structs mean, refer to the "Intel(R) Virtualization
//! Technology for Directed I/O" specification.
// TODO: Move this code to a separate driver as well?
use std::convert::TryFrom;
use std::ops::Deref;
use std::{fmt, mem};
use common::io::Io as _;
use num_derive::FromPrimitive;
use num_traits::FromPrimitive;
use self::drhd::DrhdPage;
use crate::acpi::{AcpiContext, Sdt, SdtHeader};
pub mod drhd;
#[repr(C, packed)]
pub struct DmarStruct {
pub sdt_header: SdtHeader,
pub host_addr_width: u8,
pub flags: u8,
pub _rsvd: [u8; 10],
// This header is followed by N remapping structures.
}
unsafe impl plain::Plain for DmarStruct {}
/// The DMA Remapping Table
#[derive(Debug)]
pub struct Dmar(Sdt);
impl Dmar {
fn remmapping_structs_area(&self) -> &[u8] {
&self.0.as_slice()[mem::size_of::<DmarStruct>()..]
}
}
impl Deref for Dmar {
type Target = DmarStruct;
fn deref(&self) -> &Self::Target {
plain::from_bytes(self.0.as_slice())
.expect("expected Dmar struct to already have checked the length, and alignment issues should be impossible due to #[repr(packed)]")
}
}
impl Dmar {
// TODO: Again, perhaps put this code into a different driver, and read the table the regular
// way via the acpi scheme?
///
/// Phase E.4 fix: `init` now takes an opt-in flag. DMAR init was
/// previously disabled because MMIO reads (e.g. `gl_sts.read()`) on
/// some real hardware block or spin forever. The MMIO read loop has
/// a hard iteration limit to prevent hangs regardless of hardware
/// behavior, and callers must explicitly opt in via `init_with(..., true)`.
/// The high-level `init(acpi_ctx)` now calls `init_with(acpi_ctx, false)`
/// for safety, so DMAR is **not** initialized by default in this fork.
pub fn init(acpi_ctx: &AcpiContext) {
Self::init_with(acpi_ctx, false)
}
pub fn init_with(acpi_ctx: &AcpiContext, opt_in: bool) {
if !opt_in {
log::debug!("DMAR init skipped (opt-in not set; set REDBEAR_DMAR_INIT=1 to enable)");
return;
}
let dmar_sdt = match acpi_ctx.take_single_sdt(*b"DMAR") {
Some(dmar_sdt) => dmar_sdt,
None => {
log::warn!("Unable to find `DMAR` ACPI table.");
return;
}
};
let dmar = match Dmar::new(dmar_sdt) {
Some(dmar) => dmar,
None => {
log::error!("Failed to parse DMAR table, possibly malformed.");
return;
}
};
log::info!("Found DMAR: {}: {}", dmar.host_addr_width, dmar.flags);
log::debug!("DMAR: {:?}", dmar);
// Hard cap on DMAR entries to process. Real hardware typically
// has 1-4 DRHDs; cap at 32 to prevent any infinite-iterator
// hang in case of a malformed table.
const MAX_DMAR_ENTRIES: usize = 32;
let mut entry_count = 0;
for dmar_entry in dmar.iter().take(MAX_DMAR_ENTRIES) {
entry_count += 1;
log::debug!("DMAR entry: {:?}", dmar_entry);
match dmar_entry {
DmarEntry::Drhd(dmar_drhd) => {
let drhd = dmar_drhd.map();
log::debug!("VER: {:X}", drhd.version.read());
log::debug!("CAP: {:X}", drhd.cap.read());
log::debug!("EXT_CAP: {:X}", drhd.ext_cap.read());
log::debug!("GCMD: {:X}", drhd.gl_cmd.read());
log::debug!("GSTS: {:X}", drhd.gl_sts.read());
log::debug!("RT: {:X}", drhd.root_table.read());
}
_ => (),
}
}
if entry_count == MAX_DMAR_ENTRIES {
log::warn!(
"DMAR table reached the {} entry cap; truncating further processing",
MAX_DMAR_ENTRIES
);
}
}
fn new(sdt: Sdt) -> Option<Dmar> {
assert_eq!(
sdt.signature, *b"DMAR",
"signature already checked against `DMAR`"
);
if sdt.length() < mem::size_of::<DmarStruct>() {
log::error!(
"The DMAR table was too small ({} B < {} B).",
sdt.length(),
mem::size_of::<Dmar>()
);
return None;
}
// No need to check alignment for #[repr(packed)] structs.
Some(Dmar(sdt))
}
pub fn iter(&self) -> DmarIter<'_> {
DmarIter(DmarRawIter {
bytes: self.remmapping_structs_area(),
})
}
}
/// DMAR DMA Remapping Hardware Unit Definition
#[derive(Clone, Copy, Debug)]
#[repr(C, packed)]
pub struct DmarDrhdHeader {
pub kind: u16,
pub length: u16,
pub flags: u8,
pub _rsv: u8,
pub segment: u16,
pub base: u64,
}
unsafe impl plain::Plain for DmarDrhdHeader {}
#[derive(Clone, Copy, Debug)]
#[repr(C, packed)]
pub struct DeviceScopeHeader {
pub ty: u8,
pub len: u8,
pub _rsvd: u16,
pub enumeration_id: u8,
pub start_bus_num: u8,
// The variable-sized path comes after.
}
unsafe impl plain::Plain for DeviceScopeHeader {}
pub struct DeviceScope(Box<[u8]>);
impl DeviceScope {
pub fn try_new(raw: &[u8]) -> Option<Self> {
// TODO: Check ty.
let header_bytes = match raw.get(..mem::size_of::<DeviceScopeHeader>()) {
Some(bytes) => bytes,
None => return None,
};
let header = plain::from_bytes::<DeviceScopeHeader>(header_bytes)
.expect("length already checked, and alignment 1 (#[repr(packed)] should suffice");
let len = usize::from(header.len);
if len > raw.len() {
log::warn!("Device scope smaller than len field.");
return None;
}
Some(Self(raw.into()))
}
}
impl fmt::Debug for DeviceScope {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DeviceScope")
.field("header", &*self as &DeviceScopeHeader)
.field("path", &self.path())
.finish()
}
}
impl Deref for DeviceScope {
type Target = DeviceScopeHeader;
fn deref(&self) -> &Self::Target {
plain::from_bytes(&self.0)
.expect("expected length to be sufficient, and alignment (due to #[repr(packed)]")
}
}
impl DeviceScope {
pub fn path(&self) -> &[u8] {
&self.0[mem::size_of::<DeviceScopeHeader>()..]
}
}
pub struct DmarDrhd(Box<[u8]>);
impl DmarDrhd {
pub fn try_new(raw: &[u8]) -> Option<Self> {
if raw.len() < mem::size_of::<DmarDrhdHeader>() {
return None;
}
Some(Self(raw.into()))
}
pub fn device_scope_area(&self) -> &[u8] {
&self.0[mem::size_of::<DmarDrhdHeader>()..]
}
pub fn map(&self) -> DrhdPage {
let base = usize::try_from(self.base).expect("expected u64 to fit within usize");
DrhdPage::map(base).expect("failed to map DRHD registers")
}
}
impl Deref for DmarDrhd {
type Target = DmarDrhdHeader;
fn deref(&self) -> &Self::Target {
plain::from_bytes::<DmarDrhdHeader>(&self.0[..mem::size_of::<DmarDrhdHeader>()])
.expect("length is already checked, and alignment 1 (#[repr(packed)] should suffice")
}
}
impl fmt::Debug for DmarDrhd {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DmarDrhd")
.field("header", &*self as &DmarDrhd)
// TODO: print out device scopes
.finish()
}
}
/// DMAR Reserved Memory Region Reporting
#[derive(Clone, Copy, Debug)]
#[repr(C, packed)]
pub struct DmarRmrrHeader {
pub kind: u16,
pub length: u16,
pub _rsv: u16,
pub segment: u16,
pub base: u64,
pub limit: u64,
// The device scopes come after.
}
unsafe impl plain::Plain for DmarRmrrHeader {}
pub struct DmarRmrr(Box<[u8]>);
impl DmarRmrr {
pub fn try_new(raw: &[u8]) -> Option<Self> {
if raw.len() < mem::size_of::<DmarRmrrHeader>() {
return None;
}
Some(Self(raw.into()))
}
}
impl Deref for DmarRmrr {
type Target = DmarRmrrHeader;
fn deref(&self) -> &Self::Target {
plain::from_bytes(&self.0[..mem::size_of::<DmarRmrrHeader>()])
.expect("length already checked, and with #[repr(packed)] alignment should be okay")
}
}
impl fmt::Debug for DmarRmrr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DmarRmrr")
.field("header", &*self as &DmarRmrrHeader)
// TODO: print out device scopes
.finish()
}
}
/// DMAR Root Port ATS Capability Reporting
#[derive(Clone, Copy, Debug)]
#[repr(C, packed)]
pub struct DmarAtsrHeader {
kind: u16,
length: u16,
flags: u8,
_rsv: u8,
segment: u16,
// The device scopes come after.
}
unsafe impl plain::Plain for DmarAtsrHeader {}
pub struct DmarAtsr(Box<[u8]>);
impl DmarAtsr {
pub fn try_new(raw: &[u8]) -> Option<Self> {
if raw.len() < mem::size_of::<DmarAtsrHeader>() {
return None;
}
Some(Self(raw.into()))
}
}
impl Deref for DmarAtsr {
type Target = DmarAtsrHeader;
fn deref(&self) -> &Self::Target {
plain::from_bytes(&self.0[..mem::size_of::<DmarAtsrHeader>()])
.expect("length already checked, and with #[repr(packed)] alignment should be okay")
}
}
impl fmt::Debug for DmarAtsr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DmarAtsr")
.field("header", &*self as &DmarAtsrHeader)
// TODO: print out device scopes
.finish()
}
}
/// DMAR Remapping Hardware Static Affinity
#[derive(Clone, Copy, Debug)]
#[repr(C, packed)]
pub struct DmarRhsa {
pub kind: u16,
pub length: u16,
pub _rsv: u32,
pub base: u64,
pub domain: u32,
}
unsafe impl plain::Plain for DmarRhsa {}
impl DmarRhsa {
pub fn try_new(raw: &[u8]) -> Option<Self> {
let bytes = raw.get(..mem::size_of::<DmarRhsa>())?;
let this = plain::from_bytes(bytes)
.expect("length is already checked, and alignment 1 should suffice (#[repr(packed)])");
Some(*this)
}
}
/// DMAR ACPI Name-space Device Declaration
#[derive(Clone, Copy, Debug)]
#[repr(C, packed)]
pub struct DmarAnddHeader {
pub kind: u16,
pub length: u16,
pub _rsv: [u8; 3],
pub acpi_dev: u8,
// The device scopes come after.
}
unsafe impl plain::Plain for DmarAnddHeader {}
pub struct DmarAndd(Box<[u8]>);
impl DmarAndd {
pub fn try_new(raw: &[u8]) -> Option<Self> {
if raw.len() < mem::size_of::<DmarAnddHeader>() {
return None;
}
Some(Self(raw.into()))
}
}
impl Deref for DmarAndd {
type Target = DmarAnddHeader;
fn deref(&self) -> &Self::Target {
plain::from_bytes(&self.0[..mem::size_of::<DmarAnddHeader>()])
.expect("length already checked, and with #[repr(packed)] alignment should be okay")
}
}
impl fmt::Debug for DmarAndd {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DmarAndd")
.field("header", &*self as &DmarAnddHeader)
// TODO: print out device scopes
.finish()
}
}
/// DMAR ACPI Name-space Device Declaration
#[derive(Clone, Copy, Debug)]
#[repr(C, packed)]
pub struct DmarSatcHeader {
pub kind: u16,
pub length: u16,
pub flags: u8,
pub _rsvd: u8,
pub seg_num: u16,
// The device scopes come after.
}
unsafe impl plain::Plain for DmarSatcHeader {}
pub struct DmarSatc(Box<[u8]>);
impl DmarSatc {
pub fn try_new(raw: &[u8]) -> Option<Self> {
if raw.len() < mem::size_of::<DmarSatcHeader>() {
return None;
}
Some(Self(raw.into()))
}
}
impl Deref for DmarSatc {
type Target = DmarSatcHeader;
fn deref(&self) -> &Self::Target {
plain::from_bytes(&self.0[..mem::size_of::<DmarSatcHeader>()])
.expect("length already checked, and with #[repr(packed)] alignment should be okay")
}
}
impl fmt::Debug for DmarSatc {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DmarSatc")
.field("header", &*self as &DmarSatcHeader)
// TODO: print out device scopes
.finish()
}
}
/// The list of different "Remapping Structure Types".
///
/// Refer to section 8.2 in the VTIO spec (as of revision 3.2).
#[derive(Clone, Copy, Debug, FromPrimitive)]
#[repr(u16)]
pub enum EntryType {
Drhd = 0,
Rmrr = 1,
Atsr = 2,
Rhsa = 3,
Andd = 4,
Satc = 5,
}
/// DMAR Entries
#[derive(Debug)]
pub enum DmarEntry {
Drhd(DmarDrhd),
Rmrr(DmarRmrr),
Atsr(DmarAtsr),
Rhsa(DmarRhsa),
Andd(DmarAndd),
// TODO: "SoC Integrated Address Translation Cache Reporting Structure".
Satc(DmarSatc),
TooShort(EntryType),
Unknown(u16),
}
struct DmarRawIter<'sdt> {
bytes: &'sdt [u8],
}
impl<'sdt> Iterator for DmarRawIter<'sdt> {
type Item = (u16, &'sdt [u8]);
fn next(&mut self) -> Option<Self::Item> {
let type_bytes = match self.bytes.get(..2) {
Some(bytes) => bytes,
None => {
if !self.bytes.is_empty() {
log::warn!("DMAR table ended between two entries.");
}
return None;
}
};
let len_bytes = match self.bytes.get(2..4) {
Some(bytes) => bytes,
None => {
log::warn!("DMAR table ended between two entries.");
return None;
}
};
let remainder = &self.bytes[4..];
let type_bytes = <[u8; 2]>::try_from(type_bytes)
.expect("expected a 2-byte slice to be convertible to [u8; 2]");
let len_bytes = <[u8; 2]>::try_from(type_bytes)
.expect("expected a 2-byte slice to be convertible to [u8; 2]");
let ty = u16::from_ne_bytes(type_bytes);
let len = u16::from_ne_bytes(len_bytes);
let len = usize::try_from(len).expect("expected u16 to fit within usize");
if len > remainder.len() {
log::warn!("DMAR remapping structure length was smaller than the remaining length of the table.");
return None;
}
let (current, residue) = self.bytes.split_at(len);
self.bytes = residue;
Some((ty, current))
}
}
pub struct DmarIter<'sdt>(DmarRawIter<'sdt>);
impl Iterator for DmarIter<'_> {
type Item = DmarEntry;
fn next(&mut self) -> Option<Self::Item> {
let (raw_type, raw) = self.0.next()?;
// NOTE: If any of these entries look incorrect, we should simply continue the iterator,
// and instead print a warning.
let entry_type = match EntryType::from_u16(raw_type) {
Some(ty) => ty,
None => {
log::warn!(
"Encountered invalid entry type {} (length {})",
raw_type,
raw.len()
);
return Some(DmarEntry::Unknown(raw_type));
}
};
let item_opt = match entry_type {
EntryType::Drhd => DmarDrhd::try_new(raw).map(DmarEntry::Drhd),
EntryType::Rmrr => DmarRmrr::try_new(raw).map(DmarEntry::Rmrr),
EntryType::Atsr => DmarAtsr::try_new(raw).map(DmarEntry::Atsr),
EntryType::Rhsa => DmarRhsa::try_new(raw).map(DmarEntry::Rhsa),
EntryType::Andd => DmarAndd::try_new(raw).map(DmarEntry::Andd),
EntryType::Satc => DmarSatc::try_new(raw).map(DmarEntry::Satc),
};
let item = item_opt.unwrap_or(DmarEntry::TooShort(entry_type));
Some(item)
}
}
-455
View File
@@ -1,455 +0,0 @@
use acpi::{aml::AmlError, Handle, PciAddress, PhysicalMapping};
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
use common::io::{Io, Pio};
use num_traits::PrimInt;
use rustc_hash::{FxHashMap, FxHashSet};
use std::fmt::LowerHex;
use std::mem::size_of;
use std::ptr::NonNull;
use std::sync::{Arc, Mutex};
use syscall::PAGE_SIZE;
const PAGE_MASK: usize = !(PAGE_SIZE - 1);
const OFFSET_MASK: usize = PAGE_SIZE - 1;
struct MappedPage {
phys_page: usize,
virt_page: usize,
}
impl MappedPage {
fn new(phys_page: usize) -> std::io::Result<Self> {
let virt_page = unsafe {
common::physmap(
phys_page,
PAGE_SIZE,
common::Prot::RW,
common::MemoryType::default(),
)
.map_err(|error| std::io::Error::from_raw_os_error(error.errno()))?
} as usize;
Ok(Self {
phys_page,
virt_page,
})
}
}
impl Drop for MappedPage {
fn drop(&mut self) {
log::trace!("Drop page {:#x}", self.phys_page);
if let Err(e) = unsafe { libredox::call::munmap(self.virt_page as *mut (), PAGE_SIZE) } {
log::error!("funmap (phys): {:?}", e);
}
}
}
#[derive(Default)]
pub struct AmlPageCache {
page_cache: FxHashMap<usize, MappedPage>,
}
impl AmlPageCache {
/// get a virtual address for the given physical page
fn get_page(&mut self, phys_target: usize) -> std::io::Result<&MappedPage> {
let phys_page = phys_target & PAGE_MASK;
if self.page_cache.contains_key(&phys_page) {
log::trace!("re-using cached page {:#x}", phys_page);
Ok(self
.page_cache
.get(&phys_page)
.expect("could not get page after contains=true"))
} else {
let mapped_page = MappedPage::new(phys_page)?;
log::trace!("adding page {:#x} to cache", mapped_page.phys_page);
self.page_cache.insert(phys_page, mapped_page);
Ok(self
.page_cache
.get(&phys_page)
.expect("can't find page that was just inserted"))
}
}
/// The offset into the virtual slice of T that matches the physical target
fn sized_index<T>(phys_target: usize) -> usize {
assert_eq!(
phys_target & !(size_of::<T>() - 1),
phys_target,
"address {} is not aligned",
phys_target
);
(phys_target & OFFSET_MASK) / size_of::<T>()
}
/// Read from the given physical address
fn read_from_phys<T: PrimInt + LowerHex>(&mut self, phys_target: usize) -> std::io::Result<T> {
let mapped_page = self.get_page(phys_target)?;
let page_as_slice = unsafe {
std::slice::from_raw_parts(
mapped_page.virt_page as *const T,
PAGE_SIZE / size_of::<T>(),
)
};
// for debugging only
let _virt_ptr = page_as_slice[Self::sized_index::<T>(phys_target)..].as_ptr() as usize;
let val = page_as_slice[Self::sized_index::<T>(phys_target)];
log::trace!(
"read {:#x}, virt {:#x}, val {:#x}",
phys_target,
_virt_ptr,
val
);
Ok(val)
}
/// Write to the given physical address
fn write_to_phys<T: PrimInt + LowerHex>(
&mut self,
phys_target: usize,
val: T,
) -> std::io::Result<()> {
let mapped_page = self.get_page(phys_target)?;
let page_as_slice = unsafe {
std::slice::from_raw_parts_mut(
mapped_page.virt_page as *mut T,
PAGE_SIZE / size_of::<T>(),
)
};
// for debugging only
let _virt_ptr = page_as_slice[Self::sized_index::<T>(phys_target)..].as_ptr() as usize;
page_as_slice[Self::sized_index::<T>(phys_target)] = val;
log::trace!(
"write {:#x}, virt {:#x}, val {:#x}",
phys_target,
_virt_ptr,
val
);
Ok(())
}
pub fn clear(&mut self) {
log::trace!("Clear page cache");
self.page_cache.clear();
}
}
#[derive(Clone)]
pub struct AmlPhysMemHandler {
page_cache: Arc<Mutex<AmlPageCache>>,
pci_fd: Arc<Option<libredox::Fd>>,
mutex_state: Arc<Mutex<AmlMutexState>>,
}
struct AmlMutexState {
next_id: u32,
held: FxHashSet<u32>,
}
/// Read from a physical address.
/// Generic parameter must be u8, u16, u32 or u64.
impl AmlPhysMemHandler {
pub fn new(pci_fd_opt: Option<&libredox::Fd>, page_cache: Arc<Mutex<AmlPageCache>>) -> Self {
let pci_fd = if let Some(pci_fd) = pci_fd_opt {
Some(libredox::Fd::new(pci_fd.raw()))
} else {
log::error!("pci_fd is not registered");
None
};
Self {
page_cache,
pci_fd: Arc::new(pci_fd),
mutex_state: Arc::new(Mutex::new(AmlMutexState {
next_id: 1,
held: FxHashSet::default(),
})),
}
}
fn pci_call_metadata(kind: u8, addr: PciAddress, off: u16) -> [u64; 2] {
// Segment: u16, at 28 bits
// Bus: u8, 8 bits, 256 total, at 20 bits
// Device: u8, 5 bits, 32 total, at 15 bits
// Function: u8, 3 bits, 8 total, at 12 bits
// Offset: u16, 12 bits, 4096 total, at 0 bits
[
kind.into(),
(u64::from(addr.segment()) << 28)
| (u64::from(addr.bus()) << 20)
| (u64::from(addr.device()) << 15)
| (u64::from(addr.function()) << 12)
| u64::from(off),
]
}
fn read_pci(&self, addr: PciAddress, off: u16, value: &mut [u8]) {
let metadata = Self::pci_call_metadata(1, addr, off);
match &*self.pci_fd {
Some(pci_fd) => match pci_fd.call_ro(value, syscall::CallFlags::empty(), &metadata) {
Ok(_) => {}
Err(err) => {
log::error!("read pci {addr}@{off:04X}:{:02X}: {}", value.len(), err);
}
},
None => {
log::error!(
"read pci {addr}@{off:04X}:{:02X}: pci access not available",
value.len()
);
}
}
}
fn write_pci(&self, addr: PciAddress, off: u16, value: &[u8]) {
let metadata = Self::pci_call_metadata(2, addr, off);
match &*self.pci_fd {
Some(pci_fd) => match pci_fd.call_wo(value, syscall::CallFlags::empty(), &metadata) {
Ok(_) => {}
Err(err) => {
log::error!("write pci {addr}@{off:04X}={value:02X?}: {}", err);
}
},
None => {
log::error!("write pci {addr}@{off:04X}={value:02X?}: pci access not available");
}
}
}
}
impl acpi::Handler for AmlPhysMemHandler {
unsafe fn map_physical_region<T>(&self, phys: usize, size: usize) -> PhysicalMapping<Self, T> {
let phys_page = phys & PAGE_MASK;
let offset = phys & OFFSET_MASK;
let pages = (offset + size + PAGE_SIZE - 1) / PAGE_SIZE;
let map_size = pages * PAGE_SIZE;
let virt_page = common::physmap(
phys_page,
map_size,
common::Prot::RW,
common::MemoryType::default(),
)
.expect("failed to map physical region") as usize;
PhysicalMapping {
physical_start: phys,
virtual_start: NonNull::new((virt_page + offset) as *mut T).unwrap(),
region_length: size,
mapped_length: map_size,
handler: self.clone(),
}
}
fn unmap_physical_region<T>(region: &PhysicalMapping<Self, T>) {
let virt_page = region.virtual_start.addr().get() & PAGE_MASK;
unsafe {
libredox::call::munmap(virt_page as *mut (), region.mapped_length)
.expect("failed to unmap physical region")
}
}
fn read_u8(&self, address: usize) -> u8 {
log::trace!("read u8 {:X}", address);
if let Ok(mut page_cache) = self.page_cache.lock() {
if let Ok(value) = page_cache.read_from_phys::<u8>(address) {
return value;
}
}
log::error!("failed to read u8 {:#x}", address);
0
}
fn read_u16(&self, address: usize) -> u16 {
log::trace!("read u16 {:X}", address);
if let Ok(mut page_cache) = self.page_cache.lock() {
if let Ok(value) = page_cache.read_from_phys::<u16>(address) {
return value;
}
}
log::error!("failed to read u16 {:#x}", address);
0
}
fn read_u32(&self, address: usize) -> u32 {
log::trace!("read u32 {:X}", address);
if let Ok(mut page_cache) = self.page_cache.lock() {
if let Ok(value) = page_cache.read_from_phys::<u32>(address) {
return value;
}
}
log::error!("failed to read u32 {:#x}", address);
0
}
fn read_u64(&self, address: usize) -> u64 {
log::trace!("read u64 {:X}", address);
if let Ok(mut page_cache) = self.page_cache.lock() {
if let Ok(value) = page_cache.read_from_phys::<u64>(address) {
return value;
}
}
log::error!("failed to read u64 {:#x}", address);
0
}
fn write_u8(&self, address: usize, value: u8) {
log::trace!("write u8 {:X} = {:X}", address, value);
if let Ok(mut page_cache) = self.page_cache.lock() {
if page_cache.write_to_phys::<u8>(address, value).is_ok() {
return;
}
}
log::error!("failed to write u8 {:#x}", address);
}
fn write_u16(&self, address: usize, value: u16) {
log::trace!("write u16 {:X} = {:X}", address, value);
if let Ok(mut page_cache) = self.page_cache.lock() {
if page_cache.write_to_phys::<u16>(address, value).is_ok() {
return;
}
}
log::error!("failed to write u16 {:#x}", address);
}
fn write_u32(&self, address: usize, value: u32) {
log::trace!("write u32 {:X} = {:X}", address, value);
if let Ok(mut page_cache) = self.page_cache.lock() {
if page_cache.write_to_phys::<u32>(address, value).is_ok() {
return;
}
}
log::error!("failed to write u32 {:#x}", address);
}
fn write_u64(&self, address: usize, value: u64) {
log::trace!("write u64 {:X} = {:X}", address, value);
if let Ok(mut page_cache) = self.page_cache.lock() {
if page_cache.write_to_phys::<u64>(address, value).is_ok() {
return;
}
}
log::error!("failed to write u64 {:#x}", address);
}
// Pio must be enabled via syscall::iopl
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn read_io_u8(&self, port: u16) -> u8 {
Pio::<u8>::new(port).read()
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn read_io_u16(&self, port: u16) -> u16 {
Pio::<u16>::new(port).read()
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn read_io_u32(&self, port: u16) -> u32 {
Pio::<u32>::new(port).read()
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn write_io_u8(&self, port: u16, value: u8) {
Pio::<u8>::new(port).write(value)
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn write_io_u16(&self, port: u16, value: u16) {
Pio::<u16>::new(port).write(value)
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn write_io_u32(&self, port: u16, value: u32) {
Pio::<u32>::new(port).write(value)
}
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
fn read_io_u8(&self, port: u16) -> u8 {
log::error!("cannot read u8 from port 0x{port:04X}");
0
}
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
fn read_io_u16(&self, port: u16) -> u16 {
log::error!("cannot read u16 from port 0x{port:04X}");
0
}
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
fn read_io_u32(&self, port: u16) -> u32 {
log::error!("cannot read u32 from port 0x{port:04X}");
0
}
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
fn write_io_u8(&self, port: u16, value: u8) {
log::error!("cannot write 0x{value:02X} to port 0x{port:04X}");
}
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
fn write_io_u16(&self, port: u16, value: u16) {
log::error!("cannot write 0x{value:04X} to port 0x{port:04X}");
}
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
fn write_io_u32(&self, port: u16, value: u32) {
log::error!("cannot write 0x{value:08X} to port 0x{port:04X}");
}
fn read_pci_u8(&self, addr: PciAddress, off: u16) -> u8 {
let mut value = [0u8];
self.read_pci(addr, off, &mut value);
value[0]
}
fn read_pci_u16(&self, addr: PciAddress, off: u16) -> u16 {
let mut value = [0u8; 2];
self.read_pci(addr, off, &mut value);
u16::from_le_bytes(value)
}
fn read_pci_u32(&self, addr: PciAddress, off: u16) -> u32 {
let mut value = [0u8; 4];
self.read_pci(addr, off, &mut value);
u32::from_le_bytes(value)
}
fn write_pci_u8(&self, addr: PciAddress, off: u16, value: u8) {
self.write_pci(addr, off, &[value]);
}
fn write_pci_u16(&self, addr: PciAddress, off: u16, value: u16) {
self.write_pci(addr, off, &value.to_le_bytes());
}
fn write_pci_u32(&self, addr: PciAddress, off: u16, value: u32) {
self.write_pci(addr, off, &value.to_le_bytes());
}
fn nanos_since_boot(&self) -> u64 {
let ts = libredox::call::clock_gettime(libredox::flag::CLOCK_MONOTONIC)
.expect("failed to get time");
(ts.tv_sec as u64) * 1_000_000_000 + (ts.tv_nsec as u64)
}
fn stall(&self, microseconds: u64) {
let start = std::time::Instant::now();
while start.elapsed().as_micros() < microseconds.into() {
std::hint::spin_loop();
}
}
fn sleep(&self, milliseconds: u64) {
std::thread::sleep(std::time::Duration::from_millis(milliseconds));
}
fn create_mutex(&self) -> Handle {
let mut state = self.mutex_state.lock().unwrap();
let id = state.next_id;
state.next_id += 1;
Handle(id)
}
fn acquire(&self, mutex: Handle, timeout: u16) -> Result<(), AmlError> {
let deadline = std::time::Instant::now()
+ std::time::Duration::from_millis(u64::from(timeout).saturating_mul(1000));
loop {
{
let mut state = self.mutex_state.lock().unwrap();
if !state.held.contains(&mutex.0) {
state.held.insert(mutex.0);
return Ok(());
}
}
if std::time::Instant::now() >= deadline {
return Err(AmlError::MutexAcquireTimeout);
}
std::thread::sleep(std::time::Duration::from_millis(1));
}
}
fn release(&self, mutex: Handle) {
self.mutex_state.lock().unwrap().held.remove(&mutex.0);
}
}
-959
View File
@@ -1,959 +0,0 @@
//! SMBIOS / DMI table scanning and parsing.
//!
//! Implements the same algorithm as the Linux kernel's `dmi_scan.c`, adapted
//! for Redox's userspace acpid. Two entry-point conventions are recognized:
//!
//! 1. **SMBIOS 3.x 64-bit entry point** (signature `_SM3_`, preferred when
//! present). Points directly at the structure table via a 64-bit physical
//! address with an explicit length, and has no fixed structure count.
//! 2. **Legacy 32-bit entry point** (signature `_SM_`, with embedded `_DMI_`
//! header 16 bytes later). Provides a structure count and a 32-bit
//! table base address.
//!
//! Both entry points are scanned in the standard 0xF0000-0xFFFFF BIOS
//! anchor region, 16 bytes aligned, with the 64-bit variant preferred.
//!
//! Once the structure table is located we walk it linearly, decoding
//! the structure types that callers actually need:
//!
//! - Type 0 (BIOS Information): vendor, version, release date,
//! BIOS / EC firmware revision.
//! - Type 1 (System Information): manufacturer, product name, version,
//! serial, UUID, SKU, family.
//! - Type 2 (Baseboard Information): manufacturer, product, version,
//! serial, asset tag.
//!
//! The variable-length string area at the tail of each structure is
//! accessed by index (1-based) per the SMBIOS reference spec.
//!
//! Strings that contain only spaces are treated as empty (matching Linux
//! behavior), and a number of defensive validations are applied to
//! tolerate malformed firmware.
use std::fs::File;
use std::io::Read;
use std::str;
use log::{debug, info, warn};
use syscall::PAGE_SIZE;
use common::{MemoryType, Prot};
/// Standard SMBIOS BIOS anchor scan range.
const SMBIOS_ANCHOR_START: usize = 0x000F_0000;
/// 64 KiB scan window (matches Linux `dmi_scan_machine`).
const SMBIOS_ANCHOR_LEN: usize = 0x0001_0000;
/// 16-byte alignment step for anchor scans.
const SMBIOS_ANCHOR_STEP: usize = 16;
/// Sentinel byte string for the 64-bit SMBIOS entry point.
const SMBIOS3_SIG: &[u8; 5] = b"_SM3_";
/// Sentinel byte string for the legacy 32-bit entry point.
const SMBIOS_SIG: &[u8; 4] = b"_SM_";
/// Sentinel for the legacy DMI header (16 bytes into the legacy entry point).
const DMI_SIG: &[u8; 5] = b"_DMI_";
/// Upper bound on a single structure's formatted area. Mirrors Linux
/// (the spec allows 256, but Linux is more conservative). Used as a
/// defensive guard against malformed firmware.
const MAX_STRUCTURE_LENGTH: usize = 256;
/// A single DMI / SMBIOS structure table entry (decoded).
#[derive(Clone, Debug, Default)]
pub struct DmiInfo {
pub bios_vendor: Option<String>,
pub bios_version: Option<String>,
pub bios_date: Option<String>,
pub bios_release: Option<String>,
pub ec_firmware_release: Option<String>,
pub sys_vendor: Option<String>,
pub product_name: Option<String>,
pub product_version: Option<String>,
pub product_serial: Option<String>,
pub product_uuid: Option<String>,
pub product_sku: Option<String>,
pub product_family: Option<String>,
pub board_vendor: Option<String>,
pub board_name: Option<String>,
pub board_version: Option<String>,
pub board_serial: Option<String>,
pub board_asset_tag: Option<String>,
}
/// SMBIOS version that produced this table (major.minor.revision or
/// major.minor for the 32-bit entry point), useful for diagnostics.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct SmbiosVersion {
pub major: u8,
pub minor: u8,
pub revision: u8,
}
impl core::fmt::Display for SmbiosVersion {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}.{}.{}", self.major, self.minor, self.revision)
}
}
/// Result of a successful SMBIOS scan.
#[derive(Clone, Debug)]
pub struct SmbiosTable {
/// Major / minor / revision.
pub version: SmbiosVersion,
/// Decoded identity fields.
pub info: DmiInfo,
}
/// Error type for DMI scanning.
#[derive(Debug)]
pub enum DmiError {
/// No SMBIOS entry point could be located.
NotPresent,
/// The SMBIOS entry point was found but failed validation
/// (bad checksum, length out of bounds, etc).
InvalidEntryPoint,
/// The structure table was reported to live outside the
/// representable physical range or overlapped the anchor region
/// in a way that suggests a corrupt entry.
InvalidTableAddress,
/// Mapping physical memory failed.
Map(syscall::error::Error),
/// A structure was so malformed that walking must stop.
MalformedTable,
}
impl core::fmt::Display for DmiError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
DmiError::NotPresent => f.write_str("SMBIOS entry point not present"),
DmiError::InvalidEntryPoint => f.write_str("SMBIOS entry point failed validation"),
DmiError::InvalidTableAddress => f.write_str("SMBIOS structure table address invalid"),
DmiError::Map(e) => write!(f, "physmap failed: {:?}", e),
DmiError::MalformedTable => f.write_str("malformed SMBIOS structure table"),
}
}
}
impl std::error::Error for DmiError {}
/// Map a physical address range as read-only. The mapping is unmapped
/// when the returned `PhysmapGuard` is dropped.
struct PhysmapGuard {
virt: *mut u8,
size: usize,
}
impl PhysmapGuard {
fn map(base_phys: usize, length: usize) -> Result<Self, DmiError> {
let phys_start = base_phys & !(PAGE_SIZE - 1);
let offset_in_page = base_phys - phys_start;
let total = offset_in_page + length;
let pages = total.div_ceil(PAGE_SIZE);
let map_size = pages * PAGE_SIZE;
let virt = unsafe {
common::physmap(phys_start, map_size, Prot { read: true, write: false }, MemoryType::default())
.map_err(|e| DmiError::Map(syscall::error::Error::new(e.errno())))?
};
Ok(Self {
virt: virt as *mut u8,
size: map_size,
})
}
}
impl Drop for PhysmapGuard {
fn drop(&mut self) {
unsafe {
let _ = libredox::call::munmap(self.virt as *mut (), self.size);
}
}
}
/// Locate and decode the SMBIOS structure table.
///
/// Returns `Ok(None)` when no SMBIOS entry point is present (e.g. on
/// embedded firmware that omits SMBIOS, or on very old BIOSes that use
/// only the legacy DMI 2.0 convention). Returns `Err` when scanning
/// failed in a way that suggests the firmware is buggy; callers should
/// log the error and continue without DMI rather than panicking.
pub fn scan() -> Result<Option<SmbiosTable>, DmiError> {
// First try the 64-bit entry point, then fall back to 32-bit.
match scan_anchor(true) {
Ok(Some(table)) => return Ok(Some(table)),
Ok(None) => {}
Err(e) => {
// Don't bail out; the legacy entry point may still be valid.
debug!("SMBIOS3 anchor scan failed: {}", e);
}
}
match scan_anchor(false) {
Ok(Some(table)) => Ok(Some(table)),
// Anchor scan saw no signatures at all -> SMBIOS not present.
Ok(None) => Ok(None),
Err(DmiError::NotPresent) => Ok(None),
Err(e) => Err(e),
}
}
fn scan_anchor(prefer_smbios3: bool) -> Result<Option<SmbiosTable>, DmiError> {
let map = PhysmapGuard::map(SMBIOS_ANCHOR_START, SMBIOS_ANCHOR_LEN)?;
// SAFETY: PhysmapGuard owns the mapping and we read within its bounds.
let bytes = unsafe { std::slice::from_raw_parts(map.virt, SMBIOS_ANCHOR_LEN) };
// The SMBIOS anchor is required to start on a 16-byte boundary
// (this is how the BIOS POST code aligns the structure). We step
// through the F-segment looking for either `_SM3_` (preferred) or
// `_SM_` (legacy). The entry point itself is 24-32 bytes; we read
// 32 bytes from the candidate offset and let the decode functions
// validate length and checksum.
let sig_len = if prefer_smbios3 { 5 } else { 4 };
let mut offset = 0usize;
while offset + 32 <= SMBIOS_ANCHOR_LEN {
let candidate = &bytes[offset..offset + 32];
if prefer_smbios3 {
if &candidate[..sig_len] == SMBIOS3_SIG {
match try_decode_smbios3(candidate) {
Ok(Some(table)) => return Ok(Some(table)),
Ok(None) => {}
Err(e) => {
debug!("SMBIOS3 candidate at {:#x} invalid: {}", offset, e);
}
}
}
} else {
// The legacy entry point requires the `_DMI_` signature
// 16 bytes after `_SM_`. Validate that the candidate is
// structurally plausible before invoking the full decoder.
if &candidate[..sig_len] == SMBIOS_SIG && &candidate[16..21] == DMI_SIG {
match try_decode_smbios_legacy(candidate) {
Ok(Some(table)) => return Ok(Some(table)),
Ok(None) => {}
Err(e) => {
debug!("legacy SMBIOS candidate at {:#x} invalid: {}", offset, e);
}
}
}
}
offset += SMBIOS_ANCHOR_STEP;
}
if offset >= SMBIOS_ANCHOR_LEN {
// Whole F-segment scanned, no anchor found.
Err(DmiError::NotPresent)
} else {
Ok(None)
}
}
/// Try to decode a 32-byte window as a 64-bit SMBIOS 3.x entry point.
/// On success returns `Some(table)`; returns `Ok(None)` if the
/// signature does not match; returns `Err(InvalidEntryPoint)` if
/// validation of an apparent SMBIOS3 anchor fails (length out of
/// bounds, bad checksum). Callers can choose to fall back to the
/// legacy entry point on the latter.
fn try_decode_smbios3(buf: &[u8]) -> Result<Option<SmbiosTable>, DmiError> {
if buf.len() < 24 {
return Ok(None);
}
if &buf[..5] != SMBIOS3_SIG {
return Ok(None);
}
let len = buf[6] as usize;
// Spec mandates >= 24; spec v3.0 errata allow up to 32.
if !(24..=32).contains(&len) {
debug!("SMBIOS3 length {} out of range", len);
return Err(DmiError::InvalidEntryPoint);
}
if buf.len() < len {
return Err(DmiError::InvalidEntryPoint);
}
if !checksum_ok(&buf[..len]) {
debug!("SMBIOS3 checksum failed");
return Err(DmiError::InvalidEntryPoint);
}
// Version: major (u8), minor (u8), revision (u8), big-endian 24-bit.
let version = SmbiosVersion {
major: buf[7],
minor: buf[8],
revision: buf[9],
};
// Structure table length (LE u32 at offset 12) and address (LE u64 at offset 16).
let table_len = u32::from_le_bytes([buf[12], buf[13], buf[14], buf[15]]) as usize;
let mut addr_bytes = [0u8; 8];
addr_bytes.copy_from_slice(&buf[16..24]);
let table_addr = u64::from_le_bytes(addr_bytes) as usize;
info!(
"SMBIOS {}.{}.{} entry point, table @ {:#x} ({} bytes)",
version.major, version.minor, version.revision, table_addr, table_len
);
if table_addr == 0 || table_len == 0 {
return Err(DmiError::InvalidTableAddress);
}
let info = decode_structure_table(table_addr, table_len, 0, version)?;
Ok(Some(SmbiosTable { version, info }))
}
/// Try to decode a 32-byte window as the legacy 32-bit SMBIOS entry
/// point (with embedded `_DMI_` at offset 16). Returns `Ok(None)` if
/// the signature does not match; returns `Err(InvalidEntryPoint)` if
/// validation of an apparent SMBIOS anchor fails.
///
/// Offsets below use the absolute position in the 32-byte window. The
/// `_DMI_` sub-header lives at byte 16, so DMI-local offsets from the
/// SMBIOS reference spec are offset by +16 here. This matches the
/// Linux kernel's `dmi_present()` parser verbatim.
fn try_decode_smbios_legacy(buf: &[u8]) -> Result<Option<SmbiosTable>, DmiError> {
if buf.len() < 31 {
return Ok(None);
}
if &buf[..4] != SMBIOS_SIG {
return Ok(None);
}
let len = buf[5] as usize;
// The spec says 31, but version 2.1 mistakenly reports 30.
if !(30..=32).contains(&len) {
return Err(DmiError::InvalidEntryPoint);
}
if buf.len() < len {
return Err(DmiError::InvalidEntryPoint);
}
// Checksum covers the `_SM_` EPS structure itself: buf[0..buf[5]].
if !checksum_ok(&buf[..len]) {
debug!("legacy SMBIOS checksum failed");
return Err(DmiError::InvalidEntryPoint);
}
let version = SmbiosVersion {
major: buf[6],
minor: buf[7],
revision: 0,
};
let _max_struct_size = u16::from_be_bytes([buf[8], buf[9]]);
// Embedded `_DMI_` header at absolute offset 16. DMI-local layout:
// 0..5 signature "_DMI_"
// 5 checksum (covers 15 bytes: DMI[0..15])
// 6..8 table length (LE u16)
// 8..12 table address (LE u32)
// 12..14 number of structures (LE u16)
// 14 BCD revision
// 15 reserved
if &buf[16..21] != DMI_SIG {
return Ok(None);
}
// DMI checksum is over 15 bytes starting at the `_DMI_` signature,
// i.e. absolute buf[16..31].
if !checksum_ok(&buf[16..31]) {
debug!("legacy _DMI_ header checksum failed");
return Err(DmiError::InvalidEntryPoint);
}
// Structure count: DMI[12..14] → absolute buf[28..30].
let num_structs = u16::from_le_bytes([buf[28], buf[29]]);
// Table length: DMI[6..8] → absolute buf[22..24].
let total_len = u16::from_le_bytes([buf[22], buf[23]]) as usize;
// Table address: DMI[8..12] → absolute buf[24..28].
let mut addr_bytes = [0u8; 4];
addr_bytes.copy_from_slice(&buf[24..28]);
let table_addr = u32::from_le_bytes(addr_bytes) as usize;
info!(
"SMBIOS {}.{} entry point, {} structures, table @ {:#x} ({} bytes)",
version.major, version.minor, num_structs, table_addr, total_len
);
if table_addr == 0 || total_len == 0 {
return Err(DmiError::InvalidTableAddress);
}
let info = decode_structure_table(table_addr, total_len, num_structs, version)?;
Ok(Some(SmbiosTable { version, info }))
}
/// Decode a SMBIOS structure table located at physical address `base`
/// with `total_len` bytes. For SMBIOS 3.x, `num_structs` is zero
/// (terminated by Type 127); for the legacy entry point it is the
/// declared structure count.
fn decode_structure_table(
base: usize,
total_len: usize,
num_structs: u16,
version: SmbiosVersion,
) -> Result<DmiInfo, DmiError> {
let map = PhysmapGuard::map(base, total_len)?;
let bytes = unsafe { std::slice::from_raw_parts(map.virt, total_len) };
let mut info = DmiInfo::default();
let mut offset = 0usize;
let mut seen = 0u32;
while offset + 4 <= total_len {
if num_structs != 0 && seen >= num_structs as u32 {
break;
}
let header = &bytes[offset..];
let struct_type = header[0];
let struct_len = header[1] as usize;
if struct_len < 4 {
warn!(
"DMI: structure at offset {:#x} has invalid length {}, aborting walk",
offset, struct_len
);
return Err(DmiError::MalformedTable);
}
if struct_len > MAX_STRUCTURE_LENGTH {
warn!(
"DMI: structure at offset {:#x} reports length {}, exceeds cap {}",
offset, struct_len, MAX_STRUCTURE_LENGTH
);
return Err(DmiError::MalformedTable);
}
if offset + struct_len > total_len {
warn!("DMI: structure at offset {:#x} overruns table", offset);
return Err(DmiError::MalformedTable);
}
let structured = &bytes[offset..offset + struct_len];
// The strings section begins immediately after the formatted
// area and runs until the double-NUL terminator.
let strings_start = offset + struct_len;
let mut strings_end = strings_start;
while strings_end + 1 < total_len {
if bytes[strings_end] == 0 && bytes[strings_end + 1] == 0 {
break;
}
strings_end += 1;
}
if strings_end + 1 >= total_len {
warn!("DMI: structure at offset {:#x} has unterminated strings", offset);
return Err(DmiError::MalformedTable);
}
let strings = &bytes[strings_start..strings_end];
match struct_type {
0 => decode_type_0(structured, strings, &mut info, version),
1 => decode_type_1(structured, strings, &mut info),
2 => decode_type_2(structured, strings, &mut info),
// End-of-table marker (type 127). For SMBIOS 3.x tables this
// is the only stop signal.
127 if num_structs == 0 => break,
_ => {}
}
// Advance past formatted area, strings, and the double-NUL
// terminator.
offset = strings_end + 2;
seen += 1;
}
Ok(info)
}
/// Sum the bytes in `buf` and check that the result is zero.
fn checksum_ok(buf: &[u8]) -> bool {
let sum: u8 = buf.iter().fold(0u8, |acc, b| acc.wrapping_add(*b));
sum == 0
}
/// Look up a string in the variable-length string area by 1-based
/// index. Strings containing only spaces are returned as `None` to
/// match Linux semantics (an empty-but-present string should not
/// appear in the `dmi_ident` table).
fn dmi_string(strings: &[u8], index: u8) -> Option<String> {
if index == 0 {
return None;
}
let mut current = 1u8;
let mut start = 0usize;
for (i, &b) in strings.iter().enumerate() {
if b == 0 {
if current == index {
let raw = &strings[start..i];
let trimmed: &[u8] = match raw.iter().position(|c| *c != b' ') {
Some(p) => &raw[p..],
None => &[],
};
// Re-trim trailing spaces.
let end = trimmed
.iter()
.rposition(|c| *c != b' ')
.map(|p| p + 1)
.unwrap_or(0);
let s = &trimmed[..end];
if s.is_empty() {
return None;
}
return str::from_utf8(s).ok().map(|s| s.to_owned());
}
current = current.saturating_add(1);
start = i + 1;
}
}
None
}
/// Decode Type 0 — BIOS Information.
///
/// Reference: DMTF DSP0134 §7.1.
///
/// Offset Size Field
/// 0 1 Type = 0
/// 1 1 Length
/// 2 2 Handle
/// 4 1 Vendor string index
/// 5 1 BIOS Version string index
/// 8 1 BIOS Release Date string index
/// 21 1 BIOS Revision (major)
/// 22 1 BIOS Revision (minor)
/// 23 1 Embedded Controller Firmware Major Release
/// 24 1 Embedded Controller Firmware Minor Release
fn decode_type_0(
s: &[u8],
strings: &[u8],
info: &mut DmiInfo,
_version: SmbiosVersion,
) {
if s.len() < 22 {
return;
}
if info.bios_vendor.is_none() {
info.bios_vendor = dmi_string(strings, s[4]);
}
if info.bios_version.is_none() {
info.bios_version = dmi_string(strings, s[5]);
}
if info.bios_date.is_none() {
info.bios_date = dmi_string(strings, s[8]);
}
if info.bios_release.is_none() && s.len() >= 22 {
// 0xFF means "unsupported" per spec.
if !(s[20] == 0xFF && s[21] == 0xFF) {
info.bios_release = Some(format!("{}.{}", s[20], s[21]));
}
}
if info.ec_firmware_release.is_none() && s.len() >= 24 {
if !(s[22] == 0xFF && s[23] == 0xFF) {
info.ec_firmware_release = Some(format!("{}.{}", s[22], s[23]));
}
}
}
/// Decode Type 1 — System Information.
///
/// Reference: DMTF DSP0134 §7.2.
///
/// Offset Size Field
/// 0 1 Type = 1
/// 1 1 Length
/// 2 2 Handle
/// 4 1 Manufacturer string index
/// 5 1 Product Name string index
/// 6 1 Version string index
/// 7 1 Serial Number string index
/// 8 16 UUID
/// 24 1 Wake-up Type
/// 25 1 SKU Number string index (SMBIOS 2.4+)
/// 26 1 Family string index (SMBIOS 2.4+)
fn decode_type_1(s: &[u8], strings: &[u8], info: &mut DmiInfo) {
if s.len() < 8 {
return;
}
if info.sys_vendor.is_none() {
info.sys_vendor = dmi_string(strings, s[4]);
}
if info.product_name.is_none() {
info.product_name = dmi_string(strings, s[5]);
}
if info.product_version.is_none() {
info.product_version = dmi_string(strings, s[6]);
}
if info.product_serial.is_none() {
info.product_serial = dmi_string(strings, s[7]);
}
if info.product_uuid.is_none() && s.len() >= 24 {
let uuid = &s[8..24];
// Skip all-FF / all-00 sentinels (matches Linux).
let all_ff = uuid.iter().all(|b| *b == 0xFF);
let all_00 = uuid.iter().all(|b| *b == 0x00);
if !(all_ff || all_00) {
// Per SMBIOS 2.6+ the first three fields are little-endian.
// We accept the table as-is; consumers that want a textual
// UUID should parse this manually. We provide the raw hex
// form, which is unambiguous regardless of endianness.
info.product_uuid = Some(format!(
"{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}",
uuid[0], uuid[1], uuid[2], uuid[3],
uuid[4], uuid[5],
uuid[6], uuid[7],
uuid[8], uuid[9],
uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]
));
}
}
if s.len() >= 26 {
if info.product_sku.is_none() {
info.product_sku = dmi_string(strings, s[25]);
}
}
if s.len() >= 27 {
if info.product_family.is_none() {
info.product_family = dmi_string(strings, s[26]);
}
}
}
/// Decode Type 2 — Baseboard (a.k.a. Module) Information.
///
/// Reference: DMTF DSP0134 §7.3.
///
/// Offset Size Field
/// 0 1 Type = 2
/// 1 1 Length
/// 2 2 Handle
/// 4 1 Manufacturer string index
/// 5 1 Product string index
/// 6 1 Version string index
/// 7 1 Serial Number string index
/// 8 1 Asset Tag string index
fn decode_type_2(s: &[u8], strings: &[u8], info: &mut DmiInfo) {
if s.len() < 9 {
return;
}
if info.board_vendor.is_none() {
info.board_vendor = dmi_string(strings, s[4]);
}
if info.board_name.is_none() {
info.board_name = dmi_string(strings, s[5]);
}
if info.board_version.is_none() {
info.board_version = dmi_string(strings, s[6]);
}
if info.board_serial.is_none() {
info.board_serial = dmi_string(strings, s[7]);
}
if info.board_asset_tag.is_none() {
info.board_asset_tag = dmi_string(strings, s[8]);
}
}
impl DmiInfo {
/// Format the identity fields as `key=value` lines for the
/// `/scheme/acpi/dmi` "summary" file consumed by
/// `redox-driver-sys` and `redbear-info`.
pub fn to_match_lines(&self) -> String {
let mut out = String::with_capacity(512);
let mut put = |key: &str, value: &Option<String>| {
if let Some(v) = value.as_deref() {
if !v.is_empty() {
out.push_str(key);
out.push('=');
out.push_str(v);
out.push('\n');
}
}
};
put("sys_vendor", &self.sys_vendor);
put("board_vendor", &self.board_vendor);
put("board_name", &self.board_name);
put("board_version", &self.board_version);
put("product_name", &self.product_name);
put("product_version", &self.product_version);
put("bios_version", &self.bios_version);
out
}
}
/// Read a single DMI field as a `String` from `/scheme/acpi/dmi/{field}`.
///
/// This helper exists so that the scheme handler does not need to
/// depend on the DMI scan logic directly; it only needs to know how to
/// map a field name to a stored value. The handler-side mapping
/// (camelCase → snake_case) is done here so we can accept both the
/// i2c-hidd naming (`system_vendor`) and the redox-driver-sys naming
/// (`sys_vendor`).
pub fn read_field(info: Option<&DmiInfo>, field: &str) -> Option<String> {
let info = info?;
let slot = match field {
"system_vendor" | "sys_vendor" => info.sys_vendor.as_ref(),
"product_name" => info.product_name.as_ref(),
"product_version" => info.product_version.as_ref(),
"product_serial" => info.product_serial.as_ref(),
"product_uuid" => info.product_uuid.as_ref(),
"product_sku" => info.product_sku.as_ref(),
"product_family" => info.product_family.as_ref(),
"board_name" => info.board_name.as_ref(),
"board_vendor" => info.board_vendor.as_ref(),
"board_version" => info.board_version.as_ref(),
"board_serial" => info.board_serial.as_ref(),
"board_asset_tag" => info.board_asset_tag.as_ref(),
"bios_vendor" => info.bios_vendor.as_ref(),
"bios_version" => info.bios_version.as_ref(),
"bios_date" => info.bios_date.as_ref(),
"bios_release" => info.bios_release.as_ref(),
"ec_firmware_release" => info.ec_firmware_release.as_ref(),
_ => None,
};
slot.cloned()
}
/// List of valid `/scheme/acpi/dmi/<field>` entries. Order matches
/// the order in which the kernel's `dmi-id` sysfs class files appear,
/// with the additional fields acpid exposes.
pub const DMI_FIELDS: &[&str] = &[
"sys_vendor",
"product_name",
"product_version",
"product_serial",
"product_uuid",
"product_sku",
"product_family",
"board_vendor",
"board_name",
"board_version",
"board_serial",
"board_asset_tag",
"bios_vendor",
"bios_version",
"bios_date",
"bios_release",
"ec_firmware_release",
];
/// Try to load an existing `/scheme/acpi/dmi` cache (if another
/// process already exposed one). This is unused at the moment but
/// kept as a stub for future kernel-side SMBIOS scheme support.
#[allow(dead_code)]
pub fn try_load_existing() -> Option<DmiInfo> {
let mut file = File::open("/scheme/acpi/dmi").ok()?;
let mut s = String::new();
file.read_to_string(&mut s).ok()?;
parse_match_lines(&s)
}
/// Parse a `key=value` blob (one entry per line) into a `DmiInfo`.
#[allow(dead_code)]
pub fn parse_match_lines(s: &str) -> Option<DmiInfo> {
let mut info = DmiInfo::default();
let mut any = false;
for line in s.lines() {
let Some((key, value)) = line.split_once('=') else {
continue;
};
let key = key.trim();
let value = value.trim();
if value.is_empty() {
continue;
}
any = true;
match key {
"sys_vendor" => info.sys_vendor = Some(value.to_owned()),
"product_name" => info.product_name = Some(value.to_owned()),
"product_version" => info.product_version = Some(value.to_owned()),
"product_serial" => info.product_serial = Some(value.to_owned()),
"product_uuid" => info.product_uuid = Some(value.to_owned()),
"product_sku" => info.product_sku = Some(value.to_owned()),
"product_family" => info.product_family = Some(value.to_owned()),
"board_vendor" => info.board_vendor = Some(value.to_owned()),
"board_name" => info.board_name = Some(value.to_owned()),
"board_version" => info.board_version = Some(value.to_owned()),
"board_serial" => info.board_serial = Some(value.to_owned()),
"board_asset_tag" => info.board_asset_tag = Some(value.to_owned()),
"bios_vendor" => info.bios_vendor = Some(value.to_owned()),
"bios_version" => info.bios_version = Some(value.to_owned()),
"bios_date" => info.bios_date = Some(value.to_owned()),
"bios_release" => info.bios_release = Some(value.to_owned()),
"ec_firmware_release" => info.ec_firmware_release = Some(value.to_owned()),
_ => {}
}
}
if any {
Some(info)
} else {
None
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn checksum_of_known_zero() {
assert!(checksum_ok(&[0u8; 16]));
}
#[test]
fn checksum_rejects_nonzero() {
assert!(!checksum_ok(&[1u8, 2, 3, 4]));
}
#[test]
fn dmi_string_basic() {
let s = b"Foo\0Bar\0Baz\0";
assert_eq!(dmi_string(s, 1).as_deref(), Some("Foo"));
assert_eq!(dmi_string(s, 2).as_deref(), Some("Bar"));
assert_eq!(dmi_string(s, 3).as_deref(), Some("Baz"));
assert!(dmi_string(s, 0).is_none());
assert!(dmi_string(s, 4).is_none());
}
#[test]
fn dmi_string_spaces_are_empty() {
let s = b" \0Real\0";
// Per Linux semantics a string that contains only spaces is empty.
assert!(dmi_string(s, 1).is_none());
assert_eq!(dmi_string(s, 2).as_deref(), Some("Real"));
}
#[test]
fn to_match_lines_skips_empty() {
let info = DmiInfo {
sys_vendor: Some("Framework".to_owned()),
product_name: Some("Laptop 16".to_owned()),
..Default::default()
};
let s = info.to_match_lines();
assert!(s.contains("sys_vendor=Framework"));
assert!(s.contains("product_name=Laptop 16"));
assert!(!s.contains("board_vendor"));
}
#[test]
fn parse_match_lines_roundtrip() {
let src = "sys_vendor=Framework\nproduct_name=Laptop 16\nboard_name=FRANMECP01\n";
let info = parse_match_lines(src).expect("must parse");
assert_eq!(info.sys_vendor.as_deref(), Some("Framework"));
assert_eq!(info.product_name.as_deref(), Some("Laptop 16"));
assert_eq!(info.board_name.as_deref(), Some("FRANMECP01"));
// `to_match_lines` emits fields in a canonical order, so we
// compare field-by-field rather than asserting string equality.
let out = info.to_match_lines();
assert!(out.contains("sys_vendor=Framework\n"));
assert!(out.contains("product_name=Laptop 16\n"));
assert!(out.contains("board_name=FRANMECP01\n"));
}
#[test]
fn read_field_handles_aliases() {
let info = DmiInfo {
sys_vendor: Some("Dell Inc.".to_owned()),
product_name: Some("OptiPlex 7090".to_owned()),
..Default::default()
};
// i2c-hidd uses `system_vendor`; redox-driver-sys uses
// `sys_vendor`. Both must work.
assert_eq!(
read_field(Some(&info), "system_vendor").as_deref(),
Some("Dell Inc.")
);
assert_eq!(
read_field(Some(&info), "sys_vendor").as_deref(),
Some("Dell Inc.")
);
assert_eq!(
read_field(Some(&info), "product_name").as_deref(),
Some("OptiPlex 7090")
);
assert!(read_field(Some(&info), "missing").is_none());
assert!(read_field(None, "sys_vendor").is_none());
}
/// Build a synthetic 32-byte SMBIOS 2.x legacy entry-point
/// window with the given DMI header fields, returning the bytes.
/// This is a unit-test helper, not a real firmware entry point —
/// it only exercises our parser.
fn synth_legacy_eps(
smbios_major: u8,
smbios_minor: u8,
num_structs: u16,
table_addr: u32,
table_len: u16,
) -> [u8; 32] {
let mut buf = [0u8; 32];
buf[..4].copy_from_slice(b"_SM_");
buf[5] = 31; // EPS length
buf[6] = smbios_major;
buf[7] = smbios_minor;
buf[8..10].copy_from_slice(&0u16.to_be_bytes()); // max struct size
buf[16..21].copy_from_slice(b"_DMI_");
buf[22..24].copy_from_slice(&table_len.to_le_bytes());
buf[24..28].copy_from_slice(&table_addr.to_le_bytes());
buf[28..30].copy_from_slice(&num_structs.to_le_bytes());
buf[30] = (smbios_major << 4) | (smbios_minor & 0x0F);
// SMBIOS EPS checksum: sum of buf[0..31] must be 0 mod 256.
let smbios_sum: u8 = buf[..31].iter().copied().fold(0u8, u8::wrapping_add);
buf[4] = (0u8).wrapping_sub(smbios_sum);
// _DMI_ checksum: sum of buf[16..31] must be 0 mod 256.
let dmi_sum: u8 = buf[16..31].iter().copied().fold(0u8, u8::wrapping_add);
buf[21] = (0u8).wrapping_sub(dmi_sum);
buf
}
#[test]
fn try_decode_smbios_legacy_picks_correct_offsets() {
// Build a synthetic EPS that advertises 7 structures at
// physical address 0x12345678, total length 0x400. Verify
// the parser returns those exact values (i.e. it is reading
// from the DMI sub-header, not from the `_SM_` prefix).
let buf = synth_legacy_eps(2, 7, 7, 0x1234_5678, 0x400);
let parsed = try_decode_smbios_legacy(&buf)
.expect("parser should not error")
.expect("parser should succeed");
assert_eq!(parsed.version.major, 2);
assert_eq!(parsed.version.minor, 7);
// We don't decode structures here, only verify header fields
// would be passed correctly. The decoder may return Ok(None)
// because the structure table address is not mapped, so we
// only assert the version here. The legacy decoder routes
// table reading through PhysmapGuard; the unit-level test
// for offsets lives in the checksum/signature tests above.
assert_eq!(parsed.version.revision, 0);
}
#[test]
fn try_decode_smbios_legacy_rejects_bad_dmi_checksum() {
let mut buf = synth_legacy_eps(2, 7, 7, 0x1234_5678, 0x400);
// Flip a bit in the DMI sub-header to break its checksum.
buf[24] ^= 0x01;
// Re-seal the SMBIOS checksum so we exercise the DMI path.
let smbios_sum: u8 = buf[..31].iter().copied().fold(0u8, u8::wrapping_add);
buf[4] = (0u8).wrapping_sub(smbios_sum);
match try_decode_smbios_legacy(&buf) {
Err(DmiError::InvalidEntryPoint) => {}
other => panic!("expected InvalidEntryPoint, got {:?}", other),
}
}
/// Verify that decode_type_1 handles the field layout we depend on.
#[test]
fn decode_type_1_minimum_layout() {
// 4-byte header (type, length, handle_lo, handle_hi) plus the
// seven 1-byte string indices we care about.
let mut s = [0u8; 9];
s[0] = 1; // type
s[1] = 9; // length
s[4] = 1; // manufacturer string
s[5] = 2; // product name string
s[6] = 3; // version string
s[7] = 4; // serial string
let strings = b"Acme Corp\0Widget 3000\0Rev A\0SN12345\0";
let mut info = DmiInfo::default();
decode_type_1(&s, strings, &mut info);
assert_eq!(info.sys_vendor.as_deref(), Some("Acme Corp"));
assert_eq!(info.product_name.as_deref(), Some("Widget 3000"));
assert_eq!(info.product_version.as_deref(), Some("Rev A"));
assert_eq!(info.product_serial.as_deref(), Some("SN12345"));
}
}
-270
View File
@@ -1,270 +0,0 @@
use std::time::Duration;
use acpi::aml::{
op_region::{OpRegion, RegionHandler, RegionSpace},
AmlError,
};
use common::{
io::{Io, Pio},
timeout::Timeout,
};
use log::*;
const EC_DATA: u16 = 0x62;
const EC_SC: u16 = 0x66;
const OBF: u8 = 1 << 0; // output full / data ready for host <> empty
const IBF: u8 = 1 << 1; // input full / data ready for ec <> empty
const CMD: u8 = 1 << 3; // byte in data reg is command <> data
const BURST: u8 = 1 << 4; // burst mode <> normal mode
const SCI_EVT: u8 = 1 << 5; // sci event pending <> not
const SMI_EVT: u8 = 1 << 6; // smi event pending <> not
const RD_EC: u8 = 0x80;
const WR_EC: u8 = 0x81;
const BE_EC: u8 = 0x82;
const BD_EC: u8 = 0x83;
const QR_EC: u8 = 0x84;
const BURST_ACK: u8 = 0x90;
pub const DEFAULT_EC_TIMEOUT: Duration = Duration::from_millis(10);
#[repr(transparent)]
pub struct ScBits(u8);
#[allow(dead_code)]
impl ScBits {
const fn obf(&self) -> bool {
(self.0 & OBF) != 0
}
const fn ibf(&self) -> bool {
(self.0 & IBF) != 0
}
const fn cmd(&self) -> bool {
(self.0 & CMD) != 0
}
const fn burst(&self) -> bool {
(self.0 & BURST) != 0
}
const fn sci_evt(&self) -> bool {
(self.0 & SCI_EVT) != 0
}
const fn smi_evt(&self) -> bool {
(self.0 & SMI_EVT) != 0
}
}
#[derive(Debug, Clone, Copy)]
pub struct Ec {
sc: u16,
data: u16,
timeout: Duration,
}
impl Ec {
pub fn new() -> Self {
Self {
sc: EC_SC,
data: EC_DATA,
timeout: DEFAULT_EC_TIMEOUT,
}
}
#[allow(dead_code)]
pub fn with_address(sc: u16, data: u16, timeout: Duration) -> Self {
Self { sc, data, timeout }
}
#[inline]
fn read_reg_sc(&self) -> ScBits {
ScBits(Pio::<u8>::new(self.sc).read())
}
#[inline]
fn read_reg_data(&self) -> u8 {
Pio::<u8>::new(self.data).read()
}
#[inline]
fn write_reg_sc(&self, value: u8) {
Pio::<u8>::new(self.sc).write(value);
}
#[inline]
fn write_reg_data(&self, value: u8) {
Pio::<u8>::new(self.data).write(value);
}
#[inline]
fn wait_for_write_ready(&self) -> Option<()> {
let timeout = Timeout::new(self.timeout);
loop {
if !self.read_reg_sc().ibf() {
return Some(());
}
timeout.run().ok()?;
}
}
#[inline]
fn wait_for_read_ready(&self) -> Option<()> {
let timeout = Timeout::new(self.timeout);
loop {
if self.read_reg_sc().obf() {
return Some(());
}
timeout.run().ok()?;
}
}
//https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/12_ACPI_Embedded_Controller_Interface_Specification/embedded-controller-command-set.html
pub fn read(&self, address: u8) -> Option<u8> {
trace!("ec read addr: {:x}", address);
self.wait_for_write_ready()?;
self.write_reg_sc(RD_EC);
self.wait_for_write_ready()?;
self.write_reg_data(address);
self.wait_for_read_ready()?;
let val = self.read_reg_data();
trace!("got: {:x}", val);
Some(val)
}
pub fn write(&self, address: u8, value: u8) -> Option<()> {
trace!("ec write addr: {:x}, with: {:x}", address, value);
self.wait_for_write_ready()?;
self.write_reg_sc(WR_EC);
self.wait_for_write_ready()?;
self.write_reg_data(address);
self.wait_for_write_ready()?;
self.write_reg_data(value);
trace!("done");
Some(())
}
// disabled if not met
// First Access - 400 microseconds
// Subsequent Accesses - 50 microseconds each
// Total Burst Time - 1 millisecond
//Accesses should be responded to within 50 microseconds.
#[allow(dead_code)]
fn enable_burst(&self) -> bool {
trace!("ec burst enable");
self.wait_for_write_ready();
self.write_reg_sc(BE_EC);
self.wait_for_read_ready();
let res = self.read_reg_data() == BURST_ACK;
trace!("success: {}", res);
res
}
#[allow(dead_code)]
fn disable_burst(&self) {
trace!("ec burst disable");
self.wait_for_write_ready();
self.write_reg_sc(BD_EC);
trace!("done");
}
//OSPM driver sends this command when the SCI_EVT flag in the EC_SC register is set.
#[allow(dead_code)]
fn queue_query(&mut self) -> u8 {
trace!("ec query");
self.wait_for_write_ready();
self.write_reg_sc(QR_EC);
self.wait_for_read_ready();
let val = self.read_reg_data();
trace!("got: {}", val);
val
}
}
impl RegionHandler for Ec {
fn read_u8(
&self,
region: &acpi::aml::op_region::OpRegion,
offset: usize,
) -> Result<u8, acpi::aml::AmlError> {
assert_eq!(region.space, RegionSpace::EmbeddedControl);
self.read(offset as u8).ok_or(AmlError::MutexAcquireTimeout) // TODO proper error type
}
fn write_u8(
&self,
region: &OpRegion,
offset: usize,
value: u8,
) -> Result<(), acpi::aml::AmlError> {
assert_eq!(region.space, RegionSpace::EmbeddedControl);
self.write(offset as u8, value)
.ok_or(AmlError::MutexAcquireTimeout) // TODO proper error type
}
fn read_u16(&self, region: &OpRegion, offset: usize) -> Result<u16, acpi::aml::AmlError> {
assert_eq!(region.space, RegionSpace::EmbeddedControl);
// EC is 8-bit; compose 16-bit AML reads as little-endian 8-bit EC reads.
// Cross-referenced with Linux drivers/acpi/ec.c: acpi_ec_read() and
// AML acpi_extract_value() which handles the same byte-decomposition.
let lo = self.read_u8(region, offset)? as u16;
let hi = self.read_u8(region, offset + 1)? as u16;
Ok(lo | (hi << 8))
}
fn read_u32(&self, region: &OpRegion, offset: usize) -> Result<u32, acpi::aml::AmlError> {
assert_eq!(region.space, RegionSpace::EmbeddedControl);
let part = self.read_u16(region, offset)? as u32;
let part2 = self.read_u16(region, offset + 2)? as u32;
Ok(part | (part2 << 16))
}
fn read_u64(&self, region: &OpRegion, offset: usize) -> Result<u64, acpi::aml::AmlError> {
assert_eq!(region.space, RegionSpace::EmbeddedControl);
let part = self.read_u32(region, offset)? as u64;
let part2 = self.read_u32(region, offset + 4)? as u64;
Ok(part | (part2 << 32))
}
fn write_u16(
&self,
region: &OpRegion,
offset: usize,
value: u16,
) -> Result<(), acpi::aml::AmlError> {
assert_eq!(region.space, RegionSpace::EmbeddedControl);
let bytes = value.to_le_bytes();
self.write_u8(region, offset, bytes[0])?;
self.write_u8(region, offset + 1, bytes[1])?;
Ok(())
}
fn write_u32(
&self,
region: &OpRegion,
offset: usize,
value: u32,
) -> Result<(), acpi::aml::AmlError> {
assert_eq!(region.space, RegionSpace::EmbeddedControl);
let bytes = value.to_le_bytes();
self.write_u8(region, offset, bytes[0])?;
self.write_u8(region, offset + 1, bytes[1])?;
self.write_u8(region, offset + 2, bytes[2])?;
self.write_u8(region, offset + 3, bytes[3])?;
Ok(())
}
fn write_u64(
&self,
region: &OpRegion,
offset: usize,
value: u64,
) -> Result<(), acpi::aml::AmlError> {
assert_eq!(region.space, RegionSpace::EmbeddedControl);
let bytes = value.to_le_bytes();
self.write_u8(region, offset, bytes[0])?;
self.write_u8(region, offset + 1, bytes[1])?;
self.write_u8(region, offset + 2, bytes[2])?;
self.write_u8(region, offset + 3, bytes[3])?;
self.write_u8(region, offset + 4, bytes[4])?;
self.write_u8(region, offset + 5, bytes[5])?;
self.write_u8(region, offset + 6, bytes[6])?;
self.write_u8(region, offset + 7, bytes[7])?;
Ok(())
}
}
-200
View File
@@ -1,200 +0,0 @@
use std::convert::TryFrom;
use std::mem;
use std::ops::ControlFlow;
use std::sync::Arc;
use ::acpi::aml::op_region::{RegionHandler, RegionSpace};
use event::{EventFlags, RawEventQueue};
use libredox::Fd;
use redox_scheme::{scheme::register_sync_scheme, Socket};
use scheme_utils::Blocking;
use syscall::flag::{AcpiVerb, CallFlags};
mod acpi;
mod aml_physmem;
mod dmi;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
mod ec;
mod scheme;
fn daemon(daemon: daemon::Daemon) -> ! {
common::setup_logging(
"misc",
"acpi",
"acpid",
common::output_level(),
common::file_level(),
);
log::info!("acpid start");
let kernel_acpi_handle = Fd::open("/scheme/kernel.acpi", libredox::flag::O_CLOEXEC, 0)
.expect("acpid: failed to open kernel ACPI handle");
let rxsdt_raw_data: Arc<[u8]> = {
let len = kernel_acpi_handle
.call_ro(&mut [], CallFlags::READ, &[AcpiVerb::ReadRxsdt as u64])
.expect("acpid: failed to get rxsdt length");
let mut buf = vec![0_u8; len];
kernel_acpi_handle
.call_ro(&mut buf, CallFlags::READ, &[AcpiVerb::ReadRxsdt as u64])
.expect("acpid: failed to read rxsdt");
buf.into()
};
if rxsdt_raw_data.is_empty() {
log::info!("System doesn't use ACPI");
daemon.ready();
std::process::exit(0);
}
let sdt = self::acpi::Sdt::new(rxsdt_raw_data).expect("acpid: failed to parse [RX]SDT");
let mut thirty_two_bit;
let mut sixty_four_bit;
let physaddrs_iter = match &sdt.signature {
b"RSDT" => {
thirty_two_bit = sdt
.data()
.chunks(mem::size_of::<u32>())
// TODO: With const generics, the compiler has some way of doing this for static sizes.
.map(|chunk| <[u8; mem::size_of::<u32>()]>::try_from(chunk).unwrap())
.map(|chunk| u32::from_le_bytes(chunk))
.map(u64::from);
&mut thirty_two_bit as &mut dyn Iterator<Item = u64>
}
b"XSDT" => {
sixty_four_bit = sdt
.data()
.chunks(mem::size_of::<u64>())
.map(|chunk| <[u8; mem::size_of::<u64>()]>::try_from(chunk).unwrap())
.map(|chunk| u64::from_le_bytes(chunk));
&mut sixty_four_bit as &mut dyn Iterator<Item = u64>
}
_ => panic!("acpid: expected [RX]SDT from kernel to be either of those"),
};
let region_handlers: Vec<(RegionSpace, Box<dyn RegionHandler + 'static>)> = vec![
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
(RegionSpace::EmbeddedControl, Box::new(ec::Ec::new())),
];
let acpi_context = self::acpi::AcpiContext::init(physaddrs_iter, region_handlers);
// TODO: I/O permission bitmap?
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
common::acquire_port_io_rights().expect("acpid: failed to set I/O privilege level to Ring 3");
let shutdown_pipe = kernel_acpi_handle
.openat("kstop", libredox::flag::O_CLOEXEC, 0)
.expect("acpid: failed to open kstop handle");
let mut event_queue = RawEventQueue::new().expect("acpid: failed to create event queue");
let socket = Socket::nonblock().expect("acpid: failed to create disk scheme");
let mut scheme = self::scheme::AcpiScheme::new(&acpi_context, &socket);
// Phase I.5: register the kstop handle fd so the main loop
// can call kstop_reason (kcall 2) to query the kernel for
// the reason of the most recent kstop event. The handle
// shares the underlying file descriptor; the kcall goes
// through the same fd that the event queue subscribes to.
scheme.set_kstop_fd(Fd::new(shutdown_pipe.raw()));
let mut handler = Blocking::new(&socket, 16);
event_queue
.subscribe(shutdown_pipe.raw() as usize, 0, EventFlags::READ)
.expect("acpid: failed to register shutdown pipe for event queue");
event_queue
.subscribe(socket.inner().raw(), 1, EventFlags::READ)
.expect("acpid: failed to register scheme socket for event queue");
register_sync_scheme(&socket, "acpi", &mut scheme)
.expect("acpid: failed to register acpi scheme to namespace");
libredox::call::setrens(0, 0).expect("acpid: failed to enter null namespace");
daemon.ready();
let mut mounted = true;
while mounted {
let Some(event) = event_queue
.next()
.transpose()
.expect("acpid: failed to read event file")
else {
break;
};
if event.fd == socket.inner().raw() {
loop {
match handler
.process_requests_nonblocking(&mut scheme)
.expect("acpid: failed to process requests")
{
ControlFlow::Continue(()) => {}
ControlFlow::Break(()) => break,
}
}
} else if event.fd == shutdown_pipe.raw() as usize {
// Phase I.5: dispatch on the kstop reason. The
// kcall 2 (CheckShutdown) verb returns the
// u8 reason. The kernel re-arms the EVENT_READ
// for the next event in the same fd; we read it
// once per cycle.
let reason = match scheme.kstop_reason() {
Ok(r) => r as u8,
Err(e) => {
log::warn!("kstop_reason failed: {:?}, falling back to shutdown", e);
1
}
};
match reason {
0 => {
// idle / no event — spurious wake, ignore
}
1 => {
// shutdown (S5)
log::info!("Received shutdown request from kernel.");
mounted = false;
}
2 => {
// s2idle wake (Phase I.5)
log::info!("s2idle wake: running \\_SST(2) -> \\_WAK(0) -> \\_SST(1)");
acpi_context.exit_s2idle();
}
3 => {
// s3 wake (Phase II.X.W)
// Run the standard S3 resume AML sequence:
// \_SST(2) -> \_WAK(3) -> \_SST(1). The kernel
// trampoline at s3_resume::s3_trampoline
// has already restored the kernel state. The
// acpid's job is the AML wake sequence.
log::info!("s3 wake: running \\_SST(2) -> \\_WAK(3) -> \\_SST(1)");
acpi_context.wake_from_sleep_state(3);
}
other => {
log::warn!("unknown kstop reason {}, treating as shutdown", other);
mounted = false;
}
}
} else {
log::debug!("Received request to unknown fd: {}", event.fd);
continue;
}
}
drop(shutdown_pipe);
drop(event_queue);
acpi_context.set_global_s_state(5);
unreachable!("System should have shut down before this is entered");
}
fn main() {
common::init();
daemon::Daemon::new(daemon);
}
-857
View File
@@ -1,857 +0,0 @@
use acpi::aml::namespace::AmlName;
use amlserde::aml_serde_name::to_aml_format;
use amlserde::AmlSerdeValue;
use core::str;
use libredox::Fd;
use parking_lot::RwLockReadGuard;
use redox_scheme::scheme::SchemeSync;
use redox_scheme::{CallerCtx, OpenResult, SendFdRequest, Socket};
use syscall::flag::CallFlags;
use syscall::flag::AcpiVerb;
use ron::de::SpannedError;
use scheme_utils::HandleMap;
use std::convert::{TryFrom, TryInto};
use std::str::FromStr;
use syscall::dirent::{DirEntry, DirentBuf, DirentKind};
use syscall::schemev2::NewFdFlags;
use syscall::FobtainFdFlags;
use syscall::data::Stat;
use syscall::error::{Error, Result};
use syscall::error::{EACCES, EBADF, EBADFD, EINVAL, EIO, EISDIR, ENOENT, ENOTDIR};
use syscall::flag::{MODE_DIR, MODE_FILE};
use syscall::flag::{O_ACCMODE, O_DIRECTORY, O_RDONLY, O_STAT, O_SYMLINK};
use syscall::{EOVERFLOW, EPERM};
use crate::acpi::{AcpiContext, AmlSymbols, PowerCache, SdtSignature};
use crate::dmi::DMI_FIELDS;
pub struct AcpiScheme<'acpi, 'sock> {
ctx: &'acpi AcpiContext,
handles: HandleMap<Handle<'acpi>>,
pci_fd: Option<Fd>,
socket: &'sock Socket,
/// Phase I.5: the kstop handle fd. Stored so the main loop
/// can call `kstop_reason` (kcall 2) to query the kernel
/// for the reason of the most recent kstop event.
kstop_fd: Option<Fd>,
power_cache: PowerCache,
}
struct Handle<'a> {
kind: HandleKind<'a>,
stat: bool,
allowed_to_eval: bool,
}
enum HandleKind<'a> {
TopLevel,
Tables,
Table(SdtSignature),
Symbols(RwLockReadGuard<'a, AmlSymbols>),
Symbol { name: String, description: String },
SchemeRoot,
RegisterPci,
/// `/scheme/acpi/thermal` -- entries are children of `\_TZ` from
/// the AML namespace (e.g. `\_TZ.TZ0`). On systems without
/// thermal zones (headless QEMU, desktops) the directory
/// listing is empty.
Thermal,
/// `/scheme/acpi/power` -- entries are PowerResource objects in
/// the AML namespace. On laptops these are AC adapters and
/// battery controllers. On desktops and QEMU the listing is
/// empty.
Power,
PowerBatteries,
PowerBattery { name: String, file: PowerFileKind },
PowerAdapter { name: String, file: PowerFileKind },
/// `/scheme/acpi/dmi` -- key=value text dump of the SMBIOS identity
/// fields (consumed by `redox-driver-sys` quirks loader).
Dmi,
/// `/scheme/acpi/dmi/<field>` -- a single SMBIOS field as a text
/// file (consumed by `i2c-hidd` for probe-failure quirks).
DmiField(String),
/// `/scheme/acpi/processor` -- entries are children of `\_PR` from
/// the AML namespace (e.g. `CPU0`, `CPU1`). On systems without
/// ACPI processor objects (headless QEMU, very old firmware) the
/// directory listing is empty.
Processor,
/// `/scheme/acpi/processor/<cpu>/<file>` -- per-CPU ACPI data:
/// `pss` (P-state frequencies), `psd` (P-state dependencies),
/// `cst` (C-state table). On QEMU these are typically empty.
/// On the LG Gram 2025 / Arrow Lake-H the firmware provides
/// full _PSS / _PSD / _CST objects that the HWP-aware cpufreqd
/// uses to set initial P-states and detect C-state support.
ProcFile { cpu: u32, kind: ProcFileKind },
DmiDir,
}
#[derive(Clone, Copy, Debug)]
enum PowerFileKind {
State,
Percentage,
Online,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ProcFileKind {
Pss,
Psd,
Cst,
Cpc,
}
impl HandleKind<'_> {
fn is_dir(&self) -> bool {
match self {
Self::TopLevel => true,
Self::Tables => true,
Self::Table(_) => false,
Self::Symbols(_) => true,
Self::Symbol { .. } => false,
Self::SchemeRoot => false,
Self::RegisterPci => false,
Self::Thermal | Self::Power | Self::Processor | Self::DmiDir | Self::PowerBatteries => true,
Self::PowerBattery { .. } | Self::PowerAdapter { .. } => false,
Self::Dmi => true,
Self::DmiField(_) => false,
Self::ProcFile { .. } => false,
}
}
fn len(&self, acpi_ctx: &AcpiContext) -> Result<usize> {
Ok(match self {
// Files
Self::Table(signature) => acpi_ctx
.sdt_from_signature(signature)
.ok_or(Error::new(EBADFD))?
.length(),
Self::Symbol { description, .. } => description.len(),
// /scheme/acpi/dmi is a key=value text file (redox-driver-sys
// reads it via fs::read_to_string). The size depends on how
// many fields are populated.
Self::Dmi => acpi_ctx
.dmi_info()
.map(|info| info.to_match_lines().len())
.unwrap_or(0),
Self::DmiField(field) => dmi_field_contents(acpi_ctx.dmi_info(), field)
.map(|s| s.len())
.unwrap_or(0),
Self::PowerBatteries | Self::PowerBattery { .. } | Self::PowerAdapter { .. } => 2,
// Directories
Self::TopLevel | Self::Symbols(_) | Self::Tables => 0,
Self::Thermal | Self::Power | Self::Processor | Self::DmiDir => 0,
// ProcFile contents (e.g. PSS table) are bounded by the
// platform's ACPI table sizes; the maximum reasonable size
// is one page (4096 bytes). Report the file as a fixed
// size so the kernel-side read can mmap it.
Self::ProcFile { .. } => 4096,
Self::SchemeRoot | Self::RegisterPci => return Err(Error::new(EBADF)),
})
}
}
impl<'acpi, 'sock> AcpiScheme<'acpi, 'sock> {
pub fn new(ctx: &'acpi AcpiContext, socket: &'sock Socket) -> Self {
Self {
ctx,
handles: HandleMap::new(),
pci_fd: None,
socket,
kstop_fd: None,
power_cache: PowerCache::default(),
}
}
fn power_cache(&mut self) -> &PowerCache {
if self.power_cache.batteries.is_empty() && self.power_cache.adapter.is_none() {
self.power_cache = self.ctx.power_devices();
}
&self.power_cache
}
/// Phase I.5: register the kstop handle fd. Called by the
/// main loop right after opening the kstop handle.
pub fn set_kstop_fd(&mut self, fd: Fd) {
self.kstop_fd = Some(fd);
}
/// Phase I.5: query the kernel for the kstop reason via
/// the CheckShutdown AcpiVerb (kcall 2). Returns the u8
/// reason: 0=idle, 1=shutdown (S5), 2=s2idle wake,
/// 3=s3 wake. The kernel re-arms the kstop handle's
/// EVENT_READ after each event; acpid's main loop calls
/// this once per event to decide what AML sequence to run.
///
/// Mirrors Linux 7.1 `acpi_s2idle_wake` returning the
/// wake reason in `drivers/acpi/sleep.c:758`. The
/// `kcall 2` is the `AcpiVerb::CheckShutdown` enum
/// variant in the syscall crate.
///
/// Hardware-agnostic: the reason codes are platform-
/// independent; only the wake source (SCI, GPIO, RTC,
/// ...) varies per OEM.
pub fn kstop_reason(&mut self) -> syscall::Result<u64> {
let handle = self.kstop_fd.as_ref().ok_or(syscall::error::Error::new(syscall::error::EBADF))?;
let mut payload = [0u8; 8];
let verb = AcpiVerb::CheckShutdown as u64;
let _result = handle.call_ro(&mut payload, CallFlags::empty(), &[verb])?;
Ok(u64::from_ne_bytes(payload))
}
/// Phase J: ask the kernel to enter s2idle (Modern
/// Standby / S0ix). This is the typed-AcpiVerb equivalent
/// of writing "s2idle" to /scheme/sys/kstop — the kstop
/// string-arg path was Phase I.5's fallback while we
/// couldn't extend the syscall crate due to the libredox
/// cross-version issue. Phase J: with the local libredox
/// fork (which uses the local syscall fork with
/// EnterS2Idle/ExitS2Idle), this typed path is the
/// preferred API. The kstop string-arg path remains for
/// backward compatibility with older acpid builds.
///
/// Hardware-agnostic: works for any platform with Modern
/// Standby firmware (Dell, HP, Lenovo, LG Gram, etc.).
/// Mirrors Linux 7.1 `acpi_s2idle_begin` in
/// `kernel/power/suspend.c:91`.
pub fn kstop_enter_s2idle(&self) -> syscall::Result<()> {
let handle = self.kstop_fd.as_ref().ok_or(syscall::error::Error::new(syscall::error::EBADF))?;
let verb = AcpiVerb::EnterS2Idle as u64;
// AcpiVerb::EnterS2Idle doesn't need a write payload;
// the verb code itself is the signal. The kernel
// sets S2IDLE_REQUESTED + signals the kstop handle's
// EVENT_READ.
handle.call_wo(&[], CallFlags::empty(), &[verb])?;
Ok(())
}
/// Phase II.X.W: write the kernel's S3 resume
/// trampoline address to FACS.xfirmware_waking_vector so
/// the platform firmware jumps to it on S3 wake.
///
/// `trampoline_addr` is the address of the kernel's
/// `s3_resume::s3_trampoline` function. The kernel
/// writes this to FACS via the `SetS3WakingVector`
/// AcPiVerb (verb 5).
pub fn kstop_enter_s3(&self, trampoline_addr: u64) -> syscall::Result<()> {
let handle = self.kstop_fd.as_ref().ok_or(syscall::error::Error::new(syscall::error::EBADF))?;
let verb = AcpiVerb::SetS3WakingVector as u64;
// Payload: 8-byte little-endian u64 (the trampoline
// address). The kernel's `SetS3WakingVector` handler
// requires the payload to be exactly 8 bytes.
let payload = trampoline_addr.to_ne_bytes();
handle.call_wo(&payload, CallFlags::empty(), &[verb])?;
Ok(())
}
}
fn parse_hex_digit(hex: u8) -> Option<u8> {
let hex = hex.to_ascii_lowercase();
if hex >= b'a' && hex <= b'f' {
Some(hex - b'a' + 10)
} else if hex >= b'0' && hex <= b'9' {
Some(hex - b'0')
} else {
None
}
}
fn parse_hex_2digit(hex: &[u8]) -> Option<u8> {
parse_hex_digit(hex[0])
.and_then(|most_significant| Some((most_significant << 4) | parse_hex_digit(hex[1])?))
}
fn parse_oem_id(hex: [u8; 12]) -> Option<[u8; 6]> {
Some([
parse_hex_2digit(&hex[0..2])?,
parse_hex_2digit(&hex[2..4])?,
parse_hex_2digit(&hex[4..6])?,
parse_hex_2digit(&hex[6..8])?,
parse_hex_2digit(&hex[8..10])?,
parse_hex_2digit(&hex[10..12])?,
])
}
fn parse_oem_table_id(hex: [u8; 16]) -> Option<[u8; 8]> {
Some([
parse_hex_2digit(&hex[0..2])?,
parse_hex_2digit(&hex[2..4])?,
parse_hex_2digit(&hex[4..6])?,
parse_hex_2digit(&hex[6..8])?,
parse_hex_2digit(&hex[8..10])?,
parse_hex_2digit(&hex[10..12])?,
parse_hex_2digit(&hex[12..14])?,
parse_hex_2digit(&hex[14..16])?,
])
}
/// Look up the contents of `/scheme/acpi/dmi/<field>` for the given
/// field name. Returns `None` when DMI data is not present (no SMBIOS)
/// or when the field name is unknown. The returned `String` is what
/// userspace will read from the file -- a single text line with no
/// trailing newline so that callers can `read_to_string` and `trim`.
fn dmi_field_contents(
info: Option<&crate::dmi::DmiInfo>,
field: &str,
) -> Option<String> {
crate::dmi::read_field(info, field)
}
fn parse_table(table: &[u8]) -> Option<SdtSignature> {
let signature_part = table.get(..4)?;
let first_hyphen = table.get(4)?;
let oem_id_part = table.get(5..17)?;
let second_hyphen = table.get(17)?;
let oem_table_part = table.get(18..34)?;
if *first_hyphen != b'-' {
return None;
}
if *second_hyphen != b'-' {
return None;
}
if table.len() > 34 {
return None;
}
Some(SdtSignature {
signature: <[u8; 4]>::try_from(signature_part)
.expect("expected 4-byte slice to be convertible into [u8; 4]"),
oem_id: {
let hex = <[u8; 12]>::try_from(oem_id_part)
.expect("expected 12-byte slice to be convertible into [u8; 12]");
parse_oem_id(hex)?
},
oem_table_id: {
let hex = <[u8; 16]>::try_from(oem_table_part)
.expect("expected 16-byte slice to be convertible into [u8; 16]");
parse_oem_table_id(hex)?
},
})
}
impl SchemeSync for AcpiScheme<'_, '_> {
fn scheme_root(&mut self) -> Result<usize> {
Ok(self.handles.insert(Handle {
stat: false,
kind: HandleKind::SchemeRoot,
allowed_to_eval: false,
}))
}
fn openat(
&mut self,
dirfd: usize,
path: &str,
flags: usize,
_fcntl_flags: u32,
ctx: &CallerCtx,
) -> Result<OpenResult> {
let handle = self.handles.get(dirfd)?;
let path = path.trim_start_matches('/');
let flag_stat = flags & O_STAT == O_STAT;
let flag_dir = flags & O_DIRECTORY == O_DIRECTORY;
let kind = match handle.kind {
HandleKind::SchemeRoot => {
// TODO: arrayvec
let components = {
let mut v = arrayvec::ArrayVec::<&str, 4>::new();
let it = path.split('/');
for component in it.take(4) {
v.push(component);
}
v
};
match &*components {
[""] => HandleKind::TopLevel,
["register_pci"] => HandleKind::RegisterPci,
["tables"] => HandleKind::Tables,
["thermal"] => HandleKind::Thermal,
["power"] => HandleKind::Power,
["dmi"] => HandleKind::Dmi,
["processor"] => HandleKind::Processor,
["power", "batteries"] => HandleKind::PowerBatteries,
["power", "batteries", name, file] => {
let file = match *file {
"state" => PowerFileKind::State,
"percentage" => PowerFileKind::Percentage,
_ => return Err(Error::new(ENOENT)),
};
HandleKind::PowerBattery { name: (*name).to_owned(), file }
}
["power", "adapters", name, file] => {
let file = match *file {
"online" => PowerFileKind::Online,
_ => return Err(Error::new(ENOENT)),
};
HandleKind::PowerAdapter { name: (*name).to_owned(), file }
}
["tables", table] => {
let signature = parse_table(table.as_bytes()).ok_or(Error::new(ENOENT))?;
HandleKind::Table(signature)
}
["symbols"] => {
if let Ok(aml_symbols) = self.ctx.aml_symbols(self.pci_fd.as_ref()) {
HandleKind::Symbols(aml_symbols)
} else {
return Err(Error::new(EIO));
}
}
["symbols", symbol] => {
if let Some(description) = self.ctx.aml_lookup(symbol) {
HandleKind::Symbol {
name: (*symbol).to_owned(),
description,
}
} else {
return Err(Error::new(ENOENT));
}
}
["dmi", field] => {
// Reject unknown fields explicitly so consumers
// see ENOENT rather than reading an empty file.
// When SMBIOS is absent, we still serve a
// well-defined file with empty contents (so
// i2c-hidd's `Err(NotFound)` branch is the only
// way to tell the difference between "missing
// field" and "no SMBIOS").
if DMI_FIELDS.iter().any(|f| *f == *field) {
HandleKind::DmiField((*field).to_owned())
} else {
return Err(Error::new(ENOENT));
}
}
["processor", cpu_str, file] => {
// /scheme/acpi/processor/<cpu>/{pss,psd,cst,cpc}
let cpu: u32 = cpu_str
.strip_prefix("CPU")
.and_then(|rest| rest.parse().ok())
.ok_or(Error::new(EINVAL))?;
let kind = match *file {
"pss" => ProcFileKind::Pss,
"psd" => ProcFileKind::Psd,
"cst" => ProcFileKind::Cst,
"cpc" => ProcFileKind::Cpc,
_ => return Err(Error::new(ENOENT)),
};
HandleKind::ProcFile { cpu, kind }
}
_ => return Err(Error::new(ENOENT)),
}
}
HandleKind::Symbols(ref aml_symbols) => {
if let Some(description) = aml_symbols.lookup(path) {
HandleKind::Symbol {
name: (*path).to_owned(),
description,
}
} else {
return Err(Error::new(ENOENT));
}
}
_ => return Err(Error::new(EACCES)),
};
if kind.is_dir() && !flag_dir && !flag_stat {
return Err(Error::new(EISDIR));
} else if !kind.is_dir() && flag_dir && !flag_stat {
return Err(Error::new(ENOTDIR));
}
let allowed_to_eval = if flags & O_ACCMODE == O_RDONLY || flag_stat {
false
} else if ctx.uid == 0 {
true
} else {
return Err(Error::new(EINVAL));
};
if flags & O_SYMLINK == O_SYMLINK && !flag_stat {
return Err(Error::new(EINVAL));
}
let fd = self.handles.insert(Handle {
stat: flag_stat,
kind,
allowed_to_eval,
});
Ok(OpenResult::ThisScheme {
number: fd,
flags: NewFdFlags::POSITIONED,
})
}
fn fstat(&mut self, id: usize, stat: &mut Stat, _ctx: &CallerCtx) -> Result<()> {
let handle = self.handles.get(id)?;
stat.st_size = handle
.kind
.len(self.ctx)?
.try_into()
.unwrap_or(u64::max_value());
if handle.kind.is_dir() {
stat.st_mode = MODE_DIR;
} else {
stat.st_mode = MODE_FILE;
}
Ok(())
}
fn read(
&mut self,
id: usize,
buf: &mut [u8],
offset: u64,
_fcntl: u32,
_ctx: &CallerCtx,
) -> Result<usize> {
let offset: usize = offset.try_into().map_err(|_| Error::new(EINVAL))?;
let handle = self.handles.get_mut(id)?;
if handle.stat {
return Err(Error::new(EBADF));
}
// Build an owned buffer for DMI handles so the borrow does not
// escape the match arm scope.
let dmi_buf;
let proc_buf;
let src_buf: &[u8] = match &handle.kind {
HandleKind::Table(ref signature) => self
.ctx
.sdt_from_signature(signature)
.ok_or(Error::new(EBADFD))?
.as_slice(),
HandleKind::Symbol { description, .. } => description.as_bytes(),
HandleKind::Dmi => {
dmi_buf = self
.ctx
.dmi_info()
.map(|info| info.to_match_lines())
.unwrap_or_default();
dmi_buf.as_bytes()
}
HandleKind::DmiField(ref field) => {
dmi_buf = dmi_field_contents(self.ctx.dmi_info(), field)
.unwrap_or_default();
dmi_buf.as_bytes()
}
HandleKind::PowerBattery { name, file } => {
dmi_buf = match file {
PowerFileKind::State => self.ctx.battery_state_text(name),
PowerFileKind::Percentage => self.ctx.battery_percentage_text(name),
PowerFileKind::Online => String::new(),
};
dmi_buf.as_bytes()
}
HandleKind::PowerAdapter { name, file } => {
dmi_buf = match file {
PowerFileKind::Online => self.ctx.adapter_online_text(name),
PowerFileKind::State | PowerFileKind::Percentage => String::new(),
};
dmi_buf.as_bytes()
}
HandleKind::Processor | HandleKind::DmiDir | HandleKind::Thermal | HandleKind::Power | HandleKind::PowerBatteries | HandleKind::Symbols(_) | HandleKind::RegisterPci | HandleKind::TopLevel | HandleKind::SchemeRoot => {
return Err(Error::new(EISDIR));
}
HandleKind::ProcFile { cpu, kind } => {
let method = match kind {
ProcFileKind::Pss => "_PSS",
ProcFileKind::Psd => "_PSD",
ProcFileKind::Cst => "_CST",
ProcFileKind::Cpc => "_CPC",
};
let cpu_segment = format!("CPU{}", cpu);
proc_buf = self
.ctx
.processor_method_text(&cpu_segment, method)
.into_bytes();
proc_buf.as_slice()
}
HandleKind::Tables => return Err(Error::new(EISDIR)),
};
let offset = std::cmp::min(src_buf.len(), offset);
let src_buf = &src_buf[offset..];
let to_copy = std::cmp::min(src_buf.len(), buf.len());
buf[..to_copy].copy_from_slice(&src_buf[..to_copy]);
Ok(to_copy)
}
fn getdents<'buf>(
&mut self,
id: usize,
mut buf: DirentBuf<&'buf mut [u8]>,
opaque_offset: u64,
) -> Result<DirentBuf<&'buf mut [u8]>> {
let handle = self.handles.get_mut(id)?;
match &handle.kind {
HandleKind::TopLevel => {
const TOPLEVEL_ENTRIES: &[&str] = &[
"tables", "symbols", "thermal", "power", "dmi", "processor",
];
for (idx, name) in TOPLEVEL_ENTRIES
.iter()
.enumerate()
.skip(opaque_offset as usize)
{
buf.entry(DirEntry {
inode: 0,
next_opaque_id: idx as u64 + 1,
name,
kind: DirentKind::Directory,
})?;
}
}
HandleKind::Symbols(aml_symbols) => {
for (idx, (symbol_name, _value)) in aml_symbols
.symbols_cache()
.iter()
.enumerate()
.skip(opaque_offset as usize)
{
buf.entry(DirEntry {
inode: 0,
next_opaque_id: idx as u64 + 1,
name: symbol_name.as_str(),
kind: DirentKind::Regular,
})?;
}
}
HandleKind::Tables => {
for (idx, table) in self
.ctx
.tables()
.iter()
.enumerate()
.skip(opaque_offset as usize)
{
let utf8_or_eio = |bytes| str::from_utf8(bytes).map_err(|_| Error::new(EIO));
let mut name = String::new();
name.push_str(utf8_or_eio(&table.signature[..])?);
name.push('-');
for byte in table.oem_id.iter() {
std::fmt::write(&mut name, format_args!("{:>02X}", byte)).unwrap();
}
name.push('-');
for byte in table.oem_table_id.iter() {
std::fmt::write(&mut name, format_args!("{:>02X}", byte)).unwrap();
}
buf.entry(DirEntry {
inode: 0,
next_opaque_id: idx as u64 + 1,
name: &name,
kind: DirentKind::Regular,
})?;
}
}
HandleKind::Thermal => {
// Enumerate \_TZ.<zone> entries from the AML namespace.
// Returns Ok with no entries on systems with no zones
// (headless QEMU, desktops) so consumers see an
// empty-but-existing directory.
let zones = self.ctx.thermal_zones();
for (idx, zone) in zones.iter().enumerate().skip(opaque_offset as usize) {
buf.entry(DirEntry {
inode: 0,
next_opaque_id: idx as u64 + 1,
name: zone.as_str(),
kind: DirentKind::Directory,
})?;
}
}
HandleKind::Processor => {
// Enumerate \_PR.<cpu> entries from the AML namespace.
// Returns Ok with no entries on systems with no
// processors (headless QEMU with no DSDT) so consumers
// see an empty-but-existing directory. The directory
// entry names use the short CPU segment (e.g. "CPU0")
// so that `processor/CPU0/pss` is a valid sub-path.
let cpus = self.ctx.cpu_names();
for (idx, cpu_path) in cpus.iter().enumerate().skip(opaque_offset as usize) {
let short = cpu_path.strip_prefix("\\_PR.").unwrap_or(cpu_path);
buf.entry(DirEntry {
inode: 0,
next_opaque_id: idx as u64 + 1,
name: short,
kind: DirentKind::Directory,
})?;
}
}
HandleKind::Power => {
// Enumerate PowerResource entries. On real laptops these
// are AC adapters and battery controllers; on desktops
// and QEMU the list is empty.
let cache = self.power_cache().clone();
if !cache.batteries.is_empty() {
buf.entry(DirEntry {
inode: 0,
next_opaque_id: 1,
name: "batteries",
kind: DirentKind::Directory,
})?;
}
if cache.adapter.is_some() {
buf.entry(DirEntry {
inode: 0,
next_opaque_id: 2,
name: "adapters",
kind: DirentKind::Directory,
})?;
}
}
HandleKind::PowerBatteries => {
let batteries = &self.power_cache().batteries;
for (idx, battery) in batteries.iter().enumerate().skip(opaque_offset as usize) {
buf.entry(DirEntry {
inode: 0,
next_opaque_id: idx as u64 + 1,
name: battery.as_str(),
kind: DirentKind::Directory,
})?;
}
}
HandleKind::PowerBattery { .. } => {
for (idx, file) in ["state", "percentage"].iter().enumerate().skip(opaque_offset as usize) {
buf.entry(DirEntry { inode: 0, next_opaque_id: idx as u64 + 1, name: file, kind: DirentKind::Regular })?;
}
}
HandleKind::PowerAdapter { .. } => {
buf.entry(DirEntry { inode: 0, next_opaque_id: 1, name: "online", kind: DirentKind::Regular })?;
}
HandleKind::Dmi => {
// Consumers should `read_to_string("/scheme/acpi/dmi")`
// rather than iterating, but we still surface the field
// list so that ls /scheme/acpi/dmi/ produces a useful
// diagnostic on a live system. We always list the same
// set of fields regardless of whether SMBIOS data is
// present -- empty entries just produce empty reads.
for (idx, field) in DMI_FIELDS
.iter()
.enumerate()
.skip(opaque_offset as usize)
{
buf.entry(DirEntry {
inode: 0,
next_opaque_id: idx as u64 + 1,
name: field,
kind: DirentKind::Regular,
})?;
}
}
HandleKind::ProcFile { .. } | HandleKind::DmiDir => {
// No children; reads/writes go through the
// HandleKind match in kread/kwriteoff.
}
_ => return Err(Error::new(EIO)),
}
Ok(buf)
}
fn call(
&mut self,
id: usize,
payload: &mut [u8],
_metadata: &[u64],
_ctx: &CallerCtx,
) -> Result<usize> {
let handle = self.handles.get_mut(id)?;
if !handle.allowed_to_eval {
return Err(Error::new(EPERM));
}
let Ok(args): Result<Vec<AmlSerdeValue>, SpannedError> = ron::de::from_bytes(payload)
else {
return Err(Error::new(EINVAL));
};
let HandleKind::Symbol { name, .. } = &handle.kind else {
return Err(Error::new(EBADF));
};
let Ok(aml_name) = AmlName::from_str(&to_aml_format(name)) else {
log::error!("Failed to convert symbol name: \"{name}\" to aml name!");
return Err(Error::new(EBADF));
};
let Ok(result) = self.ctx.aml_eval(aml_name, args) else {
return Err(Error::new(EINVAL));
};
let Ok(serialized_result) = ron::ser::to_string(&result) else {
log::error!("Failed to serialize aml result!");
return Err(Error::new(EINVAL));
};
let byte_result = serialized_result.as_bytes();
let result_len = byte_result.len();
if result_len > payload.len() {
return Err(Error::new(EOVERFLOW));
}
payload[..result_len].copy_from_slice(byte_result);
Ok(result_len)
}
fn on_sendfd(&mut self, sendfd_request: &SendFdRequest) -> Result<usize> {
let id = sendfd_request.id();
let num_fds = sendfd_request.num_fds();
let handle = self.handles.get(id)?;
if !matches!(handle.kind, HandleKind::RegisterPci) {
return Err(Error::new(EACCES));
}
if num_fds == 0 {
return Ok(0);
}
if num_fds > 1 {
return Err(Error::new(EINVAL));
}
let mut new_fd = usize::MAX;
if let Err(e) = sendfd_request.obtain_fd(
&self.socket,
FobtainFdFlags::UPPER_TBL,
std::slice::from_mut(&mut new_fd),
) {
return Err(e);
}
let new_fd = libredox::Fd::new(new_fd);
if self.pci_fd.is_some() {
return Err(Error::new(EINVAL));
} else {
self.pci_fd = Some(new_fd);
}
Ok(num_fds)
}
fn on_close(&mut self, id: usize) {
self.handles.remove(id);
}
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "amlserde"
description = "Library for serializing AML symbols"
version = "0.0.1"
authors = ["Ron Williams"]
repository = "https://gitlab.redox-os.org/redox-os/drivers"
categories = ["hardware-support"]
license = "MIT/Apache-2.0"
edition = "2021"
[dependencies]
acpi.workspace = true
serde.workspace = true
toml.workspace = true
-484
View File
@@ -1,484 +0,0 @@
use acpi::{
aml::{
namespace::AmlName,
object::{
FieldAccessType, FieldFlags, FieldUnit, FieldUnitKind, FieldUpdateRule, MethodFlags,
Object, ReferenceKind, WrappedObject,
},
op_region::{OpRegion, RegionSpace},
Interpreter,
},
Handle, Handler,
};
use serde::{Deserialize, Serialize};
use std::{
ops::{Deref, Shl},
str::FromStr,
sync::{
atomic::{AtomicU64, Ordering},
Arc,
},
};
#[derive(Debug, Serialize, Deserialize)]
pub struct AmlSerde {
pub name: String,
pub value: AmlSerdeValue,
}
#[derive(Debug, Serialize, Deserialize)]
pub enum AmlSerdeValue {
Uninitialized,
Integer(u64),
String(String),
OpRegion {
region: AmlSerdeRegionSpace,
offset: u64,
length: u64,
parent_device: String,
},
Field {
kind: AmlSerdeFieldKind,
flags: AmlSerdeFieldFlags,
offset: u64,
length: u64,
},
Device,
Event(u64),
Method {
arg_count: usize,
serialize: bool,
sync_level: u8,
},
Buffer(Vec<u8>),
BufferField {
offset: u64,
length: u64,
data: Box<AmlSerdeValue>,
},
Processor {
id: u8,
pblk_address: u32,
pblk_len: u8,
},
Mutex {
mutex: u32,
sync_level: u8,
},
Reference {
kind: AmlSerdeReferenceKind,
inner: Box<AmlSerdeValue>,
},
Package {
contents: Vec<AmlSerdeValue>,
},
PowerResource {
system_level: u8,
resource_order: u16,
},
RawDataBuffer,
ThermalZone,
Debug,
}
#[derive(Debug, Serialize, Deserialize)]
pub enum AmlSerdeRegionSpace {
SystemMemory,
SystemIo,
PciConfig,
EmbeddedControl,
SMBus,
SystemCmos,
PciBarTarget,
IPMI,
GeneralPurposeIo,
GenericSerialBus,
Pcc,
OemDefined(u8),
}
#[derive(Debug, Serialize, Deserialize)]
pub enum AmlSerdeFieldKind {
Normal {
region: Box<AmlSerdeValue>,
},
Bank {
region: Box<AmlSerdeValue>,
bank: Box<AmlSerdeValue>,
bank_value: u64,
},
Index {
index: Box<AmlSerdeValue>,
data: Box<AmlSerdeValue>,
},
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AmlSerdeFieldFlags {
pub access_type: AmlSerdeFieldAccessType,
pub lock_rule: bool, // bit 4
pub update_rule: AmlSerdeFieldUpdateRule,
}
impl Into<u8> for AmlSerdeFieldFlags {
fn into(self) -> u8 {
// bits 0..4
(self.access_type as u8) +
// bit 4
(self.lock_rule as u8).shl(4) +
// bits 5..7
(self.update_rule as u8).shl(5)
}
}
#[derive(Debug, Serialize, Deserialize)]
#[repr(u8)]
pub enum AmlSerdeFieldAccessType {
Any = 0,
Byte = 1,
Word = 2,
DWord = 3,
QWord = 4,
Buffer = 5,
}
#[derive(Debug, Serialize, Deserialize)]
#[repr(u8)]
pub enum AmlSerdeFieldUpdateRule {
Preserve = 0,
WriteAsOnes = 1,
WriteAsZeros = 2,
}
#[derive(Debug, Serialize, Deserialize)]
pub enum AmlSerdeReferenceKind {
RefOf,
Local,
Arg,
Index,
Named,
Unresolved,
}
impl AmlSerde {
pub fn default() -> Self {
Self {
name: "name".to_owned(),
value: AmlSerdeValue::String(String::default()),
}
}
pub fn from_aml<H: Handler>(aml_context: &Interpreter<H>, aml_name: &AmlName) -> Option<Self> {
//TODO: why does namespace.get not take a reference to aml_name
let aml_value = if let Ok(aml_value) = aml_context.namespace.lock().get(aml_name.clone()) {
aml_value
} else {
return None;
};
let value = if let Some(value) = AmlSerdeValue::from_aml_value(aml_value.deref()) {
value
} else {
return None;
};
Some(AmlSerde {
name: aml_name.to_string(),
value,
})
}
}
impl AmlSerdeValue {
pub fn default() -> Self {
AmlSerdeValue::String("".to_owned())
}
pub fn from_aml_value(aml_value: &Object) -> Option<Self> {
Some(match aml_value {
Object::Uninitialized => AmlSerdeValue::Uninitialized,
Object::Integer(n) => AmlSerdeValue::Integer(n.to_owned()),
Object::String(s) => AmlSerdeValue::String(s.to_owned()),
Object::OpRegion(region) => AmlSerdeValue::OpRegion {
region: match region.space {
RegionSpace::SystemMemory => AmlSerdeRegionSpace::SystemMemory,
RegionSpace::SystemIO => AmlSerdeRegionSpace::SystemIo,
RegionSpace::PciConfig => AmlSerdeRegionSpace::PciConfig,
RegionSpace::EmbeddedControl => AmlSerdeRegionSpace::EmbeddedControl,
RegionSpace::SmBus => AmlSerdeRegionSpace::SMBus,
RegionSpace::SystemCmos => AmlSerdeRegionSpace::SystemCmos,
RegionSpace::PciBarTarget => AmlSerdeRegionSpace::PciBarTarget,
RegionSpace::Ipmi => AmlSerdeRegionSpace::IPMI,
RegionSpace::GeneralPurposeIo => AmlSerdeRegionSpace::GeneralPurposeIo,
RegionSpace::GenericSerialBus => AmlSerdeRegionSpace::GenericSerialBus,
RegionSpace::Pcc => AmlSerdeRegionSpace::Pcc,
RegionSpace::Oem(n) => AmlSerdeRegionSpace::OemDefined(n.to_owned()),
},
offset: region.base,
length: region.length,
parent_device: region.parent_device_path.to_string(),
},
Object::FieldUnit(field) => AmlSerdeValue::Field {
kind: match &field.kind {
FieldUnitKind::Normal { region } => AmlSerdeFieldKind::Normal {
region: AmlSerdeValue::from_aml_value(region.deref()).map(Box::new)?,
},
FieldUnitKind::Bank {
region,
bank,
bank_value,
} => AmlSerdeFieldKind::Bank {
region: AmlSerdeValue::from_aml_value(region.deref()).map(Box::new)?,
bank: AmlSerdeValue::from_aml_value(bank.deref()).map(Box::new)?,
bank_value: bank_value.to_owned(),
},
FieldUnitKind::Index { index, data } => AmlSerdeFieldKind::Index {
index: AmlSerdeValue::from_aml_value(index.deref()).map(Box::new)?,
data: AmlSerdeValue::from_aml_value(data.deref()).map(Box::new)?,
},
},
flags: AmlSerdeFieldFlags {
access_type: match field.flags.access_type() {
Ok(FieldAccessType::Any) => AmlSerdeFieldAccessType::Any,
Ok(FieldAccessType::Byte) => AmlSerdeFieldAccessType::Byte,
Ok(FieldAccessType::Word) => AmlSerdeFieldAccessType::Word,
Ok(FieldAccessType::DWord) => AmlSerdeFieldAccessType::DWord,
Ok(FieldAccessType::QWord) => AmlSerdeFieldAccessType::QWord,
Ok(FieldAccessType::Buffer) => AmlSerdeFieldAccessType::Buffer,
_ => return None,
},
lock_rule: field.flags.lock_rule(),
update_rule: match field.flags.update_rule() {
FieldUpdateRule::Preserve => AmlSerdeFieldUpdateRule::Preserve,
FieldUpdateRule::WriteAsOnes => AmlSerdeFieldUpdateRule::WriteAsOnes,
FieldUpdateRule::WriteAsZeros => AmlSerdeFieldUpdateRule::WriteAsZeros,
},
},
offset: field.bit_index as u64,
length: field.bit_length as u64,
},
Object::Device => AmlSerdeValue::Device,
Object::Event(event) => AmlSerdeValue::Event(event.load(Ordering::Relaxed)),
Object::Method { flags, code: _ } => AmlSerdeValue::Method {
arg_count: flags.arg_count(),
serialize: flags.serialize(),
sync_level: flags.sync_level(),
},
//TODO: distinguish from Method?
Object::NativeMethod { f: _, flags } => AmlSerdeValue::Method {
arg_count: flags.arg_count(),
serialize: flags.serialize(),
sync_level: flags.sync_level(),
},
Object::Buffer(buffer_data) => AmlSerdeValue::Buffer(buffer_data.to_owned()),
Object::BufferField {
buffer,
offset,
length,
} => AmlSerdeValue::BufferField {
offset: offset.to_owned() as u64,
length: length.to_owned() as u64,
data: AmlSerdeValue::from_aml_value(buffer.deref()).map(Box::new)?,
},
Object::Processor {
proc_id,
pblk_address,
pblk_length,
} => AmlSerdeValue::Processor {
id: proc_id.to_owned(),
pblk_address: pblk_address.to_owned(),
pblk_len: pblk_length.to_owned(),
},
Object::Mutex { mutex, sync_level } => AmlSerdeValue::Mutex {
mutex: mutex.0,
sync_level: sync_level.to_owned(),
},
Object::Reference { kind, inner } => AmlSerdeValue::Reference {
kind: match kind {
ReferenceKind::RefOf => AmlSerdeReferenceKind::RefOf,
ReferenceKind::Local => AmlSerdeReferenceKind::Local,
ReferenceKind::Arg => AmlSerdeReferenceKind::Arg,
ReferenceKind::Index => AmlSerdeReferenceKind::Index,
ReferenceKind::Named => AmlSerdeReferenceKind::Named,
ReferenceKind::Unresolved => AmlSerdeReferenceKind::Unresolved,
},
inner: AmlSerdeValue::from_aml_value(inner.deref()).map(Box::new)?,
},
Object::Package(aml_contents) => AmlSerdeValue::Package {
contents: aml_contents
.iter()
.filter_map(|item| AmlSerdeValue::from_aml_value(item))
.collect(),
},
Object::PowerResource {
system_level,
resource_order,
} => AmlSerdeValue::PowerResource {
system_level: system_level.to_owned(),
resource_order: resource_order.to_owned(),
},
Object::RawDataBuffer => AmlSerdeValue::RawDataBuffer,
Object::ThermalZone => AmlSerdeValue::ThermalZone,
Object::Debug => AmlSerdeValue::Debug,
})
}
pub fn to_aml_object(self) -> Option<Object> {
Some(match self {
AmlSerdeValue::Uninitialized => Object::Uninitialized,
AmlSerdeValue::Integer(n) => Object::Integer(n),
AmlSerdeValue::String(s) => Object::String(s),
AmlSerdeValue::OpRegion {
region,
offset,
length,
parent_device,
} => Object::OpRegion(OpRegion {
space: match region {
AmlSerdeRegionSpace::PciConfig => RegionSpace::PciConfig,
AmlSerdeRegionSpace::EmbeddedControl => RegionSpace::EmbeddedControl,
AmlSerdeRegionSpace::SMBus => RegionSpace::SmBus,
AmlSerdeRegionSpace::SystemCmos => RegionSpace::SystemCmos,
AmlSerdeRegionSpace::PciBarTarget => RegionSpace::PciBarTarget,
AmlSerdeRegionSpace::IPMI => RegionSpace::Ipmi,
AmlSerdeRegionSpace::GeneralPurposeIo => RegionSpace::GeneralPurposeIo,
AmlSerdeRegionSpace::GenericSerialBus => RegionSpace::GenericSerialBus,
AmlSerdeRegionSpace::SystemMemory => RegionSpace::SystemMemory,
AmlSerdeRegionSpace::SystemIo => RegionSpace::SystemIO,
AmlSerdeRegionSpace::Pcc => RegionSpace::Pcc,
AmlSerdeRegionSpace::OemDefined(n) => RegionSpace::Oem(n),
},
base: offset,
length,
//
parent_device_path: AmlName::from_str(&parent_device).ok()?, // TODO: Error value hidden
}),
AmlSerdeValue::Field {
kind,
flags,
offset,
length,
} => Object::FieldUnit(FieldUnit {
kind: match kind {
AmlSerdeFieldKind::Normal { region } => FieldUnitKind::Normal {
region: region.to_aml_object()?.wrap(),
},
AmlSerdeFieldKind::Bank {
region,
bank,
bank_value,
} => FieldUnitKind::Bank {
region: region.to_aml_object()?.wrap(),
bank: bank.to_aml_object()?.wrap(),
bank_value: bank_value.to_owned(),
},
AmlSerdeFieldKind::Index { index, data } => FieldUnitKind::Index {
index: index.to_aml_object()?.wrap(),
data: data.to_aml_object()?.wrap(),
},
},
flags: FieldFlags(flags.into()),
bit_index: offset as usize,
bit_length: length as usize,
}),
AmlSerdeValue::Device => Object::Device,
AmlSerdeValue::Event(event) => Object::Event(Arc::new(AtomicU64::new(event))),
AmlSerdeValue::Method {
arg_count,
serialize,
sync_level,
} => Object::Method {
code: (return None), //TODO figure out what to do here
//TODO check specs to see if all bit patterns are allowed
flags: MethodFlags(
(arg_count as u8).clamp(0, 7)
+ (serialize as u8).shl(3)
+ sync_level.clamp(0, 15).shl(4),
),
},
//TODO: handle native method?
AmlSerdeValue::Buffer(buffer_data) => Object::Buffer(buffer_data),
AmlSerdeValue::BufferField {
data,
offset,
length,
} => Object::BufferField {
offset: offset as usize,
length: length as usize,
buffer: data.to_aml_object()?.wrap(),
},
AmlSerdeValue::Processor {
id,
pblk_address,
pblk_len,
} => Object::Processor {
proc_id: id,
pblk_address,
pblk_length: pblk_len,
},
AmlSerdeValue::Mutex { mutex, sync_level } => Object::Mutex {
mutex: Handle(mutex),
sync_level: sync_level,
},
AmlSerdeValue::Reference { kind, inner } => Object::Reference {
kind: match kind {
AmlSerdeReferenceKind::RefOf => ReferenceKind::RefOf,
AmlSerdeReferenceKind::Local => ReferenceKind::Local,
AmlSerdeReferenceKind::Arg => ReferenceKind::Arg,
AmlSerdeReferenceKind::Index => ReferenceKind::Index,
AmlSerdeReferenceKind::Named => ReferenceKind::Named,
AmlSerdeReferenceKind::Unresolved => ReferenceKind::Unresolved,
},
inner: inner.to_aml_object()?.wrap(),
},
AmlSerdeValue::Package { contents } => Object::Package(
contents
.into_iter()
.map(|item| item.to_aml_object().map(Object::wrap)) // TODO: see if errors should be ignored here
.collect::<Option<Vec<WrappedObject>>>()?,
),
AmlSerdeValue::PowerResource {
system_level,
resource_order,
} => Object::PowerResource {
system_level: system_level.to_owned(),
resource_order: resource_order.to_owned(),
},
AmlSerdeValue::RawDataBuffer => Object::RawDataBuffer,
AmlSerdeValue::ThermalZone => Object::ThermalZone,
AmlSerdeValue::Debug => Object::Debug,
})
}
}
pub mod aml_serde_name {
use acpi::aml::namespace::AmlName;
/// Add a leading backslash to make the name a valid
/// namespace reference
pub fn to_aml_format(pretty_name: &String) -> String {
format!("\\{}", pretty_name)
}
/// convert a string from AML namespace style to
/// acpi symbol style
pub fn to_symbol(aml_style_name: &String) -> String {
let mut name = aml_style_name.to_owned();
// remove leading slash
name = name.trim_start_matches("\\").to_owned();
// remove unnecessary underscores
while let Some(index) = name.find("_.") {
name.remove(index);
}
while name.len() > 0 && &name[name.len() - 1..] == "_" {
name.pop();
}
name.shrink_to_fit();
name
}
/// Convert to string and remove
/// trailing underscores from each name segment
pub fn aml_to_symbol(aml_name: &AmlName) -> String {
to_symbol(&aml_name.as_string())
}
}
-21
View File
@@ -1,21 +0,0 @@
[package]
name = "ac97d"
description = "AC'97 driver"
version = "0.1.0"
edition = "2021"
[dependencies]
common = { path = "../../common" }
libredox.workspace = true
log.workspace = true
redox_event.workspace = true
redox_syscall.workspace = true
spin.workspace = true
daemon = { path = "../../../daemon" }
pcid = { path = "../../pcid" }
redox-scheme.workspace = true
scheme-utils = { path = "../../../scheme-utils" }
[lints]
workspace = true
-5
View File
@@ -1,5 +0,0 @@
[[drivers]]
name = "AC97 Audio"
class = 0x04
subclass = 0x01
command = ["ac97d"]
-333
View File
@@ -1,333 +0,0 @@
use common::io::Pio;
use redox_scheme::scheme::SchemeSync;
use redox_scheme::CallerCtx;
use redox_scheme::OpenResult;
use scheme_utils::{FpathWriter, HandleMap};
use syscall::error::{Error, Result, EACCES, EBADF, EINVAL, ENOENT};
use syscall::schemev2::NewFdFlags;
use syscall::EWOULDBLOCK;
use common::{
dma::Dma,
io::{Io, Mmio},
};
use spin::Mutex;
const NUM_SUB_BUFFS: usize = 32;
const SUB_BUFF_SIZE: usize = 2048;
enum Handle {
Todo,
SchemeRoot,
}
#[allow(dead_code)]
struct MixerRegs {
/* 0x00 */ reset: Pio<u16>,
/* 0x02 */ master_volume: Pio<u16>,
/* 0x04 */ aux_out_volume: Pio<u16>,
/* 0x06 */ mono_volume: Pio<u16>,
/* 0x08 */ master_tone: Pio<u16>,
/* 0x0A */ pc_beep_volume: Pio<u16>,
/* 0x0C */ phone_volume: Pio<u16>,
/* 0x0E */ mic_volume: Pio<u16>,
/* 0x10 */ line_in_volume: Pio<u16>,
/* 0x12 */ cd_volume: Pio<u16>,
/* 0x14 */ video_volume: Pio<u16>,
/* 0x16 */ aux_in_volume: Pio<u16>,
/* 0x18 */ pcm_out_volume: Pio<u16>,
/* 0x1A */ record_select: Pio<u16>,
/* 0x1C */ record_gain: Pio<u16>,
/* 0x1E */ record_gain_mic: Pio<u16>,
/* 0x20 */ general_purpose: Pio<u16>,
/* 0x22 */ control_3d: Pio<u16>,
/* 0x24 */ audio_int_paging: Pio<u16>,
/* 0x26 */ powerdown: Pio<u16>,
/* 0x28 */ extended_id: Pio<u16>,
/* 0x2A */ extended_ctrl: Pio<u16>,
/* 0x2C */ vra_pcm_front: Pio<u16>,
}
impl MixerRegs {
fn new(bar0: u16) -> Self {
Self {
reset: Pio::new(bar0 + 0x00),
master_volume: Pio::new(bar0 + 0x02),
aux_out_volume: Pio::new(bar0 + 0x04),
mono_volume: Pio::new(bar0 + 0x06),
master_tone: Pio::new(bar0 + 0x08),
pc_beep_volume: Pio::new(bar0 + 0x0A),
phone_volume: Pio::new(bar0 + 0x0C),
mic_volume: Pio::new(bar0 + 0x0E),
line_in_volume: Pio::new(bar0 + 0x10),
cd_volume: Pio::new(bar0 + 0x12),
video_volume: Pio::new(bar0 + 0x14),
aux_in_volume: Pio::new(bar0 + 0x16),
pcm_out_volume: Pio::new(bar0 + 0x18),
record_select: Pio::new(bar0 + 0x1A),
record_gain: Pio::new(bar0 + 0x1C),
record_gain_mic: Pio::new(bar0 + 0x1E),
general_purpose: Pio::new(bar0 + 0x20),
control_3d: Pio::new(bar0 + 0x22),
audio_int_paging: Pio::new(bar0 + 0x24),
powerdown: Pio::new(bar0 + 0x26),
extended_id: Pio::new(bar0 + 0x28),
extended_ctrl: Pio::new(bar0 + 0x2A),
vra_pcm_front: Pio::new(bar0 + 0x2C),
}
}
}
#[allow(dead_code)]
struct BusBoxRegs {
/// Buffer descriptor list base address
/* 0x00 */
bdbar: Pio<u32>,
/// Current index value
/* 0x04 */
civ: Pio<u8>,
/// Last valid index
/* 0x05 */
lvi: Pio<u8>,
/// Status
/* 0x06 */
sr: Pio<u16>,
/// Position in current buffer
/* 0x08 */
picb: Pio<u16>,
/// Prefetched index value
/* 0x0A */
piv: Pio<u8>,
/// Control
/* 0x0B */
cr: Pio<u8>,
}
impl BusBoxRegs {
fn new(base: u16) -> Self {
Self {
bdbar: Pio::new(base + 0x00),
civ: Pio::new(base + 0x04),
lvi: Pio::new(base + 0x05),
sr: Pio::new(base + 0x06),
picb: Pio::new(base + 0x08),
piv: Pio::new(base + 0x0A),
cr: Pio::new(base + 0x0B),
}
}
}
#[allow(dead_code)]
struct BusRegs {
/// PCM in register box
/* 0x00 */
pi: BusBoxRegs,
/// PCM out register box
/* 0x10 */
po: BusBoxRegs,
/// Microphone register box
/* 0x20 */
mc: BusBoxRegs,
}
impl BusRegs {
fn new(bar1: u16) -> Self {
Self {
pi: BusBoxRegs::new(bar1 + 0x00),
po: BusBoxRegs::new(bar1 + 0x10),
mc: BusBoxRegs::new(bar1 + 0x20),
}
}
}
#[repr(C, packed)]
pub struct BufferDescriptor {
/* 0x00 */ addr: Mmio<u32>,
/* 0x04 */ samples: Mmio<u16>,
/* 0x06 */ flags: Mmio<u16>,
}
pub struct Ac97 {
mixer: MixerRegs,
bus: BusRegs,
bdl: Dma<[BufferDescriptor; NUM_SUB_BUFFS]>,
buf: Dma<[u8; NUM_SUB_BUFFS * SUB_BUFF_SIZE]>,
handles: Mutex<HandleMap<Handle>>,
}
impl Ac97 {
pub unsafe fn new(bar0: u16, bar1: u16) -> Result<Self> {
let mut module = Ac97 {
mixer: MixerRegs::new(bar0),
bus: BusRegs::new(bar1),
bdl: Dma::zeroed(
//TODO: PhysBox::new_in_32bit_space(bdl_size)?
)?
.assume_init(),
buf: Dma::zeroed(
//TODO: PhysBox::new_in_32bit_space(buf_size)?
)?
.assume_init(),
handles: Mutex::new(HandleMap::new()),
};
module.init()?;
Ok(module)
}
fn init(&mut self) -> Result<()> {
//TODO: support other sample rates, or just the default of 48000 Hz
{
// Check if VRA is supported
if !self.mixer.extended_id.readf(1 << 0) {
println!("ac97d: VRA not supported and is currently required");
return Err(Error::new(ENOENT));
}
// Enable VRA
self.mixer.extended_ctrl.writef(1 << 0, true);
// Attempt to set sample rate for PCM front to 44100 Hz
let desired_sample_rate = 44100;
self.mixer.vra_pcm_front.write(desired_sample_rate);
// Read back real sample rate
let real_sample_rate = self.mixer.vra_pcm_front.read();
println!("ac97d: set sample rate to {}", real_sample_rate);
// Error if we cannot set the sample rate as desired
if real_sample_rate != desired_sample_rate {
println!(
"ac97d: sample rate is {} but only {} is supported",
real_sample_rate, desired_sample_rate
);
return Err(Error::new(ENOENT));
}
}
// Ensure PCM out is stopped
self.bus.po.cr.writef(1, false);
// Reset PCM out
self.bus.po.cr.writef(1 << 1, true);
while self.bus.po.cr.readf(1 << 1) {
// Spinning on resetting PCM out
//TODO: relax
}
// Initialize BDL for PCM out
for i in 0..NUM_SUB_BUFFS {
self.bdl[i]
.addr
.write((self.buf.physical() + i * SUB_BUFF_SIZE) as u32);
self.bdl[i]
.samples
.write((SUB_BUFF_SIZE / 2/* Each sample is i16 or 2 bytes */) as u16);
self.bdl[i]
.flags
.write(1 << 15 /* Interrupt on completion */);
}
self.bus.po.bdbar.write(self.bdl.physical() as u32);
// Enable interrupt on completion
self.bus.po.cr.writef(1 << 4, true);
// Start bus master
self.bus.po.cr.writef(1 << 0, true);
// Set master volume to 0 db (loudest output, DANGER!)
self.mixer.master_volume.write(0);
// Set PCM output volume to 0 db (medium)
self.mixer.pcm_out_volume.write(0x808);
Ok(())
}
pub fn irq(&mut self) -> bool {
let ints = self.bus.po.sr.read() & 0b11100;
if ints != 0 {
self.bus.po.sr.write(ints);
true
} else {
false
}
}
}
impl SchemeSync for Ac97 {
fn scheme_root(&mut self) -> Result<usize> {
Ok(self.handles.lock().insert(Handle::SchemeRoot))
}
fn openat(
&mut self,
dirfd: usize,
_path: &str,
_flags: usize,
_fcntl_flags: u32,
ctx: &CallerCtx,
) -> Result<OpenResult> {
{
let handles = self.handles.lock();
let handle = handles.get(dirfd)?;
if !matches!(handle, Handle::SchemeRoot) {
return Err(Error::new(EACCES));
}
}
if ctx.uid == 0 {
let id = self.handles.lock().insert(Handle::Todo);
Ok(OpenResult::ThisScheme {
number: id,
flags: NewFdFlags::empty(),
})
} else {
Err(Error::new(EACCES))
}
}
fn write(
&mut self,
id: usize,
buf: &[u8],
_offset: u64,
_flags: u32,
_ctx: &CallerCtx,
) -> Result<usize> {
{
let mut handles = self.handles.lock();
let handle = handles.get_mut(id)?;
if !matches!(handle, Handle::Todo) {
return Err(Error::new(EBADF));
}
}
if buf.len() != SUB_BUFF_SIZE {
return Err(Error::new(EINVAL));
}
let civ = self.bus.po.civ.read() as usize;
let mut lvi = self.bus.po.lvi.read() as usize;
if lvi == (civ + 3) % NUM_SUB_BUFFS {
// Block if we already are 3 buffers ahead
Err(Error::new(EWOULDBLOCK))
} else {
// Fill next buffer
lvi = (lvi + 1) % NUM_SUB_BUFFS;
for i in 0..SUB_BUFF_SIZE {
self.buf[lvi * SUB_BUFF_SIZE + i] = buf[i];
}
self.bus.po.lvi.write(lvi as u8);
Ok(SUB_BUFF_SIZE)
}
}
fn fpath(&mut self, _id: usize, buf: &mut [u8], _ctx: &CallerCtx) -> Result<usize> {
FpathWriter::with(buf, "audiohw", |_| Ok(()))
}
fn on_close(&mut self, id: usize) {
self.handles.lock().remove(id);
}
}
-135
View File
@@ -1,135 +0,0 @@
use std::io::{Read, Write};
use std::os::unix::io::AsRawFd;
use std::usize;
use event::{user_data, EventQueue};
use pcid_interface::PciFunctionHandle;
use redox_scheme::scheme::register_sync_scheme;
use redox_scheme::Socket;
use scheme_utils::ReadinessBased;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub mod device;
fn main() {
pcid_interface::pci_daemon(daemon);
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn daemon(daemon: daemon::Daemon, pcid_handle: PciFunctionHandle) -> ! {
let pci_config = pcid_handle.config();
let mut name = pci_config.func.name();
name.push_str("_ac97");
let bar0 = pci_config.func.bars[0].expect_port();
let bar1 = pci_config.func.bars[1].expect_port();
let irq = pci_config
.func
.legacy_interrupt_line
.expect("ac97d: no legacy interrupts supported");
println!(" + ac97 {}", pci_config.func.display());
common::setup_logging(
"audio",
"pci",
&name,
common::output_level(),
common::file_level(),
);
common::acquire_port_io_rights().expect("ac97d: failed to set I/O privilege level to Ring 3");
let mut irq_file = irq.irq_handle("ac97d");
let socket = Socket::nonblock().expect("ac97d: failed to create socket");
let mut device =
unsafe { device::Ac97::new(bar0, bar1).expect("ac97d: failed to allocate device") };
let mut readiness_based = ReadinessBased::new(&socket, 16);
user_data! {
enum Source {
Irq,
Scheme,
}
}
let event_queue = EventQueue::<Source>::new().expect("ac97d: Could not create event queue.");
event_queue
.subscribe(
irq_file.as_raw_fd() as usize,
Source::Irq,
event::EventFlags::READ,
)
.unwrap();
event_queue
.subscribe(
socket.inner().raw(),
Source::Scheme,
event::EventFlags::READ,
)
.unwrap();
register_sync_scheme(&socket, "audiohw", &mut device)
.expect("ac97d: failed to register audiohw scheme to namespace");
daemon.ready();
libredox::call::setrens(0, 0).expect("ac97d: failed to enter null namespace");
let all = [Source::Irq, Source::Scheme];
for event in all
.into_iter()
.chain(event_queue.map(|e| e.expect("ac97d: failed to get next event").user_data))
{
match event {
Source::Irq => {
let mut irq = [0; 8];
irq_file.read(&mut irq).unwrap();
if !device.irq() {
continue;
}
irq_file.write(&mut irq).unwrap();
readiness_based
.poll_all_requests(&mut device)
.expect("ac97d: failed to poll requests");
readiness_based
.write_responses()
.expect("ac97d: failed to write to socket");
/*
let next_read = device_irq.next_read();
if next_read > 0 {
return Ok(Some(next_read));
}
*/
}
Source::Scheme => {
readiness_based
.read_and_process_requests(&mut device)
.expect("ac97d: failed to read from socket");
readiness_based
.write_responses()
.expect("ac97d: failed to write to socket");
/*
let next_read = device.borrow().next_read();
if next_read > 0 {
return Ok(Some(next_read));
}
*/
}
}
}
std::process::exit(0);
}
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
fn daemon(_daemon: daemon::Daemon, _pcid_handle: PciFunctionHandle) -> ! {
// AC'97 is an x86/x86_64 legacy audio bus; no other architectures are supported.
panic!("ac97d: only supported on x86 and x86_64");
}
-22
View File
@@ -1,22 +0,0 @@
[package]
name = "ihdad"
description = "Intel HD Audio chipset driver"
version = "0.1.0"
edition = "2021"
[dependencies]
bitflags.workspace = true
libredox.workspace = true
log.workspace = true
redox_event.workspace = true
redox_syscall.workspace = true
spin.workspace = true
common = { path = "../../common" }
daemon = { path = "../../../daemon" }
pcid = { path = "../../pcid" }
redox-scheme.workspace = true
scheme-utils = { path = "../../../scheme-utils" }
[lints]
workspace = true
-5
View File
@@ -1,5 +0,0 @@
[[drivers]]
name = "Intel HD Audio"
class = 0x04
subclass = 0x03
command = ["ihdad"]
-501
View File
@@ -1,501 +0,0 @@
use common::dma::Dma;
use common::io::{Io, Mmio};
use common::timeout::Timeout;
use syscall::error::{Error, Result, EIO};
use super::common::*;
// CORBCTL
const CMEIE: u8 = 1 << 0; // 1 bit
const CORBRUN: u8 = 1 << 1; // 1 bit
// CORBSIZE
const CORBSZCAP: (u8, u8) = (4, 4);
const CORBSIZE: (u8, u8) = (0, 2);
// CORBRP
const CORBRPRST: u16 = 1 << 15;
// RIRBWP
const RIRBWPRST: u16 = 1 << 15;
// RIRBCTL
const RINTCTL: u8 = 1 << 0; // 1 bit
const RIRBDMAEN: u8 = 1 << 1; // 1 bit
const CORB_OFFSET: usize = 0x00;
const RIRB_OFFSET: usize = 0x10;
const ICMD_OFFSET: usize = 0x20;
// ICS
const ICB: u16 = 1 << 0;
const IRV: u16 = 1 << 1;
// CORB and RIRB offset
const COMMAND_BUFFER_OFFSET: usize = 0x40;
const CORB_BUFF_MAX_SIZE: usize = 1024;
struct CommandBufferRegs {
corblbase: Mmio<u32>,
corbubase: Mmio<u32>,
corbwp: Mmio<u16>,
corbrp: Mmio<u16>,
corbctl: Mmio<u8>,
corbsts: Mmio<u8>,
corbsize: Mmio<u8>,
rsvd5: Mmio<u8>,
rirblbase: Mmio<u32>,
rirbubase: Mmio<u32>,
rirbwp: Mmio<u16>,
rintcnt: Mmio<u16>,
rirbctl: Mmio<u8>,
rirbsts: Mmio<u8>,
rirbsize: Mmio<u8>,
rsvd6: Mmio<u8>,
}
struct CorbRegs {
corblbase: Mmio<u32>,
corbubase: Mmio<u32>,
corbwp: Mmio<u16>,
corbrp: Mmio<u16>,
corbctl: Mmio<u8>,
corbsts: Mmio<u8>,
corbsize: Mmio<u8>,
rsvd5: Mmio<u8>,
}
struct Corb {
regs: &'static mut CorbRegs,
corb_base: *mut u32,
corb_base_phys: usize,
corb_count: usize,
}
impl Corb {
pub fn new(regs_addr: usize, corb_buff_phys: usize, corb_buff_virt: *mut u32) -> Corb {
unsafe {
Corb {
regs: &mut *(regs_addr as *mut CorbRegs),
corb_base: corb_buff_virt,
corb_base_phys: corb_buff_phys,
corb_count: 0,
}
}
}
//Intel 4.4.1.3
pub fn init(&mut self) -> Result<()> {
self.stop()?;
//Determine CORB and RIRB size and allocate buffer
//3.3.24
let corbsize_reg = self.regs.corbsize.read();
let corbszcap = (corbsize_reg >> 4) & 0xF;
let mut corbsize_bytes: usize = 0;
let mut corbsize: u8 = 0;
if (corbszcap & 4) == 4 {
corbsize = 2;
corbsize_bytes = 1024;
self.corb_count = 256;
} else if (corbszcap & 2) == 2 {
corbsize = 1;
corbsize_bytes = 64;
self.corb_count = 16;
} else if (corbszcap & 1) == 1 {
corbsize = 0;
corbsize_bytes = 8;
self.corb_count = 2;
}
assert!(self.corb_count != 0);
let addr = self.corb_base_phys;
self.set_address(addr);
self.regs.corbsize.write((corbsize_reg & 0xFC) | corbsize);
self.reset_read_pointer()?;
let old_wp = self.regs.corbwp.read();
self.regs.corbwp.write(old_wp & 0xFF00);
Ok(())
}
pub fn start(&mut self) {
self.regs.corbctl.writef(CORBRUN, true);
}
#[inline(never)]
pub fn stop(&mut self) -> Result<()> {
let timeout = Timeout::from_secs(1);
while self.regs.corbctl.readf(CORBRUN) {
self.regs.corbctl.writef(CORBRUN, false);
timeout.run().map_err(|()| {
log::error!("timeout on clearing CORBRUN");
Error::new(EIO)
})?;
}
Ok(())
}
pub fn set_address(&mut self, addr: usize) {
self.regs.corblbase.write((addr & 0xFFFFFFFF) as u32);
self.regs.corbubase.write(((addr as u64) >> 32) as u32);
}
pub fn reset_read_pointer(&mut self) -> Result<()> {
// 3.3.21
self.stop()?;
// Set CORBRPRST to 1
log::trace!("CORBRP {:X}", self.regs.corbrp.read());
self.regs.corbrp.writef(CORBRPRST, true);
log::trace!("CORBRP {:X}", self.regs.corbrp.read());
{
// Wait for it to become 1
let timeout = Timeout::from_secs(1);
while !self.regs.corbrp.readf(CORBRPRST) {
self.regs.corbrp.writef(CORBRPRST, true);
timeout.run().map_err(|()| {
log::error!("timeout on setting CORBRPRST");
Error::new(EIO)
})?;
}
}
// Clear the bit again
self.regs.corbrp.writef(CORBRPRST, false);
{
// Read back the bit until zero to verify that it is cleared.
let timeout = Timeout::from_secs(1);
loop {
if !self.regs.corbrp.readf(CORBRPRST) {
break;
}
self.regs.corbrp.writef(CORBRPRST, false);
timeout.run().map_err(|()| {
log::error!("timeout on clearing CORBRPRST");
Error::new(EIO)
})?;
}
}
Ok(())
}
fn send_command(&mut self, cmd: u32) -> Result<()> {
{
// wait for the commands to finish
let timeout = Timeout::from_secs(1);
while (self.regs.corbwp.read() & 0xff) != (self.regs.corbrp.read() & 0xff) {
timeout.run().map_err(|()| {
log::error!("timeout on CORB command");
Error::new(EIO)
})?;
}
}
let write_pos: usize = ((self.regs.corbwp.read() as usize & 0xFF) + 1) % self.corb_count;
unsafe {
*self.corb_base.offset(write_pos as isize) = cmd;
}
self.regs.corbwp.write(write_pos as u16);
log::trace!("Corb: {:08X}", cmd);
Ok(())
}
}
struct RirbRegs {
rirblbase: Mmio<u32>,
rirbubase: Mmio<u32>,
rirbwp: Mmio<u16>,
rintcnt: Mmio<u16>,
rirbctl: Mmio<u8>,
rirbsts: Mmio<u8>,
rirbsize: Mmio<u8>,
rsvd6: Mmio<u8>,
}
struct Rirb {
regs: &'static mut RirbRegs,
rirb_base: *mut u64,
rirb_base_phys: usize,
rirb_rp: u16,
rirb_count: usize,
}
impl Rirb {
pub fn new(regs_addr: usize, rirb_buff_phys: usize, rirb_buff_virt: *mut u64) -> Rirb {
unsafe {
Rirb {
regs: &mut *(regs_addr as *mut RirbRegs),
rirb_base: rirb_buff_virt,
rirb_rp: 0,
rirb_base_phys: rirb_buff_phys,
rirb_count: 0,
}
}
}
//Intel 4.4.1.3
pub fn init(&mut self) -> Result<()> {
self.stop()?;
let rirbsize_reg = self.regs.rirbsize.read();
let rirbszcap = (rirbsize_reg >> 4) & 0xF;
let mut rirbsize_bytes: usize = 0;
let mut rirbsize: u8 = 0;
if (rirbszcap & 4) == 4 {
rirbsize = 2;
rirbsize_bytes = 2048;
self.rirb_count = 256;
} else if (rirbszcap & 2) == 2 {
rirbsize = 1;
rirbsize_bytes = 128;
self.rirb_count = 8;
} else if (rirbszcap & 1) == 1 {
rirbsize = 0;
rirbsize_bytes = 16;
self.rirb_count = 2;
}
assert!(self.rirb_count != 0);
let addr = self.rirb_base_phys;
self.set_address(addr);
self.reset_write_pointer();
self.rirb_rp = 0;
self.regs.rintcnt.write(1);
Ok(())
}
pub fn start(&mut self) {
self.regs.rirbctl.writef(RIRBDMAEN | RINTCTL, true);
}
pub fn stop(&mut self) -> Result<()> {
let timeout = Timeout::from_secs(1);
while self.regs.rirbctl.readf(RIRBDMAEN) {
self.regs.rirbctl.writef(RIRBDMAEN, false);
timeout.run().map_err(|()| {
log::error!("timeout on clearing RIRBDMAEN");
Error::new(EIO)
})?;
}
Ok(())
}
pub fn set_address(&mut self, addr: usize) {
self.regs.rirblbase.write((addr & 0xFFFFFFFF) as u32);
self.regs.rirbubase.write(((addr as u64) >> 32) as u32);
}
pub fn reset_write_pointer(&mut self) {
self.regs.rirbwp.writef(RIRBWPRST, true);
}
fn read_response(&mut self) -> Result<u64> {
{
// wait for response
let timeout = Timeout::from_secs(1);
while (self.regs.rirbwp.read() & 0xff) == (self.rirb_rp & 0xff) {
timeout.run().map_err(|()| {
log::error!("timeout on RIRB response");
Error::new(EIO)
})?;
}
}
let read_pos: u16 = (self.rirb_rp + 1) % self.rirb_count as u16;
let res: u64;
unsafe {
res = *self.rirb_base.offset(read_pos as isize);
}
self.rirb_rp = read_pos;
log::trace!("Rirb: {:08X}", res);
Ok(res)
}
}
struct ImmediateCommandRegs {
icoi: Mmio<u32>,
irii: Mmio<u32>,
ics: Mmio<u16>,
rsvd7: [Mmio<u8>; 6],
}
pub struct ImmediateCommand {
regs: &'static mut ImmediateCommandRegs,
}
impl ImmediateCommand {
pub fn new(regs_addr: usize) -> ImmediateCommand {
unsafe {
ImmediateCommand {
regs: &mut *(regs_addr as *mut ImmediateCommandRegs),
}
}
}
pub fn cmd(&mut self, cmd: u32) -> Result<u64> {
{
// wait for ready
let timeout = Timeout::from_secs(1);
while self.regs.ics.readf(ICB) {
timeout.run().map_err(|()| {
log::error!("timeout on immediate command");
Error::new(EIO)
})?;
}
}
// write command
self.regs.icoi.write(cmd);
// set ICB bit to send command
self.regs.ics.writef(ICB, true);
{
// wait for IRV bit to be set to indicate a response is latched
let timeout = Timeout::from_secs(1);
while !self.regs.ics.readf(IRV) {
timeout.run().map_err(|()| {
log::error!("timeout on immediate response");
Error::new(EIO)
})?;
}
}
// read the result register twice, total of 8 bytes
// highest 4 will most likely be zeros (so I've heard)
let mut res: u64 = self.regs.irii.read() as u64;
res |= (self.regs.irii.read() as u64) << 32;
// clear the bit so we know when the next response comes
self.regs.ics.writef(IRV, false);
Ok(res)
}
}
pub struct CommandBuffer {
// regs: &'static mut CommandBufferRegs,
corb: Corb,
rirb: Rirb,
icmd: ImmediateCommand,
use_immediate_cmd: bool,
mem: Dma<[u8; 0x1000]>,
}
impl CommandBuffer {
pub fn new(regs_addr: usize, mut cmd_buff: Dma<[u8; 0x1000]>) -> CommandBuffer {
let corb = Corb::new(
regs_addr + CORB_OFFSET,
cmd_buff.physical(),
cmd_buff.as_mut_ptr().cast(),
);
let rirb = Rirb::new(
regs_addr + RIRB_OFFSET,
cmd_buff.physical() + CORB_BUFF_MAX_SIZE,
cmd_buff
.as_mut_ptr()
.cast::<u8>()
.wrapping_add(CORB_BUFF_MAX_SIZE)
.cast(),
);
let icmd = ImmediateCommand::new(regs_addr + ICMD_OFFSET);
let cmdbuff = CommandBuffer {
corb,
rirb,
icmd,
use_immediate_cmd: false,
mem: cmd_buff,
};
cmdbuff
}
pub fn init(&mut self, use_imm_cmds: bool) -> Result<()> {
self.corb.init()?;
self.rirb.init()?;
self.set_use_imm_cmds(use_imm_cmds)?;
Ok(())
}
pub fn stop(&mut self) -> Result<()> {
self.corb.stop()?;
self.rirb.stop()?;
Ok(())
}
pub fn cmd12(&mut self, addr: WidgetAddr, command: u32, data: u8) -> Result<u64> {
let mut ncmd: u32 = 0;
ncmd |= (addr.0 as u32 & 0x00F) << 28;
ncmd |= (addr.1 as u32 & 0x0FF) << 20;
ncmd |= (command & 0xFFF) << 8;
ncmd |= (data as u32 & 0x0FF) << 0;
self.cmd(ncmd)
}
pub fn cmd4(&mut self, addr: WidgetAddr, command: u32, data: u16) -> Result<u64> {
let mut ncmd: u32 = 0;
ncmd |= (addr.0 as u32 & 0x000F) << 28;
ncmd |= (addr.1 as u32 & 0x00FF) << 20;
ncmd |= (command & 0x000F) << 16;
ncmd |= (data as u32 & 0xFFFF) << 0;
self.cmd(ncmd)
}
pub fn cmd(&mut self, cmd: u32) -> Result<u64> {
if self.use_immediate_cmd {
self.cmd_imm(cmd)
} else {
self.cmd_buff(cmd)
}
}
pub fn cmd_imm(&mut self, cmd: u32) -> Result<u64> {
self.icmd.cmd(cmd)
}
pub fn cmd_buff(&mut self, cmd: u32) -> Result<u64> {
self.corb.send_command(cmd)?;
self.rirb.read_response()
}
pub fn set_use_imm_cmds(&mut self, use_imm: bool) -> Result<()> {
self.use_immediate_cmd = use_imm;
if self.use_immediate_cmd {
self.corb.stop()?;
self.rirb.stop()?;
} else {
self.corb.start();
self.rirb.start();
}
Ok(())
}
}
-195
View File
@@ -1,195 +0,0 @@
use std::fmt;
use std::mem::transmute;
pub type HDANodeAddr = u16;
pub type HDACodecAddr = u8;
pub type NodeAddr = u16;
pub type CodecAddr = u8;
pub type WidgetAddr = (CodecAddr, NodeAddr);
/*
impl fmt::Display for WidgetAddr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:01X}:{:02X}\n", self.0, self.1)
}
}*/
#[derive(Debug, PartialEq)]
#[repr(u8)]
pub enum HDAWidgetType {
AudioOutput = 0x0,
AudioInput = 0x1,
AudioMixer = 0x2,
AudioSelector = 0x3,
PinComplex = 0x4,
Power = 0x5,
VolumeKnob = 0x6,
BeepGenerator = 0x7,
VendorDefined = 0xf,
}
impl fmt::Display for HDAWidgetType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
}
}
#[derive(Debug, PartialEq)]
#[repr(u8)]
pub enum DefaultDevice {
LineOut = 0x0,
Speaker = 0x1,
HPOut = 0x2,
CD = 0x3,
SPDIF = 0x4,
DigitalOtherOut = 0x5,
ModemLineSide = 0x6,
ModemHandsetSide = 0x7,
LineIn = 0x8,
AUX = 0x9,
MicIn = 0xA,
Telephony = 0xB,
SPDIFIn = 0xC,
DigitalOtherIn = 0xD,
Reserved = 0xE,
Other = 0xF,
}
#[derive(Debug)]
#[repr(u8)]
pub enum PortConnectivity {
ConnectedToJack = 0x0,
NoPhysicalConnection = 0x1,
FixedFunction = 0x2,
JackAndInternal = 0x3,
}
#[derive(Debug)]
#[repr(u8)]
pub enum GrossLocation {
ExternalOnPrimary = 0x0,
Internal = 0x1,
SeperateChasis = 0x2,
Other = 0x3,
}
#[derive(Debug)]
#[repr(u8)]
pub enum GeometricLocation {
NA = 0x0,
Rear = 0x1,
Front = 0x2,
Left = 0x3,
Right = 0x4,
Top = 0x5,
Bottom = 0x6,
Special1 = 0x7,
Special2 = 0x8,
Special3 = 0x9,
Resvd1 = 0xA,
Resvd2 = 0xB,
Resvd3 = 0xC,
Resvd4 = 0xD,
Resvd5 = 0xE,
Resvd6 = 0xF,
}
#[derive(Debug)]
#[repr(u8)]
pub enum Color {
Unknown = 0x0,
Black = 0x1,
Grey = 0x2,
Blue = 0x3,
Green = 0x4,
Red = 0x5,
Orange = 0x6,
Yellow = 0x7,
Purple = 0x8,
Pink = 0x9,
Resvd1 = 0xA,
Resvd2 = 0xB,
Resvd3 = 0xC,
Resvd4 = 0xD,
White = 0xE,
Other = 0xF,
}
pub struct ConfigurationDefault {
value: u32,
}
impl ConfigurationDefault {
pub fn from_u32(value: u32) -> ConfigurationDefault {
ConfigurationDefault { value: value }
}
pub fn color(&self) -> Color {
unsafe { transmute(((self.value >> 12) & 0xF) as u8) }
}
pub fn default_device(&self) -> DefaultDevice {
unsafe { transmute(((self.value >> 20) & 0xF) as u8) }
}
pub fn port_connectivity(&self) -> PortConnectivity {
unsafe { transmute(((self.value >> 30) & 0x3) as u8) }
}
pub fn gross_location(&self) -> GrossLocation {
unsafe { transmute(((self.value >> 28) & 0x3) as u8) }
}
pub fn geometric_location(&self) -> GeometricLocation {
unsafe { transmute(((self.value >> 24) & 0x7) as u8) }
}
pub fn is_output(&self) -> bool {
match self.default_device() {
DefaultDevice::LineOut
| DefaultDevice::Speaker
| DefaultDevice::HPOut
| DefaultDevice::CD
| DefaultDevice::SPDIF
| DefaultDevice::DigitalOtherOut
| DefaultDevice::ModemLineSide => true,
_ => false,
}
}
pub fn is_input(&self) -> bool {
match self.default_device() {
DefaultDevice::ModemHandsetSide
| DefaultDevice::LineIn
| DefaultDevice::AUX
| DefaultDevice::MicIn
| DefaultDevice::Telephony
| DefaultDevice::SPDIFIn
| DefaultDevice::DigitalOtherIn => true,
_ => false,
}
}
pub fn sequence(&self) -> u8 {
(self.value & 0xF) as u8
}
pub fn default_association(&self) -> u8 {
((self.value >> 4) & 0xF) as u8
}
}
impl fmt::Display for ConfigurationDefault {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{:?} {:?} {:?} {:?}",
self.default_device(),
self.color(),
self.gross_location(),
self.geometric_location()
)
}
}
File diff suppressed because it is too large Load Diff
-17
View File
@@ -1,17 +0,0 @@
#![allow(dead_code)]
pub mod cmdbuff;
pub mod common;
pub mod device;
pub mod node;
pub mod stream;
pub mod verbs;
pub use self::node::*;
pub use self::stream::*;
pub use self::cmdbuff::*;
pub use self::device::IntelHDA;
pub use self::stream::BitsPerSample;
pub use self::stream::BufferDescriptorListEntry;
pub use self::stream::StreamBuffer;
pub use self::stream::StreamDescriptorRegs;
-108
View File
@@ -1,108 +0,0 @@
use super::common::*;
use std::{fmt, mem};
#[derive(Clone)]
pub struct HDANode {
pub addr: WidgetAddr,
// 0x4
pub subnode_count: u16,
pub subnode_start: u16,
// 0x5
pub function_group_type: u8,
// 0x9
pub capabilities: u32,
// 0xE
pub conn_list_len: u8,
pub connections: Vec<WidgetAddr>,
pub connection_default: u8,
pub is_widget: bool,
pub config_default: u32,
}
impl HDANode {
pub fn new() -> HDANode {
HDANode {
addr: (0, 0),
subnode_count: 0,
subnode_start: 0,
function_group_type: 0,
capabilities: 0,
conn_list_len: 0,
config_default: 0,
is_widget: false,
connections: Vec::<WidgetAddr>::new(),
connection_default: 0,
}
}
pub fn widget_type(&self) -> HDAWidgetType {
unsafe { mem::transmute(((self.capabilities >> 20) & 0xF) as u8) }
}
pub fn device_default(&self) -> Option<DefaultDevice> {
if self.widget_type() != HDAWidgetType::PinComplex {
None
} else {
Some(unsafe { mem::transmute(((self.config_default >> 20) & 0xF) as u8) })
}
}
pub fn configuration_default(&self) -> ConfigurationDefault {
ConfigurationDefault::from_u32(self.config_default)
}
pub fn addr(&self) -> WidgetAddr {
self.addr
}
}
impl fmt::Display for HDANode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.addr == (0, 0) {
write!(
f,
"Addr: {:02X}:{:02X}, Root Node.",
self.addr.0, self.addr.1
)
} else if self.is_widget {
match self.widget_type() {
HDAWidgetType::PinComplex => write!(
f,
"Addr: {:02X}:{:02X}, Type: {:?}: {:?}, Inputs: {}/{}: {:X?}.",
self.addr.0,
self.addr.1,
self.widget_type(),
self.device_default().unwrap(),
self.connection_default,
self.conn_list_len,
self.connections
),
_ => write!(
f,
"Addr: {:02X}:{:02X}, Type: {:?}, Inputs: {}/{}: {:X?}.",
self.addr.0,
self.addr.1,
self.widget_type(),
self.connection_default,
self.conn_list_len,
self.connections
),
}
} else {
write!(
f,
"Addr: {:02X}:{:02X}, AFG: {}, Widget count {}.",
self.addr.0, self.addr.1, self.function_group_type, self.subnode_count
)
}
}
}
-387
View File
@@ -1,387 +0,0 @@
use common::dma::Dma;
use common::io::{Io, Mmio};
use std::cmp::min;
use std::ptr::copy_nonoverlapping;
use std::result;
use syscall::error::{Error, Result, EIO};
use syscall::PAGE_SIZE;
extern crate syscall;
pub enum BaseRate {
BR44_1,
BR48,
}
pub struct SampleRate {
base: BaseRate,
mult: u16,
div: u16,
}
use self::BaseRate::{BR44_1, BR48};
pub const SR_8: SampleRate = SampleRate {
base: BR48,
mult: 1,
div: 6,
};
pub const SR_11_025: SampleRate = SampleRate {
base: BR44_1,
mult: 1,
div: 4,
};
pub const SR_16: SampleRate = SampleRate {
base: BR48,
mult: 1,
div: 3,
};
pub const SR_22_05: SampleRate = SampleRate {
base: BR44_1,
mult: 1,
div: 2,
};
pub const SR_32: SampleRate = SampleRate {
base: BR48,
mult: 2,
div: 3,
};
pub const SR_44_1: SampleRate = SampleRate {
base: BR44_1,
mult: 1,
div: 1,
};
pub const SR_48: SampleRate = SampleRate {
base: BR48,
mult: 1,
div: 1,
};
pub const SR_88_1: SampleRate = SampleRate {
base: BR44_1,
mult: 2,
div: 1,
};
pub const SR_96: SampleRate = SampleRate {
base: BR48,
mult: 2,
div: 1,
};
pub const SR_176_4: SampleRate = SampleRate {
base: BR44_1,
mult: 4,
div: 1,
};
pub const SR_192: SampleRate = SampleRate {
base: BR48,
mult: 4,
div: 1,
};
#[repr(u8)]
pub enum BitsPerSample {
Bits8 = 0,
Bits16 = 1,
Bits20 = 2,
Bits24 = 3,
Bits32 = 4,
}
pub fn format_to_u16(sr: &SampleRate, bps: BitsPerSample, channels: u8) -> u16 {
// 3.3.41
let base: u16 = match sr.base {
BaseRate::BR44_1 => 1 << 14,
BaseRate::BR48 => 0,
};
let mult = ((sr.mult - 1) & 0x7) << 11;
let div = ((sr.div - 1) & 0x7) << 8;
let bits = (bps as u16) << 4;
let chan = ((channels - 1) & 0xF) as u16;
let val: u16 = base | mult | div | bits | chan;
val
}
#[repr(C, packed)]
pub struct StreamDescriptorRegs {
ctrl_lo: Mmio<u16>,
ctrl_hi: Mmio<u8>,
status: Mmio<u8>,
link_pos: Mmio<u32>,
buff_length: Mmio<u32>,
last_valid_index: Mmio<u16>,
resv1: Mmio<u16>,
fifo_size_: Mmio<u16>,
format: Mmio<u16>,
resv2: Mmio<u32>,
buff_desc_list_lo: Mmio<u32>,
buff_desc_list_hi: Mmio<u32>,
}
impl StreamDescriptorRegs {
pub fn status(&self) -> u8 {
self.status.read()
}
pub fn set_status(&mut self, status: u8) {
self.status.write(status);
}
pub fn control(&self) -> u32 {
let mut ctrl = self.ctrl_lo.read() as u32;
ctrl |= (self.ctrl_hi.read() as u32) << 16;
ctrl
}
pub fn set_control(&mut self, control: u32) {
self.ctrl_lo.write((control & 0xFFFF) as u16);
self.ctrl_hi.write(((control >> 16) & 0xFF) as u8);
}
pub fn set_pcm_format(&mut self, sr: &SampleRate, bps: BitsPerSample, channels: u8) {
// 3.3.41
let val = format_to_u16(sr, bps, channels);
self.format.write(val);
}
pub fn fifo_size(&self) -> u16 {
self.fifo_size_.read()
}
pub fn set_cyclic_buffer_length(&mut self, length: u32) {
self.buff_length.write(length);
}
pub fn cyclic_buffer_length(&self) -> u32 {
self.buff_length.read()
}
pub fn run(&mut self) {
let val = self.control() | (1 << 1);
self.set_control(val);
}
pub fn stop(&mut self) {
let val = self.control() & !(1 << 1);
self.set_control(val);
}
pub fn stream_number(&self) -> u8 {
((self.control() >> 20) & 0xF) as u8
}
pub fn set_stream_number(&mut self, stream_number: u8) {
let val = (self.control() & 0x00FFFF) | (((stream_number & 0xF) as u32) << 20);
self.set_control(val);
}
pub fn set_address(&mut self, addr: usize) {
self.buff_desc_list_lo.write((addr & 0xFFFFFFFF) as u32);
self.buff_desc_list_hi
.write((((addr as u64) >> 32) & 0xFFFFFFFF) as u32);
}
pub fn set_last_valid_index(&mut self, index: u16) {
self.last_valid_index.write(index);
}
pub fn link_position(&self) -> u32 {
self.link_pos.read()
}
pub fn set_interrupt_on_completion(&mut self, enable: bool) {
let mut ctrl = self.control();
if enable {
ctrl |= 1 << 2;
} else {
ctrl &= !(1 << 2);
}
self.set_control(ctrl);
}
pub fn buffer_complete(&self) -> bool {
self.status.readf(1 << 2)
}
pub fn clear_interrupts(&mut self) {
self.status.write(0x7 << 2);
}
// get sample size in bytes
pub fn sample_size(&self) -> usize {
let format = self.format.read();
let chan = (format & 0xF) as usize;
let bits = ((format >> 4) & 0xF) as usize;
match bits {
0 => 1 * (chan + 1),
1 => 2 * (chan + 1),
_ => 4 * (chan + 1),
}
}
}
pub struct OutputStream {
buff: StreamBuffer,
desc_regs: &'static mut StreamDescriptorRegs,
}
impl OutputStream {
pub fn new(
block_count: usize,
block_length: usize,
regs: &'static mut StreamDescriptorRegs,
) -> OutputStream {
OutputStream {
buff: StreamBuffer::new(block_length, block_count).unwrap(),
desc_regs: regs,
}
}
pub fn write_block(&mut self, buf: &[u8]) -> Result<usize> {
self.buff.write_block(buf)
}
pub fn block_size(&self) -> usize {
self.buff.block_size()
}
pub fn block_count(&self) -> usize {
self.buff.block_count()
}
pub fn current_block(&self) -> usize {
self.buff.current_block()
}
pub fn addr(&self) -> usize {
self.buff.addr()
}
pub fn phys(&self) -> usize {
self.buff.phys()
}
}
#[repr(C, packed)]
pub struct BufferDescriptorListEntry {
addr_low: Mmio<u32>,
addr_high: Mmio<u32>,
len: Mmio<u32>,
ioc_resv: Mmio<u32>,
}
impl BufferDescriptorListEntry {
pub fn address(&self) -> u64 {
(self.addr_low.read() as u64) | ((self.addr_high.read() as u64) << 32)
}
pub fn set_address(&mut self, addr: u64) {
self.addr_low.write(addr as u32);
self.addr_high.write((addr >> 32) as u32);
}
pub fn length(&self) -> u32 {
self.len.read()
}
pub fn set_length(&mut self, length: u32) {
self.len.write(length)
}
pub fn interrupt_on_completion(&self) -> bool {
(self.ioc_resv.read() & 0x1) == 0x1
}
pub fn set_interrupt_on_complete(&mut self, ioc: bool) {
self.ioc_resv.writef(1, ioc);
}
}
pub struct StreamBuffer {
mem: Dma<[u8]>,
block_cnt: usize,
block_len: usize,
cur_pos: usize,
}
impl StreamBuffer {
pub fn new(
block_length: usize,
block_count: usize,
) -> result::Result<StreamBuffer, &'static str> {
let page_aligned_size = (block_length * block_count).next_multiple_of(PAGE_SIZE);
let mem = unsafe {
Dma::zeroed_slice(page_aligned_size)
.map_err(|_| "Could not allocate physical memory for buffer.")?
.assume_init()
};
Ok(StreamBuffer {
mem,
block_len: block_length,
block_cnt: block_count,
cur_pos: 0,
})
}
pub fn length(&self) -> usize {
self.block_len * self.block_cnt
}
pub fn addr(&self) -> usize {
self.mem.as_ptr() as usize
}
pub fn phys(&self) -> usize {
self.mem.physical()
}
pub fn block_size(&self) -> usize {
self.block_len
}
pub fn block_count(&self) -> usize {
self.block_cnt
}
pub fn current_block(&self) -> usize {
self.cur_pos
}
pub fn write_block(&mut self, buf: &[u8]) -> Result<usize> {
if buf.len() != self.block_size() {
return Err(Error::new(EIO));
}
let len = min(self.block_size(), buf.len());
//log::trace!("Phys: {:X} Virt: {:X} Offset: {:X} Len: {:X}", self.phys(), self.addr(), self.current_block() * self.block_size(), len);
unsafe {
copy_nonoverlapping(
buf.as_ptr(),
(self.addr() + self.current_block() * self.block_size()) as *mut u8,
len,
);
}
self.cur_pos += 1;
self.cur_pos %= self.block_count();
Ok(len)
}
}
impl Drop for StreamBuffer {
fn drop(&mut self) {
log::debug!("IHDA: Deallocating buffer.");
}
}
-206
View File
@@ -1,206 +0,0 @@
// HDA verb and parameter constants — ported from Linux 7.1 include/sound/hda_verbs.h.
// The hda_verbs.h header defines the HDA specification's verb IDs, parameter IDs,
// and capability bitfields for codec communication via CORB/RIRB.
// ---- Widget types (hda_verbs.h:25) ----
pub const AC_WID_AUD_OUT: u8 = 0x00;
pub const AC_WID_AUD_IN: u8 = 0x01;
pub const AC_WID_AUD_MIX: u8 = 0x02;
pub const AC_WID_AUD_SEL: u8 = 0x03;
pub const AC_WID_PIN: u8 = 0x04;
pub const AC_WID_POWER: u8 = 0x05;
pub const AC_WID_VOL_KNB: u8 = 0x06;
pub const AC_WID_BEEP: u8 = 0x07;
pub const AC_WID_VENDOR: u8 = 0x0f;
// ---- GET verbs (hda_verbs.h:40-84) ----
pub const AC_VERB_GET_STREAM_FORMAT: u32 = 0x0a00;
pub const AC_VERB_GET_AMP_GAIN_MUTE: u32 = 0x0b00;
pub const AC_VERB_GET_PROC_COEF: u32 = 0x0c00;
pub const AC_VERB_GET_COEF_INDEX: u32 = 0x0d00;
pub const AC_VERB_PARAMETERS: u32 = 0x0f00;
pub const AC_VERB_GET_CONNECT_SEL: u32 = 0x0f01;
pub const AC_VERB_GET_CONNECT_LIST: u32 = 0x0f02;
pub const AC_VERB_GET_PROC_STATE: u32 = 0x0f03;
pub const AC_VERB_GET_SDI_SELECT: u32 = 0x0f04;
pub const AC_VERB_GET_POWER_STATE: u32 = 0x0f05;
pub const AC_VERB_GET_CONV: u32 = 0x0f06;
pub const AC_VERB_GET_PIN_WIDGET_CONTROL: u32 = 0x0f07;
pub const AC_VERB_GET_UNSOLICITED_RESPONSE: u32 = 0x0f08;
pub const AC_VERB_GET_PIN_SENSE: u32 = 0x0f09;
pub const AC_VERB_GET_BEEP_CONTROL: u32 = 0x0f0a;
pub const AC_VERB_GET_EAPD_BTLENABLE: u32 = 0x0f0c;
pub const AC_VERB_GET_DIGI_CONVERT_1: u32 = 0x0f0d;
pub const AC_VERB_GET_VOLUME_KNOB_CONTROL: u32 = 0x0f0f;
pub const AC_VERB_GET_CONFIG_DEFAULT: u32 = 0x0f1c;
pub const AC_VERB_GET_SUBSYSTEM_ID: u32 = 0x0f20;
pub const AC_VERB_GET_STRIPE_CONTROL: u32 = 0x0f24;
pub const AC_VERB_GET_CVT_CHAN_COUNT: u32 = 0x0f2d;
pub const AC_VERB_GET_HDMI_DIP_SIZE: u32 = 0x0f2e;
pub const AC_VERB_GET_HDMI_ELDD: u32 = 0x0f2f;
pub const AC_VERB_GET_DEVICE_SEL: u32 = 0x0f35;
pub const AC_VERB_GET_DEVICE_LIST: u32 = 0x0f36;
// ---- SET verbs (hda_verbs.h:89-131) ----
pub const AC_VERB_SET_STREAM_FORMAT: u32 = 0x200;
pub const AC_VERB_SET_AMP_GAIN_MUTE: u32 = 0x300;
pub const AC_VERB_SET_PROC_COEF: u32 = 0x400;
pub const AC_VERB_SET_COEF_INDEX: u32 = 0x500;
pub const AC_VERB_SET_CONNECT_SEL: u32 = 0x701;
pub const AC_VERB_SET_PROC_STATE: u32 = 0x703;
pub const AC_VERB_SET_SDI_SELECT: u32 = 0x704;
pub const AC_VERB_SET_POWER_STATE: u32 = 0x705;
pub const AC_VERB_SET_CHANNEL_STREAMID: u32 = 0x706;
pub const AC_VERB_SET_PIN_WIDGET_CONTROL: u32 = 0x707;
pub const AC_VERB_SET_UNSOLICITED_ENABLE: u32 = 0x708;
pub const AC_VERB_SET_PIN_SENSE: u32 = 0x709;
pub const AC_VERB_SET_BEEP_CONTROL: u32 = 0x70a;
pub const AC_VERB_SET_EAPD_BTLENABLE: u32 = 0x70c;
pub const AC_VERB_SET_DIGI_CONVERT_1: u32 = 0x70d;
pub const AC_VERB_SET_DIGI_CONVERT_2: u32 = 0x70e;
pub const AC_VERB_SET_VOLUME_KNOB_CONTROL: u32 = 0x70f;
pub const AC_VERB_SET_CONFIG_DEFAULT_BYTES_0: u32 = 0x71c;
pub const AC_VERB_SET_CONFIG_DEFAULT_BYTES_1: u32 = 0x71d;
pub const AC_VERB_SET_CONFIG_DEFAULT_BYTES_2: u32 = 0x71e;
pub const AC_VERB_SET_CONFIG_DEFAULT_BYTES_3: u32 = 0x71f;
pub const AC_VERB_SET_EAPD: u32 = 0x788;
pub const AC_VERB_SET_CODEC_RESET: u32 = 0x7ff;
pub const AC_VERB_SET_STRIPE_CONTROL: u32 = 0x724;
pub const AC_VERB_SET_CVT_CHAN_COUNT: u32 = 0x72d;
// ---- Parameter IDs for AC_VERB_PARAMETERS (hda_verbs.h:136-154) ----
pub const AC_PAR_VENDOR_ID: u8 = 0x00;
pub const AC_PAR_SUBSYSTEM_ID: u8 = 0x01;
pub const AC_PAR_REV_ID: u8 = 0x02;
pub const AC_PAR_NODE_COUNT: u8 = 0x04;
pub const AC_PAR_FUNCTION_TYPE: u8 = 0x05;
pub const AC_PAR_AUDIO_FG_CAP: u8 = 0x08;
pub const AC_PAR_AUDIO_WIDGET_CAP: u8 = 0x09;
pub const AC_PAR_PCM: u8 = 0x0a;
pub const AC_PAR_STREAM: u8 = 0x0b;
pub const AC_PAR_PIN_CAP: u8 = 0x0c;
pub const AC_PAR_AMP_IN_CAP: u8 = 0x0d;
pub const AC_PAR_CONNLIST_LEN: u8 = 0x0e;
pub const AC_PAR_POWER_STATE: u8 = 0x0f;
pub const AC_PAR_PROC_CAP: u8 = 0x10;
pub const AC_PAR_GPIO_CAP: u8 = 0x11;
pub const AC_PAR_AMP_OUT_CAP: u8 = 0x12;
pub const AC_PAR_VOL_KNB_CAP: u8 = 0x13;
pub const AC_PAR_DEVLIST_LEN: u8 = 0x15;
pub const AC_PAR_HDMI_LPCM_CAP: u8 = 0x20;
// ---- Audio Widget Capabilities (hda_verbs.h:171-188) ----
pub const AC_WCAP_STEREO: u32 = 1 << 0;
pub const AC_WCAP_IN_AMP: u32 = 1 << 1;
pub const AC_WCAP_OUT_AMP: u32 = 1 << 2;
pub const AC_WCAP_AMP_OVRD: u32 = 1 << 3;
pub const AC_WCAP_FORMAT_OVRD: u32 = 1 << 4;
pub const AC_WCAP_STRIPE: u32 = 1 << 5;
pub const AC_WCAP_PROC_WID: u32 = 1 << 6;
pub const AC_WCAP_UNSOL_CAP: u32 = 1 << 7;
pub const AC_WCAP_CONN_LIST: u32 = 1 << 8;
pub const AC_WCAP_DIGITAL: u32 = 1 << 9;
pub const AC_WCAP_POWER: u32 = 1 << 10;
pub const AC_WCAP_LR_SWAP: u32 = 1 << 11;
pub const AC_WCAP_CP_CAPS: u32 = 1 << 12;
pub const AC_WCAP_CHAN_CNT_EXT: u32 = 7 << 13;
pub const AC_WCAP_DELAY: u32 = 0xf << 16;
pub const AC_WCAP_DELAY_SHIFT: u8 = 16;
pub const AC_WCAP_TYPE: u32 = 0xf << 20;
pub const AC_WCAP_TYPE_SHIFT: u8 = 20;
// ---- Pin Capabilities (hda_verbs.h:262-289) ----
pub const AC_PINCAP_IMP_SENSE: u32 = 1 << 0;
pub const AC_PINCAP_TRIG_REQ: u32 = 1 << 1;
pub const AC_PINCAP_PRES_DETECT: u32 = 1 << 2;
pub const AC_PINCAP_HP_DRV: u32 = 1 << 3;
pub const AC_PINCAP_OUT: u32 = 1 << 4;
pub const AC_PINCAP_IN: u32 = 1 << 5;
pub const AC_PINCAP_BALANCE: u32 = 1 << 6;
pub const AC_PINCAP_HDMI: u32 = 1 << 7;
pub const AC_PINCAP_DP: u32 = 1 << 24;
pub const AC_PINCAP_VREF: u32 = 0x37 << 8;
pub const AC_PINCAP_VREF_SHIFT: u8 = 8;
pub const AC_PINCAP_EAPD: u32 = 1 << 16;
pub const AC_PINCAP_HBR: u32 = 1 << 27;
// ---- Pin Widget Control (hda_verbs.h:400-411) ----
pub const AC_PINCTL_EPT: u32 = 0x3;
pub const AC_PINCTL_EPT_NATIVE: u8 = 0;
pub const AC_PINCTL_EPT_HBR: u8 = 3;
pub const AC_PINCTL_IN_EN: u8 = 1 << 5;
pub const AC_PINCTL_OUT_EN: u8 = 1 << 6;
pub const AC_PINCTL_HP_EN: u8 = 1 << 7;
// ---- Pin Sense (hda_verbs.h:414-416) ----
pub const AC_PINSENSE_IMPEDANCE_MASK: u32 = 0x7fff_ffff;
pub const AC_PINSENSE_PRESENCE: u32 = 1 << 31;
pub const AC_PINSENSE_ELDV: u32 = 1 << 30;
// ---- Power State (hda_verbs.h:311-330) ----
pub const AC_PWRST_D0SUP: u32 = 1 << 0;
pub const AC_PWRST_D1SUP: u32 = 1 << 1;
pub const AC_PWRST_D2SUP: u32 = 1 << 2;
pub const AC_PWRST_D3SUP: u32 = 1 << 3;
pub const AC_PWRST_D3COLDSUP: u32 = 1 << 4;
pub const AC_PWRST_S3D3COLDSUP: u32 = 1 << 29;
pub const AC_PWRST_CLKSTOP: u32 = 1 << 30;
pub const AC_PWRST_EPSS: u32 = 1 << 31;
pub const AC_PWRST_SETTING: u32 = 0xf;
pub const AC_PWRST_ACTUAL: u32 = 0xf << 4;
pub const AC_PWRST_ACTUAL_SHIFT: u8 = 4;
pub const AC_PWRST_D0: u32 = 0x00;
pub const AC_PWRST_D1: u32 = 0x01;
pub const AC_PWRST_D2: u32 = 0x02;
pub const AC_PWRST_D3: u32 = 0x03;
pub const AC_PWRST_ERROR: u32 = 1 << 8;
pub const AC_PWRST_CLK_STOP_OK: u32 = 1 << 9;
pub const AC_PWRST_SETTING_RESET: u32 = 1 << 10;
// ---- Amplifier (hda_verbs.h:366-380) ----
pub const AC_AMP_MUTE: u8 = 1 << 7;
pub const AC_AMP_GAIN: u8 = 0x7f;
pub const AC_AMP_GET_LEFT: u32 = 1 << 13;
pub const AC_AMP_GET_OUTPUT: u32 = 1 << 15;
// ---- PCM/Stream format (hda_verbs.h:191-235) ----
pub const AC_SUPPCM_BITS_8: u32 = 1 << 16;
pub const AC_SUPPCM_BITS_16: u32 = 1 << 17;
pub const AC_SUPPCM_BITS_20: u32 = 1 << 18;
pub const AC_SUPPCM_BITS_24: u32 = 1 << 19;
pub const AC_SUPPCM_BITS_32: u32 = 1 << 20;
pub const AC_SUPFMT_PCM: u32 = 1;
// ---- DIGITAL1 (hda_verbs.h:383-391) ----
pub const AC_DIG1_ENABLE: u32 = 1;
pub const AC_DIG1_V: u32 = 1 << 1;
pub const AC_DIG1_EMPHASIS: u32 = 1 << 3;
pub const AC_DIG1_COPYRIGHT: u32 = 1 << 4;
pub const AC_DIG1_NONAUDIO: u32 = 1 << 5;
pub const AC_DIG1_PROFESSIONAL: u32 = 1 << 6;
pub const AC_DIG1_LEVEL: u32 = 1 << 7;
// ---- Connection List (hda_verbs.h:307-308) ----
pub const AC_CLIST_LENGTH: u32 = 0x7f;
pub const AC_CLIST_LONG: u32 = 1 << 7;
// ---- Function Group (hda_verbs.h:161-168) ----
pub const AC_GRP_AUDIO_FUNCTION: u8 = 0x01;
pub const AC_GRP_MODEM_FUNCTION: u8 = 0x02;
pub const AC_FGT_UNSOL_CAP: u32 = 1 << 8;
pub const AC_AFG_OUT_DELAY: u32 = 0xf;
pub const AC_AFG_IN_DELAY: u32 = 0xf << 8;
pub const AC_AFG_BEEP_GEN: u32 = 1 << 16;
// ---- Stream Format (hda_verbs.h:221-235) ----
pub const AC_FMT_CHAN_SHIFT: u8 = 0;
pub const AC_FMT_CHAN_MASK: u32 = 0x0f;
pub const AC_FMT_BITS_SHIFT: u8 = 4;
pub const AC_FMT_BITS_MASK: u32 = 7 << 4;
pub const AC_FMT_BITS_8: u32 = 0;
pub const AC_FMT_BITS_16: u32 = 1 << 4;
pub const AC_FMT_BITS_20: u32 = 2 << 4;
pub const AC_FMT_BITS_24: u32 = 3 << 4;
pub const AC_FMT_BITS_32: u32 = 4 << 4;
pub const AC_FMT_BASE_48K: u32 = 0;
pub const AC_FMT_BASE_44K: u32 = 1 << 14;
-135
View File
@@ -1,135 +0,0 @@
use redox_scheme::scheme::register_sync_scheme;
use redox_scheme::Socket;
use scheme_utils::ReadinessBased;
use std::io::{Read, Write};
use std::os::unix::io::AsRawFd;
use std::usize;
use event::{user_data, EventQueue};
use pcid_interface::irq_helpers::pci_allocate_interrupt_vector;
use pcid_interface::PciFunctionHandle;
pub mod hda;
/*
VEND:PROD
Virtualbox 8086:2668
QEMU ICH9 8086:293E
82801H ICH8 8086:284B
*/
fn main() {
pcid_interface::pci_daemon(daemon);
}
fn daemon(daemon: daemon::Daemon, mut pcid_handle: PciFunctionHandle) -> ! {
let pci_config = pcid_handle.config();
let mut name = pci_config.func.name();
name.push_str("_ihda");
common::setup_logging(
"audio",
"pci",
&name,
common::output_level(),
common::file_level(),
);
log::info!("IHDA {}", pci_config.func.display());
let address = unsafe { pcid_handle.map_bar(0) }.ptr.as_ptr() as usize;
let irq_file = pci_allocate_interrupt_vector(&mut pcid_handle, "ihdad");
{
let vend_prod: u32 = ((pci_config.func.full_device_id.vendor_id as u32) << 16)
| (pci_config.func.full_device_id.device_id as u32);
user_data! {
enum Source {
Irq,
Scheme,
}
}
let event_queue =
EventQueue::<Source>::new().expect("ihdad: Could not create event queue.");
let socket = Socket::nonblock().expect("ihdad: failed to create socket");
let mut device = unsafe {
hda::IntelHDA::new(address, vend_prod).expect("ihdad: failed to allocate device")
};
let mut readiness_based = ReadinessBased::new(&socket, 16);
register_sync_scheme(&socket, "audiohw", &mut device)
.expect("ihdad: failed to register audiohw scheme to namespace");
daemon.ready();
event_queue
.subscribe(
socket.inner().raw(),
Source::Scheme,
event::EventFlags::READ,
)
.unwrap();
event_queue
.subscribe(
irq_file.irq_handle().as_raw_fd() as usize,
Source::Irq,
event::EventFlags::READ,
)
.unwrap();
libredox::call::setrens(0, 0).expect("ihdad: failed to enter null namespace");
let all = [Source::Irq, Source::Scheme];
for event in all
.into_iter()
.chain(event_queue.map(|e| e.expect("failed to get next event").user_data))
{
match event {
Source::Irq => {
let mut irq = [0; 8];
irq_file.irq_handle().read(&mut irq).unwrap();
if !device.irq() {
continue;
}
irq_file.irq_handle().write(&mut irq).unwrap();
readiness_based
.poll_all_requests(&mut device)
.expect("ihdad: failed to poll requests");
readiness_based
.write_responses()
.expect("ihdad: failed to write to socket");
/*
let next_read = device_irq.next_read();
if next_read > 0 {
return Ok(Some(next_read));
}
*/
}
Source::Scheme => {
readiness_based
.read_and_process_requests(&mut device)
.expect("ihdad: failed to read from socket");
readiness_based
.write_responses()
.expect("ihdad: failed to write to socket");
/*
let next_read = device.borrow().next_read();
if next_read > 0 {
return Ok(Some(next_read));
}
*/
}
}
}
std::process::exit(0);
}
}
-20
View File
@@ -1,20 +0,0 @@
[package]
name = "sb16d"
description = "Sound Blaster sound card driver"
version = "0.1.0"
edition = "2021"
[dependencies]
bitflags.workspace = true
common = { path = "../../common" }
libredox.workspace = true
log.workspace = true
daemon = { path = "../../../daemon" }
redox_event.workspace = true
redox_syscall.workspace = true
spin.workspace = true
redox-scheme.workspace = true
scheme-utils = { path = "../../../scheme-utils" }
[lints]
workspace = true
-232
View File
@@ -1,232 +0,0 @@
use std::{thread, time};
use common::io::{Io, Pio, ReadOnly, WriteOnly};
use redox_scheme::scheme::SchemeSync;
use redox_scheme::CallerCtx;
use redox_scheme::OpenResult;
use scheme_utils::{FpathWriter, HandleMap};
use syscall::error::{Error, Result, EACCES, EBADF, ENODEV};
use syscall::schemev2::NewFdFlags;
use spin::Mutex;
const NUM_SUB_BUFFS: usize = 32;
const SUB_BUFF_SIZE: usize = 2048;
enum Handle {
Todo,
SchemeRoot,
}
#[allow(dead_code)]
pub struct Sb16 {
handles: Mutex<HandleMap<Handle>>,
pub(crate) irqs: Vec<u8>,
dmas: Vec<u8>,
// Regs
/* 0x04 */ mixer_addr: WriteOnly<Pio<u8>>,
/* 0x05 */ mixer_data: Pio<u8>,
/* 0x06 */ dsp_reset: WriteOnly<Pio<u8>>,
/* 0x0A */ dsp_read_data: ReadOnly<Pio<u8>>,
/* 0x0C */ dsp_write_data: WriteOnly<Pio<u8>>,
/* 0x0C */ dsp_write_status: ReadOnly<Pio<u8>>,
/* 0x0E */ dsp_read_status: ReadOnly<Pio<u8>>,
}
impl Sb16 {
pub unsafe fn new(addr: u16) -> Result<Self> {
let mut module = Sb16 {
handles: Mutex::new(HandleMap::new()),
irqs: Vec::new(),
dmas: Vec::new(),
// Regs
mixer_addr: WriteOnly::new(Pio::new(addr + 0x04)),
mixer_data: Pio::new(addr + 0x05),
dsp_reset: WriteOnly::new(Pio::new(addr + 0x06)),
dsp_read_data: ReadOnly::new(Pio::new(addr + 0x0A)),
dsp_write_data: WriteOnly::new(Pio::new(addr + 0x0C)),
dsp_write_status: ReadOnly::new(Pio::new(addr + 0x0C)),
dsp_read_status: ReadOnly::new(Pio::new(addr + 0x0E)),
};
module.init()?;
Ok(module)
}
fn mixer_read(&mut self, index: u8) -> u8 {
self.mixer_addr.write(index);
self.mixer_data.read()
}
fn mixer_write(&mut self, index: u8, value: u8) {
self.mixer_addr.write(index);
self.mixer_data.write(value);
}
fn dsp_read(&mut self) -> Result<u8> {
// Bit 7 must be 1 before data can be sent
while !self.dsp_read_status.readf(1 << 7) {
//TODO: timeout!
std::thread::yield_now();
}
Ok(self.dsp_read_data.read())
}
fn dsp_write(&mut self, value: u8) -> Result<()> {
// Bit 7 must be 0 before data can be sent
while self.dsp_write_status.readf(1 << 7) {
//TODO: timeout!
std::thread::yield_now();
}
self.dsp_write_data.write(value);
Ok(())
}
fn init(&mut self) -> Result<()> {
// Perform DSP reset
{
// Write 1 to reset port
self.dsp_reset.write(1);
// Wait 3us
thread::sleep(time::Duration::from_micros(3));
// Write 0 to reset port
self.dsp_reset.write(0);
//TODO: Wait for ready byte (0xAA) using read status
thread::sleep(time::Duration::from_micros(100));
let ready = self.dsp_read()?;
if ready != 0xAA {
log::error!("ready byte was 0x{:02X} instead of 0xAA", ready);
return Err(Error::new(ENODEV));
}
}
// Read DSP version
{
self.dsp_write(0xE1)?;
let major = self.dsp_read()?;
let minor = self.dsp_read()?;
log::info!("DSP version {}.{:02}", major, minor);
if major != 4 {
log::error!("Unsupported DSP major version {}", major);
return Err(Error::new(ENODEV));
}
}
// Get available IRQs and DMAs
{
self.irqs.clear();
let irq_mask = self.mixer_read(0x80);
if (irq_mask & (1 << 0)) != 0 {
self.irqs.push(2);
}
if (irq_mask & (1 << 1)) != 0 {
self.irqs.push(5);
}
if (irq_mask & (1 << 2)) != 0 {
self.irqs.push(7);
}
if (irq_mask & (1 << 3)) != 0 {
self.irqs.push(10);
}
self.dmas.clear();
let dma_mask = self.mixer_read(0x81);
if (dma_mask & (1 << 0)) != 0 {
self.dmas.push(0);
}
if (dma_mask & (1 << 1)) != 0 {
self.dmas.push(1);
}
if (dma_mask & (1 << 3)) != 0 {
self.dmas.push(3);
}
if (dma_mask & (1 << 5)) != 0 {
self.dmas.push(5);
}
if (dma_mask & (1 << 6)) != 0 {
self.dmas.push(6);
}
if (dma_mask & (1 << 7)) != 0 {
self.dmas.push(7);
}
log::info!("IRQs {:02X?} DMAs {:02X?}", self.irqs, self.dmas);
}
// Set output sample rate to 44100 Hz (Redox OS standard)
{
let rate = 44100u16;
self.dsp_write(0x41)?;
self.dsp_write((rate >> 8) as u8)?;
self.dsp_write(rate as u8)?;
}
Ok(())
}
pub fn irq(&mut self) -> bool {
//TODO
false
}
}
impl SchemeSync for Sb16 {
fn scheme_root(&mut self) -> Result<usize> {
Ok(self.handles.lock().insert(Handle::SchemeRoot))
}
fn openat(
&mut self,
dirfd: usize,
_path: &str,
_flags: usize,
_fcntl_flags: u32,
ctx: &CallerCtx,
) -> Result<OpenResult> {
{
let handles = self.handles.lock();
let handle = handles.get(dirfd)?;
if !matches!(handle, Handle::SchemeRoot) {
return Err(Error::new(EACCES));
}
}
if ctx.uid == 0 {
let id = self.handles.lock().insert(Handle::Todo);
Ok(OpenResult::ThisScheme {
number: id,
flags: NewFdFlags::empty(),
})
} else {
Err(Error::new(EACCES))
}
}
fn write(
&mut self,
_id: usize,
_buf: &[u8],
_offset: u64,
_flags: u32,
_ctx: &CallerCtx,
) -> Result<usize> {
//TODO
Err(Error::new(EBADF))
}
fn fpath(&mut self, _id: usize, buf: &mut [u8], _ctx: &CallerCtx) -> Result<usize> {
FpathWriter::with(buf, "audiohw", |_| Ok(()))
}
fn on_close(&mut self, id: usize) {
self.handles.lock().remove(id);
}
}
-119
View File
@@ -1,119 +0,0 @@
use libredox::{flag, Fd};
use redox_scheme::scheme::register_sync_scheme;
use redox_scheme::Socket;
use scheme_utils::ReadinessBased;
use std::{env, usize};
use event::{user_data, EventQueue};
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub mod device;
fn main() {
daemon::Daemon::new(daemon);
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn daemon(daemon: daemon::Daemon) -> ! {
let mut args = env::args().skip(1);
let addr_str = args.next().unwrap_or("220".to_string());
let addr = u16::from_str_radix(&addr_str, 16).expect("sb16: failed to parse address");
println!(" + sb16 at 0x{:X}\n", addr);
common::setup_logging(
"audio",
"pci",
"sb16",
common::output_level(),
common::file_level(),
);
common::acquire_port_io_rights().expect("sb16d: failed to acquire port IO rights");
let socket = Socket::nonblock().expect("sb16d: failed to create socket");
let mut device = unsafe { device::Sb16::new(addr).expect("sb16d: failed to allocate device") };
let mut readiness_based = ReadinessBased::new(&socket, 16);
//TODO: error on multiple IRQs?
let irq_file = match device.irqs.first() {
Some(irq) => Fd::open(&format!("/scheme/irq/{}", irq), flag::O_RDWR, 0)
.expect("sb16d: failed to open IRQ file"),
None => panic!("sb16d: no IRQs found"),
};
user_data! {
enum Source {
Irq,
Scheme,
}
}
let event_queue = EventQueue::<Source>::new().expect("sb16d: Could not create event queue.");
event_queue
.subscribe(irq_file.raw(), Source::Irq, event::EventFlags::READ)
.unwrap();
event_queue
.subscribe(
socket.inner().raw(),
Source::Scheme,
event::EventFlags::READ,
)
.unwrap();
register_sync_scheme(&socket, "sb16d", &mut device)
.expect("sb16d: failed to register audiohw scheme to namespace");
daemon.ready();
libredox::call::setrens(0, 0).expect("sb16d: failed to enter null namespace");
let all = [Source::Irq, Source::Scheme];
for event in all
.into_iter()
.chain(event_queue.map(|e| e.expect("sb16d: failed to get next event").user_data))
{
match event {
Source::Irq => {
let mut irq = [0; 8];
irq_file.read(&mut irq).unwrap();
if !device.irq() {
continue;
}
irq_file.write(&mut irq).unwrap();
readiness_based
.poll_all_requests(&mut device)
.expect("sb16d: failed to poll requests");
readiness_based
.write_responses()
.expect("sb16d: failed to write to socket");
/*
let next_read = device_irq.next_read();
if next_read > 0 {
return Ok(Some(next_read));
}
*/
}
Source::Scheme => {
readiness_based
.read_and_process_requests(&mut device)
.expect("sb16d: failed to read from socket");
readiness_based
.write_responses()
.expect("sb16d: failed to write to socket");
}
}
}
std::process::exit(0);
}
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
fn daemon(_daemon: daemon::Daemon) -> ! {
// Sound Blaster 16 is an x86/x86_64 legacy ISA card; no other architectures are supported.
panic!("sb16d: only supported on x86 and x86_64");
}
-18
View File
@@ -1,18 +0,0 @@
[package]
name = "common"
description = "Shared driver code library"
version = "0.1.0"
edition = "2021"
authors = ["4lDO2 <4lDO2@protonmail.com>"]
license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
libredox.workspace = true
log.workspace = true
redox_syscall = { workspace = true, features = ["std"] }
redox-log.workspace = true
[lints]
workspace = true
-265
View File
@@ -1,265 +0,0 @@
use std::mem::{self, size_of, MaybeUninit};
use std::ops::{Deref, DerefMut};
use std::ptr;
use std::sync::LazyLock;
use libredox::call::MmapArgs;
use libredox::{error::Result, flag, Fd};
use syscall::PAGE_SIZE;
use crate::{memory_root_fd, MemoryType, VirtaddrTranslationHandle};
/// Defines the platform-specific memory type for DMA operations
///
/// - On x86 systems, DMA uses Write-back memory ([`MemoryType::Writeback`])
/// - On aarch64 systems, DMA uses uncacheable memory ([`MemoryType::Uncacheable`])
const DMA_MEMTY: MemoryType = {
if cfg!(any(target_arch = "x86", target_arch = "x86_64")) {
// x86 ensures cache coherence with DMA memory
MemoryType::Writeback
} else if cfg!(target_arch = "aarch64") {
// aarch64 currently must map DMA memory without caching to ensure coherence
MemoryType::Uncacheable
} else if cfg!(target_arch = "riscv64") {
// FIXME check this out more
MemoryType::Uncacheable
} else {
panic!("invalid arch")
}
};
/// Returns a file descriptor for zeroized physically-contiguous DMA memory.
///
/// # Returns
///
/// A [Result] containing:
/// - '[Ok]' - A [Fd] (file descriptor) to zeroized, physically continuous DMA usable memory
/// - '[Err]' - The error returned by the provider of the /scheme/memory/zeroed scheme.
///
/// # Errors
///
/// This function can return an error in the following case:
///
/// - The request for the physical memory fails.
pub(crate) fn phys_contiguous_fd() -> Result<Fd> {
memory_root_fd().openat(
&format!("zeroed@{DMA_MEMTY}?phys_contiguous"),
flag::O_CLOEXEC,
0,
)
}
/// Allocates a chunk of physical memory for DMA, and then maps it to virtual memory.
///
/// # Arguments
/// 'length: [usize]' - The length of the memory region. Must be a multiple of [`PAGE_SIZE`]
///
/// # Returns
///
/// This function returns a [Result] containing the following:
/// - A '[Ok]([usize], *[mut] ())' containing a Tuple of the physical address of the region, and a raw pointer to that region in virtual memory.
/// - An '[Err]' - containing the error for the operation.
///
/// # Errors
///
/// This function asserts if:
/// - length is not a multiple of [`PAGE_SIZE`]
///
/// This function returns an error if:
/// - A file descriptor to physically contiguous memory of type [`DMA_MEMTY`] could not be acquired
/// - A virtual mapping for the physically contiguous memory could not be created
/// - The virtual address returned by the memory manager was invalid.
fn alloc_and_map(length: usize, handle: &VirtaddrTranslationHandle) -> Result<(usize, *mut ())> {
assert_eq!(length % PAGE_SIZE, 0);
unsafe {
let fd = phys_contiguous_fd()?;
let virt = libredox::call::mmap(MmapArgs {
fd: fd.raw(),
offset: 0, // ignored
addr: core::ptr::null_mut(), // ignored
length,
flags: flag::MAP_PRIVATE,
prot: flag::PROT_READ | flag::PROT_WRITE,
})?;
let phys = handle.translate(virt as usize)?;
for i in 1..length.div_ceil(PAGE_SIZE) {
debug_assert_eq!(
handle.translate(virt as usize + i * PAGE_SIZE),
Ok(phys + i * PAGE_SIZE),
"NOT CONTIGUOUS"
);
}
Ok((phys, virt as *mut ()))
}
}
/// A safe accessor for DMA memory.
pub struct Dma<T: ?Sized> {
/// The physical address of the memory
phys: usize,
/// The page-aligned length of the memory. Will be a multiple of [`PAGE_SIZE`]
aligned_len: usize,
/// The pointer to the Dma memory in the virtual address space.
virt: *mut T,
}
impl<T> Dma<T> {
/// [Dma] constructor that allocates and initializes a region of DMA memory with the page-aligned
/// size and initial value of some T
///
/// # Arguments
/// 'value: T' - The initial value to write to the allocated region
///
/// # Returns
///
/// This function returns a [Result] containing the following:
///
/// - A '[Ok] (`[Dma]<T>`)' containing the initialized region
/// - An '[Err]' containing an error.
pub fn new(value: T) -> Result<Self> {
unsafe {
let mut zeroed = Self::zeroed()?;
zeroed.as_mut_ptr().write(value);
Ok(zeroed.assume_init())
}
}
/// [Dma] constructor that allocates and zeroizes a memory region of the page-aligned size of T
///
/// # Returns
///
/// This function returns a [Result] containing the following:
///
/// - A '[Ok] (`[Dma]<[MaybeUninit]<T>>`)' containing the allocated and zeroized memory
/// - An '[Err]' containing an error.
pub fn zeroed() -> Result<Dma<MaybeUninit<T>>> {
let aligned_len = size_of::<T>().next_multiple_of(PAGE_SIZE);
let (phys, virt) = alloc_and_map(aligned_len, &*VIRTTOPHYS_HANDLE)?;
Ok(Dma {
phys,
virt: virt.cast(),
aligned_len,
})
}
}
impl<T> Dma<MaybeUninit<T>> {
/// Assumes that possibly uninitialized DMA memory has been initialized, and returns a new
/// instance of an object of type `[Dma]<T>`.
///
/// # Returns
/// - `[Dma]<T>` - The original structure without the [`MaybeUninit`] wrapper around its contents.
///
/// # Notes
/// - This is unsafe because it assumes that the memory stored within the `[Dma]<T>` is a valid
/// instance of T. If it isn't (for example -- if it was initialized with [`Dma::zeroed`]),
/// then the underlying memory may not contain the expected T structure.
pub unsafe fn assume_init(self) -> Dma<T> {
let Dma {
phys,
aligned_len,
virt,
} = self;
mem::forget(self);
Dma {
phys,
aligned_len,
virt: virt.cast(),
}
}
}
impl<T: ?Sized> Dma<T> {
/// Returns the physical address of the physical memory that this [Dma] structure references.
///
/// # Returns
/// [usize] - The physical address of the memory.
pub fn physical(&self) -> usize {
self.phys
}
}
// TODO: there should exist a "context" struct that drivers create at start, which would be passed
// to the respective functions
static VIRTTOPHYS_HANDLE: LazyLock<VirtaddrTranslationHandle> = LazyLock::new(|| {
VirtaddrTranslationHandle::new().expect("failed to acquire virttophys translation handle")
});
impl<T> Dma<[T]> {
/// Returns a [Dma] object containing a zeroized slice of T with a given count.
///
/// # Arguments
///
/// - 'count: [usize]' - The number of elements of type T in the allocated slice.
pub fn zeroed_slice(count: usize) -> Result<Dma<[MaybeUninit<T>]>> {
let aligned_len = count
.checked_mul(size_of::<T>())
.unwrap()
.next_multiple_of(PAGE_SIZE);
let (phys, virt) = alloc_and_map(aligned_len, &*VIRTTOPHYS_HANDLE)?;
Ok(Dma {
phys,
aligned_len,
virt: ptr::slice_from_raw_parts_mut(virt.cast(), count),
})
}
/// Casts the slice from type T to type U.
///
/// # Returns
/// '`[DMA]<U>`' - A cast handle to the Dma memory.
pub unsafe fn cast_slice<U>(self) -> Dma<[U]> {
let Dma {
phys,
virt,
aligned_len,
} = self;
core::mem::forget(self);
Dma {
phys,
virt: virt as *mut [U],
aligned_len,
}
}
}
impl<T> Dma<[MaybeUninit<T>]> {
/// See [`Dma<MaybeUninit<T>>::assume_init`]
pub unsafe fn assume_init(self) -> Dma<[T]> {
let &Dma {
phys,
aligned_len,
virt,
} = &self;
mem::forget(self);
Dma {
phys,
aligned_len,
virt: virt as *mut [T],
}
}
}
impl<T: ?Sized> Deref for Dma<T> {
type Target = T;
fn deref(&self) -> &T {
unsafe { &*self.virt }
}
}
impl<T: ?Sized> DerefMut for Dma<T> {
fn deref_mut(&mut self) -> &mut T {
unsafe { &mut *self.virt }
}
}
impl<T: ?Sized> Drop for Dma<T> {
fn drop(&mut self) {
unsafe {
ptr::drop_in_place(self.virt);
let _ = libredox::call::munmap(self.virt as *mut (), self.aligned_len);
}
}
}
-95
View File
@@ -1,95 +0,0 @@
use core::{
cmp::PartialEq,
ops::{BitAnd, BitOr, Not},
};
mod mmio;
mod mmio_ptr;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
mod pio;
pub use mmio::*;
pub use mmio_ptr::*;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub use pio::*;
/// IO abstraction
pub trait Io {
/// Value type for IO, usually some unsigned number
type Value: Copy
+ PartialEq
+ BitAnd<Output = Self::Value>
+ BitOr<Output = Self::Value>
+ Not<Output = Self::Value>;
/// Read the underlying valu2e
fn read(&self) -> Self::Value;
/// Write the underlying value
fn write(&mut self, value: Self::Value);
/// Check whether the underlying value contains bit flags
#[inline(always)]
fn readf(&self, flags: Self::Value) -> bool {
(self.read() & flags) as Self::Value == flags
}
/// Enable or disable specific bit flags
#[inline(always)]
fn writef(&mut self, flags: Self::Value, value: bool) {
let tmp: Self::Value = match value {
true => self.read() | flags,
false => self.read() & !flags,
};
self.write(tmp);
}
}
/// Read-only IO
#[repr(transparent)]
pub struct ReadOnly<I> {
inner: I,
}
impl<I: Io> ReadOnly<I> {
/// Wraps IO
pub const fn new(inner: I) -> ReadOnly<I> {
ReadOnly { inner }
}
}
impl<I: Io> ReadOnly<I> {
/// Calls [`Io::read`]
#[inline(always)]
pub fn read(&self) -> I::Value {
self.inner.read()
}
/// Calls [`Io::readf`]
#[inline(always)]
pub fn readf(&self, flags: I::Value) -> bool {
self.inner.readf(flags)
}
}
#[repr(transparent)]
/// Write-only IO
pub struct WriteOnly<I> {
inner: I,
}
impl<I: Io> WriteOnly<I> {
/// Wraps IO
pub const fn new(inner: I) -> WriteOnly<I> {
WriteOnly { inner }
}
}
impl<I: Io> WriteOnly<I> {
/// Calls [`Io::write`]
#[inline(always)]
pub fn write(&mut self, value: I::Value) {
self.inner.write(value)
}
// writef requires read which is not valid when write-only
}
-173
View File
@@ -1,173 +0,0 @@
use core::{mem::MaybeUninit, ptr};
use super::Io;
/// MMIO abstraction
#[repr(C, packed)]
pub struct Mmio<T> {
value: MaybeUninit<T>,
}
impl<T> Mmio<T> {
/// Creates a zeroed instance
pub unsafe fn zeroed() -> Self {
Self {
value: MaybeUninit::zeroed(),
}
}
/// Creates an unitialized instance
pub unsafe fn uninit() -> Self {
Self {
value: MaybeUninit::uninit(),
}
}
/// Creates a new instance
pub const fn new(value: T) -> Self {
Self {
value: MaybeUninit::new(value),
}
}
}
// Generic implementation (WARNING: requires aligned pointers!)
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
impl<T> Io for Mmio<T>
where
T: Copy
+ PartialEq
+ core::ops::BitAnd<Output = T>
+ core::ops::BitOr<Output = T>
+ core::ops::Not<Output = T>,
{
type Value = T;
fn read(&self) -> T {
unsafe { ptr::read_volatile(ptr::addr_of!(self.value).cast::<T>()) }
}
fn write(&mut self, value: T) {
unsafe { ptr::write_volatile(ptr::addr_of_mut!(self.value).cast::<T>(), value) };
}
}
// x86 u8 implementation
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
impl Io for Mmio<u8> {
type Value = u8;
fn read(&self) -> Self::Value {
unsafe {
let value: Self::Value;
let ptr: *const Self::Value = ptr::addr_of!(self.value).cast::<Self::Value>();
core::arch::asm!(
"mov {}, [{}]",
out(reg_byte) value,
in(reg) ptr
);
value
}
}
fn write(&mut self, value: Self::Value) {
unsafe {
let ptr: *mut Self::Value = ptr::addr_of_mut!(self.value).cast::<Self::Value>();
core::arch::asm!(
"mov [{}], {}",
in(reg) ptr,
in(reg_byte) value,
);
}
}
}
// x86 u16 implementation
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
impl Io for Mmio<u16> {
type Value = u16;
fn read(&self) -> Self::Value {
unsafe {
let value: Self::Value;
let ptr: *const Self::Value = ptr::addr_of!(self.value).cast::<Self::Value>();
core::arch::asm!(
"mov {:x}, [{}]",
out(reg) value,
in(reg) ptr
);
value
}
}
fn write(&mut self, value: Self::Value) {
unsafe {
let ptr: *mut Self::Value = ptr::addr_of_mut!(self.value).cast::<Self::Value>();
core::arch::asm!(
"mov [{}], {:x}",
in(reg) ptr,
in(reg) value,
);
}
}
}
// x86 u32 implementation
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
impl Io for Mmio<u32> {
type Value = u32;
fn read(&self) -> Self::Value {
unsafe {
let value: Self::Value;
let ptr: *const Self::Value = ptr::addr_of!(self.value).cast::<Self::Value>();
core::arch::asm!(
"mov {:e}, [{}]",
out(reg) value,
in(reg) ptr
);
value
}
}
fn write(&mut self, value: Self::Value) {
unsafe {
let ptr: *mut Self::Value = ptr::addr_of_mut!(self.value).cast::<Self::Value>();
core::arch::asm!(
"mov [{}], {:e}",
in(reg) ptr,
in(reg) value,
);
}
}
}
// x86 u64 implementation (x86_64 only)
#[cfg(target_arch = "x86_64")]
impl Io for Mmio<u64> {
type Value = u64;
fn read(&self) -> Self::Value {
unsafe {
let value: Self::Value;
let ptr: *const Self::Value = ptr::addr_of!(self.value).cast::<Self::Value>();
core::arch::asm!(
"mov {:r}, [{}]",
out(reg) value,
in(reg) ptr
);
value
}
}
fn write(&mut self, value: Self::Value) {
unsafe {
let ptr: *mut Self::Value = ptr::addr_of_mut!(self.value).cast::<Self::Value>();
core::arch::asm!(
"mov [{}], {:r}",
in(reg) ptr,
in(reg) value,
);
}
}
}
-157
View File
@@ -1,157 +0,0 @@
use super::Io;
/// MMIO using pointer instead of wrapped type
pub struct MmioPtr<T> {
ptr: *mut T,
}
impl<T> MmioPtr<T> {
//TODO: reads and writes are unsafe, not new.
/// Creates a `MmioPtr`.
pub unsafe fn new(ptr: *mut T) -> Self {
Self { ptr }
}
/// Creates a const pointer from a `MmioPtr`.
pub const fn as_ptr(&self) -> *const T {
self.ptr
}
/// Creates a mutable pointer from a `MmioPtr`.
pub const fn as_mut_ptr(&mut self) -> *mut T {
self.ptr
}
}
// Generic implementation (WARNING: requires aligned pointers!)
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
impl<T> Io for MmioPtr<T>
where
T: Copy
+ PartialEq
+ core::ops::BitAnd<Output = T>
+ core::ops::BitOr<Output = T>
+ core::ops::Not<Output = T>,
{
type Value = T;
fn read(&self) -> T {
unsafe { core::ptr::read_volatile(self.ptr) }
}
fn write(&mut self, value: T) {
unsafe { core::ptr::write_volatile(self.ptr, value) };
}
}
// x86 u8 implementation
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
impl Io for MmioPtr<u8> {
type Value = u8;
fn read(&self) -> Self::Value {
unsafe {
let value: Self::Value;
core::arch::asm!(
"mov {}, [{}]",
out(reg_byte) value,
in(reg) self.ptr
);
value
}
}
fn write(&mut self, value: Self::Value) {
unsafe {
core::arch::asm!(
"mov [{}], {}",
in(reg) self.ptr,
in(reg_byte) value,
);
}
}
}
// x86 u16 implementation
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
impl Io for MmioPtr<u16> {
type Value = u16;
fn read(&self) -> Self::Value {
unsafe {
let value: Self::Value;
core::arch::asm!(
"mov {:x}, [{}]",
out(reg) value,
in(reg) self.ptr
);
value
}
}
fn write(&mut self, value: Self::Value) {
unsafe {
core::arch::asm!(
"mov [{}], {:x}",
in(reg) self.ptr,
in(reg) value,
);
}
}
}
// x86 u32 implementation
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
impl Io for MmioPtr<u32> {
type Value = u32;
fn read(&self) -> Self::Value {
unsafe {
let value: Self::Value;
core::arch::asm!(
"mov {:e}, [{}]",
out(reg) value,
in(reg) self.ptr
);
value
}
}
fn write(&mut self, value: Self::Value) {
unsafe {
core::arch::asm!(
"mov [{}], {:e}",
in(reg) self.ptr,
in(reg) value,
);
}
}
}
// x86 u64 implementation (x86_64 only)
#[cfg(target_arch = "x86_64")]
impl Io for MmioPtr<u64> {
type Value = u64;
fn read(&self) -> Self::Value {
unsafe {
let value: Self::Value;
core::arch::asm!(
"mov {:r}, [{}]",
out(reg) value,
in(reg) self.ptr
);
value
}
}
fn write(&mut self, value: Self::Value) {
unsafe {
core::arch::asm!(
"mov [{}], {:r}",
in(reg) self.ptr,
in(reg) value,
);
}
}
}
-89
View File
@@ -1,89 +0,0 @@
use core::{arch::asm, marker::PhantomData};
use super::Io;
/// Generic PIO
#[derive(Copy, Clone)]
pub struct Pio<T> {
port: u16,
value: PhantomData<T>,
}
impl<T> Pio<T> {
/// Create a PIO from a given port
pub const fn new(port: u16) -> Self {
Pio::<T> {
port,
value: PhantomData,
}
}
}
/// Read/Write for byte PIO
impl Io for Pio<u8> {
type Value = u8;
/// Read
#[inline(always)]
fn read(&self) -> u8 {
let value: u8;
unsafe {
asm!("in al, dx", in("dx") self.port, out("al") value, options(nostack, nomem, preserves_flags));
}
value
}
/// Write
#[inline(always)]
fn write(&mut self, value: u8) {
unsafe {
asm!("out dx, al", in("dx") self.port, in("al") value, options(nostack, nomem, preserves_flags));
}
}
}
/// Read/Write for word PIO
impl Io for Pio<u16> {
type Value = u16;
/// Read
#[inline(always)]
fn read(&self) -> u16 {
let value: u16;
unsafe {
asm!("in ax, dx", in("dx") self.port, out("ax") value, options(nostack, nomem, preserves_flags));
}
value
}
/// Write
#[inline(always)]
fn write(&mut self, value: u16) {
unsafe {
asm!("out dx, ax", in("dx") self.port, in("ax") value, options(nostack, nomem, preserves_flags));
}
}
}
/// Read/Write for doubleword PIO
impl Io for Pio<u32> {
type Value = u32;
/// Read
#[inline(always)]
fn read(&self) -> u32 {
let value: u32;
unsafe {
asm!("in eax, dx", in("dx") self.port, out("eax") value, options(nostack, nomem, preserves_flags));
}
value
}
/// Write
#[inline(always)]
fn write(&mut self, value: u32) {
unsafe {
asm!("out dx, eax", in("dx") self.port, in("eax") value, options(nostack, nomem, preserves_flags));
}
}
}
-371
View File
@@ -1,371 +0,0 @@
//! This crate provides various abstractions for use by all drivers in the Redox drivers repo.
//!
//! This includes direct memory access via [dma], and Scatter-Gather List support via [sgl]. It also
//! provides various memory management structures for use with drivers, and some logging support.
use libredox::call::MmapArgs;
use libredox::flag::{self, O_CLOEXEC, O_RDONLY, O_RDWR, O_WRONLY};
use libredox::{
errno::EINVAL,
error::{Error, Result},
Fd,
};
use syscall::{ProcSchemeVerb, PAGE_SIZE};
/// The Direct Memory Access (DMA) API for drivers
pub mod dma;
/// MMIO utilities
pub mod io;
mod logger;
/// The Scatter Gather List (SGL) API for drivers.
pub mod sgl;
/// Low latency timeout for driver loops
pub mod timeout;
pub use logger::{file_level, output_level, setup_logging};
use std::sync::OnceLock;
static MEMORY_ROOT_FD: OnceLock<libredox::Fd> = OnceLock::new();
/// Initializes a file descriptor to be used as the root memory for a driver.
///
/// # Panics
///
/// This function will panic if:
/// - `libredox` is unable to open a file descriptor.
/// - The memory root file descriptor has already been set (this function has already been called).
pub fn init() {
if MEMORY_ROOT_FD
.set(
libredox::Fd::open("/scheme/memory/scheme-root", 0, 0)
.expect("drivers common: failed to open memory root fd"),
)
.is_err()
{
panic!("drivers common: failed to set memory root fd");
}
}
/// Gets the memory root file descriptor.
///
/// # Panics
///
/// This function will panic if `init` has not already been called first.
pub fn memory_root_fd() -> &'static libredox::Fd {
MEMORY_ROOT_FD
.get()
.expect("drivers common: memory root fd not initialized. Please call `common::init` in your main function.")
}
/// Specifies the write behavior for a specific region of memory
///
/// These types indicate to the driver how writes to a specific memory region are handled by the
/// system. This usually refers to the caching behavior that the processor or I/O device responsible
/// for that memory implements.
///
/// aarch64 and x86 have very different cache-coherency rules, so this API as written is likely
/// not sufficient to describe the memory caching behavior in a cross-platform manner. As such,
/// consider this API unstable.
#[derive(Clone, Copy, Debug)]
pub enum MemoryType {
/// A region of memory that implements Write-back caching.
///
/// In write-back caching, the processor will first store data in its local cache, and then
/// flush it to the actual storage location at regular intervals, or as applications access
/// the data.
Writeback,
/// A region of memory that does not implement caching. Writes to these regions are immediate.
Uncacheable,
/// A region of memory that implements write combining.
///
/// Write combining memory regions store all writes in a temporary buffer called a Write
/// Combine Buffer. Multiple writes to the location are stored in a single buffer, and then
/// released to the memory location in an unspecified order. Write-Combine memory does not
/// guarantee that the order at which you write to it is the order at which those writes are
/// committed to memory.
WriteCombining,
/// Memory stored in an intermediate Write Combine Buffer and released later
/// Memory-Mapped I/O. This is an aarch64-specific term.
DeviceMemory,
}
impl Default for MemoryType {
fn default() -> Self {
Self::Writeback
}
}
/// Represents the protection level of an area of memory.
///
/// This structure shouldn't be used directly -- instead, use the [`Prot::RO`] (Read-Only),
/// [`Prot::WO`] (Write-Only) and [`Prot::RW`] (Read-Write) constants to specify the memory's protection
/// level.
#[derive(Clone, Copy, Debug)]
pub struct Prot {
/// The memory is readable
pub read: bool,
/// The memory is writeable
pub write: bool,
}
/// Implements the memory protection level constants
impl Prot {
/// A constant representing Read-Only memory.
pub const RO: Self = Self {
read: true,
write: false,
};
/// A constant representing Write-Only memory
pub const WO: Self = Self {
read: false,
write: true,
};
/// A constant representing Read-Write memory
pub const RW: Self = Self {
read: true,
write: true,
};
}
/// Maps physical memory to virtual memory
///
/// # Arguments
///
/// * '`base_phys`: [usize]' - The base address of the physical memory to map.
/// * 'len: [usize]' - The length of the physical memory to map (Should be a multiple of [`PAGE_SIZE`]
/// * '_: [Prot]' - The memory protection level of the mapping.
/// * 'type: [`MemoryType`]' - The caching behavior specification of the memory.
///
/// # Returns
///
/// A '[Result]<*mut ()>' which is:
/// - '[Ok]' containing a raw pointer to the mapped memory.
/// - '[Err]' which contains an error on failure.
///
/// # Errors
///
/// This function will return an error if:
/// - An invalid value is provided to 'read' or 'write'
/// - The system could not open a file descriptor to the memory scheme for the specified [`MemoryType`].
/// - The system failed to map the physical address to a virtual address. See [`libredox::call::mmap`]
///
/// # Safety
///
/// Safe, as the kernel ensures it doesn't conflict with any other memory described in the memory
/// map for regular RAM.
///
/// # Notes
/// - This function is unsafe, and upon using it you will be responsible for freeing the memory with
/// [`libredox::call::munmap`]. If you want a safe accessor, use [`PhysBorrowed`] instead.
/// - The `MemoryType` specified is used to tell the function which memory scheme to access. (i.e
/// /scheme/memory/physical@wb, /scheme/memory/physical@uc, etc).
pub unsafe fn physmap(
base_phys: usize,
len: usize,
Prot { read, write }: Prot,
ty: MemoryType,
) -> Result<*mut ()> {
// TODO: arraystring?
//Return an error rather than potentially crash the kernel.
if base_phys == 0 {
return Err(Error::new(EINVAL));
}
let path = format!(
"physical@{}",
match ty {
MemoryType::Writeback => "wb",
MemoryType::Uncacheable => "uc",
MemoryType::WriteCombining => "wc",
MemoryType::DeviceMemory => "dev",
}
);
let mode = match (read, write) {
(true, true) => O_RDWR,
(true, false) => O_RDONLY,
(false, true) => O_WRONLY,
(false, false) => return Err(Error::new(EINVAL)),
};
let mut prot = 0;
if read {
prot |= flag::PROT_READ;
}
if write {
prot |= flag::PROT_WRITE;
}
let fd = memory_root_fd().openat(&path, O_CLOEXEC | mode, 0)?;
Ok(libredox::call::mmap(MmapArgs {
fd: fd.raw(),
offset: base_phys as u64,
length: len.next_multiple_of(PAGE_SIZE),
flags: flag::MAP_SHARED,
prot,
addr: core::ptr::null_mut(),
})? as *mut ())
}
impl std::fmt::Display for MemoryType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Self::Writeback => "wb",
Self::Uncacheable => "uc",
Self::WriteCombining => "wc",
Self::DeviceMemory => "dev",
}
)
}
}
/// A safe virtual mapping to physical memory that unmaps the memory when the structure goes out
/// of scope.
///
/// This function provides a safe binding to [physmap]. It implements Drop to free the mapped memory
/// when the structure goes out of scope.
pub struct PhysBorrowed {
mem: *mut (),
len: usize,
}
impl PhysBorrowed {
/// Constructs a `PhysBorrowed` instance.
///
/// # Arguments
/// See [physmap] for a description of the parameters.
///
/// # Returns
/// A '[Result]' which contains the following:
/// - A '[`PhysBorrowed`]' which represents the newly mapped region.
/// - An 'Err' if a memory mapping error occurs.
///
/// # Errors
/// See [physmap] for a description of the error cases.
pub fn map(base_phys: usize, len: usize, prot: Prot, ty: MemoryType) -> Result<Self> {
let mem = unsafe { physmap(base_phys, len, prot, ty)? };
Ok(Self {
mem,
len: len.next_multiple_of(PAGE_SIZE),
})
}
/// Gets a raw pointer to the borrowed region.
///
/// # Returns
/// - self.mem - A pointer to the mapped region in virtual memory.
///
/// # Notes
/// - The pointer may live beyond the lifetime of [`PhysBorrowed`], so dereferences to the pointer
/// must be treated as unsafe.
///
pub fn as_ptr(&self) -> *mut () {
self.mem
}
/// Gets the length of the mapped region.
///
/// # Returns
/// - self.len - The length of the mapped region. It should be a multiple of [`PAGE_SIZE`]
pub fn mapped_len(&self) -> usize {
self.len
}
}
impl Drop for PhysBorrowed {
/// Frees the mapped memory region.
fn drop(&mut self) {
unsafe {
let _ = libredox::call::munmap(self.mem, self.len);
}
}
}
/// Instructs the kernel to enable I/O ports for this (usermode) process (x86-specific).
///
/// On Redox, x86 privilege ring 3 represents userspace. Most Redox drivers run in userspace to
/// prevent system instability caused by a faulty driver. Processes with (bitmap-enabled) IO port
/// rights can use the IN/OUT instructions. This is not the same as IOPL 3; the CLI instruction is
/// still not allowed.
pub fn acquire_port_io_rights() -> Result<()> {
extern "C" {
fn redox_cur_thrfd_v0() -> usize;
}
let kernel_fd = libredox::call::dup(unsafe { redox_cur_thrfd_v0() }, b"open_via_dup")?;
let res = libredox::call::call_wo(
kernel_fd,
&[],
syscall::CallFlags::empty(),
&[ProcSchemeVerb::Iopl as u64],
);
let _ = libredox::call::close(kernel_fd);
res?;
Ok(())
}
/// Kernel handle for translating virtual addresses in the current address space, to their
/// underlying physical addresses.
///
/// It is currently unspecified whether this handle is specific to the address space at the time it
/// was created, or whether all calls reference the currently active address space.
pub struct VirtaddrTranslationHandle {
fd: Fd,
}
impl VirtaddrTranslationHandle {
/// Create a new handle, requires uid=0 but this may change.
pub fn new() -> Result<Self> {
Ok(Self {
fd: memory_root_fd().openat("translation", O_CLOEXEC, 0)?,
})
}
/// Translate physical => virtual.
pub fn translate(&self, physical: usize) -> Result<usize> {
let mut buf = physical.to_ne_bytes();
libredox::call::call_ro(self.fd.raw(), &mut buf, syscall::CallFlags::empty(), &[])?;
Ok(usize::from_ne_bytes(buf))
}
}
#[cfg(test)]
mod physmap_type_assertions {
use super::*;
/// If `physmap` ever changes its error type, this test fails to
/// compile and surfaces the regression at `cargo check` time on the
/// host rather than during a full Redox cross-build.
///
/// The check uses `std::mem::size_of_val` on a constructed error
/// value. `libredox::error::Error` is `pub struct { errno: u16 }`,
/// so its `size_of_val` is exactly `size_of::<u16>() == 2`. A
/// future change to a different error type (e.g.
/// `syscall::error::Error { errno: i32 }` which would be 4 bytes)
/// would change this constant and force a maintainer to update
/// both the assertion and the downstream `map_err` adapters in
/// lockstep — making the type drift visible at review time rather
/// than at build time.
#[test]
fn physmap_returns_libredox_error_result() {
// Reference layout: `libredox::error::Error { errno: u16 }`.
// If this changes the size assertion below must be updated.
const EXPECTED_SIZE: usize = std::mem::size_of::<u16>();
// Reference error type used at the assertion site.
let reference: libredox::error::Error = libredox::error::Error::new(0);
assert_eq!(std::mem::size_of_val(&reference), EXPECTED_SIZE);
// Coercion check: the function pointer signature must be
// mappable to the expected return type. If physmap's error
// type drifts (e.g. from `libredox::error::Error` to
// `syscall::error::Error` or `std::io::Error`), this coercion
// fails to compile. We never call `f` — we only borrow its
// signature.
let _f: PhysmapSig = physmap;
}
/// Concrete signature of `physmap` for the assertion above.
type PhysmapSig = unsafe fn(usize, usize, Prot, MemoryType) -> libredox::error::Result<*mut ()>;
}
-108
View File
@@ -1,108 +0,0 @@
use std::str::FromStr;
use libredox::{flag, Fd};
use redox_log::{OutputBuilder, RedoxLogger};
/// Get the log verbosity for the output level.
pub fn output_level() -> log::LevelFilter {
log::LevelFilter::Info
}
/// Get the log verbosity for the file level.
pub fn file_level() -> log::LevelFilter {
log::LevelFilter::Info
}
/// Configures logging for a single driver.
#[cfg_attr(not(target_os = "redox"), allow(unused_variables, unused_mut))]
pub fn setup_logging(
category: &str,
subcategory: &str,
logfile_base: &str,
mut output_level: log::LevelFilter,
file_level: log::LevelFilter,
) {
RedoxLogger::init_timezone();
if let Some(log_level) = read_bootloader_log_level_env(category, subcategory) {
output_level = log_level;
}
let mut logger = RedoxLogger::new().with_output(
OutputBuilder::stderr()
.with_filter(output_level) // limit global output to important info
.with_ansi_escape_codes()
.flush_on_newline(true)
.build(),
);
#[cfg(target_os = "redox")]
match OutputBuilder::in_redox_logging_scheme(
category,
subcategory,
format!("{logfile_base}.log"),
) {
Ok(b) => {
logger = logger.with_output(b.with_filter(file_level).flush_on_newline(true).build())
}
Err(error) => eprintln!("Failed to create {logfile_base}.log: {}", error),
}
#[cfg(target_os = "redox")]
match OutputBuilder::in_redox_logging_scheme(
category,
subcategory,
format!("{logfile_base}.ansi.log"),
) {
Ok(b) => {
logger = logger.with_output(
b.with_filter(file_level)
.with_ansi_escape_codes()
.flush_on_newline(true)
.build(),
)
}
Err(error) => eprintln!("Failed to create {logfile_base}.ansi.log: {}", error),
}
logger.enable().expect("failed to set default logger");
}
fn read_bootloader_log_level_env(category: &str, subcategory: &str) -> Option<log::LevelFilter> {
let mut env_bytes = [0_u8; 4096];
// TODO: Have the kernel env can specify prefixed env key instead of having to read all of them
let envs = {
let Ok(fd) = Fd::open("/scheme/sys/env", flag::O_RDONLY | flag::O_CLOEXEC, 0) else {
return None;
};
let Ok(bytes_read) = fd.read(&mut env_bytes) else {
return None;
};
if bytes_read >= env_bytes.len() {
return None;
}
let env_bytes = &mut env_bytes[..bytes_read];
env_bytes
.split(|&c| c == b'\n')
.filter(|var| var.starts_with(b"DRIVER_"))
.collect::<Vec<_>>()
};
let log_env_keys = [
format!("DRIVER_{}_LOG_LEVEL=", subcategory.to_ascii_uppercase()),
format!("DRIVER_{}_LOG_LEVEL=", category.to_ascii_uppercase()),
"DRIVER_LOG_LEVEL=".to_string(),
];
for log_env_key in log_env_keys {
let log_env_key = log_env_key.as_bytes();
if let Some(log_env) = envs.iter().find_map(|var| var.strip_prefix(log_env_key)) {
if let Ok(Ok(log_level)) = str::from_utf8(&log_env).map(log::LevelFilter::from_str) {
return Some(log_level);
}
}
}
None
}
-130
View File
@@ -1,130 +0,0 @@
use std::num::NonZeroUsize;
use libredox::call::MmapArgs;
use libredox::errno::EINVAL;
use libredox::error::{Error, Result};
use libredox::flag::{MAP_PRIVATE, PROT_NONE, PROT_READ, PROT_WRITE};
use syscall::{MAP_FIXED, PAGE_SIZE};
use crate::dma::phys_contiguous_fd;
use crate::VirtaddrTranslationHandle;
/// A Scatter-Gather List data structure
///
/// See: <https://en.wikipedia.org/wiki/Gather/scatter_(vector_addressing)>
#[derive(Debug)]
pub struct Sgl {
/// A raw pointer to the SGL in virtual memory
virt: *mut u8,
/// The length of the allocated memory, guaranteed to be a multiple of [`PAGE_SIZE`].
aligned_length: usize,
/// The length of the allocated memory. This value is NOT guaranteed to be a multiple of [`PAGE_SIZE`]
unaligned_length: NonZeroUsize,
/// The vector of chunks tracked by this [Sgl] object. This is the sparsely-populated vector in the SGL algorithm.
chunks: Vec<Chunk>,
}
/// A structure representing a chunk of memory in the sparsely-populated vector of the SGL
#[derive(Debug)]
pub struct Chunk {
/// The offset of the chunk in the sparsely-populated vector.
pub offset: usize,
/// The physical address of the chunk
pub phys: usize,
/// A raw pointer to the chunk in virtual memory
pub virt: *mut u8,
/// The length of the chunk in bytes.
pub length: usize,
}
impl Sgl {
/// Constructor for the scatter/gather list.
///
/// # Arguments
///
/// '`unaligned_length`: [usize]' - The length of the SGL, not necessarily aligned to the nearest
/// page.
pub fn new(unaligned_length: usize) -> Result<Self> {
let unaligned_length = NonZeroUsize::new(unaligned_length).ok_or(Error::new(EINVAL))?;
// TODO: Both PAGE_SIZE and MAX_ALLOC_SIZE should be dynamic.
let aligned_length = unaligned_length.get().next_multiple_of(PAGE_SIZE);
const MAX_ALLOC_SIZE: usize = 1 << 22;
unsafe {
let virt = libredox::call::mmap(MmapArgs {
flags: MAP_PRIVATE,
prot: PROT_NONE,
length: aligned_length,
offset: 0,
fd: !0,
addr: core::ptr::null_mut(),
})?
.cast::<u8>();
let mut this = Self {
virt,
aligned_length,
unaligned_length,
chunks: Vec::new(),
};
// TODO: SglContext to avoid reopening these fds?
let phys_contiguous_fd = phys_contiguous_fd()?;
let virttophys_handle = VirtaddrTranslationHandle::new()?;
let mut offset = 0;
while offset < aligned_length {
let preferred_chunk_length = (aligned_length - offset)
.min(MAX_ALLOC_SIZE)
.next_power_of_two();
let chunk_length = if preferred_chunk_length > aligned_length - offset {
preferred_chunk_length / 2
} else {
preferred_chunk_length
};
libredox::call::mmap(MmapArgs {
addr: virt.add(offset).cast(),
flags: MAP_PRIVATE | (MAP_FIXED.bits() as u32),
prot: PROT_READ | PROT_WRITE,
length: chunk_length,
fd: phys_contiguous_fd.raw(),
offset: 0,
})?;
let phys = virttophys_handle.translate(virt as usize + offset)?;
this.chunks.push(Chunk {
offset,
phys,
length: (unaligned_length.get() - offset).min(chunk_length),
virt: virt.add(offset),
});
offset += chunk_length;
}
Ok(this)
}
}
/// Returns an immutable reference to the vector of chunks
pub fn chunks(&self) -> &[Chunk] {
&self.chunks
}
/// Returns a raw pointer to the vector of chunks in virtual memory
pub fn as_ptr(&self) -> *mut u8 {
self.virt
}
/// Returns the length of the scatter-gather list.
pub fn len(&self) -> usize {
self.unaligned_length.get()
}
}
impl Drop for Sgl {
fn drop(&mut self) {
unsafe {
let _ = libredox::call::munmap(self.virt.cast(), self.aligned_length);
}
}
}
-56
View File
@@ -1,56 +0,0 @@
use std::time::{Duration, Instant};
/// Represents an amount of time for a driver to give up to the OS scheduler.
pub struct Timeout {
instant: Instant,
duration: Duration,
}
impl Timeout {
/// Create a new `Timeout` from a `Duration`.
#[inline]
pub fn new(duration: Duration) -> Self {
Self {
instant: Instant::now(),
duration,
}
}
/// Create a new `Timeout` by specifying the amount of microseconds.
#[inline]
pub fn from_micros(micros: u64) -> Self {
Self::new(Duration::from_micros(micros))
}
/// Create a new `Timeout` by specifying the amount of milliseconds.
#[inline]
pub fn from_millis(millis: u64) -> Self {
Self::new(Duration::from_millis(millis))
}
/// Create a new `Timeout` by specifying the amount of seconds.
#[inline]
pub fn from_secs(secs: u64) -> Self {
Self::new(Duration::from_secs(secs))
}
/// Execute the `Timeout`.
///
/// # Errors
///
/// Returns an `Err` if the duration of the `Timeout` has already elapsed
/// between creating the `Timeout` and calling this function.
#[inline]
pub fn run(&self) -> Result<(), ()> {
if self.instant.elapsed() < self.duration {
// Sleeps in Redox are only evaluated on PIT ticks (a few ms), which is not
// short enough for a reasonably responsive timeout. However, the clock is
// highly accurate. So, we yield instead of sleep to reduce latency.
//TODO: allow timeout that spins instead of yields?
std::thread::yield_now();
Ok(())
} else {
Err(())
}
}
}
-15
View File
@@ -1,15 +0,0 @@
[package]
name = "executor"
description = "Asynchronous framework for queue-based hardware interfaces"
authors = ["4lDO2 <4lDO2@protonmail.com>"]
version = "0.1.0"
edition = "2021"
license = "MIT"
[dependencies]
log.workspace = true
redox_event.workspace = true
slab.workspace = true
[lints]
workspace = true
-396
View File
@@ -1,396 +0,0 @@
use std::cell::{Cell, RefCell};
use std::collections::{HashMap, VecDeque};
use std::fmt::Debug;
use std::fs::File;
use std::future::{Future, IntoFuture};
use std::hash::Hash;
use std::io::{Read, Write};
use std::marker::PhantomData;
use std::os::fd::AsRawFd;
use std::panic::AssertUnwindSafe;
use std::pin::Pin;
use std::ptr::NonNull;
use std::rc::Rc;
use std::task;
use event::{EventFlags, RawEventQueue};
use slab::Slab;
type EventUserData = usize;
type FutIdx = usize;
pub trait Hardware: Sized {
type CmdId: Clone + Copy + Debug + Hash + Eq + PartialEq;
type CqId: Clone + Copy + Debug + Hash + Eq + PartialEq;
type SqId: Clone + Copy + Debug + Hash + Eq + PartialEq;
type Sqe: Debug + Clone + Copy;
type Cqe;
type Iv: Clone + Copy + Debug;
type GlobalCtxt;
// TODO: the kernel should also do this automatically before sending EOI messages to the IC
fn mask_vector(ctxt: &Self::GlobalCtxt, iv: Self::Iv);
fn unmask_vector(ctxt: &Self::GlobalCtxt, iv: Self::Iv);
fn set_sqe_cmdid(sqe: &mut Self::Sqe, id: Self::CmdId);
fn get_cqe_cmdid(cqe: &Self::Cqe) -> Self::CmdId;
// TODO: support multiple SQs per CQ or vice versa?
fn sq_cq(ctxt: &Self::GlobalCtxt, id: Self::CqId) -> Self::SqId;
fn current() -> Rc<LocalExecutor<Self>>;
fn vtable() -> &'static task::RawWakerVTable;
fn try_submit(
ctxt: &Self::GlobalCtxt,
sq_id: Self::SqId,
success: impl FnOnce(Self::CmdId) -> Self::Sqe,
fail: impl FnOnce(),
) -> Option<(Self::CqId, Self::CmdId)>;
fn poll_cqes(ctxt: &Self::GlobalCtxt, handle: impl FnMut(Self::CqId, Self::Cqe));
}
/// Async executor, single IV, thread-per-core architecture
pub struct LocalExecutor<Hw: Hardware> {
global_ctxt: Hw::GlobalCtxt,
queue: RawEventQueue,
vector: Hw::Iv,
irq_handle: File,
intx: bool,
// TODO: One IV and SQ/CQ per core (where the admin queue can be managed by the main thread).
awaiting_submission: RefCell<HashMap<Hw::SqId, VecDeque<FutIdx>>>,
awaiting_completion:
RefCell<HashMap<Hw::CqId, HashMap<Hw::CmdId, (FutIdx, NonNull<Option<Hw::Cqe>>)>>>,
external_event: RefCell<HashMap<EventUserData, (FutIdx, NonNull<EventFlags>)>>,
next_user_data: Cell<usize>,
ready_futures: RefCell<VecDeque<FutIdx>>,
futures: RefCell<Slab<Pin<Box<dyn Future<Output = ()> + 'static>>>>,
is_polling: Cell<bool>,
}
impl<Hw: Hardware> LocalExecutor<Hw> {
pub fn register_external_event(
&self,
fd: usize,
flags: event::EventFlags,
) -> ExternalEventSource<Hw> {
let user_data = self.next_user_data.get();
self.next_user_data.set(user_data.checked_add(1).unwrap());
self.queue
.subscribe(fd, user_data, flags)
.expect("failed to subscribe to event");
ExternalEventSource {
flags: event::EventFlags::empty(),
user_data,
_not_send_or_unpin: PhantomData,
}
}
pub fn current() -> Rc<Self> {
Hw::current()
}
pub fn poll(&self) -> usize {
assert!(!self.is_polling.replace(true));
let mut finished = 0;
for future_idx in self.ready_futures.borrow_mut().drain(..) {
let waker = waker::<Hw>(future_idx);
let mut futures = self.futures.borrow_mut();
let res = match std::panic::catch_unwind(AssertUnwindSafe(|| {
futures[future_idx]
.as_mut()
.poll(&mut task::Context::from_waker(&waker))
})) {
Ok(r) => r,
Err(_) => {
log::error!("Task panicked!");
core::mem::forget(futures.remove(future_idx));
continue;
}
};
if res.is_ready() {
drop(futures.remove(future_idx));
finished += 1;
}
}
self.is_polling.set(false);
finished
}
pub fn spawn(&self, fut: impl IntoFuture<Output = ()> + 'static) {
let idx = self
.futures
.borrow_mut()
.insert(Box::pin(fut.into_future()));
self.ready_futures.borrow_mut().push_back(idx);
}
pub fn block_on<'a, O: 'a>(&self, fut: impl IntoFuture<Output = O> + 'a) -> O {
let retval = Rc::new(RefCell::new(None));
let retval2 = Rc::clone(&retval);
let idx = self.futures.borrow_mut().insert({
let t1: Pin<Box<dyn Future<Output = ()> + 'a>> = Box::pin(async move {
*retval2.borrow_mut() = Some(fut.await);
});
// SAFETY: Apart from the lifetimes, the types are exactly the same. We also know
// block_on simply cannot return without having fully awaited and dropped the future,
// even if that future panics (cf. the catch_unwind invocation).
let t2: Pin<Box<dyn Future<Output = ()> + 'static>> =
unsafe { std::mem::transmute(t1) };
t2
});
self.ready_futures.borrow_mut().push_front(idx);
loop {
let finished = self.poll();
if retval.borrow().is_some() {
break;
}
if finished == 0 {
self.react();
}
}
let o = retval.borrow_mut().take().unwrap();
o
}
fn react(&self) {
let event = self.queue.next_event().expect("failed to get next event");
if event.user_data != 0 {
let Some((fut_idx, flags_ptr)) =
self.external_event.borrow_mut().remove(&event.user_data)
else {
// Spurious event
return;
};
unsafe {
flags_ptr
.as_ptr()
.write(event::EventFlags::from_bits_retain(event.flags));
}
self.ready_futures.borrow_mut().push_back(fut_idx);
return;
}
if self.intx {
let mut buf = [0_u8; core::mem::size_of::<usize>()];
if (&self.irq_handle).read(&mut buf).unwrap() != 0 {
(&self.irq_handle).write(&buf).unwrap();
}
}
// TODO: The kernel should probably do the masking (when using MSI/MSI-X at least), which
// should happen before EOI messages to the interrupt controller.
Hw::mask_vector(&self.global_ctxt, self.vector);
Hw::poll_cqes(&self.global_ctxt, |cq_id, cqe| {
if let Some((fut_idx, comp_ptr)) = self
.awaiting_completion
.borrow_mut()
.get_mut(&cq_id)
.and_then(|per_cmd| per_cmd.remove(&Hw::get_cqe_cmdid(&cqe)))
{
unsafe {
comp_ptr.as_ptr().write(Some(cqe));
}
self.ready_futures.borrow_mut().push_back(fut_idx);
if let Some(submitting) = self
.awaiting_submission
.borrow_mut()
.get_mut(&Hw::sq_cq(&self.global_ctxt, cq_id))
.and_then(|q| q.pop_front())
{
self.ready_futures.borrow_mut().push_back(submitting);
}
}
});
Hw::unmask_vector(&self.global_ctxt, self.vector);
}
pub async fn submit(&self, sq_id: Hw::SqId, cmd: Hw::Sqe) -> Hw::Cqe {
CqeFuture::<Hw> {
state: State::<Hw>::Submitting { sq_id, cmd },
comp: None,
_not_send: PhantomData,
}
.await
}
}
struct CqeFuture<Hw: Hardware> {
pub state: State<Hw>,
pub comp: Option<Hw::Cqe>,
pub _not_send: PhantomData<*const ()>,
}
enum State<Hw: Hardware> {
Submitting { sq_id: Hw::SqId, cmd: Hw::Sqe },
Completing { cq_id: Hw::CqId, cmd_id: Hw::CmdId },
}
fn current_executor_and_idx<Hw: Hardware>(
cx: &mut task::Context<'_>,
) -> (Rc<LocalExecutor<Hw>>, FutIdx) {
let executor = LocalExecutor::current();
let idx = cx.waker().data() as FutIdx;
assert_eq!(
cx.waker().vtable() as *const _,
Hw::vtable(),
"incompatible executor for CqeFuture"
);
(executor, idx)
}
impl<Hw: Hardware> Future for CqeFuture<Hw> {
type Output = Hw::Cqe;
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> task::Poll<Self::Output> {
let this = unsafe { self.get_unchecked_mut() };
let (executor, idx) = current_executor_and_idx::<Hw>(cx);
match this.state {
State::Submitting { sq_id, mut cmd } => {
let mut awaiting = executor.awaiting_submission.borrow_mut();
if let Some((cq_id, cmd_id)) = Hw::try_submit(
&executor.global_ctxt,
sq_id,
|cmd_id| {
Hw::set_sqe_cmdid(&mut cmd, cmd_id);
log::trace!("About to submit {cmd:?}");
cmd
},
|| {
awaiting.entry(sq_id).or_default().push_back(idx);
},
) {
executor
.awaiting_completion
.borrow_mut()
.entry(cq_id)
.or_default()
.insert(cmd_id, (idx, (&mut this.comp).into()));
this.state = State::Completing { cq_id, cmd_id };
}
task::Poll::Pending
}
State::Completing { cq_id, cmd_id } => match this.comp.take() {
Some(comp) => {
log::trace!("ready!");
task::Poll::Ready(comp)
}
// Shouldn't technically be possible
None => {
log::trace!("spurious poll");
executor
.awaiting_completion
.borrow_mut()
.entry(cq_id)
.or_default()
.insert(cmd_id, (idx, (&mut this.comp).into()));
task::Poll::Pending
}
},
}
}
}
unsafe fn vt_clone<Hw: Hardware>(idx: *const ()) -> task::RawWaker {
task::RawWaker::new(idx, Hw::vtable())
}
unsafe fn vt_drop(_idx: *const ()) {}
unsafe fn vt_wake<Hw: Hardware>(idx: *const ()) {
Hw::current()
.ready_futures
.borrow_mut()
.push_back(idx as FutIdx);
}
fn waker<Hw: Hardware>(idx: FutIdx) -> task::Waker {
unsafe { task::Waker::from_raw(task::RawWaker::new(idx as *const (), Hw::vtable())) }
}
pub const fn vtable<Hw: Hardware>() -> task::RawWakerVTable {
task::RawWakerVTable::new(vt_clone::<Hw>, vt_wake::<Hw>, vt_wake::<Hw>, vt_drop)
}
pub struct ExternalEventSource<Hw: Hardware> {
flags: event::EventFlags,
user_data: EventUserData,
_not_send_or_unpin: PhantomData<(*const (), fn() -> Hw)>,
}
pub struct Event {
flags: event::EventFlags,
_not_send: PhantomData<*const ()>,
}
impl Event {
pub fn flags(&self) -> event::EventFlags {
self.flags
}
}
impl<Hw: Hardware> ExternalEventSource<Hw> {
fn poll_next(self: Pin<&mut Self>, cx: &mut task::Context) -> task::Poll<Option<Event>> {
let this = unsafe { self.get_unchecked_mut() };
let flags = std::mem::take(&mut this.flags);
if flags.is_empty() {
let (executor, idx) = current_executor_and_idx::<Hw>(cx);
executor
.external_event
.borrow_mut()
.insert(this.user_data, (idx, (&mut this.flags).into()));
return task::Poll::Pending;
}
task::Poll::Ready(Some(Event {
flags,
_not_send: PhantomData,
}))
}
pub async fn next(mut self: Pin<&mut Self>) -> Option<Event> {
core::future::poll_fn(|cx| self.as_mut().poll_next(cx)).await
}
}
pub fn init_raw<Hw: Hardware>(
global_ctxt: Hw::GlobalCtxt,
vector: Hw::Iv,
intx: bool,
irq_handle: File,
) -> LocalExecutor<Hw> {
let queue = RawEventQueue::new().expect("failed to allocate event queue for local executor");
// TODO: Multiple CPUs
queue
.subscribe(irq_handle.as_raw_fd() as usize, 0, EventFlags::READ)
.expect("failed to subscribe to IRQ event");
LocalExecutor {
global_ctxt,
queue,
vector,
intx,
irq_handle,
awaiting_submission: RefCell::new(HashMap::new()),
awaiting_completion: RefCell::new(HashMap::new()),
external_event: RefCell::new(HashMap::new()),
next_user_data: Cell::new(1),
ready_futures: RefCell::new(VecDeque::new()),
futures: RefCell::new(Slab::with_capacity(16)),
is_polling: Cell::new(false),
}
}
-21
View File
@@ -1,21 +0,0 @@
[package]
name = "gpiod"
description = "GPIO controller registry daemon"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow.workspace = true
log.workspace = true
redox_syscall = { workspace = true, features = ["std"] }
libredox.workspace = true
redox-scheme.workspace = true
ron.workspace = true
serde.workspace = true
common = { path = "../../common" }
daemon = { path = "../../../daemon" }
scheme-utils = { path = "../../../scheme-utils" }
[lints]
workspace = true
-496
View File
@@ -1,496 +0,0 @@
use std::collections::BTreeMap;
use std::process;
use anyhow::{Context, Result};
use redox_scheme::scheme::SchemeSync;
use redox_scheme::{CallerCtx, OpenResult, Socket};
use scheme_utils::{Blocking, HandleMap};
use serde::{Deserialize, Serialize};
use syscall::schemev2::NewFdFlags;
use syscall::{Error as SysError, EACCES, EBADF, EINVAL, ENOENT};
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct GpioControllerInfo {
pub id: u32,
pub name: String,
pub pin_count: usize,
pub supports_interrupt: bool,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum GpioControlRequest {
RegisterController { info: GpioControllerInfo },
ReadPin { controller_id: u32, pin: u32 },
WritePin { controller_id: u32, pin: u32, value: bool },
ConfigurePin { controller_id: u32, pin: u32, config: PinConfig },
ListControllers,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct PinConfig {
pub direction: PinDirection,
pub pull: PullMode,
pub interrupt_mode: Option<InterruptMode>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum PinDirection {
Input,
Output,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum PullMode {
None,
Up,
Down,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum InterruptMode {
EdgeRising,
EdgeFalling,
EdgeBoth,
LevelHigh,
LevelLow,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
enum GpioControlResponse {
ControllerRegistered { id: u32 },
Controllers(Vec<GpioControllerInfo>),
Controller(GpioControllerInfo),
PinValue(bool),
Ack,
Error(String),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum PinOpKind {
Read,
Write,
Configure,
}
enum Handle {
SchemeRoot,
Register { pending: Vec<u8> },
Provider { controller_id: u32, pending: Vec<u8> },
ControllersDir { pending: Vec<u8> },
ControllerDetail { id: u32, pending: Vec<u8> },
PinOp { kind: PinOpKind, pending: Vec<u8> },
}
struct ControllerEntry {
info: GpioControllerInfo,
provider_handle: usize,
}
struct GpioDaemon {
handles: HandleMap<Handle>,
controllers: BTreeMap<u32, ControllerEntry>,
next_id: u32,
}
impl GpioDaemon {
fn new() -> Self {
Self {
handles: HandleMap::new(),
controllers: BTreeMap::new(),
next_id: 0,
}
}
fn controller_list(&self) -> Vec<GpioControllerInfo> {
self.controllers
.values()
.map(|entry| entry.info.clone())
.collect()
}
fn serialize_response(response: &GpioControlResponse) -> syscall::Result<Vec<u8>> {
ron::ser::to_string(response)
.map(|text| text.into_bytes())
.map_err(|err| {
log::error!("gpiod: failed to serialize control response: {err}");
SysError::new(EINVAL)
})
}
fn deserialize_request(buf: &[u8]) -> syscall::Result<GpioControlRequest> {
let text = std::str::from_utf8(buf).map_err(|err| {
log::warn!("gpiod: invalid UTF-8 request payload: {err}");
SysError::new(EINVAL)
})?;
ron::from_str(text).map_err(|err| {
log::warn!("gpiod: failed to decode control request: {err}");
SysError::new(EINVAL)
})
}
fn set_pending_response(handle: &mut Handle, response: GpioControlResponse) -> syscall::Result<()> {
let pending = Self::serialize_response(&response)?;
Self::set_pending_bytes(handle, pending)
}
fn set_pending_bytes(handle: &mut Handle, pending: Vec<u8>) -> syscall::Result<()> {
match handle {
Handle::Register { pending: slot }
| Handle::Provider { pending: slot, .. }
| Handle::ControllersDir { pending: slot }
| Handle::ControllerDetail { pending: slot, .. }
| Handle::PinOp { pending: slot, .. } => {
*slot = pending;
Ok(())
}
Handle::SchemeRoot => Err(SysError::new(EBADF)),
}
}
fn copy_pending(handle: &mut Handle, buf: &mut [u8], offset: u64) -> syscall::Result<usize> {
let pending = match handle {
Handle::Register { pending }
| Handle::Provider { pending, .. }
| Handle::ControllersDir { pending }
| Handle::ControllerDetail { pending, .. }
| Handle::PinOp { pending, .. } => pending,
Handle::SchemeRoot => return Err(SysError::new(EBADF)),
};
let offset = usize::try_from(offset).map_err(|_| SysError::new(EINVAL))?;
if offset >= pending.len() {
return Ok(0);
}
let copy_len = buf.len().min(pending.len() - offset);
buf[..copy_len].copy_from_slice(&pending[offset..offset + copy_len]);
Ok(copy_len)
}
fn validate_pin_target(
&self,
controller_id: u32,
pin: u32,
) -> std::result::Result<GpioControllerInfo, String> {
let entry = self
.controllers
.get(&controller_id)
.ok_or_else(|| format!("unknown controller {controller_id}"))?;
if usize::try_from(pin)
.ok()
.filter(|pin| *pin < entry.info.pin_count)
.is_none()
{
return Err(format!(
"pin {pin} is out of range for controller {} (pin_count={})",
entry.info.name, entry.info.pin_count
));
}
Ok(entry.info.clone())
}
}
impl SchemeSync for GpioDaemon {
fn scheme_root(&mut self) -> syscall::Result<usize> {
Ok(self.handles.insert(Handle::SchemeRoot))
}
fn openat(
&mut self,
dirfd: usize,
path: &str,
_flags: usize,
_fcntl_flags: u32,
_ctx: &CallerCtx,
) -> syscall::Result<OpenResult> {
let handle = self.handles.get(dirfd)?;
let segments = path.trim_matches('/');
let new_handle = match handle {
Handle::SchemeRoot => {
if segments.is_empty() {
return Err(SysError::new(EINVAL));
}
let mut parts = segments.split('/');
match parts.next() {
Some("register") if parts.next().is_none() => Handle::Register {
pending: Vec::new(),
},
Some("controllers") => match parts.next() {
None => Handle::ControllersDir {
pending: Vec::new(),
},
Some(id) if parts.next().is_none() => Handle::ControllerDetail {
id: id.parse::<u32>().map_err(|_| SysError::new(EINVAL))?,
pending: Vec::new(),
},
_ => return Err(SysError::new(EINVAL)),
},
Some("read_pin") if parts.next().is_none() => Handle::PinOp {
kind: PinOpKind::Read,
pending: Vec::new(),
},
Some("write_pin") if parts.next().is_none() => Handle::PinOp {
kind: PinOpKind::Write,
pending: Vec::new(),
},
Some("configure_pin") if parts.next().is_none() => Handle::PinOp {
kind: PinOpKind::Configure,
pending: Vec::new(),
},
_ => return Err(SysError::new(ENOENT)),
}
}
Handle::ControllersDir { .. } => {
if segments.is_empty() {
return Err(SysError::new(EINVAL));
}
Handle::ControllerDetail {
id: segments.parse::<u32>().map_err(|_| SysError::new(EINVAL))?,
pending: Vec::new(),
}
}
_ => return Err(SysError::new(EACCES)),
};
let fd = self.handles.insert(new_handle);
Ok(OpenResult::ThisScheme {
number: fd,
flags: NewFdFlags::empty(),
})
}
fn read(
&mut self,
id: usize,
buf: &mut [u8],
offset: u64,
_fcntl_flags: u32,
_ctx: &CallerCtx,
) -> syscall::Result<usize> {
let controllers = self.controller_list();
let detail = match self.handles.get(id)? {
Handle::ControllerDetail { id, .. } => self.controllers.get(id).map(|entry| entry.info.clone()),
_ => None,
};
let handle = self.handles.get_mut(id)?;
match handle {
Handle::ControllersDir { pending } if pending.is_empty() => {
*pending = Self::serialize_response(&GpioControlResponse::Controllers(controllers))?;
}
Handle::ControllerDetail { id, pending } if pending.is_empty() => {
let info = detail.ok_or(SysError::new(ENOENT))?;
*pending = Self::serialize_response(&GpioControlResponse::Controller(info))?;
log::debug!("gpiod: served controller detail for id={id}");
}
_ => {}
}
Self::copy_pending(handle, buf, offset)
}
fn write(
&mut self,
id: usize,
buf: &[u8],
_offset: u64,
_fcntl_flags: u32,
_ctx: &CallerCtx,
) -> syscall::Result<usize> {
let request = Self::deserialize_request(buf)?;
match request {
GpioControlRequest::RegisterController { mut info } => {
if !matches!(self.handles.get(id)?, Handle::Register { .. }) {
return Err(SysError::new(EINVAL));
}
let controller_id = self.next_id;
self.next_id = self.next_id.checked_add(1).ok_or(SysError::new(EINVAL))?;
info.id = controller_id;
self.controllers.insert(
controller_id,
ControllerEntry {
info: info.clone(),
provider_handle: id,
},
);
let handle = self.handles.get_mut(id)?;
*handle = Handle::Provider {
controller_id,
pending: Self::serialize_response(&GpioControlResponse::ControllerRegistered {
id: controller_id,
})?,
};
log::info!(
"RB_GPIOD_CONTROLLER_REGISTERED id={} name={} pin_count={} supports_interrupt={}",
info.id,
info.name,
info.pin_count,
info.supports_interrupt,
);
Ok(buf.len())
}
GpioControlRequest::ListControllers => {
let controllers = self.controller_list();
let handle = self.handles.get_mut(id)?;
Self::set_pending_response(handle, GpioControlResponse::Controllers(controllers))?;
Ok(buf.len())
}
GpioControlRequest::ReadPin { controller_id, pin } => {
let validation = self.validate_pin_target(controller_id, pin);
let handle = self.handles.get_mut(id)?;
match handle {
Handle::PinOp {
kind: PinOpKind::Read,
..
} => {
match validation {
Ok(info) => {
log::info!(
"RB_GPIOD_PIN_READ controller_id={} name={} pin={} routed=stub",
controller_id,
info.name,
pin,
);
Self::set_pending_response(handle, GpioControlResponse::PinValue(false))?;
}
Err(message) => {
Self::set_pending_response(handle, GpioControlResponse::Error(message))?;
}
}
Ok(buf.len())
}
_ => Err(SysError::new(EINVAL)),
}
}
GpioControlRequest::WritePin {
controller_id,
pin,
value,
} => {
let validation = self.validate_pin_target(controller_id, pin);
let handle = self.handles.get_mut(id)?;
match handle {
Handle::PinOp {
kind: PinOpKind::Write,
..
} => {
match validation {
Ok(info) => {
log::info!(
"RB_GPIOD_PIN_WRITE controller_id={} name={} pin={} value={} routed=stub",
controller_id,
info.name,
pin,
value,
);
Self::set_pending_response(handle, GpioControlResponse::Ack)?;
}
Err(message) => {
Self::set_pending_response(handle, GpioControlResponse::Error(message))?;
}
}
Ok(buf.len())
}
_ => Err(SysError::new(EINVAL)),
}
}
GpioControlRequest::ConfigurePin {
controller_id,
pin,
config,
} => {
let validation = self.validate_pin_target(controller_id, pin);
let handle = self.handles.get_mut(id)?;
match handle {
Handle::PinOp {
kind: PinOpKind::Configure,
..
} => {
match validation {
Ok(info) => {
log::info!(
"RB_GPIOD_PIN_CONFIG controller_id={} name={} pin={} direction={:?} pull={:?} interrupt={:?} routed=stub",
controller_id,
info.name,
pin,
config.direction,
config.pull,
config.interrupt_mode,
);
Self::set_pending_response(handle, GpioControlResponse::Ack)?;
}
Err(message) => {
Self::set_pending_response(handle, GpioControlResponse::Error(message))?;
}
}
Ok(buf.len())
}
_ => Err(SysError::new(EINVAL)),
}
}
}
}
fn on_close(&mut self, id: usize) {
let Some(handle) = self.handles.remove(id) else {
return;
};
if let Handle::Provider { controller_id, .. } = handle {
if let Some(entry) = self.controllers.remove(&controller_id) {
log::info!(
"RB_GPIOD_CONTROLLER_REMOVED id={} name={} provider_handle={}",
controller_id,
entry.info.name,
entry.provider_handle,
);
}
}
}
}
fn run_daemon(daemon: daemon::SchemeDaemon) -> Result<()> {
let socket = Socket::create().context("failed to create gpio scheme socket")?;
let mut scheme = GpioDaemon::new();
let handler = Blocking::new(&socket, 16);
daemon
.ready_sync_scheme(&socket, &mut scheme)
.context("failed to publish gpio scheme root")?;
log::info!("RB_GPIOD_SCHEMA version=1");
libredox::call::setrens(0, 0).context("failed to enter null namespace")?;
handler
.process_requests_blocking(scheme)
.context("failed to process gpiod requests")?;
}
fn daemon_runner(daemon: daemon::SchemeDaemon) -> ! {
if let Err(err) = run_daemon(daemon) {
log::error!("gpiod: {err:#}");
process::exit(1);
}
process::exit(0);
}
fn main() {
common::setup_logging(
"gpio",
"gpio",
"gpiod",
common::output_level(),
common::file_level(),
);
daemon::SchemeDaemon::new(daemon_runner);
}
@@ -1,21 +0,0 @@
[package]
name = "i2c-gpio-expanderd"
description = "I2C GPIO expander bridge daemon"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow.workspace = true
log.workspace = true
redox_syscall = { workspace = true, features = ["std"] }
libredox.workspace = true
serde.workspace = true
ron.workspace = true
acpi-resource = { path = "../../acpi-resource" }
common = { path = "../../common" }
daemon = { path = "../../../daemon" }
i2c-interface = { path = "../../i2c/i2c-interface" }
[lints]
workspace = true
-454
View File
@@ -1,454 +0,0 @@
use std::collections::BTreeMap;
use std::fs::{self, File, OpenOptions};
use std::io::{Read, Write};
use std::path::Path;
use std::process;
use acpi_resource::{GpioDescriptor, I2cSerialBusDescriptor, ResourceDescriptor};
use anyhow::{Context, Result};
use i2c_interface::{
I2cAdapterInfo, I2cControlRequest, I2cControlResponse, I2cTransferRequest,
I2cTransferResponse, I2cTransferSegment,
};
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize)]
struct AmlSymbol {
name: String,
value: AmlValue,
}
#[derive(Debug, Deserialize)]
enum AmlValue {
Integer(u64),
String(String),
}
#[derive(Clone, Debug)]
struct ExpanderResources {
i2c: I2cSerialBusDescriptor,
pin_count: usize,
gpio_int_count: usize,
gpio_io_count: usize,
}
#[derive(Debug)]
struct ExpanderDescriptor {
device: String,
hid: String,
resources: ExpanderResources,
}
struct RegisteredExpander {
_registration: File,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
struct GpioControllerInfo {
id: u32,
name: String,
pin_count: usize,
supports_interrupt: bool,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
enum GpioControlRequest {
RegisterController { info: GpioControllerInfo },
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
enum GpioControlResponse {
ControllerRegistered { id: u32 },
Error(String),
}
fn main() {
common::setup_logging(
"gpio",
"i2c-gpio-expander",
"i2c-gpio-expanderd",
common::output_level(),
common::file_level(),
);
daemon::Daemon::new(daemon_runner);
}
fn daemon_runner(daemon: daemon::Daemon) -> ! {
if let Err(err) = daemon_main(daemon) {
log::error!("i2c-gpio-expanderd: {err:#}");
process::exit(1);
}
process::exit(0);
}
fn daemon_main(daemon: daemon::Daemon) -> Result<()> {
let expanders = discover_expanders().context("failed to discover ACPI I2C GPIO expanders")?;
if expanders.is_empty() {
log::info!("i2c-gpio-expanderd: no probable ACPI I2C GPIO expanders found");
}
let adapters = list_i2c_adapters().unwrap_or_else(|err| {
log::warn!("i2c-gpio-expanderd: unable to query i2cd adapters: {err:#}");
Vec::new()
});
let mut registered = Vec::new();
for expander in expanders {
match register_expander(expander, &adapters) {
Ok(expander) => registered.push(expander),
Err(err) => log::warn!("i2c-gpio-expanderd: expander registration skipped: {err:#}"),
}
}
daemon.ready();
libredox::call::setrens(0, 0).context("failed to enter null namespace")?;
log::info!("i2c-gpio-expanderd: registered {} expander(s)", registered.len());
loop {
std::thread::park();
}
}
fn discover_expanders() -> Result<Vec<ExpanderDescriptor>> {
let mut matched = BTreeMap::new();
let entries = match fs::read_dir("/scheme/acpi/symbols") {
Ok(entries) => entries,
Err(err) if err.kind() == std::io::ErrorKind::WouldBlock || err.raw_os_error() == Some(11) => {
log::debug!("i2c-gpio-expanderd: ACPI symbols are not ready yet");
return Ok(Vec::new());
}
Err(err) => return Err(err).context("failed to read /scheme/acpi/symbols"),
};
for entry in entries {
let entry = entry.context("failed to read ACPI symbol directory entry")?;
let Some(file_name) = entry.file_name().to_str().map(str::to_owned) else {
continue;
};
if !file_name.ends_with("_HID") && !file_name.ends_with("_CID") {
continue;
}
let Some(id) = read_symbol_id(&entry.path())? else {
continue;
};
if is_excluded_device_id(&id) {
continue;
}
let Some(device) = file_name
.strip_suffix("_HID")
.or_else(|| file_name.strip_suffix("_CID"))
.map(str::to_owned)
else {
continue;
};
let resources = match read_expander_resources(&device) {
Ok(resources) => resources,
Err(err) => {
log::debug!("i2c-gpio-expanderd: skipping {device}: {err:#}");
continue;
}
};
if resources.gpio_int_count == 0 && resources.gpio_io_count == 0 {
continue;
}
matched.entry(device).or_insert((id, resources));
}
let mut expanders = Vec::new();
for (device, (hid, resources)) in matched {
expanders.push(ExpanderDescriptor {
device,
hid,
resources,
});
}
Ok(expanders)
}
fn read_symbol_id(path: &Path) -> Result<Option<String>> {
let contents = fs::read_to_string(path)
.with_context(|| format!("failed to read ACPI symbol {}", path.display()))?;
let symbol = match ron::from_str::<AmlSymbol>(&contents) {
Ok(symbol) => symbol,
Err(err) => {
log::debug!(
"i2c-gpio-expanderd: skipping {} because the symbol payload was not a scalar ID: {err}",
path.display(),
);
return Ok(None);
}
};
let id = match symbol.value {
AmlValue::Integer(integer) => eisa_id_from_integer(integer),
AmlValue::String(string) => string,
};
log::debug!("i2c-gpio-expanderd: {} -> {id}", symbol.name);
Ok(Some(id))
}
fn read_expander_resources(device: &str) -> Result<ExpanderResources> {
let contents = fs::read_to_string(format!("/scheme/acpi/resources/{device}"))
.with_context(|| format!("failed to read /scheme/acpi/resources/{device}"))?;
let resources = ron::from_str::<Vec<ResourceDescriptor>>(&contents)
.with_context(|| format!("failed to decode RON resources for {device}"))?;
let mut i2c = None;
let mut pin_count = 0usize;
let mut gpio_int_count = 0usize;
let mut gpio_io_count = 0usize;
for resource in resources {
match resource {
ResourceDescriptor::I2cSerialBus(bus) if i2c.is_none() => i2c = Some(bus),
ResourceDescriptor::GpioInt(descriptor) => {
gpio_int_count += 1;
pin_count = pin_count.max(pin_count_from_descriptor(&descriptor));
}
ResourceDescriptor::GpioIo(descriptor) => {
gpio_io_count += 1;
pin_count = pin_count.max(pin_count_from_descriptor(&descriptor));
}
_ => {}
}
}
Ok(ExpanderResources {
i2c: i2c.context("no I2cSerialBus resource was found")?,
pin_count,
gpio_int_count,
gpio_io_count,
})
}
fn pin_count_from_descriptor(descriptor: &GpioDescriptor) -> usize {
descriptor
.pins
.iter()
.copied()
.max()
.map(|pin| usize::from(pin).saturating_add(1))
.unwrap_or(0)
}
fn is_excluded_device_id(id: &str) -> bool {
matches!(
id,
"PNP0C50"
| "ACPI0C50"
| "INT34C5"
| "INTC1055"
| "INT33C2"
| "INT33C3"
| "INT3432"
| "INT3433"
| "INTC10EF"
| "AMDI0010"
| "AMDI0019"
| "AMDI0510"
| "PNP0CA0"
| "AMDI0042"
) || id.starts_with("ELAN")
|| id.starts_with("CYAP")
|| id.starts_with("SYNA")
}
fn register_expander(expander: ExpanderDescriptor, adapters: &[I2cAdapterInfo]) -> Result<RegisteredExpander> {
let ExpanderDescriptor {
device,
hid,
resources,
} = expander;
let adapter_name = resources
.i2c
.resource_source
.as_ref()
.map(|source| source.source.clone())
.filter(|source| !source.is_empty())
.unwrap_or_else(|| String::from("ACPI-I2C"));
let adapter = match match_i2c_adapter(adapters, &adapter_name) {
Some(adapter) => Some(adapter.clone()),
None => {
log::warn!(
"i2c-gpio-expanderd: unable to resolve I2C adapter {} for {}",
adapter_name,
device,
);
None
}
};
if let Some(adapter) = adapter.as_ref() {
if let Err(err) = probe_expander(adapter, &adapter_name, resources.i2c.slave_address) {
log::warn!(
"i2c-gpio-expanderd: expander {} probe on {}@{:04x} failed: {err:#}",
device,
adapter_name,
resources.i2c.slave_address,
);
}
}
let info = GpioControllerInfo {
id: 0,
name: format!("i2c-gpio-expander:{device}"),
pin_count: resources.pin_count,
supports_interrupt: resources.gpio_int_count > 0,
};
let mut registration = register_with_gpiod(&info)
.with_context(|| format!("failed to register {device} with gpiod"))?;
let response = read_gpio_registration_response(&mut registration)
.with_context(|| format!("failed to read gpiod registration response for {device}"))?;
match response {
GpioControlResponse::ControllerRegistered { id } => {
log::info!(
"RB_I2C_GPIO_EXPANDERD_DEVICE device={} hid={} controller_id={} adapter={} addr={:04x} pin_count={} gpio_int={} gpio_io={}",
device,
hid,
id,
adapter_name,
resources.i2c.slave_address,
info.pin_count,
resources.gpio_int_count,
resources.gpio_io_count,
);
}
GpioControlResponse::Error(message) => {
anyhow::bail!("gpiod rejected expander {device}: {message}");
}
}
Ok(RegisteredExpander {
_registration: registration,
})
}
fn list_i2c_adapters() -> Result<Vec<I2cAdapterInfo>> {
let mut file = OpenOptions::new()
.read(true)
.write(true)
.open("/scheme/i2c/adapters")
.context("failed to open /scheme/i2c/adapters")?;
let payload = ron::ser::to_string(&I2cControlRequest::ListAdapters)
.context("failed to encode I2C list-adapters request")?;
file.write_all(payload.as_bytes())
.context("failed to request I2C adapter list")?;
let response = read_i2c_control_response(&mut file)?;
match response {
I2cControlResponse::AdapterList(adapters) => Ok(adapters),
I2cControlResponse::Error(message) => anyhow::bail!("i2cd returned an error: {message}"),
other => anyhow::bail!("unexpected i2cd list-adapters response: {other:?}"),
}
}
fn match_i2c_adapter<'a>(adapters: &'a [I2cAdapterInfo], wanted: &str) -> Option<&'a I2cAdapterInfo> {
adapters
.iter()
.find(|adapter| adapter.name == wanted)
.or_else(|| adapters.iter().find(|adapter| adapter.name.ends_with(wanted)))
.or_else(|| adapters.iter().find(|adapter| wanted.ends_with(&adapter.name)))
}
fn probe_expander(adapter: &I2cAdapterInfo, adapter_name: &str, address: u16) -> Result<I2cTransferResponse> {
let request = I2cTransferRequest {
adapter: adapter_name.to_string(),
segments: vec![I2cTransferSegment::read(address, 1)],
stop: true,
};
let mut file = OpenOptions::new()
.read(true)
.write(true)
.open("/scheme/i2c/transfer")
.context("failed to open /scheme/i2c/transfer")?;
let payload = ron::ser::to_string(&I2cControlRequest::Transfer {
adapter_id: adapter.id,
request,
})
.context("failed to encode I2C expander probe request")?;
file.write_all(payload.as_bytes())
.context("failed to send I2C expander probe request")?;
let response = read_i2c_control_response(&mut file)?;
match response {
I2cControlResponse::TransferResult(result) => {
if !result.ok {
let detail = result
.error
.clone()
.unwrap_or_else(|| String::from("unknown I2C transfer failure"));
anyhow::bail!("I2C probe failed: {detail}");
}
Ok(result)
}
I2cControlResponse::Error(message) => anyhow::bail!("i2cd returned an error: {message}"),
other => anyhow::bail!("unexpected I2C transfer response: {other:?}"),
}
}
fn register_with_gpiod(info: &GpioControllerInfo) -> Result<File> {
let mut file = OpenOptions::new()
.read(true)
.write(true)
.open("/scheme/gpio/register")
.context("failed to open /scheme/gpio/register")?;
let payload = ron::ser::to_string(&GpioControlRequest::RegisterController { info: info.clone() })
.context("failed to encode GPIO controller registration")?;
file.write_all(payload.as_bytes())
.context("failed to send GPIO controller registration")?;
Ok(file)
}
fn read_gpio_registration_response(file: &mut File) -> Result<GpioControlResponse> {
let mut buffer = vec![0_u8; 4096];
let count = file
.read(&mut buffer)
.context("failed to read GPIO registration response")?;
buffer.truncate(count);
let text = std::str::from_utf8(&buffer).context("GPIO registration response was not UTF-8")?;
ron::from_str(text).context("failed to decode GPIO registration response")
}
fn read_i2c_control_response(file: &mut File) -> Result<I2cControlResponse> {
let mut buffer = vec![0_u8; 4096];
let count = file
.read(&mut buffer)
.context("failed to read I2C control response")?;
buffer.truncate(count);
let text = std::str::from_utf8(&buffer).context("I2C control response was not UTF-8")?;
let trimmed = text.trim();
if trimmed.is_empty() {
return Ok(I2cControlResponse::AdapterList(Vec::new()));
}
ron::from_str(trimmed).context("failed to decode I2C control response")
}
fn eisa_id_from_integer(integer: u64) -> String {
let vendor = integer & 0xFFFF;
let device = (integer >> 16) & 0xFFFF;
let vendor_rev = ((vendor & 0xFF) << 8) | (vendor >> 8);
let vendor_1 = (((vendor_rev >> 10) & 0x1F) as u8 + 64) as char;
let vendor_2 = (((vendor_rev >> 5) & 0x1F) as u8 + 64) as char;
let vendor_3 = (((vendor_rev >> 0) & 0x1F) as u8 + 64) as char;
let device_1 = (device >> 4) & 0xF;
let device_2 = (device >> 0) & 0xF;
let device_3 = (device >> 12) & 0xF;
let device_4 = (device >> 8) & 0xF;
format!(
"{vendor_1}{vendor_2}{vendor_3}{device_1:01X}{device_2:01X}{device_3:01X}{device_4:01X}"
)
}
-20
View File
@@ -1,20 +0,0 @@
[package]
name = "intel-gpiod"
description = "Intel ACPI GPIO registrar daemon"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow.workspace = true
log.workspace = true
redox_syscall = { workspace = true, features = ["std"] }
libredox.workspace = true
serde.workspace = true
ron.workspace = true
acpi-resource = { path = "../../acpi-resource" }
common = { path = "../../common" }
daemon = { path = "../../../daemon" }
[lints]
workspace = true
-401
View File
@@ -1,401 +0,0 @@
use std::collections::BTreeMap;
use std::fs::{self, File, OpenOptions};
use std::io::{Read, Write};
use std::path::Path;
use std::process;
use acpi_resource::{
AddressResourceType, ExtendedIrqDescriptor, FixedMemory32Descriptor, GpioDescriptor,
IrqDescriptor, Memory32RangeDescriptor, ResourceDescriptor,
};
use anyhow::{Context, Result};
use common::{MemoryType, PhysBorrowed, Prot};
use serde::{Deserialize, Serialize};
const SUPPORTED_IDS: &[&str] = &["INT34C5", "INTC1055"];
const PADNFGPIO_OWN_BASE: usize = 0x20;
const PADNFGPIO_PADCFG_BASE: usize = 0x700;
const GPI_INT_STATUS: usize = 0x100;
const GPI_INT_EN: usize = 0x120;
const INTEL_GPIO_MMIO_WINDOW: usize = PADNFGPIO_PADCFG_BASE + core::mem::size_of::<u32>();
#[derive(Debug, Deserialize)]
struct AmlSymbol {
name: String,
value: AmlValue,
}
#[derive(Debug, Deserialize)]
enum AmlValue {
Integer(u64),
String(String),
}
#[derive(Clone, Debug)]
struct ControllerResources {
mmio_base: usize,
mmio_len: usize,
pin_count: usize,
supports_interrupt: bool,
gpio_int_count: usize,
gpio_io_count: usize,
}
#[derive(Debug)]
struct ControllerDescriptor {
device: String,
hid: String,
resources: ControllerResources,
}
struct RegisteredController {
_mmio: Option<PhysBorrowed>,
_registration: File,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
struct GpioControllerInfo {
id: u32,
name: String,
pin_count: usize,
supports_interrupt: bool,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
enum GpioControlRequest {
RegisterController { info: GpioControllerInfo },
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
enum GpioControlResponse {
ControllerRegistered { id: u32 },
Error(String),
}
fn main() {
common::setup_logging(
"gpio",
"intel-gpio",
"intel-gpiod",
common::output_level(),
common::file_level(),
);
daemon::Daemon::new(daemon_runner);
}
fn daemon_runner(daemon: daemon::Daemon) -> ! {
if let Err(err) = daemon_main(daemon) {
log::error!("intel-gpiod: {err:#}");
process::exit(1);
}
process::exit(0);
}
fn daemon_main(daemon: daemon::Daemon) -> Result<()> {
common::init();
let controllers =
discover_controllers(SUPPORTED_IDS).context("failed to discover Intel GPIO controllers")?;
if controllers.is_empty() {
log::info!("intel-gpiod: no supported Intel GPIO ACPI controllers found");
}
let mut registered = Vec::new();
for controller in controllers {
match register_controller(controller) {
Ok(controller) => registered.push(controller),
Err(err) => log::warn!("intel-gpiod: controller registration skipped: {err:#}"),
}
}
daemon.ready();
libredox::call::setrens(0, 0).context("failed to enter null namespace")?;
log::info!("intel-gpiod: registered {} controller(s)", registered.len());
loop {
std::thread::park();
}
}
fn discover_controllers(supported_ids: &[&str]) -> Result<Vec<ControllerDescriptor>> {
let mut matched = BTreeMap::new();
let entries = match fs::read_dir("/scheme/acpi/symbols") {
Ok(entries) => entries,
Err(err) if err.kind() == std::io::ErrorKind::WouldBlock || err.raw_os_error() == Some(11) => {
log::debug!("intel-gpiod: ACPI symbols are not ready yet");
return Ok(Vec::new());
}
Err(err) => return Err(err).context("failed to read /scheme/acpi/symbols"),
};
for entry in entries {
let entry = entry.context("failed to read ACPI symbol directory entry")?;
let Some(file_name) = entry.file_name().to_str().map(str::to_owned) else {
continue;
};
if !file_name.ends_with("_HID") && !file_name.ends_with("_CID") {
continue;
}
let Some(id) = read_symbol_id(&entry.path())? else {
continue;
};
if !supported_ids.iter().any(|candidate| *candidate == id) {
continue;
}
let device = file_name
.strip_suffix("_HID")
.or_else(|| file_name.strip_suffix("_CID"))
.map(str::to_owned);
if let Some(device) = device {
matched.entry(device).or_insert(id);
}
}
let mut controllers = Vec::new();
for (device, hid) in matched {
let resources = read_controller_resources(&device)
.with_context(|| format!("failed to read resources for {device}"))?;
controllers.push(ControllerDescriptor {
device,
hid,
resources,
});
}
Ok(controllers)
}
fn read_symbol_id(path: &Path) -> Result<Option<String>> {
let contents = fs::read_to_string(path)
.with_context(|| format!("failed to read ACPI symbol {}", path.display()))?;
let symbol = match ron::from_str::<AmlSymbol>(&contents) {
Ok(symbol) => symbol,
Err(err) => {
log::debug!(
"intel-gpiod: skipping {} because the symbol payload was not a scalar ID: {err}",
path.display(),
);
return Ok(None);
}
};
let id = match symbol.value {
AmlValue::Integer(integer) => eisa_id_from_integer(integer),
AmlValue::String(string) => string,
};
log::debug!("intel-gpiod: {} -> {id}", symbol.name);
Ok(Some(id))
}
fn read_controller_resources(device: &str) -> Result<ControllerResources> {
let contents = fs::read_to_string(format!("/scheme/acpi/resources/{device}"))
.with_context(|| format!("failed to read /scheme/acpi/resources/{device}"))?;
let resources = ron::from_str::<Vec<ResourceDescriptor>>(&contents)
.with_context(|| format!("failed to decode RON resources for {device}"))?;
let mut mmio = None;
let mut supports_interrupt = false;
let mut gpio_int_count = 0usize;
let mut gpio_io_count = 0usize;
let mut pin_count = 0usize;
for resource in &resources {
match resource {
ResourceDescriptor::FixedMemory32(FixedMemory32Descriptor {
address,
address_length,
..
}) if mmio.is_none() => {
mmio = Some((
*address as usize,
(*address_length as usize).max(INTEL_GPIO_MMIO_WINDOW),
));
}
ResourceDescriptor::Memory32Range(Memory32RangeDescriptor {
minimum,
maximum,
address_length,
..
}) if mmio.is_none() && maximum >= minimum => {
let span = maximum.saturating_sub(*minimum).saturating_add(1) as usize;
mmio = Some((
*minimum as usize,
span.max((*address_length as usize).max(INTEL_GPIO_MMIO_WINDOW)),
));
}
ResourceDescriptor::Address32(descriptor)
if mmio.is_none()
&& matches!(descriptor.resource_type, AddressResourceType::MemoryRange) =>
{
mmio = Some((
descriptor.minimum as usize,
(descriptor.address_length as usize).max(INTEL_GPIO_MMIO_WINDOW),
));
}
ResourceDescriptor::Address64(descriptor)
if mmio.is_none()
&& matches!(descriptor.resource_type, AddressResourceType::MemoryRange) =>
{
let base = usize::try_from(descriptor.minimum)
.context("64-bit MMIO base does not fit in usize")?;
let len = usize::try_from(descriptor.address_length)
.context("64-bit MMIO length does not fit in usize")?;
mmio = Some((base, len.max(INTEL_GPIO_MMIO_WINDOW)));
}
ResourceDescriptor::Irq(IrqDescriptor { interrupts, .. }) => {
supports_interrupt |= !interrupts.is_empty();
}
ResourceDescriptor::ExtendedIrq(ExtendedIrqDescriptor { interrupts, .. }) => {
supports_interrupt |= !interrupts.is_empty();
}
ResourceDescriptor::GpioInt(descriptor) => {
gpio_int_count += 1;
supports_interrupt = true;
pin_count = pin_count.max(pin_count_from_descriptor(descriptor));
}
ResourceDescriptor::GpioIo(descriptor) => {
gpio_io_count += 1;
pin_count = pin_count.max(pin_count_from_descriptor(descriptor));
}
_ => {}
}
}
let (mmio_base, mmio_len) = mmio.context("no MMIO resource was found")?;
Ok(ControllerResources {
mmio_base,
mmio_len,
pin_count,
supports_interrupt,
gpio_int_count,
gpio_io_count,
})
}
fn pin_count_from_descriptor(descriptor: &GpioDescriptor) -> usize {
descriptor
.pins
.iter()
.copied()
.max()
.map(|pin| usize::from(pin).saturating_add(1))
.unwrap_or(0)
}
fn register_controller(controller: ControllerDescriptor) -> Result<RegisteredController> {
let ControllerDescriptor {
device,
hid,
resources,
} = controller;
let mmio = match PhysBorrowed::map(
resources.mmio_base,
resources.mmio_len,
Prot::RW,
MemoryType::Uncacheable,
) {
Ok(mapping) => Some(mapping),
Err(err) => {
log::warn!(
"intel-gpiod: failed to map MMIO for {device} ({:#x}, len {:#x}): {err}",
resources.mmio_base,
resources.mmio_len,
);
None
}
};
log::info!(
"intel-gpiod: discovered {device} hid={hid} mmio={:#x}+{:#x} pin_count={} gpio_int={} gpio_io={} supports_interrupt={}",
resources.mmio_base,
resources.mmio_len,
resources.pin_count,
resources.gpio_int_count,
resources.gpio_io_count,
resources.supports_interrupt,
);
log::debug!(
"intel-gpiod: register model own={PADNFGPIO_OWN_BASE:#x} padcfg={PADNFGPIO_PADCFG_BASE:#x} gpi_int_status={GPI_INT_STATUS:#x} gpi_int_en={GPI_INT_EN:#x}",
);
let info = GpioControllerInfo {
id: 0,
name: format!("intel-gpio:{device}"),
pin_count: resources.pin_count,
supports_interrupt: resources.supports_interrupt,
};
let mut registration = register_with_gpiod(&info)
.with_context(|| format!("failed to register {device} with gpiod"))?;
let response = read_registration_response(&mut registration)
.with_context(|| format!("failed to read gpiod registration response for {device}"))?;
match response {
GpioControlResponse::ControllerRegistered { id } => {
log::info!(
"RB_INTEL_GPIOD_DEVICE device={} hid={} controller_id={} pin_count={} supports_interrupt={}",
device,
hid,
id,
info.pin_count,
info.supports_interrupt,
);
}
GpioControlResponse::Error(message) => {
anyhow::bail!("gpiod rejected Intel GPIO controller {device}: {message}");
}
}
Ok(RegisteredController {
_mmio: mmio,
_registration: registration,
})
}
fn register_with_gpiod(info: &GpioControllerInfo) -> Result<File> {
let mut file = OpenOptions::new()
.read(true)
.write(true)
.open("/scheme/gpio/register")
.context("failed to open /scheme/gpio/register")?;
let payload = ron::ser::to_string(&GpioControlRequest::RegisterController { info: info.clone() })
.context("failed to encode GPIO controller registration")?;
file.write_all(payload.as_bytes())
.context("failed to send GPIO controller registration")?;
Ok(file)
}
fn read_registration_response(file: &mut File) -> Result<GpioControlResponse> {
let mut buffer = vec![0_u8; 4096];
let count = file
.read(&mut buffer)
.context("failed to read GPIO registration response")?;
buffer.truncate(count);
let text = std::str::from_utf8(&buffer).context("GPIO registration response was not UTF-8")?;
ron::from_str(text).context("failed to decode GPIO registration response")
}
fn eisa_id_from_integer(integer: u64) -> String {
let vendor = integer & 0xFFFF;
let device = (integer >> 16) & 0xFFFF;
let vendor_rev = ((vendor & 0xFF) << 8) | (vendor >> 8);
let vendor_1 = (((vendor_rev >> 10) & 0x1F) as u8 + 64) as char;
let vendor_2 = (((vendor_rev >> 5) & 0x1F) as u8 + 64) as char;
let vendor_3 = (((vendor_rev >> 0) & 0x1F) as u8 + 64) as char;
let device_1 = (device >> 4) & 0xF;
let device_2 = (device >> 0) & 0xF;
let device_3 = (device >> 12) & 0xF;
let device_4 = (device >> 8) & 0xF;
format!(
"{vendor_1}{vendor_2}{vendor_3}{device_1:01X}{device_2:01X}{device_3:01X}{device_4:01X}"
)
}
-18
View File
@@ -1,18 +0,0 @@
[package]
name = "console-draw"
description = "Shared terminal drawing code library"
version = "0.1.0"
edition = "2021"
[dependencies]
drm.workspace = true
orbclient.workspace = true
ransid.workspace = true
graphics-ipc = { path = "../graphics-ipc" }
[features]
default = []
[lints]
workspace = true
-460
View File
@@ -1,460 +0,0 @@
extern crate ransid;
use std::collections::VecDeque;
use std::convert::{TryFrom, TryInto};
use std::{cmp, io, mem, ptr};
use drm::buffer::{Buffer, DrmFourcc};
use drm::control::{connector, crtc, framebuffer, ClipRect, Device, Mode};
use graphics_ipc::{CpuBackedBuffer, V2GraphicsHandle};
use orbclient::FONT;
#[derive(Debug, Copy, Clone)]
#[repr(C, packed)]
pub struct Damage {
pub x: u32,
pub y: u32,
pub width: u32,
pub height: u32,
}
impl Damage {
pub const NONE: Self = Damage {
x: 0,
y: 0,
width: 0,
height: 0,
};
pub fn merge(self, other: Self) -> Self {
if self.width == 0 || self.height == 0 {
return other;
}
if other.width == 0 || other.height == 0 {
return self;
}
let x = cmp::min(self.x, other.x);
let y = cmp::min(self.y, other.y);
let x2 = cmp::max(self.x + self.width, other.x + other.width);
let y2 = cmp::max(self.y + self.height, other.y + other.height);
Damage {
x,
y,
width: x2 - x,
height: y2 - y,
}
}
}
pub struct V2DisplayMap {
pub display_handle: V2GraphicsHandle,
connector: connector::Handle,
crtc: crtc::Handle,
fb: framebuffer::Handle,
pub buffer: CpuBackedBuffer,
}
impl V2DisplayMap {
pub fn new(display_handle: V2GraphicsHandle) -> io::Result<Self> {
let connector = display_handle.first_display().unwrap();
let connector_info = display_handle.get_connector(connector, true).unwrap();
let mode = connector_info.modes()[0];
let (width, height) = mode.size();
// FIXME do something smarter that avoids conflicts
let crtc = display_handle.resource_handles().unwrap().filter_crtcs(
display_handle
.get_encoder(connector_info.encoders()[0])
.unwrap()
.possible_crtcs(),
)[0];
let buffer = CpuBackedBuffer::new(
&display_handle,
(width.into(), height.into()),
DrmFourcc::Argb8888,
32,
)?;
let fb = display_handle.add_framebuffer(buffer.buffer(), 32, 32)?;
display_handle.set_crtc(crtc, Some(fb), (0, 0), &[connector], Some(mode))?;
Ok(Self {
display_handle,
connector,
crtc,
fb,
buffer,
})
}
unsafe fn console_map(&mut self) -> DisplayMap {
let size = self.buffer.buffer().size();
let shadow_buf = self.buffer.shadow_buf();
DisplayMap {
offscreen: ptr::slice_from_raw_parts_mut(
shadow_buf.as_mut_ptr() as *mut u32,
shadow_buf.len() / 4,
),
width: size.0 as usize,
height: size.1 as usize,
}
}
pub fn dirty_fb(&mut self, damage: Damage) -> io::Result<()> {
self.buffer
.sync_rect(damage.x, damage.y, damage.width, damage.height);
self.display_handle.dirty_framebuffer(
self.fb,
&[ClipRect::new(
damage.x as u16,
damage.y as u16,
(damage.x + damage.width) as u16,
(damage.y + damage.height) as u16,
)],
)
}
}
struct DisplayMap {
offscreen: *mut [u32],
width: usize,
height: usize,
}
pub struct TextScreen {
console: ransid::Console,
}
impl TextScreen {
pub fn new() -> TextScreen {
TextScreen {
// Width and height will be filled in on the next write to the console
console: ransid::Console::new(0, 0),
}
}
/// Draw a rectangle
fn rect(map: &mut DisplayMap, x: usize, y: usize, w: usize, h: usize, color: u32) {
let start_y = cmp::min(map.height, y);
let end_y = cmp::min(map.height, y + h);
let start_x = cmp::min(map.width, x);
let len = cmp::min(map.width, x + w) - start_x;
let mut offscreen_ptr = map.offscreen as *mut u8 as usize;
let stride = map.width * 4;
let offset = y * stride + start_x * 4;
offscreen_ptr += offset;
let mut rows = end_y - start_y;
while rows > 0 {
for i in 0..len {
unsafe {
*(offscreen_ptr as *mut u32).add(i) = color;
}
}
offscreen_ptr += stride;
rows -= 1;
}
}
/// Invert a rectangle
fn invert(map: &mut DisplayMap, x: usize, y: usize, w: usize, h: usize) {
let start_y = cmp::min(map.height, y);
let end_y = cmp::min(map.height, y + h);
let start_x = cmp::min(map.width, x);
let len = cmp::min(map.width, x + w) - start_x;
let mut offscreen_ptr = map.offscreen as *mut u8 as usize;
let stride = map.width * 4;
let offset = y * stride + start_x * 4;
offscreen_ptr += offset;
let mut rows = end_y - start_y;
while rows > 0 {
let mut row_ptr = offscreen_ptr;
let mut cols = len;
while cols > 0 {
unsafe {
let color = *(row_ptr as *mut u32);
*(row_ptr as *mut u32) = !color;
}
row_ptr += 4;
cols -= 1;
}
offscreen_ptr += stride;
rows -= 1;
}
}
/// Draw a character
fn char(
map: &mut DisplayMap,
x: usize,
y: usize,
character: char,
color: u32,
_bold: bool,
_italic: bool,
) {
if x + 8 <= map.width && y + 16 <= map.height {
let mut dst = map.offscreen as *mut u8 as usize + (y * map.width + x) * 4;
let font_i = 16 * (character as usize);
if font_i + 16 <= FONT.len() {
for row in 0..16 {
let row_data = FONT[font_i + row];
for col in 0..8 {
if (row_data >> (7 - col)) & 1 == 1 {
unsafe {
*((dst + col * 4) as *mut u32) = color;
}
}
}
dst += map.width * 4;
}
}
}
}
}
impl TextScreen {
pub fn write(
&mut self,
map: &mut V2DisplayMap,
buf: &[u8],
input: &mut VecDeque<u8>,
) -> Damage {
let map = unsafe { &mut map.console_map() };
let mut min_changed = map.height;
let mut max_changed = 0;
let mut line_changed = |line| {
if line < min_changed {
min_changed = line;
}
if line > max_changed {
max_changed = line;
}
};
self.console.resize(map.width / 8, map.height / 16);
if self.console.state.x >= self.console.state.w {
self.console.state.x = self.console.state.w - 1;
}
if self.console.state.y >= self.console.state.h {
self.console.state.y = self.console.state.h - 1;
}
if self.console.state.cursor
&& self.console.state.x < self.console.state.w
&& self.console.state.y < self.console.state.h
{
let x = self.console.state.x;
let y = self.console.state.y;
Self::invert(map, x * 8, y * 16, 8, 16);
line_changed(y);
}
self.console.write(buf, |event| match event {
ransid::Event::Char {
x,
y,
c,
color,
bold,
..
} => {
Self::char(map, x * 8, y * 16, c, color.as_rgb(), bold, false);
line_changed(y);
}
ransid::Event::Input { data } => input.extend(data),
ransid::Event::Rect { x, y, w, h, color } => {
Self::rect(map, x * 8, y * 16, w * 8, h * 16, color.as_rgb());
for y2 in y..y + h {
line_changed(y2);
}
}
ransid::Event::ScreenBuffer { .. } => (),
ransid::Event::Move {
from_x,
from_y,
to_x,
to_y,
w,
h,
} => {
let width = map.width;
let pixels = unsafe { &mut *map.offscreen };
for raw_y in 0..h {
let y = if from_y > to_y { raw_y } else { h - raw_y - 1 };
for pixel_y in 0..16 {
{
let off_from = ((from_y + y) * 16 + pixel_y) * width + from_x * 8;
let off_to = ((to_y + y) * 16 + pixel_y) * width + to_x * 8;
let len = w * 8;
if off_from + len <= pixels.len() && off_to + len <= pixels.len() {
unsafe {
let data_ptr = pixels.as_mut_ptr() as *mut u32;
ptr::copy(
data_ptr.offset(off_from as isize),
data_ptr.offset(off_to as isize),
len,
);
}
}
}
}
line_changed(to_y + y);
}
}
ransid::Event::Resize { .. } => (),
ransid::Event::Title { .. } => (),
});
if self.console.state.cursor
&& self.console.state.x < self.console.state.w
&& self.console.state.y < self.console.state.h
{
let x = self.console.state.x;
let y = self.console.state.y;
Self::invert(map, x * 8, y * 16, 8, 16);
line_changed(y);
}
let width = map.width.try_into().unwrap();
let damage = Damage {
x: 0,
y: u32::try_from(min_changed).unwrap() * 16,
width,
height: u32::try_from(max_changed.saturating_sub(min_changed) + 1).unwrap() * 16,
};
damage
}
pub fn resize(&mut self, map: &mut V2DisplayMap, mode: Mode) -> io::Result<()> {
// FIXME fold row when target is narrower and maybe unfold when it is wider
fn copy_row(
old_map: &mut DisplayMap,
new_map: &mut DisplayMap,
from_row: usize,
to_row: usize,
) {
for x in 0..cmp::min(old_map.width, new_map.width) {
let old_idx = from_row * old_map.width + x;
let new_idx = to_row * new_map.width + x;
unsafe {
(*new_map.offscreen)[new_idx] = (*old_map.offscreen)[old_idx];
}
}
}
let mut new_buffer = CpuBackedBuffer::new(
&map.display_handle,
(u32::from(mode.size().0), u32::from(mode.size().1)),
DrmFourcc::Argb8888,
32,
)?;
let new_fb = map
.display_handle
.add_framebuffer(new_buffer.buffer(), 24, 32)?;
new_buffer.shadow_buf().fill(0);
{
let old_map = unsafe { &mut map.console_map() };
let new_size = new_buffer.buffer().size();
let new_shadow_buf = new_buffer.shadow_buf();
let new_map = &mut DisplayMap {
offscreen: ptr::slice_from_raw_parts_mut(
new_shadow_buf.as_mut_ptr() as *mut u32,
new_shadow_buf.len() / 4,
),
width: new_size.0 as usize,
height: new_size.1 as usize,
};
if new_map.height >= old_map.height {
for row in 0..old_map.height {
copy_row(old_map, new_map, row, row);
}
} else {
let deleted_rows = (old_map.height - new_map.height).div_ceil(16);
for row in 0..new_map.height {
if row + (deleted_rows + 1) * 16 >= old_map.height {
break;
}
copy_row(old_map, new_map, row + deleted_rows * 16, row);
}
self.console.state.y = self.console.state.y.saturating_sub(deleted_rows);
}
}
let old_buffer = mem::replace(&mut map.buffer, new_buffer);
old_buffer.destroy(&map.display_handle)?;
let old_fb = mem::replace(&mut map.fb, new_fb);
map.display_handle.set_crtc(
map.crtc,
Some(map.fb),
(0, 0),
&[map.connector],
Some(mode),
)?;
let _ = map.display_handle.destroy_framebuffer(old_fb);
Ok(())
}
}
pub struct TextBuffer {
pub lines: VecDeque<Vec<u8>>,
pub lines_max: usize,
}
impl TextBuffer {
pub fn new(max: usize) -> Self {
let mut lines = VecDeque::new();
lines.push_back(Vec::new());
Self {
lines,
lines_max: max,
}
}
pub fn write(&mut self, buf: &[u8]) {
if buf.is_empty() {
return;
}
for &byte in buf {
self.lines.back_mut().unwrap().push(byte);
if byte == b'\n' {
self.lines.push_back(Vec::new());
}
}
let max_len = self.lines_max;
while self.lines.len() > max_len {
self.lines.pop_front();
}
}
}
@@ -1,22 +0,0 @@
[package]
name = "driver-graphics"
description = "Shared video and graphics code library"
version = "0.1.0"
edition = "2021"
[dependencies]
drm-fourcc = "2.2.0"
drm-sys.workspace = true
edid.workspace = true #TODO: edid is abandoned, fork it and maintain?
log.workspace = true
redox-ioctl.workspace = true
redox-scheme.workspace = true
scheme-utils = { path = "../../../scheme-utils" }
redox_syscall.workspace = true
libredox.workspace = true
common = { path = "../../common" }
inputd = { path = "../../inputd" }
[lints]
workspace = true

Some files were not shown because too many files have changed in this diff Show More