11 #ifdef DISABLE_SOCKETS
15 mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
17 g_assert_not_reached ();
22 #if defined(HAVE_POLL) && !defined(__APPLE__)
24 mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
26 return poll (ufds, nfds, timeout);
31 mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
33 struct timeval tv, *tvptr;
34 int i, fd, events, affected, count;
35 fd_set rfds, wfds, efds;
42 tv.tv_sec = timeout / 1000;
43 tv.tv_usec = (timeout % 1000) * 1000;
51 for (i = 0; i < nfds; i++) {
58 if (nexc >= FD_SETSIZE) {
59 ufds [i].revents = MONO_POLLNVAL;
63 if (fd > FD_SETSIZE) {
64 ufds [i].revents = MONO_POLLNVAL;
69 events = ufds [i].events;
70 if ((events & MONO_POLLIN) != 0)
73 if ((events & MONO_POLLOUT) != 0)
83 affected = select (maxfd + 1, &rfds, &wfds, &efds, tvptr);
86 int error = WSAGetLastError ();
88 case WSAEFAULT: errno = EFAULT; break;
89 case WSAEINVAL: errno = EINVAL; break;
90 case WSAEINTR: errno = EINTR; break;
91 /* case WSAEINPROGRESS: errno = EINPROGRESS; break; */
92 case WSAEINPROGRESS: errno = EINTR; break;
93 case WSAENOTSOCK: errno = EBADF; break;
95 case WSAENETDOWN: errno = ENOSR; break;
105 for (i = 0; i < nfds && affected > 0; i++) {
110 events = ufds [i].events;
111 if ((events & MONO_POLLIN) != 0 && FD_ISSET (fd, &rfds)) {
112 ufds [i].revents |= MONO_POLLIN;
116 if ((events & MONO_POLLOUT) != 0 && FD_ISSET (fd, &wfds)) {
117 ufds [i].revents |= MONO_POLLOUT;
121 if (FD_ISSET (fd, &efds)) {
122 ufds [i].revents |= MONO_POLLERR;
126 if (ufds [i].revents != 0)
135 #endif /* #ifndef DISABLE_SOCKETS */