authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-07 14:43:37-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-07 17:33:07-08:00
log1b43f27a91cfa2722e256f561b7e08f163913933
treec916cbfe0ed859c10eeb80ba55912377d6d1ed1e
parent55ad03e261712c99d6318b6021cc21304d38ae6b

std.posix: delete epoll APIs

see #6600

1 files changed, 0 insertions(+), 88 deletions(-)

lib/std/posix.zig-88
...@@ -677,94 +677,6 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {...@@ -677,94 +677,6 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {
677 }677 }
678}678}
679679
680pub const EpollCreateError = error{
681 /// The per-user limit on the number of epoll instances imposed by
682 /// /proc/sys/fs/epoll/max_user_instances was encountered. See epoll(7) for further
683 /// details.
684 /// Or, The per-process limit on the number of open file descriptors has been reached.
685 ProcessFdQuotaExceeded,
686
687 /// The system-wide limit on the total number of open files has been reached.
688 SystemFdQuotaExceeded,
689
690 /// There was insufficient memory to create the kernel object.
691 SystemResources,
692} || UnexpectedError;
693
694pub fn epoll_create1(flags: u32) EpollCreateError!i32 {
695 const rc = system.epoll_create1(flags);
696 switch (errno(rc)) {
697 .SUCCESS => return @intCast(rc),
698 else => |err| return unexpectedErrno(err),
699
700 .INVAL => unreachable,
701 .MFILE => return error.ProcessFdQuotaExceeded,
702 .NFILE => return error.SystemFdQuotaExceeded,
703 .NOMEM => return error.SystemResources,
704 }
705}
706
707pub const EpollCtlError = error{
708 /// op was EPOLL_CTL_ADD, and the supplied file descriptor fd is already registered
709 /// with this epoll instance.
710 FileDescriptorAlreadyPresentInSet,
711
712 /// fd refers to an epoll instance and this EPOLL_CTL_ADD operation would result in a
713 /// circular loop of epoll instances monitoring one another.
714 OperationCausesCircularLoop,
715
716 /// op was EPOLL_CTL_MOD or EPOLL_CTL_DEL, and fd is not registered with this epoll
717 /// instance.
718 FileDescriptorNotRegistered,
719
720 /// There was insufficient memory to handle the requested op control operation.
721 SystemResources,
722
723 /// The limit imposed by /proc/sys/fs/epoll/max_user_watches was encountered while
724 /// trying to register (EPOLL_CTL_ADD) a new file descriptor on an epoll instance.
725 /// See epoll(7) for further details.
726 UserResourceLimitReached,
727
728 /// The target file fd does not support epoll. This error can occur if fd refers to,
729 /// for example, a regular file or a directory.
730 FileDescriptorIncompatibleWithEpoll,
731} || UnexpectedError;
732
733pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*system.epoll_event) EpollCtlError!void {
734 const rc = system.epoll_ctl(epfd, op, fd, event);
735 switch (errno(rc)) {
736 .SUCCESS => return,
737 else => |err| return unexpectedErrno(err),
738
739 .BADF => unreachable, // always a race condition if this happens
740 .EXIST => return error.FileDescriptorAlreadyPresentInSet,
741 .INVAL => unreachable,
742 .LOOP => return error.OperationCausesCircularLoop,
743 .NOENT => return error.FileDescriptorNotRegistered,
744 .NOMEM => return error.SystemResources,
745 .NOSPC => return error.UserResourceLimitReached,
746 .PERM => return error.FileDescriptorIncompatibleWithEpoll,
747 }
748}
749
750/// Waits for an I/O event on an epoll file descriptor.
751/// Returns the number of file descriptors ready for the requested I/O,
752/// or zero if no file descriptor became ready during the requested timeout milliseconds.
753pub fn epoll_wait(epfd: i32, events: []system.epoll_event, timeout: i32) usize {
754 while (true) {
755 // TODO get rid of the @intCast
756 const rc = system.epoll_wait(epfd, events.ptr, @intCast(events.len), timeout);
757 switch (errno(rc)) {
758 .SUCCESS => return @intCast(rc),
759 .INTR => continue,
760 .BADF => unreachable,
761 .FAULT => unreachable,
762 .INVAL => unreachable,
763 else => unreachable,
764 }
765 }
766}
767
768pub const EventFdError = error{680pub const EventFdError = error{
769 SystemResources,681 SystemResources,
770 ProcessFdQuotaExceeded,682 ProcessFdQuotaExceeded,