Commit graph

37277 commits

Author SHA1 Message Date
Andrew Kelley
0403f9647b std: different mechanism for disabling network dependency
On Windows, it is sometimes problematic to depend on ws2_32.dll. Before,
users of std.Io.Threaded would have to call ioBasic() rather than io()
in order to avoid unnecessary dependencies on ws2_32.dll. Now, the
application can disable networking with std.Options.

This change is necessary due to moving networking functionality to
be based on Io.Operation, which is a tagged union.
2026-03-05 22:36:33 -08:00
Andrew Kelley
9c9af37a0c std.Io.Dispatch: fix compile errors 2026-03-05 18:08:36 -08:00
Andrew Kelley
79afa8b033 std.Io.Uring: implement net_receive operate
Batch implementation still TODO.
2026-03-05 18:04:35 -08:00
Andrew Kelley
3ab20d5fe2 std.Io.Threaded: implement net_receive for Windows 2026-03-05 17:46:07 -08:00
Andrew Kelley
ebb2752c07 std.Io.Threaded: optimize batchAwaitConcurrent for net_receive
Eagerly receive messages with MSG_DONTWAIT before polling. This makes
the DNS resolution use case end up doing:

recvmsg (EAGAIN)
poll
recvmsg (success)
recvmsg (success)

rather than:

poll
recvmsg (success)
poll
recvmsg (success)
2026-03-05 16:34:16 -08:00
Andrew Kelley
a14d5e1418 std.Io: move netReceive to become an Operation
Notably, the timeout becomes provided by the general-purpose Batch API
rather than being special-purposed.
2026-03-05 15:06:33 -08:00
Koko Bhadra
4fa465fc8f compiler_rt: optimize udivmod large-divisor case with trial quotient
Replace the O(n) shift-subtract loop with a constant-time trial
quotient approach (Knuth Algorithm D, TAOCP Vol 2 Section 4.3.1).

The old code iterates clz(b_hi)-clz(a_hi)+1 times (up to 64
iterations of 128-bit arithmetic). The new code uses a single
divwide call to get a trial quotient, then verifies with two
native-width widening multiplies.

Benchmark (Apple M1, ReleaseFast):
- Large divisor, large shift: 87ns -> 7.5ns (11.5x faster)
- Small divisor / uniform: unchanged
2026-03-05 20:22:19 +01:00
xeondev
15f0af09d0 Io.Threaded.batchAwaitConcurrent: fix poll args 2026-03-05 20:17:21 +01:00
Alex Rønne Petersen
b778826df5
std.crypto.argon2: disable kdf test
https://codeberg.org/ziglang/zig/issues/31402
2026-03-05 18:49:31 +01:00
Alex Rønne Petersen
571543237f
ci: update to wasmtime 42.0.1 2026-03-04 21:29:48 +01:00
Alex Rønne Petersen
0ae1c6b54a
std.Io.RwLock: disable smoke test on aarch64-netbsd
https://codeberg.org/ziglang/zig/issues/31393
2026-03-04 12:14:11 +01:00
Alex Rønne Petersen
ce32003625
std.Io.net.test: disable listen on a port, send bytes, receive bytes
https://codeberg.org/ziglang/zig/issues/31388
2026-03-04 01:21:08 +01:00
Alex Rønne Petersen
af1ab5fa08
ci: bump aarch64-freebsd-debug timeout by 1 hour 2026-03-04 00:16:47 +01:00
Alex Rønne Petersen
96a19d3a6b ci: stop downloading tarballs on x86_64-windows
It's annoying to have jobs fail on new machines or when switching tarball. Also
quirky is easily accessible over SSH now, so we can just upload tarballs as we
do for other machines.
2026-03-03 23:28:01 +01:00
Alex Rønne Petersen
852c5d2824
build: bump some max_rss values 2026-03-03 22:50:48 +01:00
Robby Zambito
d2db1d45f1 fix: inline to propagate comptime-ness to call site
See conversation at: https://ziggit.dev/t/why-is-the-comptime-keyword-needed-in-this-inline-for-loop-condition/14090
2026-03-03 21:10:30 +01:00
Andrew Kelley
2d88a5a103 Merge pull request 'Another dll dependency bites the dust (advapi32.dll)' (#31384) from squeek502/zig:delete-advapi32 into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31384
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-03 18:26:12 +01:00
Ryan Liptak
fdde8e6394 Delete advapi32 bindings 2026-03-03 01:12:48 -08:00
Ryan Liptak
70058471e3 WindowsSdk: Use ntdll instead of advapi32 APIs for registry querying
The dependency on advapi32.dll actually silently brings along 3 other dlls at runtime (msvcrt.dll, sechost.dll, bcrypt.dll), even if no advapi32 APIs are called. So, this commit actually reduces the number of dlls loaded at runtime by 4 (but only when LLVM is not linked, since LLVM has its own dependency on advapi32.dll).

The data is not super conclusive, but the ntdll version of WindowsSdk appears to run slightly faster than the previous advapi32 version:

Benchmark 1: libc-ntdll.exe ..
  Time (mean ± σ):       6.0 ms ±   0.6 ms    [User: 3.9 ms, System: 7.1 ms]
  Range (min … max):     4.8 ms …   7.9 ms    112 runs

Benchmark 2: libc-advapi32.exe ..
  Time (mean ± σ):       7.2 ms ±   0.5 ms    [User: 5.4 ms, System: 9.2 ms]
  Range (min … max):     6.1 ms …   8.9 ms    103 runs

Summary
  'libc-ntdll.exe ..' ran
    1.21 ± 0.15 times faster than 'libc-advapi32.exe ..'

and this mostly seems to be due to changes in the implementation (the advapi32 APIs do a lot of NtQueryKey calls that the new implementation doesn't do) rather than due to the decrease in dll loading. LLVM-less zig binaries don't show the same reduction (the only difference here is the DLLs being loaded):

Benchmark 1: stage4-ntdll\bin\zig.exe version
  Time (mean ± σ):       3.0 ms ±   0.6 ms    [User: 5.3 ms, System: 4.8 ms]
  Range (min … max):     1.3 ms …   4.2 ms    112 runs

Benchmark 2: stage4-advapi32\bin\zig.exe version
  Time (mean ± σ):       3.5 ms ±   0.6 ms    [User: 6.9 ms, System: 5.5 ms]
  Range (min … max):     2.5 ms …   5.9 ms    111 runs

Summary
  'stage4-ntdll\bin\zig.exe version' ran
    1.16 ± 0.28 times faster than 'stage4-advapi32\bin\zig.exe version'

---

With the removal of the advapi32 dependency, the non-ntdll dependencies that remain in an LLVM-less Zig binary are ws2_32.dll (which brings along rpcrt4.dll at runtime), kernel32.dll (which brings along kernelbase.dll at runtime), and crypt32.dll (which brings along ucrtbase.dll at runtime).
2026-03-03 01:12:47 -08:00
Andrew Kelley
0a412853aa std.Io: fix Select cancel deadlock with no tasks 2026-03-03 02:26:23 +01:00
Alex Rønne Petersen
ac24e6caf5 Merge pull request 'enable aarch64-netbsd CI' (#31377) from alexrp/zig:aarch64-netbsd-ci into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31377
2026-03-03 01:25:45 +01:00
Alex Rønne Petersen
421c3c3cc5 ci: update qemu to 10.2.1.1
https://patchwork.kernel.org/project/qemu-devel/list/?series=1059138
2026-03-02 19:25:09 +01:00
invlpg
0a2f6a048b fix msghdr and cmsghdr on non-Linux targets, document musl behaviour
The following assertions fail on non-Linux platforms after c0c2010535
which inserted padding based on musl definitions. This padding only
exists on musl to workaround a discrepancy betweeen the POSIX API and
Linux ABI, and is incorrect on other POSIX operating systems.

This change makes the padding musl-only, and documents the reason it
exists. With this change, the assertions pass on Linux and FreeBSD
targets. The corresponding definitions on other targets line up with the
POSIX and FreeBSD ones, so they should work there too.

```zig
const std = @import("std");
const assert = std.debug.assert;
const msghdr = std.c.msghdr;
const cmsghdr = std.c.cmsghdr;

const c = @cImport({
    @cInclude("sys/socket.h");
});

comptime {
    assert(@offsetOf(msghdr, "iovlen") == @offsetOf(c.msghdr, "msg_iovlen"));
    assert(@offsetOf(msghdr, "controllen") == @offsetOf(c.msghdr, "msg_controllen"));
    assert(@offsetOf(msghdr, "control") == @offsetOf(c.msghdr, "msg_control"));
    assert(@offsetOf(msghdr, "flags") == @offsetOf(c.msghdr, "msg_flags"));

    assert(@sizeOf(msghdr) == @sizeOf(c.msghdr));

    assert(@offsetOf(cmsghdr, "len") == @offsetOf(c.cmsghdr, "cmsg_len"));
    assert(@offsetOf(cmsghdr, "level") == @offsetOf(c.cmsghdr, "cmsg_level"));

    assert(@sizeOf(cmsghdr) == @sizeOf(c.cmsghdr));
}
```
2026-03-02 17:46:26 +01:00
Alex Rønne Petersen
d6e9b9eb64
ci: enable aarch64-netbsd 2026-03-02 15:08:37 +01:00
Alex Rønne Petersen
d182feacf7
ci: add aarch64-netbsd scripts 2026-03-02 15:08:37 +01:00
Alex Rønne Petersen
f75e4027bd
test: disable an error trace test on optimized aarch64-netbsd 2026-03-02 15:08:37 +01:00
rpkak
442b292a37
zig fetch: wait until all jobs are finished 2026-03-02 10:17:55 +01:00
Ryan Liptak
e58fea8227 tar: Fix symlink test when symlinks can't be created on Windows 2026-03-01 15:01:51 -08:00
hemisputnik
74f361a5ce std.math.big.int: address log2/log10 reviews
There were good reviews made after #31365 was merged, so this commit
addresses them separately.

1. Assert that the number is greater than zero
2. Use `constants` instead of calculating constants manually
3. Use `Const.bitCountAbs` for log2
2026-03-01 20:34:17 +01:00
Alex Rønne Petersen
da6d4e28ef
Revert "ci: disable aarch64-freebsd"
This reverts commit 104e73ecb2.

The OOM issues should be resolved now.
2026-03-01 17:54:47 +01:00
Alex Rønne Petersen
104e73ecb2
ci: disable aarch64-freebsd
Working through some OOM issues.
2026-03-01 12:04:55 +01:00
Alex Rønne Petersen
bf13b6b41d
test: partially disable cmakedefine standalone test
https://codeberg.org/ziglang/zig/issues/31368
2026-03-01 11:53:05 +01:00
Andrew Kelley
9ef1050bb3 Merge pull request 'std.math.big.int: add log2 and log10 operations' (#31365) from hemisputnik/zig:work/13642-bigint-log2-log10 into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31365
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-01 03:35:16 +01:00
hemisputnik
bd6f512f0c
std.math.big.int: add log10 2026-02-28 20:16:32 +02:00
Alex Rønne Petersen
41594c1903 Merge pull request 'enable aarch64-freebsd CI' (#31354) from alexrp/zig:aarch64-freebsd-ci into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31354
2026-02-28 08:19:51 +01:00
Alex Rønne Petersen
b3c8c0df0d ci: switch to VS 2026 in x86_64-windows scripts 2026-02-28 07:08:06 +01:00
Andrew Kelley
02142a54d2 std.Io: remove cancelation propagation assertions
While the general guidance remains useful, it is not the case that
error.Canceled will always pass across the Group task function boundary.

Remove the too-aggressive assertions and add unit test coverage.

Closes #30096
Closes #31340
Closes #31358
2026-02-28 05:07:54 +01:00
hemisputnik
925f82da09
std.math.big.int: add log2 2026-02-28 04:15:19 +02:00
hemisputnik
99229ceb55 std.Io.{Writer|Duration}: move duration formatting to a format method
Remove the `{D}` format specifier. It is moved into `std.Io.Duration` as
a format method.

Migration plan:

```diff
-writer.print("{D}", .{ns});
+writer.print("{f}", .{std.Io.Duration{ .nanoseconds = ns }});
```

All instances where `{D}` was used have been changed to use
`std.Io.Duration` and `{f}`.

Fixes #31281
2026-02-28 02:46:04 +01:00
Andrew Kelley
8c70fd0a57 std.Io.Select: introduce cancelDiscard
and make the return value of `cancel` return queue items.

I don't think it's possible to make `cancel` not deadlock with an empty
queue buffer without introducing a new Group primitive.

This is the best I could come up with based on existing primitives.
Let's see if applications find these APIs palatable.
2026-02-28 01:46:43 +01:00
Alex Rønne Petersen
424061381b
ci: enable aarch64-freebsd 2026-02-27 20:30:31 +01:00
mintonmu
e779ca7223 fix(docs/wasm):zig std html render error function 'a' 2026-02-27 19:17:47 +01:00
Nils Juto
2da1370a7e sync CallModifier in langref with what's actually there 2026-02-27 13:50:12 +01:00
Alex Rønne Petersen
d130f76bab
ci: add aarch64-freebsd scripts 2026-02-27 08:49:27 +01:00
Alex Rønne Petersen
b781615e09
test: disable an error trace test on optimized aarch64-freebsd 2026-02-27 08:49:27 +01:00
Justus Klausecker
bbc77df3eb std.heap: delete ThreadSafeAllocator
We can keep ourselves safe from those threads perfectly well without you, thanks!
2026-02-26 21:20:34 +01:00
Saurabh Mishra
4e2cec265d Make std.PriorityQueue an unmanaged container (#31299)
## Summary of changes

+ Make adjustments to the `allocator` field and ensure the below tests pass:

  ```sh
  zig test lib/std/std.zig --zig-lib-dir lib
  zig build test-std -Dno-matrix --summary all
  ```

+ Rename `add` to `push` and `remove` to `pop` in methods and tests

+ Incorporate the functionality of `pop` in `popOrNull`, then rename the `popOrNull` to `pop` and update tests

+ Use `.empty` to set default field values and rename the `init` method to `initContext`

+ Improve variable types in tests: min heap uses the less than context function and max heap uses greater than context function

+ Remove the `dump` method as its not being used anywhere

+ Document methods `clearRetainingCapacity`, `clearAndFree`, `update`, and `ensureTotalCapacityPrecise`

Closes https://codeberg.org/ziglang/zig/issues/31298

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31299
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: Saurabh Mishra <saurabh.m@proton.me>
Co-committed-by: Saurabh Mishra <saurabh.m@proton.me>
2026-02-26 21:09:52 +01:00
estevesnp
0b6b65b387 fix: Allow async and concurrent from Io.Select to accept non-void error unions 2026-02-26 20:49:05 +01:00
Alex Rønne Petersen
2d867223be build: use -ffunction-sections -fdata-sections for the Zig compiler on ARM
See 7daf0b6f46; builds for ARM can run into the
same problems due to limited branch range.
2026-02-26 20:48:29 +01:00
Andrew Kelley
7bc6546fdf Merge pull request 'std.heap.ArenaAllocator: Get rid of cmpxchg loop in hot path' (#31343) from justusk/zig:lock-free-arena-overshoot into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31343
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-02-26 20:42:30 +01:00