summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-03 04:37:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-03 04:37:43 +0000
commit39c4aeec4cf9f127ecb4b0cae92c58540fea6a7c (patch)
tree4e8c1a799164b9fc05d49a152390c4b8c2001c55
parentfb35457f77bfe5dbdeba62569de53ef38cbcbecd (diff)
Fix wrong use of BIGNUM_EMBED_LEN_NUMBITS
* internal.h (BIGNUM_EMBED_LEN_SHIFT): BIGNUM_EMBED_LEN_NUMBITS is the bit width of embedded bignum length, and BIGNUM_EMBED_LEN_SHIFT is the bit offset of it. These two values happened to equal by chance, however they are different things. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--internal.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/internal.h b/internal.h
index 7f9aaf6707..ff8bb6364e 100644
--- a/internal.h
+++ b/internal.h
@@ -625,8 +625,10 @@ struct RBignum {
#define BIGNUM_NEGATE(b) (RBASIC(b)->flags ^= BIGNUM_SIGN_BIT)
#define BIGNUM_EMBED_FLAG ((VALUE)FL_USER2)
-#define BIGNUM_EMBED_LEN_MASK ((VALUE)(FL_USER5|FL_USER4|FL_USER3))
-#define BIGNUM_EMBED_LEN_SHIFT (FL_USHIFT+BIGNUM_EMBED_LEN_NUMBITS)
+#define BIGNUM_EMBED_LEN_MASK \
+ (~(~(VALUE)0U << BIGNUM_EMBED_LEN_NUMBITS) << BIGNUM_EMBED_LEN_SHIFT)
+#define BIGNUM_EMBED_LEN_SHIFT \
+ (FL_USHIFT+3) /* bit offset of BIGNUM_EMBED_LEN_MASK */
#define BIGNUM_LEN(b) \
((RBASIC(b)->flags & BIGNUM_EMBED_FLAG) ? \
(size_t)((RBASIC(b)->flags >> BIGNUM_EMBED_LEN_SHIFT) & \