35218 Commits

Author SHA1 Message Date
Lukas Lalinsky
2b5306a94b Add missing clobbers to context switching
This only shows in release mode, the compiler tries to preserve some
value in rdi, but that gets replaced inside the fiber. This would not
happen in the C calling convention, but in these normal Zig functions,
it can happen.
2025-10-09 00:45:49 -07:00
Andrew Kelley
88693a56fc std.Io.net.HostName: implement DNS name expansion 2025-10-02 20:45:16 -07:00
Andrew Kelley
b08f1d0e2a std.Io.net.HostName: implement DNS reply parsing 2025-10-02 19:57:23 -07:00
Andrew Kelley
a5d8dcc025 std.Io.Threaded.netReceive: recvmsg first, then poll
Calling recvmsg first means no poll syscall needed when messages are
already in the operating system queue. Empirically, this happens when
repeating a DNS query that has been already been made recently. In such
case, poll() is never called!
2025-10-02 18:21:24 -07:00
Andrew Kelley
8d03ec6766 std.Io.net: implement receiving connectionless messages 2025-10-02 16:30:59 -07:00
Andrew Kelley
062d17ccab std: fix msghdr and cmsghdr when using musl libc
glibc and linux kernel use size_t for some field lengths while POSIX and
musl use int. This bug would have caused breakage the first time someone
tried to call sendmsg on a 64-bit big endian system when linking musl
libc.

my opinion:
* msghdr.iovlen: kernel and glibc have it right. This field should
  definitely be size_t. With int, the padding bytes are wasted for no
  reason.
* msghdr.controllen: POSIX and musl have it right. 4 bytes is plenty for
  the length, and it saves 4 bytes next to flags.
* cmsghdr.len: POSIX and musl have it right. 4 bytes is plenty for the
  length, and it saves 4 bytes since the other fields are also 32-bits
  each.
2025-10-02 16:30:59 -07:00
Andrew Kelley
96cf75977b std.Io: implement netSend 2025-10-02 16:30:59 -07:00
Andrew Kelley
29d4de53d6 std.os.linux: remove unnecessary warnings from sendmmsg
The one about INT_MAX is self-evident from the type system.

The one about kernel having bad types doesn't seem accurate as I checked
the source code and it uses size_t for all the appropriate types,
matching the libc struct definition for msghdr and msghdr_const.
2025-10-02 16:30:59 -07:00
Andrew Kelley
9354036dc2 std.os.linux: remove sendmmsg workaround
This "fix" is too opinionated to belong here. Better instead to
document the pitfalls.
2025-10-02 16:30:59 -07:00
Andrew Kelley
47f18ee6a0 std.Io.net: make netSend support multiple messages
this lowers to sendmmsg on linux, and means Io.Group is no longer
needed, resulting in a more efficient implementation.
2025-10-02 16:30:59 -07:00
Andrew Kelley
46e5068e48 std.Io.net.HostName: finish implementing DNS lookup 2025-10-02 16:30:59 -07:00
Andrew Kelley
a37c0bca22 std.Io.Threaded: implement Group.cancel 2025-10-02 16:30:59 -07:00
Andrew Kelley
3c9fdf810f std.Io: implement Group API 2025-10-02 16:30:59 -07:00
Andrew Kelley
d37d795cba std.Thread.ResetEvent: make it more reusable 2025-10-02 16:30:59 -07:00
Andrew Kelley
96dc44b5ea std.Io: rename asyncConcurrent to concurrent 2025-10-02 16:30:59 -07:00
Andrew Kelley
79b807bf1c Io.net: implement more networking
the next task is now implementing Io.Group
2025-10-02 16:30:59 -07:00
Andrew Kelley
3e8cc9c496 std.Io.net: progress towards DNS resolution 2025-10-02 16:30:59 -07:00
Andrew Kelley
3e828b02bd std.net: fix parsing IPv6 addr "::" 2025-10-02 16:30:59 -07:00
Andrew Kelley
0806252a9b Io.net: finish implementing IPv6 parsing 2025-10-02 16:30:59 -07:00
Andrew Kelley
888bf35ab0 Io.net: use resolve for IPv6
/etc/resolv.conf might have IPv6 addresses with scope in it, so this is
needed.
2025-10-02 16:30:59 -07:00
Andrew Kelley
dac7ae1e43 Io.net: rework IPv6 parsing and printing
extract pure functional logic into pure functions and then layer the
scope crap on top properly

the formatting code incorrectly didn't do the reverse operation
(if_indextoname). fix that with some TODO panics
2025-10-02 16:30:59 -07:00
Andrew Kelley
0f2427c5d2 std.Io: rename ThreadPool to Threaded 2025-10-02 16:30:59 -07:00
Andrew Kelley
43eea7beec std.Io: extract Dir to separate file 2025-10-02 16:30:59 -07:00
Andrew Kelley
e34bb9a413 Io.net: partial implementation of dns lookup 2025-10-02 16:30:59 -07:00
Andrew Kelley
4e887625d4 Io.net: implement sortLookupResults 2025-10-02 16:30:59 -07:00
Andrew Kelley
676f1b492e std: start moving fs.File to Io 2025-10-02 16:30:59 -07:00
Andrew Kelley
bdf463bee2 std.Io.net: partially implement HostName.lookup 2025-10-02 16:30:59 -07:00
Andrew Kelley
07cc4077fb add some networking 2025-10-02 16:30:59 -07:00
Andrew Kelley
f680c095bd add std.testing.io 2025-10-02 16:30:59 -07:00
Andrew Kelley
2746239fd3 std.Io: delete asyncParallel 2025-10-02 16:30:59 -07:00
Andrew Kelley
25b2954c0c std.Io: fix error handling and asyncParallel docs 2025-10-02 16:30:59 -07:00
Andrew Kelley
9fd1ecb348 std.Io: add asyncConcurrent and asyncParallel 2025-10-02 16:30:59 -07:00
Andrew Kelley
ba51b392e6 std.Io.EventLoop: add aarch64 support 2025-10-02 16:30:59 -07:00
Andrew Kelley
f0499abd88 std.Io.ThreadPool: fix asyncDetached 2025-10-02 16:30:59 -07:00
Andrew Kelley
806214797a std.Io: rename go to asyncDetached
it's a better name because it's more descriptive, not a reference, and
hints that it is less common than async
2025-10-02 16:30:59 -07:00
Andrew Kelley
9a62dc4d89 revert std.Thread.Pool for now
and move the Io impl to a separate file
2025-10-02 16:30:59 -07:00
Andrew Kelley
fdd59f0fa7 update to sync with master 2025-10-02 16:30:59 -07:00
Andrew Kelley
0c0ea7844e Io: update for new linked list API 2025-10-02 16:30:59 -07:00
Andrew Kelley
61c38d77c6 std.Io: remove @ptrCast workarounds
thanks to d53cc5e5b2ac51793ea19a847d8cee409af1dee3
2025-10-02 16:30:59 -07:00
Andrew Kelley
0c1e102e97 std.Io.EventLoop: implement select 2025-10-02 16:30:59 -07:00
Andrew Kelley
b4fb7df140 Io.EventLoop: select stub 2025-10-02 16:30:59 -07:00
Andrew Kelley
4a3ef0f779 introduce Io.select and implement it in thread pool 2025-10-02 16:30:59 -07:00
Jacob Young
6ba65ca972 Io.Condition: implement full API 2025-10-02 16:30:59 -07:00
Jacob Young
b174777437 EventLoop: implement detached fibers 2025-10-02 16:30:59 -07:00
Andrew Kelley
5c4ddb8d35 EventLoop: let the allocator do its job
to bucket and free fiber allocations
2025-10-02 16:30:59 -07:00
Jacob Young
c8950b5dd5 EventLoop: fix std.Io.Condition implementation
1. a fiber can't put itself on a queue that allows it to be rescheduled
 2. allow the idle fiber to unlock a mutex held by another fiber by
    ignoring reschedule requests originating from the idle fiber
2025-10-02 16:30:59 -07:00
Jacob Young
5952fc2c73 EventLoop: revert incorrect optimization 2025-10-02 16:30:59 -07:00
Andrew Kelley
34e85db4a2 EventLoop: remove broken mechanism for making deinit block on detached 2025-10-02 16:30:59 -07:00
Andrew Kelley
e5b2df0c9b std.Io.Condition: change primitive to support only one
and no timer
2025-10-02 16:30:59 -07:00
Andrew Kelley
63b3a3d11c EventLoop: take DetachedClosure into account when allocating 2025-10-02 16:30:59 -07:00