ruby-changes:29104
From: akr <ko1@a...>
Date: Sat, 8 Jun 2013 06:01:53 +0900 (JST)
Subject: [ruby-changes:29104] akr:r41156 (trunk): * random.c: include internal.h.
akr 2013-06-08 06:01:42 +0900 (Sat, 08 Jun 2013) New Revision: 41156 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41156 Log: * random.c: include internal.h. (mt_state): Use rb_integer_unpack. Modified files: trunk/ChangeLog trunk/common.mk trunk/random.c Index: ChangeLog =================================================================== --- ChangeLog (revision 41155) +++ ChangeLog (revision 41156) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Jun 8 06:00:47 2013 Tanaka Akira <akr@f...> + + * random.c: include internal.h. + (mt_state): Use rb_integer_unpack. + Sat Jun 8 00:55:51 2013 Tanaka Akira <akr@f...> * bignum.c (integer_pack_loop_setup): word_num_nailbytes_ret argument Index: common.mk =================================================================== --- common.mk (revision 41155) +++ common.mk (revision 41156) @@ -717,7 +717,7 @@ process.$(OBJEXT): {$(VPATH)}process.c $ https://github.com/ruby/ruby/blob/trunk/common.mk#L717 $(VM_CORE_H_INCLUDES) {$(VPATH)}internal.h \ {$(VPATH)}thread.h {$(VPATH)}vm_opts.h random.$(OBJEXT): {$(VPATH)}random.c $(RUBY_H_INCLUDES) \ - {$(VPATH)}siphash.c {$(VPATH)}siphash.h + {$(VPATH)}siphash.c {$(VPATH)}siphash.h {$(VPATH)}internal.h range.$(OBJEXT): {$(VPATH)}range.c $(RUBY_H_INCLUDES) \ $(ENCODING_H_INCLUDES) {$(VPATH)}internal.h {$(VPATH)}id.h rational.$(OBJEXT): {$(VPATH)}rational.c $(RUBY_H_INCLUDES) {$(VPATH)}internal.h $(hdrdir)/ruby.h Index: random.c =================================================================== --- random.c (revision 41155) +++ random.c (revision 41156) @@ -60,6 +60,7 @@ The original copyright notice follows. https://github.com/ruby/ruby/blob/trunk/random.c#L60 */ #include "ruby/ruby.h" +#include "internal.h" #include <limits.h> #ifdef HAVE_UNISTD_H @@ -617,23 +618,9 @@ random_copy(VALUE obj, VALUE orig) https://github.com/ruby/ruby/blob/trunk/random.c#L618 static VALUE mt_state(const struct MT *mt) { - VALUE bigo = rb_big_new(sizeof(mt->state) / sizeof(BDIGIT), 1); - BDIGIT *d = RBIGNUM_DIGITS(bigo); - int i; - - for (i = 0; i < numberof(mt->state); ++i) { - unsigned int x = mt->state[i]; -#if SIZEOF_BDIGITS < SIZEOF_INT32 - int j; - for (j = 0; j < SIZEOF_INT32 / SIZEOF_BDIGITS; ++j) { - *d++ = BIGLO(x); - x = BIGDN(x); - } -#else - *d++ = (BDIGIT)x; -#endif - } - return rb_big_norm(bigo); + return rb_integer_unpack(1, mt->state, numberof(mt->state), + sizeof(*mt->state), 0, + INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER); } /* :nodoc: */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/