authorgravatar for 117967760+mochalins@users.noreply.github.commochalins <117967760+mochalins@users.noreply.github.com> 2024-06-23 14:23:53+09:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-07-10 01:35:01-04:00
logf58ee387c7c9a512d802f819f870190c900cb6e2
tree92c67da89fac5471818637ed98a9133698fbc1b2
parent9363e995fcf49a9496523c857fa925539fc7c2d6

fix: Use `std.os.windows.poll` rather than `libc`


1 files changed, 20 insertions(+), 22 deletions(-)

lib/std/posix.zig+20-22
......@@ -6479,33 +6479,31 @@ pub const PollError = error{
64796479} || UnexpectedError;
64806480
64816481pub fn poll(fds: []pollfd, timeout: i32) PollError!usize {
6482 if (native_os == .windows) {
6483 switch (windows.poll(fds.ptr, @intCast(fds.len), timeout)) {
6484 windows.ws2_32.SOCKET_ERROR => switch (windows.ws2_32.WSAGetLastError()) {
6485 .WSANOTINITIALISED => unreachable,
6486 .WSAENETDOWN => return error.NetworkSubsystemFailed,
6487 .WSAENOBUFS => return error.SystemResources,
6488 // TODO: handle more errors
6489 else => |err| return windows.unexpectedWSAError(err),
6490 },
6491 else => |rc| return @intCast(rc),
6492 }
6493 }
64826494 while (true) {
64836495 const fds_count = cast(nfds_t, fds.len) orelse return error.SystemResources;
64846496 const rc = system.poll(fds.ptr, fds_count, timeout);
6485 if (native_os == .windows) {
6486 if (rc == windows.ws2_32.SOCKET_ERROR) {
6487 switch (windows.ws2_32.WSAGetLastError()) {
6488 .WSANOTINITIALISED => unreachable,
6489 .WSAENETDOWN => return error.NetworkSubsystemFailed,
6490 .WSAENOBUFS => return error.SystemResources,
6491 // TODO: handle more errors
6492 else => |err| return windows.unexpectedWSAError(err),
6493 }
6494 } else {
6495 return @intCast(rc);
6496 }
6497 } else {
6498 switch (errno(rc)) {
6499 .SUCCESS => return @intCast(rc),
6500 .FAULT => unreachable,
6501 .INTR => continue,
6502 .INVAL => unreachable,
6503 .NOMEM => return error.SystemResources,
6504 else => |err| return unexpectedErrno(err),
6505 }
6497 switch (errno(rc)) {
6498 .SUCCESS => return @intCast(rc),
6499 .FAULT => unreachable,
6500 .INTR => continue,
6501 .INVAL => unreachable,
6502 .NOMEM => return error.SystemResources,
6503 else => |err| return unexpectedErrno(err),
65066504 }
6507 unreachable;
65086505 }
6506 unreachable;
65096507}
65106508
65116509pub const PPollError = error{