Add a check for broken poll on Mac OS X.
authorMatthias Clasen <mclasen@redhat.com>
Tue, 12 Dec 2006 20:04:45 +0000 (20:04 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Tue, 12 Dec 2006 20:04:45 +0000 (20:04 +0000)
2006-12-12  Matthias Clasen  <mclasen@redhat.com>

        * configure.in: Add a check for broken poll on Mac OS X.

        * glib/gmain.c: Use poll emulation on OS X.  (#302672, Toby Peterson,
        patch by Dave Vasilevsky)

ChangeLog
configure.in
glib/gmain.c

index 7b31eee..dd08a46 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-12-12  Matthias Clasen  <mclasen@redhat.com>
+
+       * configure.in: Add a check for broken poll on Mac OS X.
+
+       * glib/gmain.c: Use poll emulation on OS X.  (#302672, Toby Peterson,
+       patch by Dave Vasilevsky)
+
 2006-12-11  Matthias Clasen  <mclasen@redhat.com>
 
        * glib/gatomic.c: Don't use local numeric labels in
index bada706..6c0a1bb 100644 (file)
@@ -2117,6 +2117,32 @@ else
   glib_cv_value_POLLNVAL=32
 fi
 
+# Check for Mac OS X's broken poll
+if test $cross_compiling != yes ; then
+  AC_MSG_CHECKING(for broken poll)
+  AC_TRY_RUN([[
+       #include <stdlib.h>
+       #include <fcntl.h>
+       #include <poll.h>
+       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])
+  )
+  AC_MSG_RESULT($broken_poll)
+fi
+
 dnl **********************
 dnl *** Win32 API libs ***
 dnl **********************
index 547ab20..bbbf8aa 100644 (file)
@@ -53,7 +53,7 @@
 /* The poll() emulation on OS/X doesn't handle fds=NULL, nfds=0,
  * so we prefer our own poll emulation.
  */
-#ifdef _POLL_EMUL_H_
+#if defined(_POLL_EMUL_H_) || defined(BROKEN_POLL)
 #undef HAVE_POLL
 #endif