summaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-23 09:48:54 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-23 09:48:54 +0000
commitff7a293dbd10cb8d17847a61c348b17fea0ba001 (patch)
tree22dc6b9959cd9e405f0aeb230ecb1df9cd1d8a90 /ext
parent3afe82becf948b9b076ac513f3b3cb3524f73886 (diff)
downloadruby-ff7a293dbd10cb8d17847a61c348b17fea0ba001.tar.gz
ruby-ff7a293dbd10cb8d17847a61c348b17fea0ba001.tar.xz
ruby-ff7a293dbd10cb8d17847a61c348b17fea0ba001.zip
* ext/dl/cptr.c (rb_dlptr_cmp): return signed value, and restrict
to Fixnum. [ruby-dev:38533] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/dl/cptr.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/ext/dl/cptr.c b/ext/dl/cptr.c
index d2fa07771..b7c27e9f9 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