~ chicken-core (chicken-5) ccfb168bf1eb1090a788231b2cccff413e9f96c6


commit ccfb168bf1eb1090a788231b2cccff413e9f96c6
Author:     Moritz Heidkamp <moritz.heidkamp@bevuta.com>
AuthorDate: Mon Aug 4 15:23:13 2014 +0200
Commit:     Christian Kellermann <ckeen@pestilenz.org>
CommitDate: Thu Sep 11 21:49:19 2014 +0200

    Invert poll(2) flag default
    
    To be on the safe side we now assume that poll(2) is available by
    default and define the NO_POSIX_POLL flag in case it isn't available on
    a platform.
    
    Signed-off-by: Christian Kellermann <ckeen@pestilenz.org>

diff --git a/Makefile.aix b/Makefile.aix
index 68b33b7c..72e9715e 100644
--- a/Makefile.aix
+++ b/Makefile.aix
@@ -74,7 +74,6 @@ chicken-config.h: chicken-defaults.h
 	echo "#define HAVE_LONG_LONG 1" >>$@
 	echo "#define HAVE_MEMMOVE 1" >>$@
 	echo "#define HAVE_MEMORY_H 1" >>$@
-	echo "#define HAVE_POSIX_POLL 1" >>$@
 	echo "#define HAVE_SIGACTION 1" >>$@
 	echo "#define HAVE_SIGSETJMP 1" >>$@
 	echo "#define HAVE_STDINT_H 1" >>$@
diff --git a/Makefile.android b/Makefile.android
index ac72ee88..819587f9 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -69,7 +69,6 @@ chicken-config.h: chicken-defaults.h
 	echo "#define HAVE_LONG_LONG 1" >>$@
 	echo "#define HAVE_MEMMOVE 1" >>$@
 	echo "#define HAVE_MEMORY_H 1" >>$@
-	echo "#define HAVE_POSIX_POLL 1" >>$@
 	echo "#define HAVE_SIGACTION 1" >>$@
 	echo "#define HAVE_SIGSETJMP 1" >>$@
 	echo "#define HAVE_STDINT_H 1" >>$@
diff --git a/Makefile.bsd b/Makefile.bsd
index af28814b..c69ea35e 100644
--- a/Makefile.bsd
+++ b/Makefile.bsd
@@ -72,7 +72,6 @@ chicken-config.h: chicken-defaults.h
 	echo "#define HAVE_LONG_LONG 1" >>$@
 	echo "#define HAVE_MEMMOVE 1" >>$@
 	echo "#define HAVE_MEMORY_H 1" >>$@
-	echo "#define HAVE_POSIX_POLL 1" >>$@
 	echo "#define HAVE_SIGACTION 1" >>$@
 	echo "#define HAVE_SIGSETJMP 1" >>$@
 	echo "#define HAVE_SIGPROCMASK 1" >>$@
diff --git a/Makefile.cross-linux-mingw b/Makefile.cross-linux-mingw
index 32a6f2f8..6e4c34a8 100644
--- a/Makefile.cross-linux-mingw
+++ b/Makefile.cross-linux-mingw
@@ -95,6 +95,7 @@ chicken-config.h: chicken-defaults.h
 	echo "#define HAVE_LONG_LONG 1" >>$@
 	echo "#define HAVE_MEMMOVE 1" >>$@
 	echo "#define HAVE_MEMORY_H 1" >>$@
+	echo "#define NO_POSIX_POLL 1" >>$@
 	echo "#define HAVE_STDINT_H 1" >>$@
 	echo "#define HAVE_STDLIB_H 1" >>$@
 	echo "#define HAVE_STRERROR 1" >>$@
diff --git a/Makefile.cygwin b/Makefile.cygwin
index 376f6b8a..f499c902 100644
--- a/Makefile.cygwin
+++ b/Makefile.cygwin
@@ -89,7 +89,6 @@ chicken-config.h: chicken-defaults.h
 	echo "#define HAVE_LONG_LONG 1" >>$@
 	echo "#define HAVE_MEMMOVE 1" >>$@
 	echo "#define HAVE_MEMORY_H 1" >>$@
-	echo "#define HAVE_POSIX_POLL 1" >>$@
 	echo "#define HAVE_SIGACTION 1" >>$@
 	echo "#define HAVE_STDINT_H 1" >>$@
 	echo "#define HAVE_STDLIB_H 1" >>$@
diff --git a/Makefile.haiku b/Makefile.haiku
index a1f58413..7eeec26e 100644
--- a/Makefile.haiku
+++ b/Makefile.haiku
@@ -66,7 +66,6 @@ chicken-config.h: chicken-defaults.h
 	echo "#define HAVE_LONG_LONG 1" >>$@
 	echo "#define HAVE_MEMMOVE 1" >>$@
 	echo "#define HAVE_MEMORY_H 1" >>$@
-	echo "#define HAVE_POSIX_POLL 1" >>$@
 	echo "#define HAVE_SIGACTION 1" >>$@
 	echo "#define HAVE_SIGSETJMP 1" >>$@
 	echo "#define HAVE_SIGPROCMASK 1" >>$@
diff --git a/Makefile.hurd b/Makefile.hurd
index 6a97db64..d2f9a1f4 100644
--- a/Makefile.hurd
+++ b/Makefile.hurd
@@ -67,7 +67,6 @@ chicken-config.h: chicken-defaults.h
 	echo "#define HAVE_LONG_LONG 1" >>$@
 	echo "#define HAVE_MEMMOVE 1" >>$@
 	echo "#define HAVE_MEMORY_H 1" >>$@
-	echo "#define HAVE_POSIX_POLL 1" >>$@
 	echo "#define HAVE_SIGACTION 1" >>$@
 	echo "#define HAVE_SIGSETJMP 1" >>$@
 	echo "#define HAVE_SIGPROCMASK 1" >>$@
diff --git a/Makefile.ios b/Makefile.ios
index 6f82e008..6c99c47c 100644
--- a/Makefile.ios
+++ b/Makefile.ios
@@ -73,7 +73,6 @@ chicken-config.h: chicken-defaults.h
 	echo "#define HAVE_LONG_LONG 1" >>$@
 	echo "#define HAVE_MEMMOVE 1" >>$@
 	echo "#define HAVE_MEMORY_H 1" >>$@
-	echo "#define HAVE_POSIX_POLL 1" >>$@
 	echo "#define HAVE_SIGACTION 1" >>$@
 	echo "#define HAVE_SIGSETJMP 1" >>$@
 	echo "#define HAVE_SIGPROCMASK 1" >>$@
diff --git a/Makefile.linux b/Makefile.linux
index 3f2aca17..c941821d 100644
--- a/Makefile.linux
+++ b/Makefile.linux
@@ -67,7 +67,6 @@ chicken-config.h: chicken-defaults.h
 	echo "#define HAVE_LONG_LONG 1" >>$@
 	echo "#define HAVE_MEMMOVE 1" >>$@
 	echo "#define HAVE_MEMORY_H 1" >>$@
-	echo "#define HAVE_POSIX_POLL 1" >>$@
 	echo "#define HAVE_SIGACTION 1" >>$@
 	echo "#define HAVE_SIGSETJMP 1" >>$@
 	echo "#define HAVE_SIGPROCMASK 1" >>$@
diff --git a/Makefile.macosx b/Makefile.macosx
index 9ce4682b..033a43e9 100644
--- a/Makefile.macosx
+++ b/Makefile.macosx
@@ -95,7 +95,6 @@ chicken-config.h: chicken-defaults.h
 	echo "#define HAVE_LONG_LONG 1" >>$@
 	echo "#define HAVE_MEMMOVE 1" >>$@
 	echo "#define HAVE_MEMORY_H 1" >>$@
-	echo "#define HAVE_POSIX_POLL 1" >>$@
 	echo "#define HAVE_SIGACTION 1" >>$@
 	echo "#define HAVE_SIGSETJMP 1" >>$@
 	echo "#define HAVE_SIGPROCMASK 1" >>$@
diff --git a/Makefile.mingw b/Makefile.mingw
index 3d8cfba4..99790281 100644
--- a/Makefile.mingw
+++ b/Makefile.mingw
@@ -87,6 +87,7 @@ chicken-config.h: chicken-defaults.h
 	echo #define HAVE_LONG_LONG 1 >>$@
 	echo #define HAVE_MEMMOVE 1 >>$@
 	echo #define HAVE_MEMORY_H 1 >>$@
+	echo #define NO_POSIX_POLL 1 >>$@
 	echo #define HAVE_STDINT_H 1 >>$@
 	echo #define HAVE_STDLIB_H 1 >>$@
 	echo #define HAVE_STRERROR 1 >>$@
diff --git a/Makefile.mingw-msys b/Makefile.mingw-msys
index 9ec6750f..d2417f78 100644
--- a/Makefile.mingw-msys
+++ b/Makefile.mingw-msys
@@ -89,6 +89,7 @@ chicken-config.h: chicken-defaults.h
 	echo "#define HAVE_LONG_LONG 1" >>$@
 	echo "#define HAVE_MEMMOVE 1" >>$@
 	echo "#define HAVE_MEMORY_H 1" >>$@
+	echo "#define NO_POSIX_POLL 1" >>$@
 	echo "#define HAVE_STDINT_H 1" >>$@
 	echo "#define HAVE_STDLIB_H 1" >>$@
 	echo "#define HAVE_STRERROR 1" >>$@
diff --git a/Makefile.solaris b/Makefile.solaris
index dc7afb23..9be873f1 100644
--- a/Makefile.solaris
+++ b/Makefile.solaris
@@ -98,7 +98,6 @@ chicken-config.h: chicken-defaults.h
 	echo "#define HAVE_LONG_LONG 1" >>$@
 	echo "#define HAVE_MEMMOVE 1" >>$@
 	echo "#define HAVE_MEMORY_H 1" >>$@
-	echo "#define HAVE_POSIX_POLL 1" >>$@
 	echo "#define HAVE_SIGACTION 1" >>$@
 	echo "#define HAVE_STDINT_H 1" >>$@
 	echo "#define HAVE_STDLIB_H 1" >>$@
diff --git a/runtime.c b/runtime.c
index 1a68906c..5585c9b4 100644
--- a/runtime.c
+++ b/runtime.c
@@ -64,7 +64,7 @@
 #endif
 
 /* TODO: Include sys/select.h? Windows doesn't seem to have it... */
-#ifdef HAVE_POSIX_POLL
+#ifndef NO_POSIX_POLL
 #  include <poll.h>
 #endif
 
@@ -4124,12 +4124,7 @@ C_regparm C_word C_fcall C_execute_shell_command(C_word string)
  */
 C_regparm int C_fcall C_check_fd_ready(int fd)
 {
-#ifdef HAVE_POSIX_POLL
-  struct pollfd ps;
-  ps.fd = fd;
-  ps.events = POLLIN;
-  return poll(&ps, 1, 0);
-#else
+#ifdef NO_POSIX_POLL
   fd_set in;
   struct timeval tm;
   int rv;
@@ -4139,6 +4134,11 @@ C_regparm int C_fcall C_check_fd_ready(int fd)
   rv = select(fd + 1, &in, NULL, NULL, &tm);
   if(rv > 0) { rv = FD_ISSET(fd, &in) ? 1 : 0; }
   return rv;
+#else
+  struct pollfd ps;
+  ps.fd = fd;
+  ps.events = POLLIN;
+  return poll(&ps, 1, 0);
 #endif
 }
 
diff --git a/scheduler.scm b/scheduler.scm
index f6e996f2..ff5d80d2 100644
--- a/scheduler.scm
+++ b/scheduler.scm
@@ -66,7 +66,33 @@ C_word C_msleep(C_word ms) {
 }
 #endif
 
-#ifdef HAVE_POSIX_POLL
+#ifdef NO_POSIX_POLL
+
+/* Shouldn't we include <sys/select.h> here? */
+static fd_set C_fdset_input, C_fdset_output;
+
+#define C_fd_input_ready(fd,pos)  C_mk_bool(FD_ISSET(C_unfix(fd), &C_fdset_input))
+#define C_fd_output_ready(fd,pos)  C_mk_bool(FD_ISSET(C_unfix(fd), &C_fdset_output))
+
+C_inline int C_ready_fds_timeout(int to, double tm) {
+  struct timeval timeout;
+  timeout.tv_sec = tm / 1000;
+  timeout.tv_usec = fmod(tm, 1000) * 1000;
+  /* we use FD_SETSIZE, but really should use max fd */
+  return select(FD_SETSIZE, &C_fdset_input, &C_fdset_output, NULL, to ? &timeout : NULL);
+}
+
+C_inline void C_prepare_fdset(int length) {
+  FD_ZERO(&C_fdset_input);
+  FD_ZERO(&C_fdset_output);
+}
+
+C_inline void C_fdset_add(int fd, int input, int output) {
+  if (input) FD_SET(fd, &C_fdset_input);
+  if (output) FD_SET(fd, &C_fdset_output);
+}
+
+#else
 #  include <poll.h>
 #  include <assert.h>
 
@@ -98,32 +124,6 @@ C_inline void C_fdset_add(int fd, int input, int output) {
   C_fdset_set[C_fdset_nfds].events = ((input ? POLLIN : 0) | (output ? POLLOUT : 0));
   C_fdset_set[C_fdset_nfds++].fd = fd;
 }
-
-#else
-
-/* Shouldn't we include <sys/select.h> here? */
-static fd_set C_fdset_input, C_fdset_output;
-
-#define C_fd_input_ready(fd,pos)  C_mk_bool(FD_ISSET(C_unfix(fd), &C_fdset_input))
-#define C_fd_output_ready(fd,pos)  C_mk_bool(FD_ISSET(C_unfix(fd), &C_fdset_output))
-
-C_inline int C_ready_fds_timeout(int to, double tm) {
-  struct timeval timeout;
-  timeout.tv_sec = tm / 1000;
-  timeout.tv_usec = fmod(tm, 1000) * 1000;
-  /* we use FD_SETSIZE, but really should use max fd */
-  return select(FD_SETSIZE, &C_fdset_input, &C_fdset_output, NULL, to ? &timeout : NULL);
-}
-
-C_inline void C_prepare_fdset(int length) {
-  FD_ZERO(&C_fdset_input);
-  FD_ZERO(&C_fdset_output);
-}
-
-C_inline void C_fdset_add(int fd, int input, int output) {
-  if (input) FD_SET(fd, &C_fdset_input);
-  if (output) FD_SET(fd, &C_fdset_output);
-}
 #endif
 EOF
 ) )
Trap