summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac28
-rw-r--r--dbus/dbus-sysdeps.h26
2 files changed, 26 insertions, 28 deletions
diff --git a/configure.ac b/configure.ac
index ded20651..05c18b5e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -633,34 +633,6 @@ fi
AC_CHECK_HEADERS_ONCE([sys/prctl.h])
AC_CHECK_FUNCS_ONCE([prctl raise])
-#### Check for broken poll; taken from Glib's configure
-
-AC_MSG_CHECKING([for broken poll])
-AC_RUN_IFELSE([AC_LANG_SOURCE([[
- #include <stdlib.h>
- #include <fcntl.h>
- #include <poll.h>
- #ifdef HAVE_SYS_POLL_H
- #include <sys/poll.h>
- #endif
- int main(void) {
- struct pollfd fds[1];
- int fd;
- fd = open("/dev/null", 1);
- fds[0].fd = fd;
- fds[0].events = POLLIN;
- fds[0].revents = 0;
- if (poll(fds, 1, 0) < 0 || (fds[0].revents & POLLNVAL) != 0) {
- exit(1); /* Does not work for devices -- fail */
- }
- exit(0);
- }]])],
- [broken_poll=no],
- [broken_poll=yes
- AC_DEFINE(BROKEN_POLL,1,[poll doesn't work on devices])],
- [broken_poll="no (cross compiling)"])
-AC_MSG_RESULT($broken_poll)
-
AC_MSG_CHECKING(for dirfd)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h
index 8642dda5..a5987ae5 100644
--- a/dbus/dbus-sysdeps.h
+++ b/dbus/dbus-sysdeps.h
@@ -48,6 +48,32 @@
#include <string.h>
#include <stdarg.h>
+#if !defined(BROKEN_POLL) && (defined(__APPLE__) || defined(__INTERIX))
+ /* Following libcurl's example, we blacklist poll() on Darwin
+ * (macOS, iOS, etc.) and Interix due to a history of implementation
+ * issues.
+ * https://github.com/curl/curl/blob/master/m4/curl-functions.m4
+ *
+ * On unspecified older macOS versions, poll() failed if given a
+ * device node to poll.
+ *
+ * On macOS < 10.9, poll() with nfds=0 failed instead of waiting for
+ * the timeout and then succeeding.
+ *
+ * On macOS >= 10.12, poll() with nfds=0 succeeded immediately
+ * instead of waiting for the timeout, resulting in busy-looping.
+ *
+ * On Interix, poll() apparently only works for files in /proc.
+ *
+ * The "legacy" build flavour in our CI machinery defines BROKEN_POLL
+ * on whatever platform is in use (normally Linux) to force use of the
+ * same select()-based poll() emulation that we use for macOS, Interix,
+ * and any platform that lacks a real poll(), so that we can test it
+ * more regularly.
+ */
+# define BROKEN_POLL
+#endif
+
/* AIX sys/poll.h does #define events reqevents, and other
* wonderousness, so must include sys/poll before declaring
* DBusPollFD