summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Djurfeldt <djurfeldt@nada.kth.se>2006-02-19 16:34:51 +0000
committerMikael Djurfeldt <djurfeldt@nada.kth.se>2006-02-19 16:34:51 +0000
commit4a9f83ff064bab4a5e43ca4f7ddf45ffa4dba2ae (patch)
treeac25a24814b7fa512eb14d54f6b6a1f782f7b7fc
parent4c7016dc06525c7910ce6c99d97eb9c52c6b43e4 (diff)
downloadguile-4a9f83ff064bab4a5e43ca4f7ddf45ffa4dba2ae.tar.gz
Test for SCM_HAVE_T_UINT64 instead of
SCM_HAVE_T_INT64. (scm_i_uniform32, scm_i_uniform32, scm_i_init_rstate): Use scm_t_uint64 and scm_t_uint32 instead of scm_t_int64 and scm_t_int32.
-rw-r--r--libguile/ChangeLog8
-rw-r--r--libguile/random.c22
2 files changed, 19 insertions, 11 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog
index 1da6c4c28..0c435bc89 100644
--- a/libguile/ChangeLog
+++ b/libguile/ChangeLog
@@ -1,3 +1,11 @@
+2006-02-19 Mikael Djurfeldt <mdj@neurologic.cc>
+
+ * random.c: Test for SCM_HAVE_T_UINT64 instead of
+ SCM_HAVE_T_INT64.
+ (scm_i_uniform32, scm_i_uniform32, scm_i_init_rstate): Use
+ scm_t_uint64 and scm_t_uint32 instead of scm_t_int64 and
+ scm_t_int32.
+
2006-01-04 Ludovic Court<E8>s <ludovic.courtes@laas.fr>
* gc-segment.c (scm_i_sweep_some_cards): Take a SWEEP_STATS
diff --git a/libguile/random.c b/libguile/random.c
index 009633db2..7c23999db 100644
--- a/libguile/random.c
+++ b/libguile/random.c
@@ -75,13 +75,13 @@ scm_t_rng scm_the_rng;
#define M_PI 3.14159265359
#endif
-#if SCM_HAVE_T_INT64
+#if SCM_HAVE_T_UINT64
unsigned long
scm_i_uniform32 (scm_t_i_rstate *state)
{
- scm_t_int64 x = (scm_t_int64) A * state->w + state->c;
- scm_t_int32 w = x & 0xffffffffUL;
+ scm_t_uint64 x = (scm_t_uint64) A * state->w + state->c;
+ scm_t_uint32 w = x & 0xffffffffUL;
state->w = w;
state->c = x >> 32L;
return w;
@@ -106,12 +106,12 @@ scm_i_uniform32 (scm_t_i_rstate *state)
unsigned long
scm_i_uniform32 (scm_t_i_rstate *state)
{
- scm_t_int32 x1 = L (A) * L (state->w);
- scm_t_int32 x2 = L (A) * H (state->w);
- scm_t_int32 x3 = H (A) * L (state->w);
- scm_t_int32 w = L (x1) + L (state->c);
- scm_t_int32 m = H (x1) + L (x2) + L (x3) + H (state->c) + H (w);
- scm_t_int32 x4 = H (A) * H (state->w);
+ scm_t_uint32 x1 = L (A) * L (state->w);
+ scm_t_uint32 x2 = L (A) * H (state->w);
+ scm_t_uint32 x3 = H (A) * L (state->w);
+ scm_t_uint32 w = L (x1) + L (state->c);
+ scm_t_uint32 m = H (x1) + L (x2) + L (x3) + H (state->c) + H (w);
+ scm_t_uint32 x4 = H (A) * H (state->w);
state->w = w = (L (m) << 16) + L (w);
state->c = H (x2) + H (x3) + x4 + H (m);
return w;
@@ -122,8 +122,8 @@ scm_i_uniform32 (scm_t_i_rstate *state)
void
scm_i_init_rstate (scm_t_i_rstate *state, const char *seed, int n)
{
- scm_t_int32 w = 0L;
- scm_t_int32 c = 0L;
+ scm_t_uint32 w = 0L;
+ scm_t_uint32 c = 0L;
int i, m;
for (i = 0; i < n; ++i)
{