Commit graph

14332 commits

Author SHA1 Message Date
GasInfinity
1ab6bf59a6
feat(libzigc): add common linux errno syscall helper 2026-01-21 12:02:08 +01:00
GasInfinity
4f652fb4e3
feat(libzigc): use common implementations for sys/utsname.h
* and remove their musl/wasi implementation
2026-01-21 00:06:42 +01:00
GasInfinity
9d3e9054a7
feat(std.c): add wasi definition for utsname 2026-01-21 00:06:42 +01:00
GasInfinity
f67d21f736
chore(libc/musl): remove unused ffs impls
* forgot to remove them in the previous PR
2026-01-21 00:06:42 +01:00
rpkak
e6ac1b77f0
libzigc: test and fix acos 2026-01-20 18:02:15 +01:00
Daggerfall-is-the-best-TES-game
21fc85f035 Add acos to ziglibc (#30888)
Since this is my first time contributing I wanted to keep it simple and I added just one function
I tested with
```bash
stage3/bin/zig build -p stage4 -Dno-lib -Dno-langref -Denable-llvm=true --search-prefix ~/repos/zig-boostrap/out/native-linux-musl-baseline/
stage4/bin/zig build test-libc -Dlibc-test-path=../libc-test -Dtest-target-filter=x86_64-linux-musl
```
and the tests passed.
I'm planning on doing more once I get the hang of it.

Co-authored-by: david <davidc.fried@gmail.com>
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30888
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: Daggerfall-is-the-best-TES-game <daggerfall-is-the-best-tes-game@noreply.codeberg.org>
Co-committed-by: Daggerfall-is-the-best-TES-game <daggerfall-is-the-best-tes-game@noreply.codeberg.org>
2026-01-19 22:43:57 +01:00
Alex Rønne Petersen
c71d32d14a
std.c.netbsd: change type of _ksiginfo.signo to std.c.SIG 2026-01-19 13:16:03 +01:00
Alex Rønne Petersen
fb66d7712c
std.c: fix W functions for NetBSD
I'm not sure where the old logic came from but it certainly didn't match NetBSD
10.1 system headers, and was causing the build system to see incorrect exit
status information for processes that were expected to crash (e.g. SIGABRT).
2026-01-19 13:15:57 +01:00
jsentity
27e8d05ee8 Fix protocol.DevicePath.next() (#30883)
fix for https://codeberg.org/ziglang/zig/issues/30882

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30883
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: jsentity <jsentity@noreply.codeberg.org>
Co-committed-by: jsentity <jsentity@noreply.codeberg.org>
2026-01-18 21:42:34 +01:00
Andrew Kelley
d2dda0737b std.Io.Threaded: sendmmsg can return EACCES 2026-01-18 21:40:15 +01:00
GasInfinity
d6b3dd25a0
chore(libzigc): document libc target checks 2026-01-18 00:26:42 +01:00
GasInfinity
f0649dd978
feat(libzigc): use common implementations for strings.h and string.h
* forwards all functions to their equivalent `std`
* removes their musl, wasi-libc and mingw implementations
2026-01-17 22:37:29 +01:00
GasInfinity
06d05decae
feat(libzigc): add wcstok and reuse more std.mem code
* also makes `wcpncpy`/`wcsncpy` pad the buffer with zeroes as required
  by the standard
2026-01-17 21:42:40 +01:00
GasInfinity
3d8b0e3324
feat(std.ascii): add boundedOrderIgnoreCaseZ 2026-01-17 21:42:38 +01:00
GasInfinity
26de7a3513
feat(std.mem): add boundedOrderZ 2026-01-17 21:42:32 +01:00
Alex Rønne Petersen
27685bcf20 std.c: fix O constants for FreeBSD
closes https://codeberg.org/ziglang/zig/issues/30861
2026-01-17 12:13:20 +01:00
Andrew Kelley
d417441f4f Merge pull request 'libc: use common implementations for wchar.h' (#30850) from GasInfinity/zig:libc-wchar into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30850
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-01-17 00:58:01 +01:00
murtaza
b5770541bd testing: ability to read environment variables from unit tests 2026-01-17 00:40:22 +01:00
Andrew Kelley
790d28d6cd std.testing: delete refAllDeclsRecursive
suggested alternatives:
- actual tests
- explicitly list the decls
- compile an example application that uses the API
- stop worrying about dead code
- refAllDecls (non recursive) in each file

Don't fight the laziness, embrace it.

closes #23608
closes #30813
2026-01-16 12:34:42 -08:00
Alex Rønne Petersen
081888286b
musl: patch riscv bits/fenv.h for soft float 2026-01-16 13:29:34 +01:00
Alex Rønne Petersen
171b104640
musl: patch loongarch bits/fenv.h for soft float
This change was missed in 1f7ee99b35.
2026-01-16 13:25:21 +01:00
Alex Rønne Petersen
f2beea3b8f
std.os.linux.IoUring.test: disable accept_direct on RISC-V
https://codeberg.org/ziglang/zig/issues/30854
2026-01-16 11:40:19 +01:00
GasInfinity
e3309aaf4f
fix(libzigc): workaround LLVM bug
* looks like we get stuck inside this loop? 2078da43e2/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp (L245-L298)
2026-01-16 01:58:35 +01:00
Andrew Kelley
7b21fd7244 std.Io.Threaded: fix memory mapping on windows
- set protection flags properly
- handle when mapping fails after unmapping
2026-01-15 14:18:21 -08:00
Andrew Kelley
d2585e68a7 std.Io.Threaded: use NtExtendSection in fileMemoryMapSetLength
is this a good idea? not sure yet. reverting in the next commit
2026-01-15 14:18:21 -08:00
Andrew Kelley
de347dd6a9 std.Io.Threaded: add missing free in MemoryMap.setLength 2026-01-15 14:18:21 -08:00
Andrew Kelley
7ff6bcc111 std.Io.Threaded: track unaligned mapping length on Windows 2026-01-15 14:18:21 -08:00
Andrew Kelley
b2776d097d std.Io.Threaded: implement MemoryMap.setLength for Windows 2026-01-15 14:18:20 -08:00
Andrew Kelley
8527ec9c7b std.Io.Threaded: implement mmap fallback for Windows 2026-01-15 14:18:20 -08:00
Andrew Kelley
3c708b19fe disable test due to wasmtime bug
tracked by #20747
2026-01-15 14:18:20 -08:00
Andrew Kelley
2b01764d86 std: fix handling of EBADF error code
In the context of read/write it's ambiguous, means file was opened
without read/write respectively.
2026-01-15 14:18:20 -08:00
Andrew Kelley
cb37a5c1fb std.Io.Threaded: fix fileReadPositional error.IsDir for wasi 2026-01-15 14:18:20 -08:00
Andrew Kelley
08a33c0671 std: workaround for #30842 2026-01-15 14:18:20 -08:00
Andrew Kelley
c4df980ac2 std.fs: fix test cases regarding error.IsDir on WASI
why were we testing for shitty behavior?
2026-01-15 14:18:20 -08:00
Andrew Kelley
e70def70ec std.Io.Threaded: passing memory mapping tests on wasm32-wasi 2026-01-15 14:18:20 -08:00
Andrew Kelley
c917f619f0 std: fix compilation failures on various targets 2026-01-15 14:18:20 -08:00
Andrew Kelley
eb163361d9 std.Io.File.MemoryMap: add some alignment type safety 2026-01-15 14:18:20 -08:00
Andrew Kelley
4821898432 std.Io.File.MemoryMap API tuning
- remove file_size parameter from MemoryMap.write
- remove requirement for mapping length to be aligned
- align allocated fallback memory
- add unit test for std.Io.Threaded.disable_memory_mapping = true
- add unit test for MemoryMap.setLength
2026-01-15 14:18:20 -08:00
Andrew Kelley
bed7bc37c4 std.File.MemoryMap updates
- change offset to u64
- make len non-optional
- make write take a file_size parameter
- std.Io.Threaded: introduce disable_memory_mapping flag to force it to
  take the fallback path.

Additionally:

- introduce BlockSize to File.Stat. On Windows, based on cached call to
  NtQuerySystemInformation. On unsupported OS's, set to 1.
- support File.NLink on Windows. this was available the whole time, we
  just didn't see the field at first.
- remove EBADF / INVALID_HANDLE from reading/writing file error sets
2026-01-15 14:18:20 -08:00
Andrew Kelley
a70e006157 std: add unit test for memory mapping 2026-01-15 14:18:20 -08:00
Andrew Kelley
5a7dc4b0fa std.Io: introduce File.MemoryMap
by defining the pointer contents to only be synchronized after explicit
sync points, makes it legal to have a fallback implementation based on
file operations while still supporting a handful of use cases for memory
mapping.

furthermore, it makes it legal for evented I/O implementations to use
evented file I/O for the sync points rather than memory mapping.

not yet done:
- implement checking the length when options.len is null
- some windows impl work
- some wasi impl work
- unit tests
- integration with compiler
2026-01-15 14:18:20 -08:00
GasInfinity
e22bf480aa
feat(libzigc): use common implementation for wchar.h
* but does not fully implement it (missing locale/unicode tables)
* also removes their musl/mingw implementation
2026-01-15 18:01:20 +01:00
Matthew Lugg
4f16e80cea std: halve the number of mutexes per mutex
On NetBSD and Illumos, we were using the `std.Thread.Futex`-based
implementation of `std.Thread.Mutex`. But since futex is not a primitive
on these targets, the implementation of `std.Thread.Futex` was based on
pthread primitives, including `pthread_mutex_t`. This had the amusing
consequence that locking a contended mutex on NetBSD would actually
perform 2 mutex locks, 2 mutex unlocks, and 1 condition wait; likewise,
unlocking a contended mutex would perform 2 mutex locks, 2 mutex
unlocks, and 1 condition signal. Having read some cutting-edge studies,
I have concluded that this is a slightly suboptimal approach. Instead,
let's just use pthread mutexes directly in this case; that's an
obviously better idea.

In the future, I think we can probably entirely remove our usages of
pthread sync primitives---no platform actually treats them as the base
primitives. Of the platforms which std has any meaningful support for
today, most support futexes, and the exceptions (NetBSD and Illumos)
support a thread parking API. We can implement futex and/or mutex on top
of thread parking and drop the pthread dependency entirely.
2026-01-15 05:28:11 +01:00
Matthew Lugg
c518593e97 std.Io.Threaded: spurious unparks are possible
Apparently the thread parking APIs on Windows and NetBSD aren't as good
as I thought---or, at least, the way they're *used* makes them not as
good. It's perfectly possible to use these APIs in a way where you don't
trigger spurious wakeups, but standard primitives (SRWLOCK on Windows,
pthread bits on NetBSD) are perfectly happy to leave pending unparks
sitting around, meaning in practice you have to assume spurious unparks
are possible. This brings me great sadness... but we soldier on!
2026-01-15 01:38:09 +01:00
GasInfinity
4df6119335 feat(libzigc): avoid division/multiplication in drand48 and erand48 2026-01-14 23:48:07 +01:00
GasInfinity
e10a325410
feat(libzigc): implement the drand48 family
* also remove their musl implementation
2026-01-14 13:14:33 +01:00
GasInfinity
d0c8fd2ce9
feat(std.Random): add a linear congruent generator 2026-01-14 12:48:09 +01:00
GasInfinity
ad3828db45
feat(libzigc): use common rand implementations
* also remove their musl implementation
2026-01-14 12:47:58 +01:00
Ryan Liptak
9d1a39c50f resinator: Sync with upstream
No functional differences, just some shuffling things around and the removal of the now-obsolete `utils.openFileNotDir`.
2026-01-14 01:04:24 +01:00
Alex Rønne Petersen
3da6e67199
std.Io.test: disable Group.concurrent on linux w/o libc
https://codeberg.org/ziglang/zig/issues/30096
2026-01-13 21:27:53 +01:00