a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * This file and its contents are supplied under the terms of the
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * Common Development and Distribution License ("CDDL"), version 1.0.
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * You may only use this file in accordance with the terms of version
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * 1.0 of the CDDL.
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * A full copy of the text of the CDDL should have accompanied this
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * source. A copy of the CDDL is also available via the Internet at
57a0264b71e479ed0dc19299607d662043907cb6Patrick Mooney * Copyright 2016 Joyent, Inc.
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * Events that match their epoll(7) equivalents.
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill#error value of EPOLLIN does not match value of POLLIN
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill#error value of EPOLLPRI does not match value of POLLPRI
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill#error value of EPOLLOUT does not match value of POLLOUT
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill#error value of EPOLLRDNORM does not match value of POLLRDNORM
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill#error value of EPOLLRDBAND does not match value of POLLRDBAND
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill#error value of EPOLLERR does not match value of POLLERR
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill#error value of EPOLLHUP does not match value of POLLHUP
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * Events that we ignore entirely. They can be set in events, but they will
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * never be returned.
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * Events that we swizzle into other bit positions.
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill (EPOLLRDHUP | EPOLLONESHOT | EPOLLET | EPOLLWRBAND | EPOLLWRNORM)
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * From the epoll_create() man page: "Since Linux 2.6.8, the size
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * argument is ignored, but must be greater than zero." You keep using
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * that word "ignored"...
a192d1c0eb1d05a03ead3c7f898e864e4bf0399cPatrick Mooney /* Reject unrecognized flags */
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrillepoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * In the modify case, we pass down two events: one to
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * remove the event and another to add it back.
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill /* FALLTHROUGH */
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * Mask off the events that we ignore, and then swizzle the
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * events for which our values differ from their epoll(7)
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill * equivalents.
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill ev = events & ~(EPOLLIGNORED | EPOLLSWIZZLED);
57a0264b71e479ed0dc19299607d662043907cb6Patrick Mooney res = write(epfd, epoll, sizeof (epoll[0]) * (i + 1));
57a0264b71e479ed0dc19299607d662043907cb6Patrick Mooney * Linux does not document EINTR as an allowed error
57a0264b71e479ed0dc19299607d662043907cb6Patrick Mooney * for epoll_ctl. The write must be retried if it is
57a0264b71e479ed0dc19299607d662043907cb6Patrick Mooney * not done automatically via SA_RESTART.
57a0264b71e479ed0dc19299607d662043907cb6Patrick Mooney * Convert the specific /dev/poll error about an fd
57a0264b71e479ed0dc19299607d662043907cb6Patrick Mooney * loop into what is expected from the Linux epoll
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrillepoll_wait(int epfd, struct epoll_event *events,
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrillepoll_pwait(int epfd, struct epoll_event *events,
a5eb7107f06a6e23e8e77e8d3a84c1ff90a73ac6Bryan Cantrill int maxevents, int timeout, const sigset_t *sigmask)