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

ruby-changes:42847

From: nobu <ko1@a...>
Date: Thu, 5 May 2016 23:03:32 +0900 (JST)
Subject: [ruby-changes:42847] nobu:r54920 (trunk): random.c: use uint32_t

nobu	2016-05-06 00:00:05 +0900 (Fri, 06 May 2016)

  New Revision: 54920

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

  Log:
    random.c: use uint32_t
    
    * random.c (struct MT, next_state): use uint32_t for the state
      vector.
    
    * random.c (init_by_array, rand_init): ditto for initializing
      keys.

  Modified files:
    trunk/random.c
Index: random.c
===================================================================
--- random.c	(revision 54919)
+++ random.c	(revision 54920)
@@ -104,8 +104,8 @@ enum {MT_MAX_STATE = N}; https://github.com/ruby/ruby/blob/trunk/random.c#L104
 
 struct MT {
     /* assume int is enough to store 32bits */
-    unsigned int state[N]; /* the array for the state vector  */
-    unsigned int *next;
+    uint32_t state[N]; /* the array for the state vector  */
+    uint32_t *next;
     int left;
 };
 
@@ -135,7 +135,7 @@ init_genrand(struct MT *mt, unsigned int https://github.com/ruby/ruby/blob/trunk/random.c#L135
 /* key_length is its length */
 /* slight change for C++, 2004/2/26 */
 static void
-init_by_array(struct MT *mt, unsigned int init_key[], int key_length)
+init_by_array(struct MT *mt, uint32_t init_key[], int key_length)
 {
     int i, j, k;
     init_genrand(mt, 19650218U);
@@ -163,7 +163,7 @@ init_by_array(struct MT *mt, unsigned in https://github.com/ruby/ruby/blob/trunk/random.c#L163
 static void
 next_state(struct MT *mt)
 {
-    unsigned int *p = mt->state;
+    uint32_t *p = mt->state;
     int j;
 
     mt->left = N;
@@ -391,7 +391,7 @@ rand_init(struct MT *mt, VALUE vseed) https://github.com/ruby/ruby/blob/trunk/random.c#L391
 
     len = rb_absint_numwords(seed, 32, NULL);
     if (len > numberof(buf0))
-        buf = ALLOC_N(unsigned int, len);
+        buf = ALLOC_N(uint32_t, len);
     sign = rb_integer_pack(seed, buf, len, sizeof(uint32_t), 0,
         INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER);
     if (sign < 0)

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

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