476 Commits

Author SHA1 Message Date
Alex Rønne Petersen 7ec6872cc4 libc: update Linux headers to 7.0 2026-04-22 08:37:15 +02:00
Chris Boesch 3ea77badf9 libc: strdup, strndup, wcsdup (#31935)
Contributes to: #30978

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31935
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-04-22 01:57:58 +02:00
GasInfinity 61cd38e8ac feat(libzigc): add common implementations of pthread_spin_*
* and remove their mingw, musl and wasi implementations
2026-04-21 09:03:06 +02:00
David Senoner 21914c7c01 ziglibc: migrate tee linux syscall (#31911)
Add the Linux syscall wrapper for `tee`.

Migrate the `tee` syscall from musl libc to zig libc.

langref: note `ssize_t` and `isize`  are ABI compatible

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31911
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: David Senoner <seda18@rolmail.net>
Co-committed-by: David Senoner <seda18@rolmail.net>
2026-04-18 07:30:43 +02:00
Josh Megnauth ff612334fa libzigc: dup2 and dup3
This commit adds `dup2` and `dup3` based on musl. Zig already has
wrappers for the syscalls, but musl's implementation checks for a rare,
temporary race condition with dup2/3 and `open`. Like musl, this
implementation adds a fallback for dup3 if the syscall isn't available.

Contributes to: #30978
2026-04-17 23:13:39 +02:00
Alex Rønne Petersen e7ee61cd64 musl: fix syscall argument width for mipsn32
https://www.openwall.com/lists/musl/2026/04/16/1
2026-04-16 16:00:18 +02:00
badayvedat a05a25e2bb zig libc: export fdiml and fdimf (#31759)
Exports `fdiml` and `fdimf` in zig libc and removes from from musl and mingw libc.

Contributes to: https://codeberg.org/ziglang/zig/issues/30978

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31759
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: badayvedat <badayvedat@gmail.com>
Co-committed-by: badayvedat <badayvedat@gmail.com>
2026-04-16 01:11:04 +02:00
David Rubin 36e2eaf2bd revert zig libc implementation of pow (#31794)
Partially reverts commit b5fbed986b.

Reverts commit 7aae7dd3f4.

Closes #31207

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31794
Co-authored-by: David Rubin <david@vortan.dev>
Co-committed-by: David Rubin <david@vortan.dev>
2026-04-09 17:38:17 +02:00
rpkak b5fbed986b musl,wasi-libc: remove unused exp_data and pow_data 2026-04-03 15:26:18 +02:00
rpkak 208a74a5c5 libc: remove duplicates of some functions
mingw,musl,wasi-libc: remove c files, that only provide functions already included in zigc

mingw: remove c files, that only provide functions, which are in ucrt

mingw: do not include mingw files/zigc functions on targets on which they in ucrt
2026-04-03 15:26:09 +02:00
mihael 9a53be5fb4 libzigc/math: Implement more precise sincosl in compiler_rt
The changes were tested by running:
```bash
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=sincosl -fqemu -fwasmtime --summary line
Build Summary: 369/369 steps succeeded
```

Additionally, I've added unit tests for `sincos`.
2026-04-02 23:54:20 +02:00
mihael a6d6af947d libzigc/math: Implement more precise cosl in compiler_rt
The implementation was ported from `musl`. Unit tests for `f80` and `f128` were also added.
`__cosl` was already implemented in `trig.zig` while working on `sinl`.

The changes were tested by running:
```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter='math.cosl' -fqemu -fwasmtime --summary line
Build Summary: 553/553 steps succeeded
```
2026-04-02 23:54:20 +02:00
mihael b5ec3e597e libzigc/math: Implement more precise sinl in compiler_rt
The implementation was ported from `musl`. Unit tests for `f80` and `f128` were also added.

The changes were tested by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=sinl -fqemu -fwasmtime --summary line
Build Summary: 553/553 steps succeeded
```
2026-04-02 23:54:20 +02:00
mihael 19334f95c1 libzigc/math: Implement lrintf
This was checked by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=lrintf -fqemu -fwasmtime --summary line
Build Summary: 369/369 steps succeeded
```
2026-04-02 23:54:20 +02:00
mihael bd1dc8948f libzigc/math: Remove straggler rint file in vendored MinGW
Seems like it was missed when implementing `rint`.

This was checked by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=rint -fqemu -fwasmtime --summary line
Build Summary: 2209/2209 steps succeeded
```
2026-04-02 23:54:19 +02:00
mihael 245c160a7b libzigc/math: Implement rintf
The implementation was ported from `musl` to Zig code, and the `rint`
unit tests were generalized so they could be used for `rintf` as well.

This was checked both through unit tests and running `libc-test` suite:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=rintf -fqemu -fwasmtime --summary line
Build Summary: 1657/1657 steps succeeded
```
2026-04-02 23:54:19 +02:00
mihael 811bada06d libzigc/math: Implement lrint
The changes were tested by running:
```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=lrint -fqemu -fwasmtime --summary line
Build Summary: 737/737 steps succeeded
```
2026-04-02 23:54:19 +02:00
mihael 2cbd6980e5 libzigc/math: Implement finite, finitef
The behaviour of `libc` `finite` functions is the same as Zig std's, so
the function basically delegates to `math.isFinite` and no new tests were
added. These functions are obsolete, but still part of `musl`.

No results are attached in this case as `libc-test` doesn't have tests for them.
2026-04-02 23:54:19 +02:00
mihael db1e649575 libzigc/math: Implement frexpl
The changes were tested by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=frexpl -fqemu -fwasmtime --summary line
Build Summary: 369/369 steps succeeded
```
2026-04-02 23:54:19 +02:00
mihael 521a093334 libzigc/math: Implement frexpf
The `frexp` implementation was generalized so it can be used for `f32`
and `c_longdouble` types as well.

The changes were tested by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=frexp -fqemu -fwasmtime --summary line
Build Summary: 737/737 steps succeeded

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=frexpf -fqemu -fwasmtime --summary line
Build Summary: 369/369 steps succeeded
```
2026-04-02 23:54:19 +02:00
mihael dcffee0672 libzigc/math: Implement frexp
The changes were tested by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=frexp -fqemu -fwasmtime --summary line
Build Summary: 737/737 steps succeeded
```

The tests were passing even when it was a straightforward calling of Zig
std library, but I wanted the `x is NaN` special case to match the
behaviour described in `libc` manpages, and for it to be consistent
with how infinities as arguments are handled in Zig.
2026-04-02 23:54:19 +02:00
mihael ba4af7aa8a libzigc/math: Switch to compiler_rt impl of tanl 2026-04-02 23:54:19 +02:00
mihael a8b710697e libzigc/math: Switch to compiler_rt impl of sincosl 2026-04-02 23:54:19 +02:00
Josh Megnauth 56507ecf98 libzigc: stropts/isastream
`isastream` is an old, deprecated function for the STREAMS framework.
Linux doesn't even support this natively, and so the musl implementation
just returns 0 (not a STREAMS file) for valid file descriptors or -1
(for bad file descriptors).
2026-04-02 15:13:39 +02:00
badayvedat 6cdd576d41 libzigc: fdim 2026-04-02 14:50:19 +02:00
Linus Groh f19be20912 libc: Update macOS headers to SDK 26.4 2026-03-26 19:25:56 +00:00
mihael 691416c24d libzigc: Implement tanhf
The changes were tested by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=tanhf -fqemu -fwasmtime --summary line
Build Summary: 553/553 steps succeeded
```
2026-03-17 23:33:10 +01:00
mihael fd680ba5fb libzigc: Implement tanh
The changes were tested by running following commands:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=tanh -fqemu -fwasmtime --summary line
Build Summary: 1289/1289 steps succeeded
```
2026-03-17 23:33:10 +01:00
mihael 4cad6f5372 libzigc: Implement modfl
The changes were tested by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=modfl -fqemu -fwasmtime --summary line
Build Summary: 369/369 steps succeeded
```
2026-03-17 23:33:10 +01:00
mihael 0141787257 libzigc: implement modff
`modf` function was generalized and renamed to `modfGeneric`, `modf` and
`modff` provide the appropriate type while calling that function. The
unit tests were also generalized so they can be reused for different
float types.

Both `modf` and `modff` were tested after making these changes:
```
$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=modf -fqemu -fwasmtime --summary line
Build Summary: 921/921 steps succeeded
```

```
stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=modff -fqemu -fwasmtime --summary line
Build Summary: 369/369 steps succeeded
```
2026-03-17 23:33:10 +01:00
mihael eab22ab2b8 libzigc: Implement modf
The behaviour regarding special cases differs between `libc` and Zig's
`stdlib` for `modf`, so the implementation couldn't be a straightforward
calling of `stdlib` function.

Other than the obvious documented differences, I also had problems with
the `INVALID` flag being raised while running `libc-test` suite on riscv
arch through qemu. The solution was to test if the argument is `NaN`,
and then return a quiet `NaN` if so.

Passing tests, that should include all the special cases to be wary of,
were also added.

Test results:
```
$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=modf -fqemu -fwasmtime --summary line
Build Summary: 921/921 steps succeeded
```
2026-03-17 23:33:10 +01:00
mihael c77103add7 libzigc: implement acoshf
The functions were tested by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=acoshf -fqemu -fwasmtime --summary line
Build Summary: 369/369 steps succeeded
```
2026-03-17 23:33:10 +01:00
mihael 69cbe8ea3c libzigc: Implement asin
The changes were tested by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=asin -fqemu -fwasmtime --summary line
Build Summary: 921/921 steps succeeded
```
2026-03-17 23:33:10 +01:00
Josh Megnauth aaba36ff76 libzigc: posix_{fadvise, fallocate}, fallocate
This commit removes `posix_fadvise`, `posix_fallocate`, and `fallocate`
from the bundled musl by forwarding to Zig's wrappers. `musl`'s
implemenation does not use `__syscall_cp`, so I assume trivially
replacing these functions is okay.

For `posix_fadvise`, `musl` notes that the arguments are reordered
for ARM and other architectures. Zig's wrapper already handles this
case.

Contributes toward: #30978
2026-03-14 22:04:43 +01:00
Alex Rønne Petersen 26f2749c1e Merge pull request 'FreeBSD libc: guard ssp headers and definitions introduced in FreeBSD 15' (#31457) from kid/zig:fbsd-libc-guard into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31457
Reviewed-by: Alex Rønne Petersen <alex@alexrp.com>
2026-03-13 04:07:26 +01:00
Huang Zhichao 3e9ab94d29 FreeBSD libc: guard ssp headers and definitions introduced in FreeBSD 15 2026-03-11 16:04:16 +08:00
Huang Zhichao feaa690dc6 FreeBSD libc: prevent ssp headers from being included before FreeBSD 15 2026-03-11 16:04:16 +08:00
mihael 159568a05a Reimplement coshf in libzigc
The function basically calls the Zig std's implementation.

The changes were tested by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=coshf -fqemu -fwasmtime --summary line
Build Summary: 553/553 steps succeeded
```
2026-03-10 00:42:32 +01:00
mihael 1f92162875 Reimplement cosh in libzigc
The function basically calls the Zig std's implementation.
The changes were tested by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=cosh -fqemu -fwasmtime --summary line
Build Summary: 921/921 steps succeeded
```
2026-03-10 00:42:14 +01:00
kj4tmp@gmail.com 3dc2a1f9ac zig libc: acosf 2026-02-13 11:30:14 -08:00
rpkak 4ea9904923 remove some unused libc files 2026-02-13 19:57:59 +01:00
kineye f36d0573cd zig libc: add rint 2026-02-12 21:42:38 -08:00
Neel 5132d78e83 libc: implement insque and remque in Zig
Implements insque() and remque() doubly-linked list functions
in lib/c/search.zig and removes musl C implementation.
Contributes to #30978
2026-02-12 21:35:36 -08:00
Andrew Kelley f5d5dbd166 wasi libc: remove malloc defines 2026-02-12 13:14:51 -08:00
Andrew Kelley e2fccd8dd5 musl: remove macro redefinitions of malloc 2026-02-12 13:14:51 -08:00
Andrew Kelley 6744160211 zig libc: implement malloc 2026-02-12 13:14:51 -08:00
Andrew Kelley b600b6e5e0 std.posix: remove close function 2026-02-11 23:37:31 +01:00
Pivok d4217e2119 zig libc: exp10, exp10f, pow10, pow10f (#31163)
See #30978.

Commands i run:
```
$ stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=../../libc-test -Dtest-filter=exp10 -fqemu -fwasmtime --summary line
Build Summary: 725/737 steps succeeded (12 skipped)
```

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31163
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: Pivok <pivoc@protonmail.com>
Co-committed-by: Pivok <pivoc@protonmail.com>
2026-02-11 19:39:40 +01:00
Andrew Kelley 7fbeeca924 Merge pull request 'Linux 6.19' (#31165) from alexrp/zig:linux-6.19 into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31165
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-02-10 05:29:00 +01:00
Alex Rønne Petersen 7af9882c6d libc: update Linux headers to 6.19 2026-02-09 23:54:30 +01:00