+#ifdef IO_USE_DEVPOLL
+static int
+io_dispatch_devpoll(struct timeval *tv)
+{
+ struct dvpoll dvp;
+ time_t sec = tv->tv_sec * 1000;
+ int i, total, ret, timeout = tv->tv_usec + sec;
+ short what;
+ struct pollfd p[100];
+
+ if (timeout < 0)
+ timeout = 1000;
+
+ total = 0;
+ do {
+ dvp.dp_timeout = timeout;
+ dvp.dp_nfds = 100;
+ dvp.dp_fds = p;
+ ret = ioctl(io_masterfd, DP_POLL, &dvp);
+ total += ret;
+ if (ret <= 0)
+ return total;
+ for (i=0; i < ret ; i++) {
+ what = 0;
+ if (p[i].revents & (POLLIN|POLLPRI))
+ what = IO_WANTREAD;
+
+ if (p[i].revents & POLLOUT)
+ what |= IO_WANTWRITE;
+
+ if (p[i].revents && !what) {
+ /* other flag is set, probably POLLERR */
+ what = IO_ERROR;
+ }
+ io_docallback(p[i].fd, what);
+ }
+ } while (ret == 100);
+
+ return total;
+}
+#endif
+
+