11#define POLL_CAN_READ (POLLIN | POLLRDNORM)
12#define POLL_CAN_WRITE (POLLOUT | POLLWRNORM | POLLWRBAND)
13#define POLL_HAS_EXCP (POLLRDBAND | POLLPRI)
15#define POLL_EVENTS_MASK (POLL_CAN_READ | POLL_CAN_WRITE | POLL_HAS_EXCP)
17int poll(
struct pollfd *fds,
unsigned long nfds,
int timeout)
31 for (i = 0; (
unsigned long)i < nfds; i++) {
32 int events = fds[i].events;
37 if ((fd < 0) || (FD_ISSET(fd, &ifd)))
43 if (events & POLL_CAN_READ)
46 if (events & POLL_CAN_WRITE)
49 if (events & POLL_HAS_EXCP)
54 timebuf.tv_sec = timeout / 1000;
55 timebuf.tv_usec = (timeout % 1000) * 1000;
59 err = lwip_select(n + 1, &rfd, &wfd, &efd, tbuf);
66 for (i = 0; (
unsigned long)i < nfds; i++) {
67 int revents = (fds[i].events & POLL_EVENTS_MASK);
73 if (FD_ISSET(fd, &ifd))
76 if (!FD_ISSET(fd, &rfd))
77 revents &= ~POLL_CAN_READ;
79 if (!FD_ISSET(fd, &wfd))
80 revents &= ~POLL_CAN_WRITE;
82 if (!FD_ISSET(fd, &efd))
83 revents &= ~POLL_HAS_EXCP;
86 if ((fds[i].revents = revents) != 0)
u32 count
start sector of fragmented bd/file