#ifdef _SFBINARY_H
#undef HAVE_SYS_ST
#undef HAVE_STAT_H
-#undef _lib_poll
#undef _stream_peek
#undef _socket_peek
#undef HAVE_VFORK_H
#define POOLMTXRETURN(p,v) { return(v); }
/* functions for polling readiness of streams */
-#ifdef HAVE_SELECT
-#undef _lib_poll
-#else
-#if _lib_poll_fd_1 || _lib_poll_fd_2
-#define _lib_poll 1
-#endif
-#endif /*HAVE_SELECT*/
-
-#ifdef _lib_poll
-#include <poll.h>
-
-#if _lib_poll_fd_1
-#define SFPOLL(pfd,n,tm) poll((pfd),(ulong)(n),(tm))
-#else
-#define SFPOLL(pfd,n,tm) poll((ulong)(n),(pfd),(tm))
-#endif
-#endif /*_lib_poll*/
#if _stream_peek
#include <stropts.h>
extern pid_t vfork(void);
#endif /*HAVE_VFORK*/
-#ifdef _lib_poll
-#if _lib_poll_fd_1
- extern int poll(struct pollfd *, ulong, int);
-#else
- extern int poll(ulong, struct pollfd *, int);
-#endif
-#endif /*_lib_poll*/
-
#endif /*_SFHDR_H*/
#ifdef __cplusplus
}
/* let select be interrupted instead of recv which autoresumes */
(t & SOCKET_PEEK)) {
r = -2;
-#if _lib_poll
- if (r == -2) {
- struct pollfd po;
- po.fd = fd;
- po.events = POLLIN;
- po.revents = 0;
-
- if ((r = SFPOLL(&po, 1, tm)) < 0) {
- if (errno == EINTR)
- return -1;
- else if (errno == EAGAIN) {
- errno = 0;
- continue;
- } else
- r = -2;
- } else
- r = (po.revents & POLLIN) ? 1 : -1;
- }
-#endif /*_lib_poll*/
#ifdef HAVE_SELECT
if (r == -2) {
fd_set rd;
}
#endif /*HAVE_SELECT*/
if (r == -2) {
-#if !_lib_poll && !defined(HAVE_SELECT) /* both poll and select cann't be used */
+#if !defined(HAVE_SELECT) /* select can't be used */
#ifdef FIONREAD /* quick and dirty check for availability */
long nsec = tm < 0 ? 0 : (tm + 999) / 1000;
while (nsec > 0 && r < 0) {
}
}
-#if _lib_poll
- if (c > 0) {
- struct pollfd *fds;
-
- /* construct the poll array */
- if (!(fds = (struct pollfd *) malloc(c * sizeof(struct pollfd))))
- return -1;
- for (r = 0; r < c; r++) {
- fds[r].fd = fa[check[r]]->file;
- fds[r].events =
- (fa[check[r]]->mode & SF_READ) ? POLLIN : POLLOUT;
- fds[r].revents = 0;
- }
-
- for (;;) { /* this loop takes care of interrupts */
- if ((r = SFPOLL(fds, c, tm)) == 0)
- break;
- else if (r < 0) {
- if (errno == EINTR || errno == EAGAIN) {
- errno = 0;
- continue;
- } else
- break;
- }
-
- for (r = 0; r < c; ++r) {
- f = fa[check[r]];
- if (((f->mode & SF_READ) && (fds[r].revents & POLLIN)) ||
- ((f->mode & SF_WRITE) && (fds[r].revents & POLLOUT)))
- status[check[r]] = 1;
- }
- break;
- }
-
- free((void *) fds);
- }
-#endif /*_lib_poll*/
-
#ifdef HAVE_SELECT
if (c > 0) {
fd_set rd, wr;