summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-04-08 13:28:13 +0900
committerGitHub <noreply@github.com>2020-04-08 13:28:13 +0900
commit9e6e39c3512f7a962c44dc3729c98a0f8be90341 (patch)
tree901a22676d54d78240e450b64a8cd06eb1703910 /hash.c
parent5ac4bf2cd87e1eb5779ca5ae7f96a1a22e8436d9 (diff)
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
Notes
Notes: Merged-By: shyouhei <shyouhei@ruby-lang.org>
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c12
1 files changed, 7 insertions, 5 deletions
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 <errno.h>
@@ -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);
}