From 9e6e39c3512f7a962c44dc3729c98a0f8be90341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Wed, 8 Apr 2020 13:28:13 +0900 Subject: Merge pull request #2991 from shyouhei/ruby.h Split ruby.h --- hash.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'hash.c') diff --git a/hash.c b/hash.c index c416799c81..904289d188 100644 --- a/hash.c +++ b/hash.c @@ -11,7 +11,7 @@ **********************************************************************/ -#include "ruby/config.h" +#include "ruby/3/config.h" #include @@ -150,10 +150,12 @@ rb_hash(VALUE obj) unsigned long ul; sign = rb_integer_pack(hval, &ul, 1, sizeof(ul), 0, INTEGER_PACK_NATIVE_BYTE_ORDER); - ul &= (1UL << (sizeof(long)*CHAR_BIT-1)) - 1; - if (sign < 0) - return LONG2FIX(-(long)ul); - return LONG2FIX((long)ul); + if (sign < 0) { + hval = LONG2FIX(ul | FIXNUM_MIN); + } + else { + hval = LONG2FIX(ul & FIXNUM_MAX); + } } hval = rb_to_int(hval); } -- cgit v1.2.3