mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-13 04:42:13 -08:00
random-state: use 32 bit types for 32 bit implementation
Signed-off-by: Daniel Kochmański <daniel@turtleware.eu>
This commit is contained in:
parent
a85579c198
commit
a8432f4f9c
2 changed files with 11 additions and 5 deletions
|
|
@ -117,8 +117,12 @@ _hash_equal(int depth, cl_hashkey h, cl_object x)
|
|||
* because otherwise two bit arrays which are EQUAL might
|
||||
* have different hash keys. */
|
||||
return hash_string(h, x->vector.self.bc, x->vector.fillp / 8);
|
||||
case t_random:
|
||||
return _hash_equal(0, h, x->random.value);
|
||||
case t_random: {
|
||||
cl_object array = x->random.value;
|
||||
return hash_string
|
||||
(h, (unsigned char*)array->vector.self.b32,
|
||||
array->vector.fillp * sizeof(ecl_uint32_t));
|
||||
}
|
||||
#ifdef ECL_SIGNED_ZERO
|
||||
case t_singlefloat: {
|
||||
float f = ecl_single_float(x);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,9 @@ n*/
|
|||
#define UPPER_MASK 0x80000000UL /* most significant w-r bits */
|
||||
#define LOWER_MASK 0x7fffffffUL /* least significant r bits */
|
||||
|
||||
#define ulong unsigned long
|
||||
/* INV: for 64 bit implementation modify accordingly _hash_equal in
|
||||
hash.d file for case t_random */
|
||||
#define ulong ecl_uint32_t
|
||||
|
||||
cl_object
|
||||
init_genrand(ulong seed)
|
||||
|
|
@ -52,7 +54,7 @@ init_genrand(ulong seed)
|
|||
ecl_alloc_simple_vector
|
||||
((MT_N + 1),
|
||||
ecl_symbol_to_elttype(@'ext::byte32'));
|
||||
ulong *mt = (ulong*)(array->base_string.self);
|
||||
ulong *mt = (ulong*)(array->vector.self.b32);
|
||||
int j = 0;
|
||||
mt[0] = seed & 0xffffffffUL;
|
||||
for (j=1; j < MT_N; j++)
|
||||
|
|
@ -90,7 +92,7 @@ generate_int32(cl_object state)
|
|||
{
|
||||
static ulong mag01[2]={0x0UL, MATRIX_A};
|
||||
ulong y;
|
||||
ulong *mt = (ulong*)state->base_string.self;
|
||||
ulong *mt = (ulong*)state->vector.self.b32;
|
||||
if (mt[MT_N] >= MT_N){
|
||||
/* refresh data */
|
||||
int kk;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue