mirror of
https://github.com/ziglang/zig.git
synced 2025-12-21 21:53:08 +00:00
fix: Use std.os.windows.poll rather than libc
This commit is contained in:
parent
9363e995fc
commit
f58ee387c7
@ -6479,22 +6479,21 @@ pub const PollError = error{
|
|||||||
} || UnexpectedError;
|
} || UnexpectedError;
|
||||||
|
|
||||||
pub fn poll(fds: []pollfd, timeout: i32) PollError!usize {
|
pub fn poll(fds: []pollfd, timeout: i32) PollError!usize {
|
||||||
while (true) {
|
|
||||||
const fds_count = cast(nfds_t, fds.len) orelse return error.SystemResources;
|
|
||||||
const rc = system.poll(fds.ptr, fds_count, timeout);
|
|
||||||
if (native_os == .windows) {
|
if (native_os == .windows) {
|
||||||
if (rc == windows.ws2_32.SOCKET_ERROR) {
|
switch (windows.poll(fds.ptr, @intCast(fds.len), timeout)) {
|
||||||
switch (windows.ws2_32.WSAGetLastError()) {
|
windows.ws2_32.SOCKET_ERROR => switch (windows.ws2_32.WSAGetLastError()) {
|
||||||
.WSANOTINITIALISED => unreachable,
|
.WSANOTINITIALISED => unreachable,
|
||||||
.WSAENETDOWN => return error.NetworkSubsystemFailed,
|
.WSAENETDOWN => return error.NetworkSubsystemFailed,
|
||||||
.WSAENOBUFS => return error.SystemResources,
|
.WSAENOBUFS => return error.SystemResources,
|
||||||
// TODO: handle more errors
|
// TODO: handle more errors
|
||||||
else => |err| return windows.unexpectedWSAError(err),
|
else => |err| return windows.unexpectedWSAError(err),
|
||||||
|
},
|
||||||
|
else => |rc| return @intCast(rc),
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return @intCast(rc);
|
|
||||||
}
|
}
|
||||||
} else {
|
while (true) {
|
||||||
|
const fds_count = cast(nfds_t, fds.len) orelse return error.SystemResources;
|
||||||
|
const rc = system.poll(fds.ptr, fds_count, timeout);
|
||||||
switch (errno(rc)) {
|
switch (errno(rc)) {
|
||||||
.SUCCESS => return @intCast(rc),
|
.SUCCESS => return @intCast(rc),
|
||||||
.FAULT => unreachable,
|
.FAULT => unreachable,
|
||||||
@ -6505,7 +6504,6 @@ pub fn poll(fds: []pollfd, timeout: i32) PollError!usize {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
unreachable;
|
unreachable;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const PPollError = error{
|
pub const PPollError = error{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user