summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-07 21:01:42 (GMT)
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-07 21:01:42 (GMT)
commit8bc16423cc6c5a85b0ec36575c869409a843bf28 (patch)
treed12e0b9cc48db9e55079ce0c4064a8af70e03db6 /random.c
parent8ce912bdb3554ea7bd75c360dbaac39a29c61c35 (diff)
* random.c: include internal.h.
(mt_state): Use rb_integer_unpack. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r--random.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/random.c b/random.c
index 04fc325..4b43773 100644
--- a/random.c
+++ b/random.c
@@ -60,6 +60,7 @@ The original copyright notice follows.
*/
#include "ruby/ruby.h"
+#include "internal.h"
#include <limits.h>
#ifdef HAVE_UNISTD_H
@@ -617,23 +618,9 @@ random_copy(VALUE obj, VALUE orig)
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: */