ruby-changes:31739
From: akr <ko1@a...>
Date: Sat, 23 Nov 2013 22:25:43 +0900 (JST)
Subject: [ruby-changes:31739] akr:r43818 (trunk): * include/ruby/ruby.h (RBIGNUM_EMBED_LEN_MAX): Limit the value to
akr 2013-11-23 22:25:36 +0900 (Sat, 23 Nov 2013) New Revision: 43818 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43818 Log: * include/ruby/ruby.h (RBIGNUM_EMBED_LEN_MAX): Limit the value to less than 8. Modified files: trunk/ChangeLog trunk/include/ruby/ruby.h Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 43817) +++ include/ruby/ruby.h (revision 43818) @@ -1067,8 +1067,11 @@ struct RStruct { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1067 #define RSTRUCT_SET(st, idx, v) OBJ_WRITE(st, &RSTRUCT_CONST_PTR(st)[idx], (v)) #define RSTRUCT_GET(st, idx) (RSTRUCT_CONST_PTR(st)[idx]) +#define RBIGNUM_EMBED_LEN_NUMBITS 3 #ifndef RBIGNUM_EMBED_LEN_MAX -# define RBIGNUM_EMBED_LEN_MAX ((int)((sizeof(VALUE)*3)/sizeof(BDIGIT))) +# define RBIGNUM_EMBED_LEN_MAX \ + (((int)((sizeof(VALUE)*3)/sizeof(BDIGIT))) < (1 << RBIGNUM_EMBED_LEN_NUMBITS)-1 ? \ + ((int)((sizeof(VALUE)*3)/sizeof(BDIGIT))) : (1 << RBIGNUM_EMBED_LEN_NUMBITS)-1) #endif struct RBignum { struct RBasic basic; @@ -1091,7 +1094,7 @@ struct RBignum { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1094 #define RBIGNUM_EMBED_FLAG FL_USER2 #define RBIGNUM_EMBED_LEN_MASK (FL_USER5|FL_USER4|FL_USER3) -#define RBIGNUM_EMBED_LEN_SHIFT (FL_USHIFT+3) +#define RBIGNUM_EMBED_LEN_SHIFT (FL_USHIFT+RBIGNUM_EMBED_LEN_NUMBITS) #define RBIGNUM_LEN(b) \ ((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? \ (long)((RBASIC(b)->flags >> RBIGNUM_EMBED_LEN_SHIFT) & \ Index: ChangeLog =================================================================== --- ChangeLog (revision 43817) +++ ChangeLog (revision 43818) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Nov 23 22:22:26 2013 Tanaka Akira <akr@f...> + + * include/ruby/ruby.h (RBIGNUM_EMBED_LEN_MAX): Limit the value to + less than 8. + Sat Nov 23 19:52:00 2013 Kenta Murata <mrkn@m...> * ext/bigdecimal/lib/bigdecimal/math.rb (BigMath.E): Use BigMath.exp. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/