5 mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
7 return poll (ufds, nfds, timeout);
12 mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
14 struct timeval tv, *tvptr;
15 int i, fd, events, affected, count;
16 fd_set rfds, wfds, efds;
23 tv.tv_sec = timeout / 1000;
24 tv.tv_usec = (timeout % 1000) * 1000;
32 for (i = 0; i < nfds; i++) {
39 if (nexc >= FD_SETSIZE) {
40 ufds [i].revents = MONO_POLLNVAL;
44 if (fd > FD_SETSIZE) {
45 ufds [i].revents = MONO_POLLNVAL;
50 events = ufds [i].events;
51 if ((events & MONO_POLLIN) != 0)
54 if ((events & MONO_POLLOUT) != 0)
64 affected = select (maxfd + 1, &rfds, &wfds, &efds, tvptr);
65 if (affected == -1) /* EBADF should be translated to POLLNVAL */
69 for (i = 0; i < nfds && affected > 0; i++) {
74 events = ufds [i].events;
75 if ((events & MONO_POLLIN) != 0 && FD_ISSET (fd, &rfds)) {
76 ufds [i].revents |= MONO_POLLIN;
80 if ((events & MONO_POLLOUT) != 0 && FD_ISSET (fd, &wfds)) {
81 ufds [i].revents |= MONO_POLLOUT;
85 if (FD_ISSET (fd, &efds)) {
86 ufds [i].revents |= MONO_POLLERR;
90 if (ufds [i].revents != 0)