librelist archives

« back to archive

[PATCH 0/2] Ruby 1.8 fixes

[PATCH 0/2] Ruby 1.8 fixes

From:
Date:
2014-02-05 @ 07:56
gem install --pre -v 2.9.0.2.gf33a kgio

Eric Wong (2):
      only define and test kgio_syssend on 1.9+
      various 1.8.7 fixes

[PATCH 2/2] various 1.8.7 fixes

From:
Date:
2014-02-05 @ 07:56
From: Eric Wong <e@80x24.org>

Some errors in the code reorganization caused some compatibility
code to be dropped :x
---
 ext/kgio/kgio.h   |  6 ++++++
 ext/kgio/write.c  |  5 -----
 ext/kgio/writev.c | 11 +++++++++++
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/ext/kgio/kgio.h b/ext/kgio/kgio.h
index 4ccd7c2..6c5da5b 100644
--- a/ext/kgio/kgio.h
+++ b/ext/kgio/kgio.h
@@ -96,4 +96,10 @@ static inline void kgio_autopush_write(VALUE io) { }
 #else
 static inline void kgio_autopush_write(VALUE io) { kgio_autopush_send(io); }
 #endif
+
+/* prefer rb_str_subseq because we don't use negative offsets */
+#ifndef HAVE_RB_STR_SUBSEQ
+#define rb_str_subseq rb_str_substr
+#endif
+
 #endif /* KGIO_H */
diff --git a/ext/kgio/write.c b/ext/kgio/write.c
index ad34bdd..fa152d8 100644
--- a/ext/kgio/write.c
+++ b/ext/kgio/write.c
@@ -4,11 +4,6 @@
 #include "nonblock.h"
 static VALUE sym_wait_writable;
 
-/* prefer rb_str_subseq because we don't use negative offsets */
-#ifndef HAVE_RB_STR_SUBSEQ
-#define rb_str_subseq rb_str_substr
-#endif
-
 struct wr_args {
 	VALUE io;
 	VALUE buf;
diff --git a/ext/kgio/writev.c b/ext/kgio/writev.c
index a723b68..aafc6d8 100644
--- a/ext/kgio/writev.c
+++ b/ext/kgio/writev.c
@@ -19,6 +19,17 @@ static ssize_t assert_writev(int fd, void* iov, int len)
 }
 #  define writev assert_writev
 #endif
+
+#ifndef HAVE_RB_ARY_SUBSEQ
+static inline VALUE my_ary_subseq(VALUE ary, long idx, long len)
+{
+       VALUE args[2] = { LONG2FIX(idx), LONG2FIX(len) };
+
+       return rb_ary_aref(2, args, ary);
+}
+#define rb_ary_subseq my_ary_subseq
+#endif
+
 static VALUE sym_wait_writable;
 
 #ifndef HAVE_WRITEV
-- 
1.8.5.3.368.gab0bcec

[PATCH 1/2] only define and test kgio_syssend on 1.9+

From:
Date:
2014-02-05 @ 07:56
From: Eric Wong <e@80x24.org>

Reported-by: Christopher Rigor <crigor@gmail.com>
---
 ext/kgio/write.c     | 2 +-
 test/test_syssend.rb | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ext/kgio/write.c b/ext/kgio/write.c
index 04f2866..ad34bdd 100644
--- a/ext/kgio/write.c
+++ b/ext/kgio/write.c
@@ -261,7 +261,7 @@ void init_kgio_write(void)
 	rb_define_method(mSocketMethods, "kgio_write", kgio_send, 1);
 	rb_define_method(mSocketMethods, "kgio_trywrite", kgio_trysend, 1);
 
-#ifdef USE_MSG_DONTWAIT
+#if defined(KGIO_HAVE_THREAD_CALL_WITHOUT_GVL)
 	rb_define_method(mSocketMethods, "kgio_syssend", kgio_syssend, 2);
 #endif
 }
diff --git a/test/test_syssend.rb b/test/test_syssend.rb
index 5089ce3..7d2511a 100644
--- a/test/test_syssend.rb
+++ b/test/test_syssend.rb
@@ -40,4 +40,4 @@ class TestKgioSyssend < Test::Unit::TestCase
   ensure
     [ srv, acc, client ].each { |io| io.close if io }
   end
-end if RUBY_PLATFORM =~ /linux/
+end if RUBY_PLATFORM =~ /linux/ && Socket.const_defined?(:MSG_MORE)
-- 
1.8.5.3.368.gab0bcec