From 1b43f27a91cfa2722e256f561b7e08f163913933 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 7 Jan 2026 14:43:37 -0800 Subject: [PATCH] std.posix: delete epoll APIs see #6600 --- lib/std/posix.zig | 88 ----------------------------------------------- 1 file changed, 88 deletions(-) diff --git a/lib/std/posix.zig b/lib/std/posix.zig index 20613b7c1d366afa1e56e60011b00ffccdfb78a2..ce6e6de15a4c82345f3a4bce99843a2b1c7228e2 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -677,94 +677,6 @@ fn setSockFlags(sock: socket_t, flags: u32) !void { } } -pub const EpollCreateError = error{ - /// The per-user limit on the number of epoll instances imposed by - /// /proc/sys/fs/epoll/max_user_instances was encountered. See epoll(7) for further - /// details. - /// Or, The per-process limit on the number of open file descriptors has been reached. - ProcessFdQuotaExceeded, - - /// The system-wide limit on the total number of open files has been reached. - SystemFdQuotaExceeded, - - /// There was insufficient memory to create the kernel object. - SystemResources, -} || UnexpectedError; - -pub fn epoll_create1(flags: u32) EpollCreateError!i32 { - const rc = system.epoll_create1(flags); - switch (errno(rc)) { - .SUCCESS => return @intCast(rc), - else => |err| return unexpectedErrno(err), - - .INVAL => unreachable, - .MFILE => return error.ProcessFdQuotaExceeded, - .NFILE => return error.SystemFdQuotaExceeded, - .NOMEM => return error.SystemResources, - } -} - -pub const EpollCtlError = error{ - /// op was EPOLL_CTL_ADD, and the supplied file descriptor fd is already registered - /// with this epoll instance. - FileDescriptorAlreadyPresentInSet, - - /// fd refers to an epoll instance and this EPOLL_CTL_ADD operation would result in a - /// circular loop of epoll instances monitoring one another. - OperationCausesCircularLoop, - - /// op was EPOLL_CTL_MOD or EPOLL_CTL_DEL, and fd is not registered with this epoll - /// instance. - FileDescriptorNotRegistered, - - /// There was insufficient memory to handle the requested op control operation. - SystemResources, - - /// The limit imposed by /proc/sys/fs/epoll/max_user_watches was encountered while - /// trying to register (EPOLL_CTL_ADD) a new file descriptor on an epoll instance. - /// See epoll(7) for further details. - UserResourceLimitReached, - - /// The target file fd does not support epoll. This error can occur if fd refers to, - /// for example, a regular file or a directory. - FileDescriptorIncompatibleWithEpoll, -} || UnexpectedError; - -pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*system.epoll_event) EpollCtlError!void { - const rc = system.epoll_ctl(epfd, op, fd, event); - switch (errno(rc)) { - .SUCCESS => return, - else => |err| return unexpectedErrno(err), - - .BADF => unreachable, // always a race condition if this happens - .EXIST => return error.FileDescriptorAlreadyPresentInSet, - .INVAL => unreachable, - .LOOP => return error.OperationCausesCircularLoop, - .NOENT => return error.FileDescriptorNotRegistered, - .NOMEM => return error.SystemResources, - .NOSPC => return error.UserResourceLimitReached, - .PERM => return error.FileDescriptorIncompatibleWithEpoll, - } -} - -/// Waits for an I/O event on an epoll file descriptor. -/// Returns the number of file descriptors ready for the requested I/O, -/// or zero if no file descriptor became ready during the requested timeout milliseconds. -pub fn epoll_wait(epfd: i32, events: []system.epoll_event, timeout: i32) usize { - while (true) { - // TODO get rid of the @intCast - const rc = system.epoll_wait(epfd, events.ptr, @intCast(events.len), timeout); - switch (errno(rc)) { - .SUCCESS => return @intCast(rc), - .INTR => continue, - .BADF => unreachable, - .FAULT => unreachable, - .INVAL => unreachable, - else => unreachable, - } - } -} - pub const EventFdError = error{ SystemResources, ProcessFdQuotaExceeded, -- 2.54.0