* [sleepy.penguin] [PATCH 1/3] test_epoll: minor compatibility fix for Ruby 2.1.0
@ 2013-09-26 21:39 Eric Wong
2013-09-26 21:39 ` [sleepy.penguin] [PATCH 2/3] avoid RARRAY_PTR usage for Linux-only bits Eric Wong
2013-09-26 21:40 ` [sleepy.penguin] [PATCH 3/3] init: avoid redefinition warning for _GNU_SOURCE Eric Wong
0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2013-09-26 21:39 UTC (permalink / raw)
To: sleepy.penguin
Ruby 2.1.0 raises a subclass of Errno::EINPROGRESS, which fails the
exact matching of assert_raises. This does not affect any known
real code.
---
test/test_epoll.rb | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/test/test_epoll.rb b/test/test_epoll.rb
index 4b4437a..9f6cf85 100644
--- a/test/test_epoll.rb
+++ b/test/test_epoll.rb
@@ -87,7 +87,12 @@ class TestEpoll < Test::Unit::TestCase
port = srv.addr[1]
addr = Socket.pack_sockaddr_in(port, host)
sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
- assert_raises(Errno::EINPROGRESS) { sock.connect_nonblock(addr) }
+ begin
+ sock.connect_nonblock(addr)
+ exc = nil
+ rescue Errno::EINPROGRESS => exc
+ end
+ assert_kind_of Errno::EINPROGRESS, exc
IO.select(nil, [ sock ], [sock ])
@ep.add(sock, epflags)
tmp = []
--
1.8.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [sleepy.penguin] [PATCH 2/3] avoid RARRAY_PTR usage for Linux-only bits
2013-09-26 21:39 [sleepy.penguin] [PATCH 1/3] test_epoll: minor compatibility fix for Ruby 2.1.0 Eric Wong
@ 2013-09-26 21:39 ` Eric Wong
2013-09-26 21:40 ` [sleepy.penguin] [PATCH 3/3] init: avoid redefinition warning for _GNU_SOURCE Eric Wong
1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2013-09-26 21:39 UTC (permalink / raw)
To: sleepy.penguin
RARRAY_PTR incurs extra overhead on the Ruby 2.1.0 and Rubinius
GC implementations, so avoid it. None of these are believed
to be performance-critical enough to benefit from RARRAY_PTR
in older Rubies, either.
---
ext/sleepy_penguin/inotify.c | 8 ++++----
ext/sleepy_penguin/signalfd.c | 6 +++---
ext/sleepy_penguin/util.c | 12 ++++++------
3 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/ext/sleepy_penguin/inotify.c b/ext/sleepy_penguin/inotify.c
index 4e771a2..5771030 100644
--- a/ext/sleepy_penguin/inotify.c
+++ b/ext/sleepy_penguin/inotify.c
@@ -255,15 +255,15 @@ static VALUE take(int argc, VALUE *argv, VALUE self)
static VALUE events(VALUE self)
{
long len = RARRAY_LEN(checks);
- VALUE *ptr = RARRAY_PTR(checks);
+ long i;
VALUE sym;
VALUE rv = rb_ary_new();
uint32_t mask;
uint32_t event_mask = NUM2UINT(rb_funcall(self, id_mask, 0));
- for (; (len -= 2) >= 0;) {
- sym = *ptr++;
- mask = NUM2UINT(*ptr++);
+ for (i = 0; i < len; ) {
+ sym = rb_ary_entry(checks, i++);
+ mask = NUM2UINT(rb_ary_entry(checks, i++));
if ((event_mask & mask) == mask)
rb_ary_push(rv, sym);
}
diff --git a/ext/sleepy_penguin/signalfd.c b/ext/sleepy_penguin/signalfd.c
index 511745c..ebd6c86 100644
--- a/ext/sleepy_penguin/signalfd.c
+++ b/ext/sleepy_penguin/signalfd.c
@@ -44,11 +44,11 @@ static void value2sigset(sigset_t *mask, VALUE set)
switch (TYPE(set)) {
case T_NIL: return;
case T_ARRAY: {
- VALUE *ptr = RARRAY_PTR(set);
+ long i;
long len = RARRAY_LEN(set);
- while (--len >= 0)
- sigaddset(mask, sig2int(*ptr++));
+ for (i = 0; i < len; i++)
+ sigaddset(mask, sig2int(rb_ary_entry(set, i)));
}
break;
default:
diff --git a/ext/sleepy_penguin/util.c b/ext/sleepy_penguin/util.c
index 11a1b13..717a099 100644
--- a/ext/sleepy_penguin/util.c
+++ b/ext/sleepy_penguin/util.c
@@ -14,13 +14,13 @@ int rb_sp_get_flags(VALUE klass, VALUE flags, int default_flags)
case T_SYMBOL:
return NUM2INT(rb_const_get(klass_for(klass), SYM2ID(flags)));
case T_ARRAY: {
- VALUE *ptr = RARRAY_PTR(flags);
+ long i;
long len = RARRAY_LEN(flags);
int rv = 0;
klass = klass_for(klass);
- while (--len >= 0) {
- VALUE tmp = *ptr++;
+ for (i = 0; i < len; i++) {
+ VALUE tmp = rb_ary_entry(flags, i);
Check_Type(tmp, T_SYMBOL);
tmp = rb_const_get(klass, SYM2ID(tmp));
@@ -42,13 +42,13 @@ unsigned rb_sp_get_uflags(VALUE klass, VALUE flags)
case T_SYMBOL:
return NUM2UINT(rb_const_get(klass_for(klass), SYM2ID(flags)));
case T_ARRAY: {
- VALUE *ptr = RARRAY_PTR(flags);
+ long i;
long len = RARRAY_LEN(flags);
unsigned rv = 0;
klass = klass_for(klass);
- while (--len >= 0) {
- VALUE tmp = *ptr++;
+ for (i = 0; i < len; i++) {
+ VALUE tmp = rb_ary_entry(flags, i);
Check_Type(tmp, T_SYMBOL);
tmp = rb_const_get(klass, SYM2ID(tmp));
--
1.8.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [sleepy.penguin] [PATCH 3/3] init: avoid redefinition warning for _GNU_SOURCE
2013-09-26 21:39 [sleepy.penguin] [PATCH 1/3] test_epoll: minor compatibility fix for Ruby 2.1.0 Eric Wong
2013-09-26 21:39 ` [sleepy.penguin] [PATCH 2/3] avoid RARRAY_PTR usage for Linux-only bits Eric Wong
@ 2013-09-26 21:40 ` Eric Wong
1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2013-09-26 21:40 UTC (permalink / raw)
To: sleepy.penguin
This is already defined for most (if not all) Rubies when ruby.h
is included.
---
ext/sleepy_penguin/init.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/ext/sleepy_penguin/init.c b/ext/sleepy_penguin/init.c
index 9b4f31c..90eddbd 100644
--- a/ext/sleepy_penguin/init.c
+++ b/ext/sleepy_penguin/init.c
@@ -1,5 +1,8 @@
-#define _GNU_SOURCE
#include <ruby.h>
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE /* TODO: confirm this is needed */
+#endif
+
#include <unistd.h>
#include <sys/types.h>
#include "git_version.h"
--
1.8.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-09-26 21:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-26 21:39 [sleepy.penguin] [PATCH 1/3] test_epoll: minor compatibility fix for Ruby 2.1.0 Eric Wong
2013-09-26 21:39 ` [sleepy.penguin] [PATCH 2/3] avoid RARRAY_PTR usage for Linux-only bits Eric Wong
2013-09-26 21:40 ` [sleepy.penguin] [PATCH 3/3] init: avoid redefinition warning for _GNU_SOURCE 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).