From: Eric Wong <normalperson@yhbt.net>
To: sleepy.penguin@librelist.org
Subject: [sleepy.penguin] [PATCH 1/3] allow building without epoll (or inotify) support
Date: Thu, 25 Apr 2013 04:07:45 +0000 [thread overview]
Message-ID: <1366862867-29521-1-git-send-email-normalperson@yhbt.net> (raw)
In-Reply-To: <1366862867-29521-1-git-send-email-normalperson@yhbt.net>
From: EW <ew@fbsd90-32.(none)>
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 <sys/epoll.h>
#include <unistd.h>
#include <time.h>
@@ -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
next parent reply other threads:[~2013-04-25 4:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-25 4:07 Eric Wong [this message]
2013-04-25 4:07 ` [sleepy.penguin] [PATCH 2/3] pkg.mk: allow passing arguments to extconf Eric Wong
2013-04-25 4:07 ` [sleepy.penguin] [PATCH 3/3] preliminary kqueue support Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/sleepy_penguin/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1366862867-29521-1-git-send-email-normalperson@yhbt.net \
--to=normalperson@yhbt.net \
--cc=sleepy.penguin@librelist.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/sleepy_penguin.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).