4 #if defined(HAVE_POLL) && !defined(__APPLE__)
6 mono_poll (mono_pollfd
*ufds
, unsigned int nfds
, int timeout
)
8 return poll (ufds
, nfds
, timeout
);
13 mono_poll (mono_pollfd
*ufds
, unsigned int nfds
, int timeout
)
15 struct timeval tv
, *tvptr
;
16 int i
, fd
, events
, affected
, count
;
17 fd_set rfds
, wfds
, efds
;
24 tv
.tv_sec
= timeout
/ 1000;
25 tv
.tv_usec
= (timeout
% 1000) * 1000;
33 for (i
= 0; i
< nfds
; i
++) {
40 if (nexc
>= FD_SETSIZE
) {
41 ufds
[i
].revents
= MONO_POLLNVAL
;
45 if (fd
> FD_SETSIZE
) {
46 ufds
[i
].revents
= MONO_POLLNVAL
;
51 events
= ufds
[i
].events
;
52 if ((events
& MONO_POLLIN
) != 0)
55 if ((events
& MONO_POLLOUT
) != 0)
65 affected
= select (maxfd
+ 1, &rfds
, &wfds
, &efds
, tvptr
);
68 int error
= WSAGetLastError ();
70 case WSAEFAULT
: errno
= EFAULT
; break;
71 case WSAEINVAL
: errno
= EINVAL
; break;
72 case WSAEINTR
: errno
= EINTR
; break;
73 /* case WSAEINPROGRESS: errno = EINPROGRESS; break; */
74 case WSAEINPROGRESS
: errno
= EINTR
; break;
75 case WSAENOTSOCK
: errno
= EBADF
; break;
77 case WSAENETDOWN
: errno
= ENOSR
; break;
87 for (i
= 0; i
< nfds
&& affected
> 0; i
++) {
92 events
= ufds
[i
].events
;
93 if ((events
& MONO_POLLIN
) != 0 && FD_ISSET (fd
, &rfds
)) {
94 ufds
[i
].revents
|= MONO_POLLIN
;
98 if ((events
& MONO_POLLOUT
) != 0 && FD_ISSET (fd
, &wfds
)) {
99 ufds
[i
].revents
|= MONO_POLLOUT
;
103 if (FD_ISSET (fd
, &efds
)) {
104 ufds
[i
].revents
|= MONO_POLLERR
;
108 if (ufds
[i
].revents
!= 0)