From b75c93507f147fa94fb1e53c23a2657d2bbade5c Mon Sep 17 00:00:00 2001 From: yugui Date: Sat, 20 Jun 2009 09:05:51 +0000 Subject: 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 --- ext/dl/cptr.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'ext/dl') 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 -- cgit