diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/dl/cptr.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ext/dl/cptr.c b/ext/dl/cptr.c index 3c08e68cd9..dbe93308be 100644 --- a/ext/dl/cptr.c +++ b/ext/dl/cptr.c @@ -317,10 +317,13 @@ rb_dlptr_eql(VALUE self, VALUE other) VALUE rb_dlptr_cmp(VALUE self, VALUE other) { - void *ptr1, *ptr2; - ptr1 = rb_dlptr2cptr(self); - ptr2 = rb_dlptr2cptr(other); - return PTR2NUM((long)ptr1 - (long)ptr2); + void *ptr1, *ptr2; + SIGNED_VALUE diff; + ptr1 = rb_dlptr2cptr(self); + ptr2 = rb_dlptr2cptr(other); + diff = (SIGNED_VALUE)ptr1 - (SIGNED_VALUE)ptr2; + if (!diff) return INT2FIX(0); + return diff > 0 ? INT2NUM(1) : INT2NUM(-1); } VALUE |