From: Roy Marples Date: Tue, 12 May 2015 19:55:45 +0000 (+0000) Subject: Add a pollts wrapper in eloop.c directly so it really should be stand alone X-Git-Tag: v6.9.0~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c3e0382cc619a4466cd3ddf2d25a07bd0a2029f;p=thirdparty%2Fdhcpcd.git Add a pollts wrapper in eloop.c directly so it really should be stand alone now! --- diff --git a/eloop.c b/eloop.c index 9b5a512a..5143c5f6 100644 --- a/eloop.c +++ b/eloop.c @@ -92,6 +92,36 @@ eloop_event_setup_fds(struct eloop *eloop) i++; } } + +/* Wrapper around pselect, to imitate the NetBSD pollts call. */ +static int +pollts(struct pollfd * fds, nfds_t nfds, + const struct timespec *ts, const sigset_t *sigmask) +{ + fd_set read_fds; + nfds_t n; + int maxfd, r; + + FD_ZERO(&read_fds); + maxfd = 0; + for (n = 0; n < nfds; n++) { + if (fds[n].events & POLLIN) { + FD_SET(fds[n].fd, &read_fds); + if (fds[n].fd > maxfd) + maxfd = fds[n].fd; + } + } + + r = pselect(maxfd + 1, &read_fds, NULL, NULL, ts, sigmask); + if (r > 0) { + for (n = 0; n < nfds; n++) { + fds[n].revents = + FD_ISSET(fds[n].fd, &read_fds) ? POLLIN : 0; + } + } + + return r; +} #endif int