[前][次][番号順一覧][スレッド一覧]

ruby-changes:52692

From: nobu <ko1@a...>
Date: Wed, 3 Oct 2018 13:37:48 +0900 (JST)
Subject: [ruby-changes:52692] nobu:r64904 (trunk): Fix wrong use of BIGNUM_EMBED_LEN_NUMBITS

nobu	2018-10-03 13:37:43 +0900 (Wed, 03 Oct 2018)

  New Revision: 64904

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64904

  Log:
    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.

  Modified files:
    trunk/internal.h
Index: internal.h
===================================================================
--- internal.h	(revision 64903)
+++ internal.h	(revision 64904)
@@ -625,8 +625,10 @@ struct RBignum { https://github.com/ruby/ruby/blob/trunk/internal.h#L625
 #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) & \

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]