* This program is free software; you can redistribute it and/or
* modify it under the same terms as Perl itself.
*
- * For systems that do not have the poll() system call (for example Linux)
- * try to emulate it as closely as possible using select()
+ * For systems that do not have the poll() system call (for example Linux
+ * kernels < v2.1.23) try to emulate it as closely as possible using select()
*
*/
#include "EXTERN.h"
#include "perl.h"
+#include "XSUB.h"
+
#include "poll.h"
#ifdef I_SYS_TIME
# include <sys/time.h>
# include <time.h>
#endif
#include <sys/types.h>
-#if defined(HAS_SOCKET) && !defined(VMS) /* VMS handles sockets via vmsish.h */
+#if defined(HAS_SOCKET) && !defined(VMS) && !defined(ultrix) /* VMS handles sockets via vmsish.h, ULTRIX dies of socket struct redefinitions */
# include <sys/socket.h>
#endif
#include <sys/stat.h>
#include <errno.h>
+#ifdef HAS_SELECT
+#ifdef I_SYS_SELECT
+#include <sys/select.h>
+#endif
+#endif
+
#ifdef EMULATE_POLL_WITH_SELECT
# define POLL_CAN_READ (POLLIN | POLLRDNORM )
# define POLL_EVENTS_MASK (POLL_CAN_READ | POLL_CAN_WRITE | POLL_HAS_EXCP)
int
-poll(fds, nfds, timeout)
-struct pollfd *fds;
-unsigned long nfds;
-int timeout;
+poll(struct pollfd *fds, unsigned long nfds, int timeout)
{
int i,err;
fd_set rfd,wfd,efd,ifd;
FD_ZERO(&wfd);
FD_ZERO(&efd);
- for(i = 0 ; i < nfds ; i++) {
+ for(i = 0 ; i < (int)nfds ; i++) {
int events = fds[i].events;
int fd = fds[i].fd;
count = 0;
- for(i = 0 ; i < nfds ; i++) {
+ for(i = 0 ; i < (int)nfds ; i++) {
int revents = (fds[i].events & POLL_EVENTS_MASK);
int fd = fds[i].fd;
}
#endif /* EMULATE_POLL_WITH_SELECT */
+
+/* gcc for SunOS 4 produces code from an empty (code/symbolwise)
+ * source code file that makes the SunOS 4.x /usr/bin/ld fail with
+ * ld: poll.o: premature EOF
+ * To avoid this, have at least something in here. */
+#if defined(__sun) && !defined(__SVR4) && defined(__GNUC__)
+static int dummy;
+#endif
+