summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-20 09:05:51 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-20 09:05:51 +0000
commit972e0b2b31da33e4a5c7e731d5cc64ed337fcc1a (patch)
tree95176c800aaaee172f5f25d4405eb0b0866f46b0 /ext
parent66be715498b22fec1fc30002948392f6320094b3 (diff)
merges r23549 from trunk into ruby_1_9_1.
-- * 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/branches/ruby_1_9_1@23756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/dl/cptr.c11
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