From 39c4aeec4cf9f127ecb4b0cae92c58540fea6a7c Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 3 Oct 2018 04:37:43 +0000 Subject: [PATCH] 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 --- internal.h | 6 ++++-- 1 file 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) & \