Commit graph

37029 commits

Author SHA1 Message Date
Andrew Kelley
4c4e9d054e std.Io: add RwLock and Semaphore sync primitives
and restore usage by std.debug.SelfInfo.Elf
2026-02-02 20:18:14 -08:00
Andrew Kelley
550da1b676 std: migrate remaining sync primitives to Io
- delete std.Thread.Futex
- delete std.Thread.Mutex
- delete std.Thread.Semaphore
- delete std.Thread.Condition
- delete std.Thread.RwLock
- delete std.once

std.Thread.Mutex.Recursive remains... for now. it will be replaced with
a special purpose mechanism used only by panic logic.

std.Io.Threaded exposes mutexLock and mutexUnlock for the advanced case
when you need to call them directly.
2026-02-02 18:57:17 -08:00
Andrew Kelley
255aeb57b2 std: introduce atomic.Mutex and use it in heap.SmpAllocator
This allocator implementation uses only lock-free operations.
2026-02-02 18:36:40 -08:00
Andrew Kelley
e9eadee006 Merge pull request 'std.Io.Threaded: sever dependency on std.Thread Mutex and Condition' (#31096) from severance into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31096
2026-02-03 03:30:42 +01:00
Andrew Kelley
5312063138 std.Io.Threaded: work around parking futex bug
This commit should be reverted - it's testing a hypothesis that Windows
is deadlocking due to bug in the implementation of
std.Io.Threaded.parking_futex
2026-02-02 14:25:27 -08:00
Andrew Kelley
eb74e23e7b std.Io.Threaded: sever dependency on std.Thread Mutex and Condition 2026-02-02 14:18:04 -08:00
Andrew Kelley
c2d4806d65 Merge pull request 'std.Thread: remove redundant sync APIs ResetEvent and WaitGroup' (#31088) from sync-cleanup-smaller into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31088
2026-02-02 23:14:05 +01: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
b71e593df4 Merge pull request 'Add process.Child.Cwd, use it for cwd and remove cwd_dir field' (#31090) from squeek502/zig:unify-child-cwd into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31090
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-02-02 19:56:40 +01:00
Andrew Kelley
633eb247ab std.Io.Event: fix single-threaded implementation 2026-02-02 10:44:50 -08:00
Ryan Liptak
05346e123b Add process.Child.Cwd, use it for cwd and remove cwd_dir field
The user must now explicitly choose between inheriting the current CWD, passing a path for the CWD, or passing a Dir for the CWD.
2026-02-02 01:41:35 -08:00
Tom Winter
83abd73801 Windows: Support directory handle for cwd instead of string for Child.process
This implementation is a bit of a hacky workaround, as we use a ntdll
API to grab the full path of the directory handle. As far as I can tell
this might be the only solution to the problem, as
kernel32.CreateProcessW takes a directory path as a string only.

I might be wrong though as haven't researched the problem thoroughly.
2026-02-02 01:21:11 -08:00
Andrew Kelley
b191e50be5 std.Thread: remove ResetEvent and WaitGroup
* std.Thread.ResetEvent -> Io.Event
* std.Thread.WaitGroup -> Io.Group
2026-02-02 00:09:48 -08:00
Andrew Kelley
60ac4e78eb std.Io.Mutex: fix tryLock
`@cmpxchgWeak` can return the expected value sometimes.
2026-02-02 00:09:48 -08:00
Jake Greenfield
aacf8ce03d Use MultiReader in zig std 2026-02-01 22:22:47 -05:00
Andrew Kelley
37d14a4f3b Merge pull request 'libzigc: cbrt, cbrtf' (#31078) from jeffective/zig:jeff/libzigc-cbrt into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31078
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-02-01 20:03:57 +01:00
Andrew Kelley
171459f678 Merge pull request 'libzigc: round, roundf' (#31075) from jeffective/zig:jeff/libzigc-round into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31075
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-02-01 20:02:06 +01:00
Andrew Kelley
59073484ba std.Io: add ioctl / DeviceIoControlFile API 2026-02-01 01:08:01 -08:00
Jeff Anderson
4aadb5e4a5 libzigc: cbrtf 2026-02-01 00:09:54 -08:00
Jeff Anderson
0aae9768aa libzigc: cbrt 2026-02-01 00:09:45 -08:00
Andrew Kelley
e5454ff780 Merge pull request 'std.Io: move fileWriteStreaming to Operation' (#31065) from more-poll into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31065
2026-02-01 07:56:09 +01:00
Andrew Kelley
cc442d24ab std.Io: move fileWriteStreaming to Operation
This serves as an example to contributors of how to move VTable
functions to becoming an Operation, thereby enabling Batch API and
timeouts.
2026-01-31 22:53:28 -08:00
Andrew Kelley
9bd648bd40 std.Io.Operation: support non-fallible results 2026-01-31 22:52:00 -08:00
Jeff Anderson
379d128cba libzigc: roundf 2026-01-31 18:18:29 -08:00
Andrew Kelley
3abc96a601 std.Io: add test for batchAwaitAsync
and make it always work for all targets including WASI

This function guarantees no additional failure modes introduced.
2026-02-01 02:49:36 +01:00
Jeff Anderson
69a95571ed libzigc: round 2026-01-31 17:26:17 -08:00
kj4tmp@gmail.com
e60ba21114 libzigc: roundl 2026-02-01 00:59:35 +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
Alex Rønne Petersen
da95409f31 Merge pull request 'llvm: handle packed structs in C ABI integer promotion' (#31062) from alexrp/zig:packed-struct-cconv-fix into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31062
2026-01-31 07:09:19 +01:00
Andrew Kelley
9646801bed std: fix Preopens compilation error 2026-01-30 22:06:33 -08:00
Andrew Kelley
14e1e5f6d8 std: IoUring test handles EINTR 2026-01-30 22:03:44 -08:00
Andrew Kelley
43866f7439 build.zig: bump max_rss
encountered error: memory usage peaked at 0.66GB (656060416 bytes),
exceeding the declared upper bound of 0.64GB (639565414 bytes)
2026-01-30 22:03:39 -08:00
Andrew Kelley
b6f4bb91c4 std.Io: add documentation to Batch 2026-01-30 22:03:33 -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
39a6d5d1c5 std.Io.File: add non-blocking flag
On Windows, we need to know ahead of time whether a file was opened in
synchronous mode or asynchronous mode. There may be advantages to
tracking this state for POSIX operating systems as well.
2026-01-30 22:03:14 -08:00
Andrew Kelley
62c97b745d std.Io.Threaded: stop checking bytes read with END_OF_FILE 2026-01-30 22:03:14 -08:00
Jacob Young
2674acdb77 Io.Batch: implement alternate API 2026-01-30 22:03:14 -08:00
Andrew Kelley
a520355e4c std.process: simplify RunError set 2026-01-30 22:03:14 -08:00
Andrew Kelley
a41ee5994d std.Build.Step: evalZigProcess handles EndOfStream
and a happy little info log when the process needs to be restarted
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
Matthew Lugg
f8828e543a std.Build: fully upgrade Step.Run to std.Io timing (and fix a typo) 2026-01-30 22:03:14 -08:00
Matthew Lugg
c2679feaaa std.Io.Threaded: fix ntdll timeouts on Windows 2026-01-30 22:03:14 -08:00
Andrew Kelley
8f8aa8346a std.Io.Threaded: ntReadFileResult handles EOF + bytes available 2026-01-30 22:03:14 -08:00
Andrew Kelley
4dd7fe90a2 std.Io.Threaded: compress ntReadFile logic
Just use the ntstatus field rather than an additional enum
2026-01-30 22:03:14 -08:00
Andrew Kelley
3320e6a1ae std.Io.Threaded.batchWait better fix for any_done
It is legal to call batchWait with already completed operations in the
ring. In such case, we need to avoid waiting in the syscall. The
any_done flag was a poor way of tracking state we already have: whether
the completion queue is empty.

This problem affects the posix poll implementation as well.

Thanks again to jacobly for finding the problem.
2026-01-30 22:03:14 -08:00
Andrew Kelley
d770e14e00 std.Io.Threaded.batchWaitWindows: eager result sets any_done true
Thanks jacobly for finding the bug
2026-01-30 22:03:14 -08:00
Andrew Kelley
7a13d57916 std.Io.Threaded: add missing check for pending status in batchCancel 2026-01-30 22:03:14 -08:00
Andrew Kelley
687123a85e std.process.run: use Io.File.MultiReader
and delete the special-cased function
2026-01-30 22:03:14 -08:00
Andrew Kelley
b2816f2698 build.zig: only-c implies no-lib 2026-01-30 22:03:14 -08:00