[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] GNU Guile branch, branch_release-1-8, updated. release_1
From: |
Andy Wingo |
Subject: |
[Guile-commits] GNU Guile branch, branch_release-1-8, updated. release_1-8-7-23-g33290f5 |
Date: |
Mon, 19 Jul 2010 20:54:45 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".
http://git.savannah.gnu.org/cgit/guile.git/commit/?id=33290f52ef171050b0d692ba3caf7ab15b30b84f
The branch, branch_release-1-8 has been updated
via 33290f52ef171050b0d692ba3caf7ab15b30b84f (commit)
from 0d559b775a68117fafdbc1fbf5fb8263e5be6b6f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 33290f52ef171050b0d692ba3caf7ab15b30b84f
Author: Andreas Rottmann <address@hidden>
Date: Mon Jul 19 22:55:16 2010 +0200
Fix random number generator on 64-bit platforms
* libguile/random.c (scm_c_random): On platforms where `unsigned long' has
64
bit, generate up to 64 bit of randomness. This is expected by
scm_c_random_bignum(), and hence was a serious distortion of the random
value
distribution for values exceeding 2^32. This change also fixes a crash
when
the `m' argument is a value above 2^32.
-----------------------------------------------------------------------
Summary of changes:
libguile/random.c | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/libguile/random.c b/libguile/random.c
index 8d2ff03..3c2d2aa 100644
--- a/libguile/random.c
+++ b/libguile/random.c
@@ -215,7 +215,8 @@ unsigned char scm_masktab[256];
unsigned long
scm_c_random (scm_t_rstate *state, unsigned long m)
{
- unsigned int r, mask;
+ unsigned long r, mask;
+#if SCM_SIZEOF_UNSIGNED_LONG == 4
mask = (m < 0x100
? scm_masktab[m]
: (m < 0x10000
@@ -224,6 +225,31 @@ scm_c_random (scm_t_rstate *state, unsigned long m)
? scm_masktab[m >> 16] << 16 | 0xffff
: scm_masktab[m >> 24] << 24 | 0xffffff)));
while ((r = scm_the_rng.random_bits (state) & mask) >= m);
+#elif SCM_SIZEOF_UNSIGNED_LONG == 8
+ mask = (m < 0x100
+ ? scm_masktab[m]
+ : (m < 0x10000
+ ? scm_masktab[m >> 8] << 8 | 0xff
+ : (m < 0x1000000
+ ? scm_masktab[m >> 16] << 16 | 0xffff
+ : (m < (1UL << 32)
+ ? scm_masktab[m >> 24] << 24 | 0xffffff
+ : (m < (1UL << 40)
+ ? ((unsigned long) scm_masktab[m >> 32] << 32
+ | 0xffffffffUL)
+ : (m < (1UL << 48)
+ ? ((unsigned long) scm_masktab[m >> 40] << 40
+ | 0xffffffffffUL)
+ : (m < (1UL << 56)
+ ? ((unsigned long) scm_masktab[m >> 48] << 48
+ | 0xffffffffffffUL)
+ : ((unsigned long) scm_masktab[m >> 56] << 56
+ | 0xffffffffffffffUL))))))));
+ while ((r = ((scm_the_rng.random_bits (state) << 32
+ | scm_the_rng.random_bits (state))) & mask) >= m);
+#else
+#error "Cannot deal with this platform's unsigned long size"
+#endif
return r;
}
hooks/post-receive
--
GNU Guile
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Guile-commits] GNU Guile branch, branch_release-1-8, updated. release_1-8-7-23-g33290f5,
Andy Wingo <=