8 mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
10 g_assert_not_reached ();
15 #if defined(HAVE_POLL) && !defined(__APPLE__)
17 mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
19 return poll (ufds, nfds, timeout);
24 mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
26 struct timeval tv, *tvptr;
27 int i, fd, events, affected, count;
28 fd_set rfds, wfds, efds;
35 tv.tv_sec = timeout / 1000;
36 tv.tv_usec = (timeout % 1000) * 1000;
44 for (i = 0; i < nfds; i++) {
51 if (nexc >= FD_SETSIZE) {
52 ufds [i].revents = MONO_POLLNVAL;
56 if (fd > FD_SETSIZE) {
57 ufds [i].revents = MONO_POLLNVAL;
62 events = ufds [i].events;
63 if ((events & MONO_POLLIN) != 0)
66 if ((events & MONO_POLLOUT) != 0)
76 affected = select (maxfd + 1, &rfds, &wfds, &efds, tvptr);
79 int error = WSAGetLastError ();
81 case WSAEFAULT: errno = EFAULT; break;
82 case WSAEINVAL: errno = EINVAL; break;
83 case WSAEINTR: errno = EINTR; break;
84 /* case WSAEINPROGRESS: errno = EINPROGRESS; break; */
85 case WSAEINPROGRESS: errno = EINTR; break;
86 case WSAENOTSOCK: errno = EBADF; break;
88 case WSAENETDOWN: errno = ENOSR; break;
98 for (i = 0; i < nfds && affected > 0; i++) {
103 events = ufds [i].events;
104 if ((events & MONO_POLLIN) != 0 && FD_ISSET (fd, &rfds)) {
105 ufds [i].revents |= MONO_POLLIN;
109 if ((events & MONO_POLLOUT) != 0 && FD_ISSET (fd, &wfds)) {
110 ufds [i].revents |= MONO_POLLOUT;
114 if (FD_ISSET (fd, &efds)) {
115 ufds [i].revents |= MONO_POLLERR;
119 if (ufds [i].revents != 0)
128 #endif /* #ifndef DISABLE_SOCKETS */