[PATCH xserver 2/2] Switch poll() users to xserver_poll()

Keith Packard keithp at keithp.com
Mon Jul 18 23:28:19 UTC 2016


This uses the wrapper in case we need to emulate poll with select
as we do on Windows.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 hw/dmx/input/lnx-ms.c                    | 4 ++--
 hw/dmx/input/lnx-ps2.c                   | 4 ++--
 hw/kdrive/linux/mouse.c                  | 6 +++---
 hw/kdrive/linux/ms.c                     | 4 ++--
 hw/kdrive/linux/ps2.c                    | 4 ++--
 hw/xfree86/drivers/modesetting/present.c | 4 ++--
 hw/xfree86/drivers/modesetting/vblank.c  | 1 -
 hw/xfree86/os-support/shared/posix_tty.c | 8 ++++----
 hw/xfree86/os-support/shared/sigio.c     | 4 ++--
 hw/xfree86/os-support/solaris/sun_bell.c | 4 ++--
 10 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/hw/dmx/input/lnx-ms.c b/hw/dmx/input/lnx-ms.c
index c7a09ca..1a5786c 100644
--- a/hw/dmx/input/lnx-ms.c
+++ b/hw/dmx/input/lnx-ms.c
@@ -76,7 +76,7 @@
 #include <X11/Xos.h>
 #include <errno.h>
 #include <termios.h>
-#include <poll.h>
+#include <xserver_poll.h>
 
 /*****************************************************************************/
 /* Define some macros to make it easier to move this file to another
@@ -135,7 +135,7 @@ msLinuxReadBytes(int fd, unsigned char *buf, int len, int min)
         }
         if (tot % min == 0)
             break;
-        n = poll(&poll_fd, 1, 100);
+        n = xserver_poll(&poll_fd, 1, 100);
         if (n <= 0)
             break;
     }
diff --git a/hw/dmx/input/lnx-ps2.c b/hw/dmx/input/lnx-ps2.c
index 00ccc01..2b6e8d6 100644
--- a/hw/dmx/input/lnx-ps2.c
+++ b/hw/dmx/input/lnx-ps2.c
@@ -73,7 +73,7 @@
 #include <X11/Xos.h>
 #include <errno.h>
 #include <termios.h>
-#include <poll.h>
+#include <xserver_poll.h>
 
 /*****************************************************************************/
 /* Define some macros to make it easier to move this file to another
@@ -131,7 +131,7 @@ ps2LinuxReadBytes(int fd, unsigned char *buf, int len, int min)
         }
         if (tot % min == 0)
             break;
-        n = poll(&poll_fd, 1, 100);
+        n = xserver_poll(&poll_fd, 1, 100);
         if (n <= 0)
             break;
     }
diff --git a/hw/kdrive/linux/mouse.c b/hw/kdrive/linux/mouse.c
index 3508b17..6bdd286 100644
--- a/hw/kdrive/linux/mouse.c
+++ b/hw/kdrive/linux/mouse.c
@@ -27,7 +27,7 @@
 #include <termios.h>
 #include <X11/X.h>
 #include <X11/Xproto.h>
-#include <poll.h>
+#include <xserver_poll.h>
 #include "inputstr.h"
 #include "scrnintstr.h"
 #include "kdrive.h"
@@ -55,7 +55,7 @@ MouseWaitForReadable(int fd, int timeout)
     poll_fd.fd = fd;
     poll_fd.events = POLLIN;
     for (;;) {
-        n = poll(&poll_fd, 1, timeout);
+        n = xserver_poll(&poll_fd, 1, timeout);
         if (n > 0)
             return TRUE;
         if (n < 0 && (errno == EAGAIN || errno == EINTR)) {
@@ -136,7 +136,7 @@ MouseWaitForWritable(int fd, int timeout)
 
     poll_fd.fd = fd;
     poll_fd.events = POLLOUT;
-    n = poll(&poll_fd, 1, timeout);
+    n = xserver_poll(&poll_fd, 1, timeout);
     if (n > 0)
         return TRUE;
     return FALSE;
diff --git a/hw/kdrive/linux/ms.c b/hw/kdrive/linux/ms.c
index 79e6373..3934682 100644
--- a/hw/kdrive/linux/ms.c
+++ b/hw/kdrive/linux/ms.c
@@ -26,7 +26,7 @@ THE SOFTWARE.
 #endif
 #include <errno.h>
 #include <termios.h>
-#include <poll.h>
+#include <xserver_poll.h>
 #include <X11/X.h>
 #include <X11/Xproto.h>
 #include "inputstr.h"
@@ -51,7 +51,7 @@ MsReadBytes(int fd, char *buf, int len, int min)
         }
         if (tot % min == 0)
             break;
-        n = poll(&poll_fd, 1, 100);
+        n = xserver_poll(&poll_fd, 1, 100);
         if (n <= 0)
             break;
     }
diff --git a/hw/kdrive/linux/ps2.c b/hw/kdrive/linux/ps2.c
index 5d4a8eb..4fec024 100644
--- a/hw/kdrive/linux/ps2.c
+++ b/hw/kdrive/linux/ps2.c
@@ -25,7 +25,7 @@
 #endif
 #include <X11/X.h>
 #include <X11/Xproto.h>
-#include <poll.h>
+#include <xserver_poll.h>
 #include "inputstr.h"
 #include "scrnintstr.h"
 #include "kdrive.h"
@@ -48,7 +48,7 @@ Ps2ReadBytes(int fd, char *buf, int len, int min)
         }
         if (tot % min == 0)
             break;
-        n = poll(&poll_fd, 1, 100);
+        n = xserver_poll(&poll_fd, 1, 100);
         if (n <= 0)
             break;
     }
diff --git a/hw/xfree86/drivers/modesetting/present.c b/hw/xfree86/drivers/modesetting/present.c
index 9a596de..0093fb5 100644
--- a/hw/xfree86/drivers/modesetting/present.c
+++ b/hw/xfree86/drivers/modesetting/present.c
@@ -27,7 +27,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <poll.h>
+#include <xserver_poll.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stdint.h>
@@ -87,7 +87,7 @@ ms_flush_drm_events(ScreenPtr screen)
     int r;
 
     do {
-            r = poll(&p, 1, 0);
+            r = xserver_poll(&p, 1, 0);
     } while (r == -1 && (errno == EINTR || errno == EAGAIN));
 
     /* If there was an error, r will be < 0.  Return that.  If there was
diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c
index 0727887..d5a9ded 100644
--- a/hw/xfree86/drivers/modesetting/vblank.c
+++ b/hw/xfree86/drivers/modesetting/vblank.c
@@ -32,7 +32,6 @@
 #include <unistd.h>
 #include <xf86.h>
 #include <xf86Crtc.h>
-#include <poll.h>
 #include "driver.h"
 #include "drmmode_display.h"
 
diff --git a/hw/xfree86/os-support/shared/posix_tty.c b/hw/xfree86/os-support/shared/posix_tty.c
index d5a70ba..6249a62 100644
--- a/hw/xfree86/os-support/shared/posix_tty.c
+++ b/hw/xfree86/os-support/shared/posix_tty.c
@@ -57,7 +57,7 @@
 #endif
 
 #include <X11/X.h>
-#include <poll.h>
+#include <xserver_poll.h>
 #include "xf86.h"
 #include "xf86Priv.h"
 #include "xf86_OSlib.h"
@@ -395,10 +395,10 @@ xf86WaitForInput(int fd, int timeout)
     poll_fd.events = POLLIN;
 
     if (fd >= 0) {
-        SYSCALL(r = poll(&poll_fd, 1, timeout));
+        SYSCALL(r = xserver_poll(&poll_fd, 1, timeout));
     }
     else {
-        SYSCALL(r = poll(&poll_fd, 0, timeout));
+        SYSCALL(r = xserver_poll(&poll_fd, 0, timeout));
     }
     xf86ErrorFVerb(9, "poll returned %d\n", r);
     return r;
@@ -427,7 +427,7 @@ xf86FlushInput(int fd)
 
     poll_fd.fd = fd;
     poll_fd.events = POLLIN;
-    while (poll(&poll_fd, 1, 0) > 0) {
+    while (xserver_poll(&poll_fd, 1, 0) > 0) {
         if (read(fd, &c, sizeof(c)) < 1)
             return 0;
     }
diff --git a/hw/xfree86/os-support/shared/sigio.c b/hw/xfree86/os-support/shared/sigio.c
index 949d1b4..884a71c 100644
--- a/hw/xfree86/os-support/shared/sigio.c
+++ b/hw/xfree86/os-support/shared/sigio.c
@@ -57,7 +57,7 @@
 #endif
 
 #include <X11/X.h>
-#include <poll.h>
+#include <xserver_poll.h>
 #include "xf86.h"
 #include "xf86Priv.h"
 #include "xf86_OSlib.h"
@@ -128,7 +128,7 @@ xf86SIGIO(int sig)
 
     inSignalContext = TRUE;
 
-    SYSCALL(r = poll(xf86SigIOFds, xf86SigIONum, 0));
+    SYSCALL(r = xserver_poll(xf86SigIOFds, xf86SigIONum, 0));
     for (f = 0; r > 0 && f < xf86SigIONum; f++) {
         if (xf86SigIOFds[f].revents & POLLIN) {
             for (i = 0; i < xf86SigIOMax; i++)
diff --git a/hw/xfree86/os-support/solaris/sun_bell.c b/hw/xfree86/os-support/solaris/sun_bell.c
index beb13d2..883728e 100644
--- a/hw/xfree86/os-support/solaris/sun_bell.c
+++ b/hw/xfree86/os-support/solaris/sun_bell.c
@@ -28,7 +28,7 @@
 #include <sys/uio.h>
 #include <limits.h>
 #include <math.h>
-#include <poll.h>
+#include <xserver_poll.h>
 
 #include "xf86.h"
 #include "xf86Priv.h"
@@ -163,7 +163,7 @@ xf86OSRingBell(int loudness, int pitch, int duration)
 
                 /* sleep a little to allow audio buffer to drain */
                 naptime = BELL_MS * i;
-                poll(NULL, 0, naptime);
+                xserver_poll(NULL, 0, naptime);
 
                 i = ((sizeof(samples) * iovcnt) - written) % sizeof(samples);
                 iovcnt = 0;
-- 
2.8.1



More information about the xorg-devel mailing list