6
int iopoll(iopoll_fd* fds, unsigned nfds, unsigned long timeout)
20
for (fdmax = 0, i = 0, io = fds; i < nfds; ++i, ++io) {
23
if (fd > fdmax) fdmax = fd + 1;
24
if (io->events & IOPOLL_READ) FD_SET(fd, &rfds);
25
if (io->events & IOPOLL_WRITE) FD_SET(fd, &wfds);
28
tv.tv_sec = timeout / 1000;
29
tv.tv_usec = (timeout % 1000) * 1000;
31
if ((r = select(fdmax, &rfds, &wfds, (fd_set*)0, &tv)) <= 0) return r;
33
for (i = 0, io = fds; i < nfds; ++i, ++io) {
36
if ((io->events & IOPOLL_READ) && FD_ISSET(fd, &rfds))
37
io->revents |= IOPOLL_READ;
38
if ((io->events & IOPOLL_WRITE) && FD_ISSET(fd, &wfds))
39
io->revents |= IOPOLL_WRITE;