commit 2b7a920f5fd65549c2d84a119ecf42969dcbe056
parent 6bce486e85d768795cbe770ab035eeb6215ba829
Author: Kyle Milz <krwmilz@gmail.com>
Date: Thu, 19 Aug 2021 19:42:59 +0000
assume we have poll
Diffstat:
M | events.c | | | 109 | +------------------------------------------------------------------------------ |
M | font-open.c | | | 16 | ++++------------ |
M | popups.c | | | 16 | ++++------------ |
M | psgs.c | | | 20 | ++++---------------- |
M | xdvi.h | | | 2 | -- |
5 files changed, 13 insertions(+), 150 deletions(-)
diff --git a/events.c b/events.c
@@ -108,20 +108,7 @@ NOTE:
# endif
#endif
-#if HAVE_POLL
-# include <poll.h>
-#else
-# if HAVE_SYS_SELECT_H
-# include <sys/select.h>
-# else
-# if HAVE_SELECT_H
-# include <select.h>
-# endif
-# endif
-# define XIO_IN 1
-# define XIO_OUT 2
-#endif
-
+#include <poll.h>
#include <errno.h>
#ifndef X11HEIGHT
@@ -3132,16 +3119,10 @@ do_sigchld()
static struct xio *iorecs = NULL; /* head of xio list */
-#if HAVE_POLL
static struct pollfd *fds = NULL;
static int num_fds = 1; /* current number of fds */
static int max_fds = 0; /* max allocated number of fds */
static Boolean io_dirty= True; /* need to recompute fds[] array */
-#else
-static int numfds = 0;
-static fd_set readfds;
-static fd_set writefds;
-#endif
void
set_io(ip)
@@ -3150,7 +3131,6 @@ set_io(ip)
ip->next = iorecs;
iorecs = ip;
-#if HAVE_POLL
++num_fds;
if (!io_dirty && num_fds <= max_fds) {
fds[num_fds - 1].fd = ip->fd;
@@ -3161,9 +3141,6 @@ set_io(ip)
ip->pfd = NULL;
io_dirty = True;
}
-#else
- if (numfds <= ip->fd) numfds = ip->fd + 1;
-#endif
}
void
@@ -3181,20 +3158,8 @@ clear_io(ip)
}
*ipp = ip->next;
-#if HAVE_POLL
--num_fds;
io_dirty = True;
-#else
-# if FLAKY_SIGPOLL
- numfds = ConnectionNumber(DISP);
-# else
- numfds = (event_freq < 0 ? -1 : ConnectionNumber(DISP));
-# endif
- for (ip = iorecs; ip != NULL; ip = ip->next)
- if (ip->fd > numfds)
- numfds = ip->fd;
- ++numfds;
-#endif /* !HAVE_POLL */
}
static void
@@ -3207,8 +3172,6 @@ do_sigpoll()
sig_flags &= ~SF_POLL;
-#if HAVE_POLL
-
if (io_dirty) {
struct pollfd *fp;
@@ -3246,39 +3209,6 @@ do_sigpoll()
if (revents & POLLOUT) (ip->write_proc)();
}
-#else
-
- FD_ZERO(&readfds);
- FD_ZERO(&writefds);
- for (ip = iorecs; ip != NULL; ip = ip->next) {
- if (ip->xio_events & XIO_IN)
- FD_SET(ip->fd, &readfds);
- if (ip->xio_events & XIO_OUT)
- FD_SET(ip->fd, &writefds);
- }
-
- for (;;) {
- struct timeval tv;
-
- tv.tv_sec = tv.tv_usec = 0;
- if (select(numfds, &readfds, &writefds, (fd_set *) NULL, &tv) >= 0)
- break;
-
- if (errno != EAGAIN && errno != EINTR) {
- perror("select (xdvi read_events)");
- return;
- }
- }
-
- for (ip = iorecs; ip != NULL; ip = ip->next) {
- if (FD_ISSET(ip->fd, &readfds))
- (ip->read_proc)();
- if (FD_ISSET(ip->fd, &writefds))
- (ip->write_proc)();
- }
-
-#endif
-
#endif /* not FLAKY_SIGPOLL */
}
@@ -3480,10 +3410,6 @@ read_events(ret_mask)
{
XEvent event;
-#if !HAVE_POLL
- if (numfds == 0) numfds = ConnectionNumber(DISP) + 1;
-#endif
-
for (;;) {
event_counter = event_freq;
/*
@@ -3548,7 +3474,6 @@ read_events(ret_mask)
/* If a SIGUSR1 signal comes right now, then it will wait
until an X event or another SIGUSR1 signal arrives. */
-#if HAVE_POLL
if (io_dirty) {
struct pollfd *fp;
@@ -3588,38 +3513,6 @@ read_events(ret_mask)
break;
}
}
-#else
- FD_ZERO(&readfds);
- FD_ZERO(&writefds);
- FD_SET(ConnectionNumber(DISP), &readfds);
- for (ip = iorecs; ip != NULL; ip = ip->next) {
- if (ip->xio_events & XIO_IN)
- FD_SET(ip->fd, &readfds);
- if (ip->xio_events & XIO_OUT)
- FD_SET(ip->fd, &writefds);
- }
-
- for (;;) {
- if (select(numfds, &readfds, &writefds, (fd_set *) NULL,
- (struct timeval *) NULL) >= 0) {
- for (ip = iorecs; ip != NULL; ip = ip->next) {
- if (FD_ISSET(ip->fd, &readfds))
- (ip->read_proc)();
- if (FD_ISSET(ip->fd, &writefds))
- (ip->write_proc)();
- }
- break;
- }
-
- if (errno == EINTR)
- break;
-
- if (errno != EAGAIN) {
- perror("xdvi: select");
- break;
- }
- }
-#endif
}
}
diff --git a/font-open.c b/font-open.c
@@ -1814,14 +1814,9 @@ try_size(font, dpi, ret_path)
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
#endif
-#if HAVE_POLL
-# include <poll.h>
-# define XIO_IN POLLIN
-# define XIO_OUT POLLOUT
-#else
-# define XIO_IN 1
-# define XIO_OUT 2
-#endif
+#include <poll.h>
+#define XIO_IN POLLIN
+#define XIO_OUT POLLOUT
#ifdef EWOULDBLOCK
#ifdef EAGAIN
@@ -1919,10 +1914,7 @@ static void mkpk_get_result(void);
static unsigned int mkpk_pos;
-static struct xio mkpk_result = {NULL, 0, XIO_IN,
-#if HAVE_POLL
- NULL,
-#endif
+static struct xio mkpk_result = {NULL, 0, XIO_IN, NULL,
mkpk_get_result, NULL};
static void
diff --git a/popups.c b/popups.c
@@ -110,14 +110,9 @@ IN THE SOFTWARE.
# endif
#endif /* EWOULDBLOCK */
-#if HAVE_POLL
-# include <poll.h>
-# define XIO_IN POLLIN
-# define XIO_OUT POLLOUT
-#else
-# define XIO_IN 1
-# define XIO_OUT 2
-#endif
+#include <poll.h>
+#define XIO_IN POLLIN
+#define XIO_OUT POLLOUT
/*
@@ -2591,10 +2586,7 @@ static void dvips_ended(int);
static struct xchild print_child = {NULL, 0, True, dvips_ended};
static void read_from_dvips(void);
-static struct xio print_xio = {NULL, 0, XIO_IN,
-#if HAVE_POLL
- NULL,
-#endif
+static struct xio print_xio = {NULL, 0, XIO_IN, NULL,
read_from_dvips, NULL};
static void dvips_alarm(struct xtimer *);
diff --git a/psgs.c b/psgs.c
@@ -42,14 +42,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#endif /* EAGAIN */
#endif /* EWOULDBLOCK */
-#if HAVE_POLL
-# include <poll.h>
-# define XIO_IN POLLIN
-# define XIO_OUT POLLOUT
-#else
-# define XIO_IN 1
-# define XIO_OUT 2
-#endif
+#include <poll.h>
+#define XIO_IN POLLIN
+#define XIO_OUT POLLOUT
#if HAVE_VFORK_H
# include <vfork.h>
@@ -146,10 +141,7 @@ static struct xchild gs_child = {NULL, 0, True, gs_died};
static void read_from_gs(void);
static void write_to_gs(void);
-static struct xio gs_xio = {NULL, 0, XIO_IN,
-#if HAVE_POLL
- NULL,
-#endif
+static struct xio gs_xio = {NULL, 0, XIO_IN, NULL,
read_from_gs, write_to_gs};
static void gs_alarm(struct xtimer *);
@@ -270,10 +262,8 @@ write_to_gs()
if (GS_outb_out == GS_outb_limit) GS_outb_out = GS_outb;
if (GS_outb_out == GS_outb_in) { /* if buffer is empty */
gs_xio.xio_events = XIO_IN;
-#if HAVE_POLL
if (gs_xio.pfd != NULL) /* write_to_gs is called directly */
gs_xio.pfd->events = XIO_IN;
-#endif
break;
}
}
@@ -327,10 +317,8 @@ gs_send(cp, len)
old_out = GS_outb_out;
if (!(gs_xio.xio_events & XIO_OUT)) { /* restart output */
gs_xio.xio_events = XIO_IN | XIO_OUT;
-#if HAVE_POLL
if (gs_xio.pfd != NULL)
gs_xio.pfd->events = POLLIN | POLLOUT;
-#endif
write_to_gs();
if (GS_outb_out != old_out) {
if (cp == cp_end)
diff --git a/xdvi.h b/xdvi.h
@@ -724,9 +724,7 @@ struct xio {
int xio_events; /* same as in struct pollfd (can't call
it events because poll.h on AIX
defines events to something else) */
-#if HAVE_POLL
struct pollfd *pfd;
-#endif
void (*read_proc)(void); /* call to read */
void (*write_proc)(void); /* call to write */
};