Commit Graph

463 Commits

Author SHA1 Message Date
Andrew Kelley 5ccfeb9268 std.Io.net: add error.PortUnreachable to NetReceive
closes #31787
2026-04-08 22:58:22 +02:00
Ryan Liptak cf0f6dd17f Io.Threaded: Reduce dirRealPathFileWindows stack usage by 64KiB
This effectively reinstates the changes made in https://github.com/ziglang/zig/pull/23657 that were lost in the transition to std.Io
2026-04-08 14:30:28 +02:00
Jonathan Marler f4eecf8d7d handle EROFS in create/open file
I hit an unexpected errno 30 on macos attempting to call createFile on a
directory in PATH.  errno 30 is EROFS, this change propagates that error
as error.ReadOnlyFileSystem.
2026-04-02 15:05:31 +02:00
Jacob Young 0db75c0116 std.Io.Threaded: fix dns queries on windows
by working around various bugs in `DnsQueryEx`.

Closes #31659
2026-03-30 09:33:04 +02:00
Andrew Kelley 2d3694ab42 Merge pull request 'std.Io.Dir: add resolve_beneath flag and implement for freebsd,macos' (#31684) from resolve_beneath into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31684
2026-03-27 12:24:09 +01:00
GasInfinity 1f79a9e4e3 feat(Io.net): add allow_broadcast to BindOptions
* and implement it in `Threaded`, `Uring` and `Kqueue`
2026-03-27 09:43:57 +01:00
Andrew Kelley 2e4482cd14 std.Io.Dir: add resolve_beneath flag and implement for freebsd,macos 2026-03-27 01:23:04 -07:00
Andrew Kelley 6f467e436d std.Io: move File.CreateFlags to Dir.CreateFileOptions
for naming consistency.

same thing with File.OpenFlags -> Dir.OpenFileFlags
2026-03-27 01:23:04 -07:00
Jake Greenfield 4431ca28b8 fix Windows clock handling
Address two separate but related issues:
- Return value of `RtlQueryPerformanceFrequency` was used inconsistently; it
  returns a nonzero value to indicate success.
- `timeoutToWindowsInterval` wasn't converting absolute deadlines back to the
  Windows epoch before passing them to the system, which meant that values (in
  the Unix epoch) were always in the distant past, so sleeps would return
  immediately.

Fixes #31653
2026-03-24 21:33:27 -04:00
Alex Rønne Petersen 558a5c7913 std.c: audit some time types for non-Linux OSs
Some initial work towards https://codeberg.org/ziglang/zig/issues/31414.

Conclusion from this: Only x86-freebsd, x86-haiku, and x86-illumos remain time32
and are currently unfixable. I don't think the upstreams for any of these
targets actually care about them anymore (probably why they weren't migrated to
time64), so this is not a particularly big concern.

I split UTIME constants out from timespec because they were causing unreasonable
code duplication by being there.
2026-03-24 09:42:32 +01:00
Evgenii Orlov 0ee6a79da5 std.Io.net.HostName.netLookup: make canonical_name_buffer optional 2026-03-23 11:02:47 +01:00
Justus Klausecker 1f78e34de0 std.Io.Threaded: make mutexLock() use cmpxchgStrong instead of cmpxchgWeak
As established in 048e38624e and d70bd0b37e, mutexes should use a strong
cmpxchg when attempting to lock to guarantee that they actually succeed
if they aren't locked yet.

Also deletes an unused near-duplicate of `mutexLock()`.
2026-03-21 03:00:50 +01:00
eshom 5119cf6ffd std.Io.Threaded: syscall with O_TMPFILE flag can return OPNOTSUPP 2026-03-20 12:12:29 -07:00
Jacob Young 83c7aba127 windows: trigger automatic fetching of root certificates 2026-03-20 19:23:48 +01:00
Jacob Young 982f26bcdd netReceiveOneWindows: fix typo 2026-03-20 00:37:00 -04:00
Jacob Young 3c8b96df6d windows: use enums for boolean types 2026-03-20 02:25:16 +01:00
Jacob Young 9ac1386c10 std.Io.Threaded: windows networking without ws2_32 2026-03-18 20:13:59 -04:00
Matthew Lugg 64f1c27332 compiler,std: fix never-mutated local variables 2026-03-15 18:22:13 +00:00
Matthew Lugg 5d71e30518 std: remove another kernel32 dependency
We can directly access this path string from the PEB (albeit with some
weirdness around addressing) and that ends up making the downstream code
simpler and more efficient. (Almost like the kernel32 API isn't very
good!)
2026-03-13 20:56:00 +01:00
Andrew Kelley 9634e98357 std.Io.Threaded: fix missing calls to syscall.finish() 2026-03-12 15:41:00 -07:00
Andrew Kelley a50458777b std.Io.Threaded: NtTerminateProcess can return PROCESS_IS_TERMINATING 2026-03-12 15:40:59 -07:00
Andrew Kelley 8973c8a826 std.Io.Threaded.netWriteWindows: IO_PENDING is not unreachable 2026-03-12 15:40:59 -07:00
Andrew Kelley 3069917384 std.Io.Threaded: use AlertableSyscall for ws2_32 operations
closes #30865
2026-03-11 22:46:13 +01:00
Andrew Kelley 80625990d5 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-08 19:20:34 -07:00
Andrew Kelley 85ed81bb94 std.Io.Threaded: implement netReceive for Windows 2026-03-08 19:20:06 -07:00
Andrew Kelley 4cbf30c2a4 std.Io.Uring: implement net_receive operate
Batch implementation still TODO.
2026-03-08 19:20:06 -07:00
Andrew Kelley c2ebbd8911 std.Io.Threaded: implement net_receive for Windows 2026-03-08 19:20:06 -07:00
Andrew Kelley 8b69341271 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-08 19:20:06 -07:00
Andrew Kelley be0f188990 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-08 19:20:06 -07:00
Ryan Liptak 6be202f466 Io: Add processSetCurrentPath
The logic used to allow providing a path for setting the CWD of a child process in https://codeberg.org/ziglang/zig/pulls/31090 applies here as well:

- Windows must provide a path when setting the CWD, so the path of an `Io.Dir` must be resolved before actually calling RtlSetCurrentDirectory_U
- A directory handle may have multiple paths associated with it, so providing the CWD as a string retains a legitimate use case in cases where the precise path matters
2026-03-09 03:19:11 +01:00
breakmit 46658257f4 Io.Threaded.spawnPosix: implement passing file descriptors as stdio (#31379)
`std.process.spawn`: remove the TODO for nonblocking file stdio and document the behavior.

Fix a bug in Io.Uring.dup2 where the function does not return on success

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31379
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: breakmit <breakmit@noreply.codeberg.org>
Co-committed-by: breakmit <breakmit@noreply.codeberg.org>
2026-03-06 04:51:28 +01:00
xeondev 15f0af09d0 Io.Threaded.batchAwaitConcurrent: fix poll args 2026-03-05 20:17:21 +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
vitalii 1838134200 fix segfault when /etc/hosts missing last newline 2026-02-15 23:12:13 +01:00
Andrew Kelley d9fc7fa04d std.Io: remove select function
This function works with a slice of futures and returns the index of a
completed one. This doesn't work very well in practice because it's
either too high level or too low level.

At the lower level we have Io.Batch for doing this kind of thing at the
Operation API layer.

At the higher level we have Io.Select which is a convenience wrapper
around an Io.Group and an Io.Queue.
2026-02-14 18:31:48 -08:00
Andrew Kelley d2c862e6ff Merge pull request 'Io.Dispatch: introduce grand central dispatch io impl' (#31198) from dispatch into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31198
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-02-13 23:19:32 +01:00
hubidubi fd74c5742d std.Io.Threaded: fix FreeBSD Futex max_waiters (#30094)
On FreeBSD, the maximum waiters should be Cs INT_MAX instead of the maximum of a u32. Waiting for the Io.Event in the broadcast test triggers this bug.

Resolves #30715

Co-authored-by: Simon Galli <hubi@hubidubi.net>
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30094
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: hubidubi <hubidubi@noreply.codeberg.org>
Co-committed-by: hubidubi <hubidubi@noreply.codeberg.org>
2026-02-13 20:39:38 +01:00
Jacob Young 2fa1a78491 Io.Dispatch: introduce grand central dispatch io impl 2026-02-13 12:29:40 -05:00
Andrew Kelley b600b6e5e0 std.posix: remove close function 2026-02-11 23:37:31 +01:00
Jacob Young 7369008d8c Io.IoUring: implement some thread pool options and other cleanup 2026-02-10 23:45:48 +01:00
Jacob Young a28d57292f IoUring: update to new Io APIs 2026-02-09 10:47:21 -05:00
Jacob Young b5bd494606 std.Threaded: replace more kernel32 functions with ntdll 2026-02-07 00:02:50 -05:00
Andrew Kelley 76d275b20f std.Io.Threaded: flatten some switch cases 2026-02-05 16:30:33 -08:00
Jacob Young c77e7146f5 std.Threaded: replace console kernel32 functions with ntdll 2026-02-05 07:41:25 -05:00
Andrew Kelley 3078a3197b std.Io.Threaded.dirCreateDirWindows: remove unexpected error handling 2026-02-04 16:30:19 -08:00
Andrew Kelley 0e7d00776e std.Io.Threaded: inline OpenFile into dirCreateDirWindows 2026-02-04 16:30:19 -08: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
Andrew Kelley fcef9905ae Merge pull request 'std.Progress: implement inter-process progress reporting for windows' (#31113) from threaded-win-cleanup into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31113
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-02-05 01:24:18 +01:00
Jacob Young 71156aff80 std.Progress: implement ipc resource cleanup 2026-02-04 15:20:10 -05:00