From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS47066 71.19.144.0/20 X-Spam-Status: No, score=-1.9 required=3.0 tests=AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: normalperson@yhbt.net Received: from zedshaw2.xen.prgmr.com (zedshaw2.xen.prgmr.com [71.19.156.177]) by dcvr.yhbt.net (Postfix) with ESMTP id 9010B1F5B6 for ; Thu, 25 Apr 2013 04:08:09 +0000 (UTC) Received: from zedshaw2.xen.prgmr.com (unknown [IPv6:::1]) by zedshaw2.xen.prgmr.com (Postfix) with ESMTP id 3050B73E2C for ; Thu, 25 Apr 2013 04:09:44 +0000 (UTC) MIME-Version: 1.0 Date: Thu, 25 Apr 2013 04:07:45 +0000 From: Eric Wong In-Reply-To: <1366862867-29521-1-git-send-email-normalperson@yhbt.net> List-Archive: List-Help: List-Id: List-Post: List-Subscribe: List-Unsubscribe: Message-Id: <1366862867-29521-1-git-send-email-normalperson@yhbt.net> Precedence: list References: <1366862867-29521-1-git-send-email-normalperson@yhbt.net> Sender: sleepy.penguin@librelist.org Subject: [sleepy.penguin] [PATCH 1/3] allow building without epoll (or inotify) support To: sleepy.penguin@librelist.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit From: EW We will support kqueue on FreeBSD-based systems. --- ext/sleepy_penguin/epoll.c | 5 +++++ ext/sleepy_penguin/extconf.rb | 2 +- ext/sleepy_penguin/init.c | 4 ++++ lib/sleepy_penguin.rb | 1 - test/test_epoll.rb | 2 +- test/test_epoll_io.rb | 2 +- test/test_inotify.rb | 2 +- 7 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ext/sleepy_penguin/epoll.c b/ext/sleepy_penguin/epoll.c index a6f86f8..d080ea5 100644 --- a/ext/sleepy_penguin/epoll.c +++ b/ext/sleepy_penguin/epoll.c @@ -1,4 +1,5 @@ #include "sleepy_penguin.h" +#ifdef HAVE_SYS_EPOLL_H #include #include #include @@ -348,4 +349,8 @@ void sleepy_penguin_init_epoll(void) if (RB_SP_GREEN_THREAD) rb_require("sleepy_penguin/epoll/io"); + + /* the high-level interface is implemented in Ruby: */ + rb_require("sleepy_penguin/epoll"); } +#endif /* HAVE_SYS_EPOLL_H */ diff --git a/ext/sleepy_penguin/extconf.rb b/ext/sleepy_penguin/extconf.rb index bd12570..12e1892 100644 --- a/ext/sleepy_penguin/extconf.rb +++ b/ext/sleepy_penguin/extconf.rb @@ -1,5 +1,5 @@ require 'mkmf' -have_header('sys/epoll.h') or abort 'sys/epoll.h not found' +have_header('sys/epoll.h') have_header('sys/eventfd.h') # it's impossible to use signalfd reliably with Ruby since Ruby currently diff --git a/ext/sleepy_penguin/init.c b/ext/sleepy_penguin/init.c index eb332bf..3195181 100644 --- a/ext/sleepy_penguin/init.c +++ b/ext/sleepy_penguin/init.c @@ -4,7 +4,11 @@ #define L1_CACHE_LINE_MAX 128 /* largest I've seen (Pentium 4) */ size_t rb_sp_l1_cache_line_size; +#ifdef HAVE_SYS_EPOLL_H void sleepy_penguin_init_epoll(void); +#else +# define sleepy_penguin_init_epoll() for(;0;) +#endif #ifdef HAVE_SYS_TIMERFD_H void sleepy_penguin_init_timerfd(void); diff --git a/lib/sleepy_penguin.rb b/lib/sleepy_penguin.rb index 60e8750..17f134e 100644 --- a/lib/sleepy_penguin.rb +++ b/lib/sleepy_penguin.rb @@ -5,7 +5,6 @@ module SleepyPenguin SLEEPY_PENGUIN_VERSION = '3.1.0' end require 'sleepy_penguin_ext' -require 'sleepy_penguin/epoll' # We need to serialize Inotify#take for Rubinius since that has no GVL # to protect the internal array diff --git a/test/test_epoll.rb b/test/test_epoll.rb index a55a4c3..7c648ff 100644 --- a/test/test_epoll.rb +++ b/test/test_epoll.rb @@ -545,4 +545,4 @@ def test_epoll_as_queue end @ep.wait(1) { |flags, io| assert_equal(first[0], io) } end -end +end if defined?(SleepyPenguin::Epoll) diff --git a/test/test_epoll_io.rb b/test/test_epoll_io.rb index 8aca155..a899e0d 100644 --- a/test/test_epoll_io.rb +++ b/test/test_epoll_io.rb @@ -21,4 +21,4 @@ def test_add_wait @epio.epoll_wait { |events, obj| ev << [ events, obj ] } assert_equal([[Epoll::OUT, @wr]], ev) end -end +end if defined?(SleepyPenguin::Epoll) diff --git a/test/test_inotify.rb b/test/test_inotify.rb index ae6b8ba..f1b257a 100644 --- a/test/test_inotify.rb +++ b/test/test_inotify.rb @@ -107,4 +107,4 @@ def test_each end assert_equal 0, nr end -end +end if defined?(SleepyPenguin::Inotify) -- 1.8.2.1.367.gc875ca7