Commit graph

1944 commits

Author SHA1 Message Date
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
George Huebner
27ef6e9a9b bpf: add missing helpers 2026-02-23 02:27:13 +01:00
Yusuf Bham
de6c0d500f uefi(guid): don't use @byteSwap in fmt, adjust fmt test
@byteSwap shouldn't be called since we're formatting
ints again, and UEFI only officially supports LE.
2026-02-22 23:13:33 +01:00
inge4pres
29e52aa040 lib: add cgroup BPF helpers
Add bpf_cgrp_storage_get and bpf_cgrp_storage_delete from
libbpf helpers.

Signed-off-by: inge4pres <fgualazzi@gmail.com>
2026-02-22 20:24:51 +01:00
Alex Rønne Petersen
e95132476d std.os.linux: fix the mmap2 unit for various architectures
closes https://codeberg.org/ziglang/zig/issues/31033
2026-02-20 04:56:07 +01:00
Yusuf Bham
1e26d885d3 uefi(guid): don't use std.mem.asBytes in format
Using std.mem.asBytes causes a panic when format
is called as slices can no longer have hex options
when formatting, so instead just print the ints.
2026-02-18 20:19:50 -05:00
Jacob Young
5763f7dbcc std.Io.Evented: clean up supporting code for select 2026-02-15 05:52:07 -05:00
Andrew Kelley
6ccabbd4e5 std: brk allocator for single-threaded mode 2026-02-12 13:14:51 -08:00
Andrew Kelley
b600b6e5e0 std.posix: remove close function 2026-02-11 23:37:31 +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
80db2e0b8b
std.os.linux: update syscalls for 6.19 2026-02-09 23:54:30 +01:00
Jacob Young
a28d57292f IoUring: update to new Io APIs 2026-02-09 10:47:21 -05:00
Ben Buhse
52a6242443 std.os.linux: add F_SEAL constants to F struct
Add the missing F_SEAL_SEAL, F_SEAL_SHRINK, F_SEAL_GROW, F_SEAL_WRITE,
F_SEAL_FUTURE_WRITE, and F_SEAL_EXEC constants used with
F.ADD_SEALS/F.GET_SEALS for memfd file sealing. These are defined in the
Linux kernel at include/uapi/linux/fcntl.h.

The FreeBSD equivalents already exist in std.c (freebsd.F),
but the Linux side was missing them.
2026-02-08 02:11:20 +01:00
Jacob Young
b5bd494606 std.Threaded: replace more kernel32 functions with ntdll 2026-02-07 00:02:50 -05:00
brickmonster
c38f9336a3 std.os.linux: fix test not building 2026-02-05 21:15:54 +01:00
Jacob Young
c77e7146f5 std.Threaded: replace console kernel32 functions with ntdll 2026-02-05 07:41:25 -05:00
Andrew Kelley
3a5fff45ec std: move os.windows.OpenFile into Io.Threaded
it needs cancelation integration
2026-02-04 16:30:17 -08:00
Andrew Kelley
2a193a3987 std: move GetFinalPathNameByHandle to Io.Threaded
unfortunately this function calls NtCreateFile so it has to participate
in cancelation
2026-02-04 16:27:13 -08:00
Jacob Young
71156aff80 std.Progress: implement ipc resource cleanup 2026-02-04 15:20:10 -05:00
Jacob Young
ffc6da29e3 std.Io.Threaded: implement and cleanup windows codepaths 2026-02-04 14:15:41 -05:00
Andrew Kelley
922ab8b8bc std: finish moving time to Io interface
Importantly, adds ability to get Clock resolution, which may be zero.
This allows error.Unexpected and error.ClockUnsupported to be removed
from timeout and clock reading error sets.
2026-02-02 23:02:31 -08:00
Krzysztof Antonowski
1cd3af43fd std.Io.Threaded: implement CPU-based clocks on Windows (#31093)
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31093
Co-authored-by: Krzysztof Antonowski <krzysztofantonowski@proton.me>
Co-committed-by: Krzysztof Antonowski <krzysztofantonowski@proton.me>
2026-02-02 22:19:19 +01:00
Andrew Kelley
2b19134c86 Merge pull request 'std.Io: introduce batching and operations API, satisfying the "poll" use case' (#30743) from poll into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30743
2026-01-31 12:07:31 +01:00
Andrew Kelley
5ccc2ea85d
std: IoUring test handles EINTR 2026-01-31 09:36:40 +01:00
Andrew Kelley
14e1e5f6d8 std: IoUring test handles EINTR 2026-01-30 22:03:44 -08:00
Andrew Kelley
25aef0dd87 std.Io.Threaded: rework file reading to observe nonblocking flag
- batchAwaitAsync does blocking reads with NtReadFile (no APC, no event)
  when the nonblocking flag is unset, but still takes advantage of
  APCs when nonblocking flag is set.
- batchAwaitConcurrent returns error.ConcurrencyUnavailable when it
  encounters a file_read_streaming operation on a file in blocking mode.
- fileReadStreaming avoids pointlessly checking sync cancelation status
  when nonblocking flag is set, uses an APC with a done flag, and waits
  on that value to change in NtDelayExecution before returning.
- fix incorrect use of NtCancelIoFile (ntdll function prototype was
  wrong, leading to misuse)
2026-01-30 22:03:14 -08:00
Andrew Kelley
866ee4f1c5 std.Io.Threaded: handle TIMEOUT from NtDelayExceution 2026-01-30 22:03:14 -08:00
Andrew Kelley
fdf1ee973e std.Io.Threaded: move the NtDelayExecution later in batchWait
also guard against receiving SUCCESS with 0 byte read

ms docs say that pipes can do this if there is a 0 byte write
2026-01-30 22:03:14 -08:00
Andrew Kelley
6d9e6e2c38 std.Io.Threaded: avoid extra fields of Thread
As mlugg pointed out those race when a thread finishes an operation just
after it is canceled and then that thread to picks up another task,
resulting in these fields being potentially overwritten.

This updates fileReadStreaming on Windows to handle being alerted, and
then manage its own cancelation of the file I/O.
2026-01-30 22:03:13 -08:00
Andrew Kelley
a933d7a6f8 std.Io.Threaded: don't pass null to NtDelayExecution
Windows returns ACCESS_VIOLATION if you do that.
2026-01-30 22:03:13 -08:00
Andrew Kelley
e705ad8302 std.Io.Threaded: implement APC cancelation
specifically the call to NtCancelIoFileEx
2026-01-30 22:03:13 -08:00
Andrew Kelley
cb7be96644 std.Io: give File a nonblocking bit on Windows
This tracks whether it is a file opened in synchronous mode, or
something that supports APC.

This will be needed in order to know whether concurrent batch operations
on the file should return error.ConcurrencyUnavailable, or use APC to
complete the batch.

This patch also switches to using NtCreateFile directly in
std.Io.Threaded for dirCreateFile, as well as NtReadFile for
fileReadStreaming, making it handle files opened in synchronous mode as
well as files opened in asynchronous mode.
2026-01-30 22:03:13 -08:00
Alex Rønne Petersen
7c68ab1d10
std.os.linux: add MAP.DROPPABLE
Introduced in Linux 6.11.
2026-01-31 00:08:35 +01:00
Andrew Kelley
e7e168727e std.posix: goodbye connect, eventfd 2026-01-30 01:58:49 -08:00
Andrew Kelley
3cc5dda756 fix RtlGetCurrentDirectory_U parameter
it's the byte length not number of wchars
2026-01-29 18:40:56 -08:00
Andrew Kelley
649aaf4814 std: migrate getcwd to Io
progress towards #30150
2026-01-29 18:40:55 -08:00
Andrew Kelley
9b415761dd std.os.windows: delete unused APIs
Intention is to go through std.Io for these things.
2026-01-30 03:39:46 +01:00
Andrew Kelley
18c6abc0ba std: finish moving os.windows.ReadLink logic to Io.Threaded
- remove error.SharingViolation from all error sets since it has the
  same meaning as FileBusy
- add error.FileBusy to CreateFileAtomicError and ReadLinkError
- update dirReadLinkWindows to use NtCreateFile and NtFsControlFile and
  integrate with cancelation properly.
- move windows CTL_CODE constants to the proper namespace
- delete os.windows.ReadLink
2026-01-28 17:02:17 -08:00
Andrew Kelley
5774248041 std.os.windows: delete unused CreateSymbolicLink 2026-01-28 15:33:04 -08:00
just_some_entity
06cf86abeb Fix BootServices.locateHandleLen() (#30877)
Fixes https://codeberg.org/ziglang/zig/issues/30876

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30877
Reviewed-by: linus <mail@linusgroh.de>
Co-authored-by: just_some_entity <entity@jsentity.dev>
Co-committed-by: just_some_entity <entity@jsentity.dev>
2026-01-27 23:09:51 +01:00
Andrew Kelley
3729a53eec Merge pull request 'libc: use common implementations for linux syscalls' (#30993) from GasInfinity/zig:libc-musl-syscalls into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30993
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-01-27 07:48:58 +01:00
jsentity
b4c86c850d Fix std.uefi.protocol.DevicePath.next() and add utility function isEnd() (#30887)
Fix for https://codeberg.org/ziglang/zig/issues/30884 and https://codeberg.org/ziglang/zig/issues/30885

Co-authored-by: jsentity <jsentity@noreply.codeberg.org>
Co-committed-by: jsentity <jsentity@noreply.codeberg.org>
2026-01-26 11:41:22 +01:00
GasInfinity
b430cd62e4
feat(std.os.linux): add some missing syscalls 2026-01-24 20:41:15 +01:00
Andrew Kelley
5c42193b17 std.Io.Threaded: rework cancelation
Now it can handle sync cancelation and alertable cancelation on Windows.

Also fix the API of NtCancelIoFileEx
2026-01-23 12:59:36 -08:00
Andrew Kelley
1badb2a840 std.Io.Threaded: dirCreateFileWindows uses NtCreateFile directly 2026-01-22 18:08:13 -08:00
brickmonster
8042096bca std.os.linux: add some missing syscalls 2026-01-20 18:30:45 +00:00
brickmonster
62ce228b37 std.os.linux: fix some compilation errors 2026-01-20 16:09:49 +00: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
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