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