sleepy_penguin RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [sleepy.penguin] [PATCH 1/3] allow building without epoll (or inotify) support
@ 2013-04-25  4:07 Eric Wong
  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
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2013-04-25  4:07 UTC (permalink / raw)
  To: sleepy.penguin

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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-04-25  4:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-25  4:07 [sleepy.penguin] [PATCH 1/3] allow building without epoll (or inotify) support Eric Wong
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

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).