Commit Graph

774 Commits

Author SHA1 Message Date
gugz0r ff66c10a27 Code cleanup. 2024-12-19 13:58:05 +01: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 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
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
Josh Megnauth 624947211a Unsafe blocks: fcntl.h, fnmatch.h 2024-12-11 01:56:30 -05: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 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 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 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 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 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
Peter Limkilde Svendsen 5045d40fa2 Add TODOs for remaining POSIX headers 2024-11-26 22:02:42 +01: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
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
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
Peter Limkilde Svendsen 2a7d01f02d Add docs for string.h, add missing functions 2024-11-19 00:20:40 +00:00
Josh Megnauth fc1e220a99 fix(netdb): Buffer overrun when parsing DNS 2024-11-18 13:43:22 +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 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
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 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