From fb3fa6aa4e3a27d5af763970ce25eb04a5102456 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 23 May 2009 09:48:54 +0000 Subject: [PATCH] * ext/dl/cptr.c (rb_dlptr_cmp): return signed value, and restrict to Fixnum. [ruby-dev:38533] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/dl/cptr.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c4ce83c06a..1b07be16ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat May 23 18:48:52 2009 Nobuyoshi Nakada + + * ext/dl/cptr.c (rb_dlptr_cmp): return signed value, and restric + to Fixnum. [ruby-dev:38533] + Fri May 22 23:22:53 2009 Yuki Sonoda (Yugui) * missing/vsnprintf.c (errno): [BUG] fixes a compilation diff --git a/ext/dl/cptr.c b/ext/dl/cptr.c index d2fa07771d..b7c27e9f9e 100644 --- a/ext/dl/cptr.c +++ b/ext/dl/cptr.c @@ -318,9 +318,12 @@ VALUE rb_dlptr_cmp(VALUE self, VALUE other) { void *ptr1, *ptr2; + SIGNED_VALUE diff; ptr1 = rb_dlptr2cptr(self); ptr2 = rb_dlptr2cptr(other); - return PTR2NUM((long)ptr1 - (long)ptr2); + diff = (SIGNED_VALUE)ptr1 - (SIGNED_VALUE)ptr2; + if (!diff) return INT2FIX(0); + return diff > 0 ? INT2NUM(1) : INT2NUM(-1); } VALUE