diff options
| author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-20 09:05:51 +0000 |
|---|---|---|
| committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-20 09:05:51 +0000 |
| commit | b75c93507f147fa94fb1e53c23a2657d2bbade5c (patch) | |
| tree | 95176c800aaaee172f5f25d4405eb0b0866f46b0 /ext/dl | |
| parent | e79df8fa214689259763e250e77bc88502408085 (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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@23756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl')
| -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 3c08e68cd..dbe93308b 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 |
