12 #include "mono-poll.h"
15 #ifdef DISABLE_SOCKETS
19 mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
21 g_assert_not_reached ();
26 #if defined(HAVE_POLL) && !defined(__APPLE__)
28 mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
30 return poll (ufds, nfds, timeout);
35 mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
37 struct timeval tv, *tvptr;
38 int i, fd, events, affected, count;
39 fd_set rfds, wfds, efds;
46 tv.tv_sec = timeout / 1000;
47 tv.tv_usec = (timeout % 1000) * 1000;
55 for (i = 0; i < nfds; i++) {
62 if (nexc >= FD_SETSIZE) {
63 ufds [i].revents = MONO_POLLNVAL;
67 if (fd >= FD_SETSIZE) {
68 ufds [i].revents = MONO_POLLNVAL;
73 events = ufds [i].events;
74 if ((events & MONO_POLLIN) != 0)
77 if ((events & MONO_POLLOUT) != 0)
87 affected = select (maxfd + 1, &rfds, &wfds, &efds, tvptr);
90 int error = WSAGetLastError ();
92 case WSAEFAULT: errno = EFAULT; break;
93 case WSAEINVAL: errno = EINVAL; break;
94 case WSAEINTR: errno = EINTR; break;
95 /* case WSAEINPROGRESS: errno = EINPROGRESS; break; */
96 case WSAEINPROGRESS: errno = EINTR; break;
97 case WSAENOTSOCK: errno = EBADF; break;
99 case WSAENETDOWN: errno = ENOSR; break;
109 for (i = 0; i < nfds && affected > 0; i++) {
114 events = ufds [i].events;
115 if ((events & MONO_POLLIN) != 0 && FD_ISSET (fd, &rfds)) {
116 ufds [i].revents |= MONO_POLLIN;
120 if ((events & MONO_POLLOUT) != 0 && FD_ISSET (fd, &wfds)) {
121 ufds [i].revents |= MONO_POLLOUT;
125 if (FD_ISSET (fd, &efds)) {
126 ufds [i].revents |= MONO_POLLERR;
130 if (ufds [i].revents != 0)
139 #endif /* #ifndef DISABLE_SOCKETS */