Ruby
2.4.2p198(2017-09-14revision59899)
|
#include "internal.h"
#include <limits.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <math.h>
#include <errno.h>
#include "ruby_atomic.h"
#include "siphash.c"
Go to the source code of this file.
Data Structures | |
struct | MT |
struct | rb_random_t |
struct | seed_keys_t |
Macros | |
#define | N 624 |
#define | M 397 |
#define | MATRIX_A 0x9908b0dfU /* constant vector a */ |
#define | UMASK 0x80000000U /* most significant w-r bits */ |
#define | LMASK 0x7fffffffU /* least significant r bits */ |
#define | MIXBITS(u, v) ( ((u) & UMASK) | ((v) & LMASK) ) |
#define | TWIST(u, v) ((MIXBITS((u),(v)) >> 1) ^ ((v)&1U ? MATRIX_A : 0U)) |
#define | genrand_initialized(mt) ((mt)->next != 0) |
#define | uninit_genrand(mt) ((mt)->next = 0) |
#define | DEFAULT_SEED_CNT 4 |
#define | SIZEOF_INT32 (31/CHAR_BIT + 1) |
#define | id_minus '-' |
#define | id_plus '+' |
#define | DEFAULT_SEED_LEN (DEFAULT_SEED_CNT * (int)sizeof(int32_t)) |
#define | USE_DEV_URANDOM 0 |
#define | fill_random_bytes_urandom(seed, size) -1 |
#define | fill_random_bytes_syscall(seed, size, need_secure) -1 |
#define | SIP_HASH_STREAMING 0 |
#define | sip_hash24 ruby_sip_hash24 |
#define | BYTE_ORDER LITTLE_ENDIAN |
#define | LITTLE_ENDIAN 1234 |
#define | BIG_ENDIAN 4321 |
Typedefs | |
typedef int | int_must_be_32bit_at_least[sizeof(int) *CHAR_BIT< 32 ? -1 :1] |
Enumerations | |
enum | { MT_MAX_STATE = N } |
Functions | |
static void | init_genrand (struct MT *mt, unsigned int s) |
static void | init_by_array (struct MT *mt, const uint32_t init_key[], int key_length) |
static void | next_state (struct MT *mt) |
static unsigned int | genrand_int32 (struct MT *mt) |
static double | int_pair_to_real_exclusive (uint32_t a, uint32_t b) |
static double | genrand_real (struct MT *mt) |
static double | int_pair_to_real_inclusive (uint32_t a, uint32_t b) |
static VALUE | rand_init (struct MT *mt, VALUE vseed) |
static VALUE | random_seed (void) |
static rb_random_t * | rand_start (rb_random_t *r) |
static struct MT * | default_mt (void) |
unsigned int | rb_genrand_int32 (void) |
double | rb_genrand_real (void) |
static void | random_mark (void *ptr) |
static void | random_free (void *ptr) |
static size_t | random_memsize (const void *ptr) |
static rb_random_t * | get_rnd (VALUE obj) |
static rb_random_t * | try_get_rnd (VALUE obj) |
static VALUE | random_alloc (VALUE klass) |
static VALUE | random_init (int argc, VALUE *argv, VALUE obj) |
static int | fill_random_bytes (void *seed, size_t size, int need_secure) |
static void | fill_random_seed (uint32_t *seed, size_t cnt) |
static VALUE | make_seed_value (uint32_t *ptr, size_t len) |
static VALUE | random_raw_seed (VALUE self, VALUE size) |
static VALUE | random_get_seed (VALUE obj) |
static VALUE | random_copy (VALUE obj, VALUE orig) |
static VALUE | mt_state (const struct MT *mt) |
static VALUE | random_state (VALUE obj) |
static VALUE | random_s_state (VALUE klass) |
static VALUE | random_left (VALUE obj) |
static VALUE | random_s_left (VALUE klass) |
static VALUE | random_dump (VALUE obj) |
static VALUE | random_load (VALUE obj, VALUE dump) |
static VALUE | rb_f_srand (int argc, VALUE *argv, VALUE obj) |
static unsigned long | make_mask (unsigned long x) |
static unsigned long | limited_rand (struct MT *mt, unsigned long limit) |
static VALUE | limited_big_rand (struct MT *mt, VALUE limit) |
unsigned long | rb_genrand_ulong_limited (unsigned long limit) |
static VALUE | obj_random_bytes (VALUE obj, void *p, long n) |
static unsigned int | random_int32 (rb_random_t *rnd) |
unsigned int | rb_random_int32 (VALUE obj) |
static double | random_real (VALUE obj, rb_random_t *rnd, int excl) |
double | rb_random_real (VALUE obj) |
static VALUE | ulong_to_num_plus_1 (unsigned long n) |
static unsigned long | random_ulong_limited (VALUE obj, rb_random_t *rnd, unsigned long limit) |
unsigned long | rb_random_ulong_limited (VALUE obj, unsigned long limit) |
static VALUE | random_ulong_limited_big (VALUE obj, rb_random_t *rnd, VALUE vmax) |
static VALUE | genrand_bytes (rb_random_t *rnd, long n) |
static VALUE | random_bytes (VALUE obj, VALUE len) |
VALUE | rb_random_bytes (VALUE obj, long n) |
static VALUE | range_values (VALUE vmax, VALUE *begp, VALUE *endp, int *exclp) |
static VALUE | rand_int (VALUE obj, rb_random_t *rnd, VALUE vmax, int restrictive) |
NORETURN (static void domain_error(void)) | |
static void | domain_error (void) |
NORETURN (static void invalid_argument(VALUE)) | |
static void | invalid_argument (VALUE arg0) |
static VALUE | check_random_number (VALUE v, const VALUE *argv) |
static double | float_value (VALUE v) |
static VALUE | rand_range (VALUE obj, rb_random_t *rnd, VALUE range) |
static VALUE | rand_random (int argc, VALUE *argv, VALUE obj, rb_random_t *rnd) |
static VALUE | random_rand (int argc, VALUE *argv, VALUE obj) |
static VALUE | rand_random_number (int argc, VALUE *argv, VALUE obj) |
static VALUE | random_equal (VALUE self, VALUE other) |
static VALUE | rb_f_rand (int argc, VALUE *argv, VALUE obj) |
static VALUE | random_s_rand (int argc, VALUE *argv, VALUE obj) |
static void | init_seed (struct MT *mt) |
st_index_t | rb_hash_start (st_index_t h) |
st_index_t | rb_memhash (const void *ptr, long len) |
void | Init_RandomSeedCore (void) |
static VALUE | init_randomseed (struct MT *mt) |
static VALUE | Init_Random_default (void) |
void | rb_reset_random_seed (void) |
void | InitVM_Random (void) |
void | Init_Random (void) |
Variables | |
static rb_random_t | default_rand |
VALUE | rb_cRandom |
static ID | id_rand |
static ID | id_bytes |
static const rb_data_type_t | random_data_type |
union { | |
seed_keys_t key | |
uint32_t u32 [type_roomof(seed_keys_t, uint32_t)] | |
} | seed |
#define BYTE_ORDER LITTLE_ENDIAN |
Definition at line 1465 of file random.c.
Referenced by SHA256_Transform(), and SHA512_Transform().
#define DEFAULT_SEED_CNT 4 |
Definition at line 240 of file random.c.
Referenced by init_randomseed(), Init_RandomSeedCore(), and random_seed().
#define DEFAULT_SEED_LEN (DEFAULT_SEED_CNT * (int)sizeof(int32_t)) |
Definition at line 423 of file random.c.
Referenced by init_randomseed(), Init_RandomSeedCore(), and random_seed().
Definition at line 535 of file random.c.
Referenced by fill_random_bytes().
Definition at line 461 of file random.c.
Referenced by fill_random_bytes().
#define genrand_initialized | ( | mt | ) | ((mt)->next != 0) |
Definition at line 112 of file random.c.
Referenced by rand_start().
#define id_minus '-' |
Definition at line 302 of file random.c.
Referenced by range_values().
#define id_plus '+' |
Definition at line 303 of file random.c.
Referenced by rand_range().
#define LITTLE_ENDIAN 1234 |
Definition at line 1468 of file random.c.
Referenced by SHA256_Transform(), and SHA512_Transform().
#define M 397 |
Definition at line 96 of file random.c.
Referenced by next_state().
#define N 624 |
Definition at line 95 of file random.c.
Referenced by init_by_array(), init_genrand(), and next_state().
#define sip_hash24 ruby_sip_hash24 |
Definition at line 1460 of file random.c.
Referenced by rb_memhash().
#define SIZEOF_INT32 (31/CHAR_BIT + 1) |
Definition at line 277 of file random.c.
Referenced by genrand_bytes(), limited_rand(), and rand_init().
#define TWIST | ( | u, | |
v | |||
) | ((MIXBITS((u),(v)) >> 1) ^ ((v)&1U ? MATRIX_A : 0U)) |
Definition at line 101 of file random.c.
Referenced by next_state().
#define uninit_genrand | ( | mt | ) | ((mt)->next = 0) |
Definition at line 113 of file random.c.
Referenced by rb_reset_random_seed().
typedef int int_must_be_32bit_at_least[sizeof(int) *CHAR_BIT< 32 ? -1 :1] |
Definition at line 1181 of file random.c.
References invalid_argument(), NUM2LONG, Qfalse, and Qnil.
Referenced by random_rand(), and random_s_rand().
|
static |
Definition at line 258 of file random.c.
References rb_random_t::mt, and rand_start().
Referenced by rb_genrand_int32(), rb_genrand_real(), and rb_genrand_ulong_limited().
|
static |
Definition at line 1167 of file random.c.
References INT2FIX, invalid_argument(), NORETURN(), rb_class_new_instance(), rb_eSystemCallError, and rb_exc_raise().
Referenced by float_value(), rand_int(), and rand_range().
|
static |
Definition at line 539 of file random.c.
References fill_random_bytes_syscall, and fill_random_bytes_urandom.
Referenced by fill_random_seed(), and random_raw_seed().
|
static |
Definition at line 547 of file random.c.
References CHAR_BIT, fill_random_bytes(), gettimeofday(), len, seed, TRUE, timeval::tv_sec, and timeval::tv_usec.
Referenced by init_randomseed(), Init_RandomSeedCore(), and random_seed().
|
inlinestatic |
Definition at line 1194 of file random.c.
References domain_error(), isinf(), isnan, and RFLOAT_VALUE.
Referenced by rand_random(), rand_range(), rb_str_format(), and sum_iter().
|
static |
Definition at line 1080 of file random.c.
References CHAR_BIT, genrand_int32(), rb_random_t::mt, rb_str_new(), RSTRING_PTR, and SIZEOF_INT32.
Referenced by random_bytes(), random_ulong_limited_big(), and rb_random_bytes().
|
static |
Definition at line 183 of file random.c.
References int_pair_to_real_exclusive(), MT::left, MT::next, and next_state().
Referenced by genrand_bytes(), genrand_real(), init_seed(), int_pair_to_real_exclusive(), limited_big_rand(), limited_rand(), random_int32(), and rb_genrand_int32().
|
static |
Definition at line 203 of file random.c.
References genrand_int32(), and int_pair_to_real_exclusive().
Referenced by rb_f_rand(), rb_genrand_real(), and rb_random_real().
|
static |
Definition at line 337 of file random.c.
References rand_start(), and TypedData_Get_Struct.
Referenced by random_bytes(), random_copy(), random_dump(), random_equal(), random_get_seed(), random_init(), random_left(), random_load(), random_rand(), and random_state().
Definition at line 138 of file random.c.
References init_genrand(), N, and MT::state.
Referenced by init_randomseed(), Init_RandomSeedCore(), and rand_init().
|
static |
Definition at line 117 of file random.c.
References MT::left, N, MT::next, and MT::state.
Referenced by init_by_array(), and rand_init().
void Init_Random | ( | void | ) |
|
static |
Definition at line 1547 of file random.c.
References default_rand, init_randomseed(), rb_random_t::mt, rb_cRandom, rb_gc_register_mark_object(), rb_random_t::seed, and TypedData_Wrap_Struct.
Referenced by InitVM_Random().
Definition at line 1533 of file random.c.
References DEFAULT_SEED_CNT, DEFAULT_SEED_LEN, explicit_bzero(), fill_random_seed(), init_by_array(), make_seed_value(), and seed.
Referenced by Init_Random_default().
void Init_RandomSeedCore | ( | void | ) |
Definition at line 1515 of file random.c.
References DEFAULT_SEED_CNT, DEFAULT_SEED_LEN, explicit_bzero(), fill_random_seed(), init_by_array(), and init_seed().
|
static |
Definition at line 1487 of file random.c.
References genrand_int32(), numberof, and seed.
Referenced by Init_RandomSeedCore().
void InitVM_Random | ( | void | ) |
Definition at line 1592 of file random.c.
References CLASS_OF, Init_Random_default(), rand_random_number(), random_alloc(), random_bytes(), random_copy(), random_dump(), random_equal(), random_get_seed(), random_init(), random_left(), random_load(), random_rand(), random_raw_seed(), random_s_left(), random_s_rand(), random_s_state(), random_seed(), random_state(), rb_cObject, rb_cRandom, rb_define_alloc_func(), rb_define_class(), rb_define_const(), rb_define_global_function(), rb_define_method(), rb_define_module_under(), rb_define_private_method(), rb_define_singleton_method(), rb_f_rand(), rb_f_srand(), and rb_include_module().
Definition at line 211 of file random.c.
References genrand_int32(), and int_pair_to_real_inclusive().
Referenced by genrand_int32(), genrand_real(), and random_real().
Definition at line 280 of file random.c.
Referenced by int_pair_to_real_exclusive(), and random_real().
|
static |
Definition at line 1175 of file random.c.
References PRIsVALUE, rb_eArgError, and rb_raise().
Referenced by check_random_number(), domain_error(), and rand_random_number().
Definition at line 838 of file random.c.
References ALLOCV_END, ALLOCV_N, genrand_int32(), INTEGER_PACK_LSWORD_FIRST, INTEGER_PACK_NATIVE_BYTE_ORDER, len, make_mask(), NULL, rb_absint_numwords(), rb_integer_pack(), rb_integer_unpack(), and val.
Referenced by random_ulong_limited_big().
|
static |
Definition at line 806 of file random.c.
References genrand_int32(), make_mask(), SIZEOF_INT32, and val.
Referenced by random_ulong_limited(), rb_genrand_ulong_limited(), and rb_random_ulong_limited().
|
static |
Definition at line 792 of file random.c.
Referenced by limited_big_rand(), and limited_rand().
Definition at line 571 of file random.c.
References INTEGER_PACK_LSWORD_FIRST, INTEGER_PACK_NATIVE_BYTE_ORDER, rb_integer_unpack(), and seed.
Referenced by init_randomseed(), and random_seed().
Definition at line 661 of file random.c.
References INTEGER_PACK_LSWORD_FIRST, INTEGER_PACK_NATIVE_BYTE_ORDER, numberof, rb_integer_unpack(), and MT::state.
Referenced by random_dump(), random_s_state(), and random_state().
|
static |
Definition at line 164 of file random.c.
References MT::left, M, N, MT::next, MT::state, and TWIST.
Referenced by genrand_int32(), and parser_yylex().
NORETURN | ( | static void | domain_errorvoid | ) |
Referenced by domain_error(), and rand_int().
NORETURN | ( | static void | invalid_argumentVALUE | ) |
Definition at line 899 of file random.c.
References Check_Type, id_bytes, len, LONG2NUM, memcpy, rb_eRangeError, rb_funcallv_public(), rb_raise(), RSTRING_LEN, RSTRING_PTR, and T_STRING.
Referenced by random_real(), random_ulong_limited(), random_ulong_limited_big(), rb_random_bytes(), and rb_random_int32().
Definition at line 365 of file random.c.
References ALLOC_N, buf, explicit_bzero(), init_by_array(), init_genrand(), INTEGER_PACK_LSWORD_FIRST, INTEGER_PACK_NATIVE_BYTE_ORDER, len, NULL, numberof, rb_absint_numwords(), rb_integer_pack(), seed, SIZEOF_INT32, and xfree().
Referenced by rand_start(), random_init(), and rb_f_srand().
|
static |
Definition at line 1130 of file random.c.
References BIGNUM_SIGN, domain_error(), FIX2LONG, FIXNUM_P, INT2FIX, LONG2NUM, max(), NORETURN(), Qnil, random_ulong_limited(), random_ulong_limited_big(), rb_big_minus(), rb_big_uminus(), rb_bigzero_p(), RB_GC_GUARD, and ULONG2NUM.
Referenced by rand_random(), and rb_f_rand().
|
static |
Definition at line 1319 of file random.c.
References float_value(), max(), NIL_P, Qnil, rand_int(), rand_range(), random_real(), rb_check_arity, rb_check_to_float(), rb_check_to_int(), rb_float_new, RB_TYPE_P, T_FLOAT, and TRUE.
Referenced by rand_random_number(), rand_range(), random_rand(), and random_s_rand().
Definition at line 1348 of file random.c.
References invalid_argument(), NIL_P, rand_random(), and try_get_rnd().
Referenced by InitVM_Random().
|
inlinestatic |
Definition at line 1204 of file random.c.
References argc, argv, BIGNUM_SIGN, BUILTIN_TYPE, DBL2NUM, domain_error(), f, FIX2LONG, FIXNUM_P, float_value(), id_plus, INT2FIX, isinf(), isnan, LONG2NUM, max(), NIL_P, Qfalse, Qnil, Qundef, rand_random(), random_real(), random_ulong_limited(), random_ulong_limited_big(), range_values(), rb_big_minus(), rb_big_norm(), rb_big_plus(), rb_bigzero_p(), rb_check_to_float(), rb_check_to_int(), rb_float_new, rb_funcallv, rb_to_float(), RB_TYPE_P, RFLOAT_VALUE, T_BIGNUM, T_FLOAT, T_NIL, TYPE, and ULONG2NUM.
Referenced by rand_random(), and rb_f_rand().
|
static |
Definition at line 248 of file random.c.
References genrand_initialized, rb_random_t::mt, rand_init(), random_seed(), and rb_random_t::seed.
Referenced by default_mt(), get_rnd(), random_s_rand(), rb_f_rand(), and try_get_rnd().
Definition at line 356 of file random.c.
References INT2FIX, rb_random_t::seed, and TypedData_Make_Struct.
Referenced by InitVM_Random().
Definition at line 1074 of file random.c.
References genrand_bytes(), get_rnd(), NUM2LONG, and rb_to_int().
Referenced by InitVM_Random().
Definition at line 644 of file random.c.
References get_rnd(), MT::left, rb_random_t::mt, MT::next, numberof, OBJ_INIT_COPY, and MT::state.
Referenced by InitVM_Random().
Definition at line 700 of file random.c.
References get_rnd(), INT2FIX, MT::left, rb_random_t::mt, mt_state(), rb_ary_new2, rb_ary_push(), and rb_random_t::seed.
Referenced by InitVM_Random().
Definition at line 1382 of file random.c.
References get_rnd(), MT::left, memcmp(), rb_random_t::mt, MT::next, Qfalse, r1, r2, rb_equal(), rb_obj_class(), rb_random_t::seed, and MT::state.
Referenced by InitVM_Random().
|
static |
Definition at line 637 of file random.c.
References get_rnd(), and rb_random_t::seed.
Referenced by InitVM_Random().
Definition at line 405 of file random.c.
References get_rnd(), rb_random_t::mt, rand_init(), random_seed(), rb_check_arity, rb_check_copyable(), rb_check_frozen, rb_to_int(), and rb_random_t::seed.
Referenced by InitVM_Random().
|
static |
Definition at line 915 of file random.c.
References genrand_int32(), and rb_random_t::mt.
Referenced by random_real(), and rb_random_int32().
Definition at line 685 of file random.c.
References get_rnd(), INT2FIX, MT::left, and rb_random_t::mt.
Referenced by InitVM_Random().
Definition at line 714 of file random.c.
References Check_Type, get_rnd(), INT2FIX, INTEGER_PACK_LSWORD_FIRST, INTEGER_PACK_NATIVE_BYTE_ORDER, MT::left, rb_random_t::mt, MT::next, NUM2ULONG, numberof, RARRAY_CONST_PTR, RARRAY_LEN, rb_check_copyable(), rb_eArgError, rb_integer_pack(), rb_raise(), rb_to_int(), rb_random_t::seed, seed, MT::state, and T_ARRAY.
Referenced by InitVM_Random().
|
static |
Definition at line 308 of file random.c.
References rb_gc_mark(), and seed.
Definition at line 1311 of file random.c.
References check_random_number(), get_rnd(), and rand_random().
Referenced by InitVM_Random().
Definition at line 613 of file random.c.
References buf, FALSE, fill_random_bytes(), NUM2ULONG, Qnil, rb_str_new(), and RSTRING_PTR.
Referenced by InitVM_Random().
|
static |
Definition at line 933 of file random.c.
References int_pair_to_real_exclusive(), int_pair_to_real_inclusive(), obj_random_bytes(), and random_int32().
Referenced by rand_random(), and rand_range().
Definition at line 693 of file random.c.
References INT2FIX, MT::left, and rb_random_t::mt.
Referenced by InitVM_Random().
Definition at line 1452 of file random.c.
References check_random_number(), Qnil, rand_random(), and rand_start().
Referenced by InitVM_Random().
Definition at line 678 of file random.c.
References rb_random_t::mt, and mt_state().
Referenced by InitVM_Random().
|
static |
Definition at line 595 of file random.c.
References buf, DEFAULT_SEED_CNT, DEFAULT_SEED_LEN, explicit_bzero(), fill_random_seed(), and make_seed_value().
Referenced by InitVM_Random(), rand_start(), random_init(), and rb_f_srand().
Definition at line 670 of file random.c.
References get_rnd(), rb_random_t::mt, and mt_state().
Referenced by InitVM_Random().
|
static |
Definition at line 987 of file random.c.
References buf, CHAR_BIT, limited_rand(), rb_random_t::mt, nlz_long(), obj_random_bytes(), u32, and val.
Referenced by rand_int(), and rand_range().
|
static |
Definition at line 1035 of file random.c.
References ALLOCV_END, ALLOCV_N, genrand_bytes(), INTEGER_PACK_MSWORD_FIRST, INTEGER_PACK_NATIVE_BYTE_ORDER, len, limited_big_rand(), rb_random_t::mt, nlz(), obj_random_bytes(), rb_absint_numwords(), rb_integer_pack(), and rb_integer_unpack().
Referenced by rand_int(), and rand_range().
Definition at line 1117 of file random.c.
References id_minus, NIL_P, Qfalse, rb_funcallv, rb_range_values(), and rb_respond_to().
Referenced by rand_range().
Definition at line 1426 of file random.c.
References DBL2NUM, genrand_real(), INT2FIX, rb_random_t::mt, NIL_P, Qfalse, Qnil, rand_int(), rand_range(), rand_start(), rb_check_arity, and rb_to_int().
Referenced by InitVM_Random().
Definition at line 774 of file random.c.
References default_rand, rb_random_t::mt, rand_init(), random_seed(), rb_check_arity, rb_to_int(), rb_random_t::seed, and seed.
Referenced by InitVM_Random().
unsigned int rb_genrand_int32 | ( | void | ) |
Definition at line 264 of file random.c.
References default_mt(), and genrand_int32().
double rb_genrand_real | ( | void | ) |
Definition at line 271 of file random.c.
References default_mt(), and genrand_real().
unsigned long rb_genrand_ulong_limited | ( | unsigned long | limit | ) |
Definition at line 893 of file random.c.
References default_mt(), and limited_rand().
Referenced by bary_sparse_p().
st_index_t rb_hash_start | ( | st_index_t | h | ) |
Definition at line 1496 of file random.c.
References seed, and st_hash_start().
Referenced by any_hash(), match_hash(), method_hash(), proc_hash(), range_hash(), rb_ary_hash(), rb_dbl_long_hash(), rb_hash_hash(), rb_ident_hash(), rb_objid_hash(), and rb_struct_hash().
st_index_t rb_memhash | ( | const void * | ptr, |
long | len | ||
) |
Definition at line 1502 of file random.c.
References seed, sip_hash24, and sip_uint64_t::u32.
Referenced by BigDecimal_hash(), d_lite_hash(), match_hash(), nucomp_hash(), nurat_hash(), ossl_bn_hash(), rb_big_hash(), rb_dbl_long_hash(), rb_str_hash(), and reg_hash().
Definition at line 1107 of file random.c.
References genrand_bytes(), NULL, obj_random_bytes(), and try_get_rnd().
unsigned int rb_random_int32 | ( | VALUE | obj | ) |
Definition at line 921 of file random.c.
References obj_random_bytes(), random_int32(), and try_get_rnd().
double rb_random_real | ( | VALUE | obj | ) |
Definition at line 956 of file random.c.
References genrand_real(), id_rand, rb_random_t::mt, NUM2DBL, rb_eRangeError, rb_funcallv, rb_raise(), and try_get_rnd().
unsigned long rb_random_ulong_limited | ( | VALUE | obj, |
unsigned long | limit | ||
) |
Definition at line 1016 of file random.c.
References id_rand, limited_rand(), rb_random_t::mt, NUM2ULONG, rb_eRangeError, rb_funcallv_public(), rb_num_negative_p(), rb_raise(), rb_to_int(), try_get_rnd(), and ulong_to_num_plus_1().
void rb_reset_random_seed | ( | void | ) |
Definition at line 1560 of file random.c.
References default_rand, INT2FIX, rb_random_t::mt, rb_random_t::seed, and uninit_genrand.
Referenced by rb_thread_start_timer_thread().
|
static |
Definition at line 345 of file random.c.
References DATA_PTR, NULL, rand_start(), rb_cRandom, and rb_typeddata_is_kind_of().
Referenced by rand_random_number(), rb_random_bytes(), rb_random_int32(), rb_random_real(), and rb_random_ulong_limited().
|
inlinestatic |
Definition at line 974 of file random.c.
References INT2FIX, rb_big_plus(), and ULONG2NUM.
Referenced by rb_random_ulong_limited().
|
static |
Definition at line 242 of file random.c.
Referenced by Init_Random_default(), rb_f_srand(), and rb_reset_random_seed().
|
static |
Definition at line 304 of file random.c.
Referenced by Init_Random(), and obj_random_bytes().
|
static |
Definition at line 304 of file random.c.
Referenced by Init_Random(), rb_random_real(), and rb_random_ulong_limited().
seed_keys_t key |
|
static |
VALUE rb_cRandom |
Definition at line 301 of file random.c.
Referenced by Init_Random_default(), InitVM_Random(), and try_get_rnd().
union { ... } seed |
uint32_t u32[type_roomof(seed_keys_t, uint32_t)] |
Definition at line 1483 of file random.c.
Referenced by random_ulong_limited().