1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2018-10-03 04:37:43 +00:00
parent fb35457f77
commit 39c4aeec4c

View file

@ -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) & \