summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Bernardy <jeanphilippe.bernardy@gmail.com>2005-02-15 11:13:00 +0000
committerJean-Philippe Bernardy <jeanphilippe.bernardy@gmail.com>2005-02-15 11:13:00 +0000
commita161ef490fa7b6d3abda489071f0c4982eb12a7b (patch)
treed1b03694a085613cb599ab145c97eb6317ac9500
parent74f941e75c6efaf3874766ada1eb0b2d61e7b139 (diff)
downloadrockbox-a161ef490fa7b6d3abda489071f0c4982eb12a7b.zip
rockbox-a161ef490fa7b6d3abda489071f0c4982eb12a7b.tar.gz
rockbox-a161ef490fa7b6d3abda489071f0c4982eb12a7b.tar.bz2
rockbox-a161ef490fa7b6d3abda489071f0c4982eb12a7b.tar.xz
long policy
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5946 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/common/random.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/firmware/common/random.c b/firmware/common/random.c
index 899ce4a..ebe60b0 100644
--- a/firmware/common/random.c
+++ b/firmware/common/random.c
@@ -56,11 +56,11 @@
#define mixBits(u, v) (hiBit(u)|loBits(v)) /* move highest bit of u to
highest bit of v */
-static unsigned int state[N+1]; /* state vector + 1 to not violate ANSI C */
-static unsigned int *next; /* next random value is computed from here */
+static unsigned long state[N+1]; /* state vector + 1 to not violate ANSI C */
+static unsigned long *next; /* next random value is computed from here */
static int left = -1; /* can *next++ this many times before reloading */
-void srand(unsigned int seed)
+void srand(unsigned long seed)
{
/*
* We initialize state[0..(N-1)] via the generator
@@ -108,16 +108,16 @@ void srand(unsigned int seed)
* so-- that's why the only change I made is to restrict to odd seeds.
*/
- unsigned int x = (seed | 1U) & 0xFFFFFFFFU, *s = state;
+ unsigned long x = (seed | 1U) & 0xFFFFFFFFU, *s = state;
int j;
for(left=0, *s++=x, j=N; --j;
*s++ = (x*=69069U) & 0xFFFFFFFFU);
}
-static int rand_reload(void)
+static long rand_reload(void)
{
- unsigned int *p0=state, *p2=state+2, *pM=state+M, s0, s1;
+ unsigned long *p0=state, *p2=state+2, *pM=state+M, s0, s1;
int j;
if(left < -1)
@@ -135,12 +135,12 @@ static int rand_reload(void)
s1 ^= (s1 >> 11);
s1 ^= (s1 << 7) & 0x9D2C5680U;
s1 ^= (s1 << 15) & 0xEFC60000U;
- return (int)s1 ^ (s1 >> 18);
+ return (long)s1 ^ (s1 >> 18);
}
-int rand(void)
+long rand(void)
{
- unsigned int y;
+ unsigned long y;
if(--left < 0) {
y = rand_reload();