Commit graph

37274 commits

Author SHA1 Message Date
Andrew Kelley
ec74d650fe incr-check: update to std.Io.File.MultiReader
from std.Io.poll
2026-01-30 22:03:14 -08:00
Andrew Kelley
a901ea23b0 update doctest API usage 2026-01-30 22:03:14 -08:00
Andrew Kelley
15ca46d1e7 std.Io.Threaded: fix compilation error on some systems 2026-01-30 22:03:14 -08:00
Andrew Kelley
a4d438562d std.Io.Threaded: fix compilation failures on Windows
it's still broken as hell tho
2026-01-30 22:03:14 -08:00
Andrew Kelley
54241bc770 tools: update for std.process API changes 2026-01-30 22:03:14 -08:00
Andrew Kelley
9134430387 std.Io.Threaded: fix batchWait impl 2026-01-30 22:03:14 -08:00
Andrew Kelley
68a34df025 std.Io.Threaded: fix error set 2026-01-30 22:03:14 -08:00
Andrew Kelley
372e8e54d3 compiler: update for std.Io.File.MultiReader API 2026-01-30 22:03:14 -08:00
Andrew Kelley
dd0153b91b std.Io.operate: fix bogus catch
this used to have a different error set. just goes to show you how
useful switching on error set is even when there is only 1 prong
2026-01-30 22:03:14 -08:00
Andrew Kelley
e56563ce3f std.Io.File.MultiReader: implementation fixes 2026-01-30 22:03:14 -08:00
Andrew Kelley
12cfc96e1b std: update rest of build runner to new File.MultiReader API 2026-01-30 22:03:14 -08:00
Andrew Kelley
20cadd60aa std.Io.File: introduce MultiReader
Concurrently read from multiple file streams, eliminating risk of
deadlocking.
2026-01-30 22:03:14 -08:00
Andrew Kelley
a0c2645948 std.Io.Threaded: delete dead code 2026-01-30 22:03:14 -08:00
Andrew Kelley
78a1476475 Build.WebServer: update concurrency API usage 2026-01-30 22:03:14 -08:00
Jacob Young
8146ccfecc Io: add ring to Batch API 2026-01-30 22:03:14 -08:00
Andrew Kelley
0a379513af std.Io.Threaded: super broken Windows impl of batch
this is a cry for help
2026-01-30 22:03:14 -08:00
Andrew Kelley
23d25dbb9e std.process.Child.collectOutput: change back to other impl
this one avoids calling poll() more than necessary
2026-01-30 22:03:14 -08:00
Andrew Kelley
642f329ac9 std.Io: exploring a different batch API proposal 2026-01-30 22:03:14 -08:00
Andrew Kelley
e2a266e744 Revert "std.process.Child: rewrite using concurrent"
This reverts commit 76e1ba8f490812c6e2ebf6f6becd89a71275d21e.
2026-01-30 22:03:13 -08:00
Andrew Kelley
87408f8add std.process.Child: rewrite using concurrent
I plan to immediately revert this, but here's a commit for posterity
2026-01-30 22:03:13 -08:00
Andrew Kelley
b996675dcf fix error set 2026-01-30 22:03:13 -08:00
Andrew Kelley
e0d06b40e3 std.Io.Threaded: set poll_buffer_len to 32
reasoning is that polling with large amount of operations will be rarely
done with std.Io.Threaded. However this still provides the opportunity
to provide concurrency for any real world use cases that need it.
2026-01-30 22:03:13 -08:00
Andrew Kelley
6a7fe61d74 std.Io.Threaded.operate: handle poll buffer exceeded 2026-01-30 22:03:13 -08:00
Andrew Kelley
93f5c99149 std.Io.Threaded.operate: handle cancelation and poll errors 2026-01-30 22:03:13 -08:00
Andrew Kelley
05064e1281 std.Io: simplify operate function
- no timeout
- no n_wait
- infallible
2026-01-30 22:03:13 -08:00
Andrew Kelley
0a0ecc4fb1 std.Io: proof-of-concept "operations" API
This commit shows a proof-of-concept direction for std.Io.VTable to go,
which is to have general support for batching, timeouts, and
non-blocking.

I'm not sure if this is a good idea or not so I'm putting it up for
scrutiny.

This commit introduces `std.Io.operate`, `std.Io.Operation`, and
implements it experimentally for `FileReadStreaming`.

In `std.Io.Threaded`, the implementation is based on poll().

This commit shows how it can be used in `std.process.run` to collect
both stdout and stderr in a single-threaded program using
`std.Threaded.Io`.

It also demonstrates how to upgrade code that was previously using
`std.Io.poll` (*not* integrated with the interface!) using concurrency.
This may not be ideal since it makes the build runner no longer support
single-threaded mode. There is still a needed abstraction for
conveniently reading multiple File streams concurrently without
io.concurrent, but this commit demonstrates that such an API can be
built on top of the new `std.Io.operate` functionality.
2026-01-30 22:03:13 -08:00
Andrew Kelley
bd4b6d8b14 std.Io: delete the poll API 2026-01-30 22:03:13 -08:00
Jacob Young
90890fcb5c Io.Threaded: fix UAF-induced crashes during asynchronous operations
When `NtReadFile` returns `SUCCESS`, the APC routine still runs when
next alertable, which was previously clobbering an out of scope `done`.
Instead of adding an extra syscall to the success path, avoid all APC
side effects, allowing instant completions to return immediately.
2026-01-30 22:03:13 -08:00
Andrew Kelley
9862518797 std.Io.Threaded: fix NtDelayExecution delay interval 2026-01-30 22:03:13 -08:00
Andrew Kelley
11b0a504df std.Io.Threaded: handle some more error codes from NtReadFile 2026-01-30 22:03:13 -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
1e3072ec46 std.Io.Threaded: introduce Thread.InterruptMethod
implements APC cancelation except for the actual call to NtCancelIoFileEx
2026-01-30 22:03:13 -08:00
Andrew Kelley
5580257596 std.Io.Threaded: add some temporary, choice panics 2026-01-30 22:03:13 -08:00
Andrew Kelley
8827488fcd std: back out the flags field of Io.File
For now, let us refrain from putting the sync mode into the Io.File
struct, and document that to do concurrent batch operations, any Windows
file handles must be in asynchronous mode. The consequences for
violating this requirement is neither illegal behavior, nor an error,
but that concurrency is lost. In other words, deadlock might occur. This
prevents the addition of flags field.

partial revert of 2faf14200f58ee72ec3a13e894d765f59e6483a9
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
Justus Klausecker
c7c4e8d802 Sema: harden switch logic against undef IB
Most places where `undefined` was previously (intentionally) passed across
function calls now use `Air.Inst.Ref.none` instead to ensure that these
`undefined` references don't accidentally outlive the `switch` logic they
belong to.
2026-01-31 06:36:07 +01: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
Alex Rønne Petersen
cbe38f771c
std.Io.Threaded: consider EOPNOTSUPP to be programmer error in createFileMap()
Not doing so was hiding bugs (e.g. on s390x-linux).
2026-01-31 00:08:34 +01:00
Alex Rønne Petersen
c6538b70f5
llvm: handle packed structs in C ABI integer promotion 2026-01-31 00:08:32 +01:00
mercenary
fa988e88ed zstd.Decompress: smarter rebase when discarding (#30891)
The call to `rebase` in `discardIndirect` and `discardDirect` was inappropriate. As `rebase` expects the `capacity` parameter to exclude the sliding window, this call was asking for ANOTHER `d.window_len` bytes. This was impossible to fulfill with a buffer smaller than 2*`d.window_len`, and caused [#25764](https://github.com/ziglang/zig/issues/25764).

This PR adds a basic test to do a discard (which does trigger [#25764](https://github.com/ziglang/zig/issues/25764)), and rebases only as much as is required to make the discard succeed ([or no rebase at all](https://github.com/ziglang/zig/issues/25764#issuecomment-3484716253)). That means: ideally rebase to fit `limit`, or if the buffer is too small, as much as possible.

I must say, `discardDirect` does not make much sense to me, but I replaced it anyway. `rebaseForDiscard` works fine with `d.reader.buffer.len == 0`. Let me know if anything should be changed.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30891
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: mercenary <mercenary@noreply.codeberg.org>
Co-committed-by: mercenary <mercenary@noreply.codeberg.org>
2026-01-30 20:19:19 +01:00
Andrew Kelley
aa38f07c51 Merge pull request 'add std.Io.net.Socket.createPair + handful of std.posix removals' (#31056) from std.posix-removals into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31056
2026-01-30 14:30:25 +01:00
Andrew Kelley
6a3226c43c std.Io: add net.Socket.createPair
and remove the following from std.posix:
- socketpair
- fcntl
2026-01-30 02:07:26 -08:00
Andrew Kelley
0c67d9ebde std.posix: goodbye gettimeofday 2026-01-30 01:58:49 -08:00
Andrew Kelley
36eb8dec98 std.posix: goodbye to some functions
- fstat
- inotify_init1
- inotify_add_watch, inotify_add_watchZ
- inotify_rm_watch
- sysctlbynameZ
2026-01-30 01:58:49 -08:00
Andrew Kelley
e7e168727e std.posix: goodbye connect, eventfd 2026-01-30 01:58:49 -08:00
rpkak
b9819fce69 Io.Threaded: limit copy_file_range len to prevent EOVERFLOW 2026-01-30 08:19:50 +01:00
Andrew Kelley
380ea6fb5e Merge pull request 'Compilation: make libzigc share zcu if possible' (#31037) from GasInfinity/zig:libc-share-zcu into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31037
2026-01-30 08:16:39 +01:00
Andrew Kelley
377bb8f237 Merge pull request 'std: migrate getcwd to Io' (#31047) from getcwd into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31047
2026-01-30 06:38:08 +01:00