sleepy_penguin RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [PATCH] drop unused Ruby 1.8 support code
@ 2017-03-16 20:12 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2017-03-16 20:12 UTC (permalink / raw)
  To: sleepy-penguin

Ruby 1.8 is long dead and we already broke 1.9 support by using
keyword args for splice, sendfile, and copy_file_range support.
---
 ext/sleepy_penguin/epoll.c          |  3 ---
 ext/sleepy_penguin/eventfd.c        |  7 +++++--
 ext/sleepy_penguin/inotify.c        |  2 --
 ext/sleepy_penguin/kqueue.c         |  3 ---
 ext/sleepy_penguin/sleepy_penguin.h | 29 +----------------------------
 ext/sleepy_penguin/timerfd.c        |  2 --
 lib/sleepy_penguin/epoll/io.rb      | 31 -------------------------------
 lib/sleepy_penguin/kqueue/io.rb     | 30 ------------------------------
 sleepy_penguin.gemspec              |  2 +-
 9 files changed, 7 insertions(+), 102 deletions(-)
 delete mode 100644 lib/sleepy_penguin/epoll/io.rb
 delete mode 100644 lib/sleepy_penguin/kqueue/io.rb

diff --git a/ext/sleepy_penguin/epoll.c b/ext/sleepy_penguin/epoll.c
index 512e11c..50a3a6f 100644
--- a/ext/sleepy_penguin/epoll.c
+++ b/ext/sleepy_penguin/epoll.c
@@ -329,9 +329,6 @@ void sleepy_penguin_init_epoll(void)
 
 	id_for_fd = rb_intern("for_fd");
 
-	if (RB_SP_GREEN_THREAD)
-		rb_require("sleepy_penguin/epoll/io");
-
 	/* the high-level interface is implemented in Ruby: */
 	rb_require("sleepy_penguin/epoll");
 }
diff --git a/ext/sleepy_penguin/eventfd.c b/ext/sleepy_penguin/eventfd.c
index 4804150..1cb2c4e 100644
--- a/ext/sleepy_penguin/eventfd.c
+++ b/ext/sleepy_penguin/eventfd.c
@@ -82,7 +82,9 @@ static VALUE incr(int argc, VALUE *argv, VALUE self)
 
 	rb_scan_args(argc, argv, "11", &value, &nonblock);
 	x.fd = rb_sp_fileno(self);
-	RTEST(nonblock) ? rb_sp_set_nonblock(x.fd) : blocking_io_prepare(x.fd);
+	if (RTEST(nonblock))
+		rb_sp_set_nonblock(x.fd);
+
 	x.val = (uint64_t)NUM2ULL(value);
 retry:
 	w = (ssize_t)rb_sp_fd_region(efd_write, &x, x.fd);
@@ -119,7 +121,8 @@ static VALUE getvalue(int argc, VALUE *argv, VALUE self)
 
 	rb_scan_args(argc, argv, "01", &nonblock);
 	x.fd = rb_sp_fileno(self);
-	RTEST(nonblock) ? rb_sp_set_nonblock(x.fd) : blocking_io_prepare(x.fd);
+	if (RTEST(nonblock))
+		rb_sp_set_nonblock(x.fd);
 retry:
 	w = (ssize_t)rb_sp_fd_region(efd_read, &x, x.fd);
 	if (w < 0) {
diff --git a/ext/sleepy_penguin/inotify.c b/ext/sleepy_penguin/inotify.c
index 56fcff2..ebc1f65 100644
--- a/ext/sleepy_penguin/inotify.c
+++ b/ext/sleepy_penguin/inotify.c
@@ -236,8 +236,6 @@ static VALUE take(int argc, VALUE *argv, VALUE self)
 
 	if (args.nonblock_p)
 		rb_sp_set_nonblock(args.fd);
-	else
-		blocking_io_prepare(args.fd);
 
 	args.buf = 0;
 	return rb_ensure(do_take, (VALUE)&args,
diff --git a/ext/sleepy_penguin/kqueue.c b/ext/sleepy_penguin/kqueue.c
index 22a2c5d..c368514 100644
--- a/ext/sleepy_penguin/kqueue.c
+++ b/ext/sleepy_penguin/kqueue.c
@@ -657,9 +657,6 @@ void sleepy_penguin_init_kqueue(void)
 
 	id_for_fd = rb_intern("for_fd");
 
-	if (RB_SP_GREEN_THREAD)
-		rb_require("sleepy_penguin/kqueue/io");
-
 	/* the high-level interface is implemented in Ruby: */
 	rb_require("sleepy_penguin/kqueue");
 
diff --git a/ext/sleepy_penguin/sleepy_penguin.h b/ext/sleepy_penguin/sleepy_penguin.h
index bd44e18..7b2074a 100644
--- a/ext/sleepy_penguin/sleepy_penguin.h
+++ b/ext/sleepy_penguin/sleepy_penguin.h
@@ -19,16 +19,6 @@ int rb_sp_io_closed(VALUE io);
 int rb_sp_fileno(VALUE io);
 void rb_sp_set_nonblock(int fd);
 
-#if defined(HAVE_RB_THREAD_BLOCKING_REGION) || \
-    defined(HAVE_RB_THREAD_IO_BLOCKING_REGION) || \
-    defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL)
-#  define RB_SP_GREEN_THREAD 0
-#  define blocking_io_prepare(fd) ((void)(fd))
-#else
-#  define RB_SP_GREEN_THREAD 1
-#  define blocking_io_prepare(fd) rb_sp_set_nonblock((fd))
-#endif
-
 #ifdef HAVE_RB_THREAD_IO_BLOCKING_REGION
 /* Ruby 1.9.3 and 2.0.0 */
 VALUE rb_thread_io_blocking_region(rb_blocking_function_t *, void *, int);
@@ -46,24 +36,7 @@ VALUE rb_thread_io_blocking_region(rb_blocking_function_t *, void *, int);
 #  define rb_sp_fd_region(fn,data,fd) \
 	rb_thread_blocking_region((fn),(data),RUBY_UBF_IO,NULL)
 #else
-/*
- * Ruby 1.8 does not have a GVL, we'll just enable signal interrupts
- * here in case we make interruptible syscalls.
- *
- * Note: epoll_wait with timeout=0 was interruptible until Linux 2.6.39
- */
-#  include <rubysig.h>
-static inline VALUE fake_blocking_region(VALUE (*fn)(void *), void *data)
-{
-	VALUE rv;
-
-	TRAP_BEG;
-	rv = fn(data);
-	TRAP_END;
-
-	return rv;
-}
-#  define rb_sp_fd_region(fn,data,fd) fake_blocking_region((fn),(data))
+#  error Ruby <= 1.8 not supported
 #endif
 
 #define NODOC_CONST(klass,name,value) \
diff --git a/ext/sleepy_penguin/timerfd.c b/ext/sleepy_penguin/timerfd.c
index e3af46c..7957802 100644
--- a/ext/sleepy_penguin/timerfd.c
+++ b/ext/sleepy_penguin/timerfd.c
@@ -120,8 +120,6 @@ static VALUE expirations(int argc, VALUE *argv, VALUE self)
 	rb_scan_args(argc, argv, "01", &nonblock);
 	if (RTEST(nonblock))
 		rb_sp_set_nonblock(fd);
-	else
-		blocking_io_prepare(fd);
 retry:
 	r = (ssize_t)rb_sp_fd_region(tfd_read, &buf, fd);
 	if (r < 0) {
diff --git a/lib/sleepy_penguin/epoll/io.rb b/lib/sleepy_penguin/epoll/io.rb
deleted file mode 100644
index 055f574..0000000
--- a/lib/sleepy_penguin/epoll/io.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-class SleepyPenguin::Epoll::IO
-  # :stopdoc:
-
-  # This is only for Ruby 1.8 using green threads
-
-  alias __epoll_wait epoll_wait
-  undef_method :epoll_wait
-  def epoll_wait(maxevents = 64, timeout = nil)
-    begin
-      if timeout == nil || timeout < 0 # wait forever
-        begin
-          IO.select([self])
-          n = __epoll_wait(maxevents, 0) { |events,io| yield(events, io) }
-        end while n == 0
-      elsif timeout == 0
-        return __epoll_wait(maxevents, 0) { |events,io| yield(events, io) }
-      else
-        done = Time.now + (timeout / 1000.0)
-        begin
-          tout = done - Time.now
-          IO.select([self], nil, nil, tout) if tout > 0
-          n = __epoll_wait(maxevents, 0) { |events,io| yield(events, io) }
-        end while n == 0 && tout > 0
-      end
-      n
-    rescue Errno::EINTR
-      retry
-    end
-  end
-  # :startdoc:
-end
diff --git a/lib/sleepy_penguin/kqueue/io.rb b/lib/sleepy_penguin/kqueue/io.rb
deleted file mode 100644
index 15502d4..0000000
--- a/lib/sleepy_penguin/kqueue/io.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-class SleepyPenguin::Kqueue::IO
-  # :stopdoc:
-  # this file is only for Ruby 1.8 green threads compatibility
-  alias __kevent kevent
-  undef_method :kevent
-
-  def __update_timeout(expire_at)
-    now = Time.now
-    diff = expire_at - now
-    diff > 0 ? diff : 0
-  end
-
-  def kevent(changelist = nil, nevents = nil, timeout = nil)
-    if block_given?
-      expire_at = timeout ? Time.now + timeout : nil
-      begin
-        IO.select([self], nil, nil, timeout)
-        n = __kevent(changelist, nevents, 0) do |*args|
-          yield(*args)
-        end
-      end while n == 0 && timeout != 0 &&
-                (expire_at == nil || timeout = __update_timeout(expire_at))
-      n
-    else
-      # nevents should be zero or nil here
-      __kevent(changelist, nevents, 0)
-    end
-  end
-  # :startdoc:
-end
diff --git a/sleepy_penguin.gemspec b/sleepy_penguin.gemspec
index 9032fdd..46a0036 100644
--- a/sleepy_penguin.gemspec
+++ b/sleepy_penguin.gemspec
@@ -19,6 +19,6 @@
   s.add_development_dependency('test-unit', '~> 3.0')
   s.add_development_dependency('olddoc', '~> 1.0')
   s.add_development_dependency('strace_me', '~> 1.0')
-
+  s.required_ruby_version = '>= 2.0'
   s.licenses = %w(LGPL-2.1+)
 end
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-03-16 20:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-16 20:12 [PATCH] drop unused Ruby 1.8 support code 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).