aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-15 03:49:21 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-15 03:49:21 +0000
commit377169d0d0527537322167920e38444728e6b21d (patch)
treeecbe2bb6a6c905833c14bb32eee5710ce90bc451 /io.c
parent416be9b2d0c04256b543176469b1cfe48a4a8b96 (diff)
downloadruby-377169d0d0527537322167920e38444728e6b21d.tar.gz
thread.c: enable ppoll for FreeBSD 11.0 and later
FreeBSD 11.0+ supports ppoll, so we may use it after accounting for portability differences in how it treats POLLOUT vs POLLHUP events as mutually exclusive (as documented in the FreeBSD poll(2) manpage). For waiting on high-numbered single FDs, this should put FreeBSD on equal footing with Linux and should allow cheaper FD readiness checking with sleepy GC in the future. * thread.c (USE_POLL, POLLERR_SET): define for FreeBSD 11.0+ (rb_wait_for_single_fd): return all requested events on POLLERR_SET io.c (USE_POLL): define for FreeBSD 11.0+ git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/io.c b/io.c
index 4c724e6166..4c01726c4c 100644
--- a/io.c
+++ b/io.c
@@ -10643,15 +10643,21 @@ maygvl_copy_stream_continue_p(int has_gvl, struct copy_stream_struct *stp)
}
/* non-Linux poll may not work on all FDs */
-#if defined(HAVE_POLL) && defined(__linux__)
-# define USE_POLL 1
-# define IOWAIT_SYSCALL "poll"
-#else
-# define IOWAIT_SYSCALL "select"
+#if defined(HAVE_POLL)
+# if defined(__linux__)
+# define USE_POLL 1
+# endif
+# if defined(__FreeBSD_version) && __FreeBSD_version >= 1100000
+# define USE_POLL 1
+# endif
+#endif
+
+#ifndef USE_POLL
# define USE_POLL 0
#endif
#if USE_POLL
+# define IOWAIT_SYSCALL "poll"
STATIC_ASSERT(pollin_expected, POLLIN == RB_WAITFD_IN);
STATIC_ASSERT(pollout_expected, POLLOUT == RB_WAITFD_OUT);
static int
@@ -10665,6 +10671,7 @@ nogvl_wait_for_single_fd(int fd, short events)
return poll(&fds, 1, -1);
}
#else /* !USE_POLL */
+# define IOWAIT_SYSCALL "select"
static int
nogvl_wait_for_single_fd(int fd, short events)
{