diff options
author | Jean-Philippe Bernardy <jeanphilippe.bernardy@gmail.com> | 2005-02-15 11:13:00 +0000 |
---|---|---|
committer | Jean-Philippe Bernardy <jeanphilippe.bernardy@gmail.com> | 2005-02-15 11:13:00 +0000 |
commit | a161ef490fa7b6d3abda489071f0c4982eb12a7b (patch) | |
tree | d1b03694a085613cb599ab145c97eb6317ac9500 /firmware | |
parent | 74f941e75c6efaf3874766ada1eb0b2d61e7b139 (diff) | |
download | rockbox-a161ef490fa7b6d3abda489071f0c4982eb12a7b.tar.gz rockbox-a161ef490fa7b6d3abda489071f0c4982eb12a7b.zip |
long policy
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5946 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/common/random.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/firmware/common/random.c b/firmware/common/random.c index 899ce4af4b..ebe60b091f 100644 --- a/firmware/common/random.c +++ b/firmware/common/random.c | |||
@@ -56,11 +56,11 @@ | |||
56 | #define mixBits(u, v) (hiBit(u)|loBits(v)) /* move highest bit of u to | 56 | #define mixBits(u, v) (hiBit(u)|loBits(v)) /* move highest bit of u to |
57 | highest bit of v */ | 57 | highest bit of v */ |
58 | 58 | ||
59 | static unsigned int state[N+1]; /* state vector + 1 to not violate ANSI C */ | 59 | static unsigned long state[N+1]; /* state vector + 1 to not violate ANSI C */ |
60 | static unsigned int *next; /* next random value is computed from here */ | 60 | static unsigned long *next; /* next random value is computed from here */ |
61 | static int left = -1; /* can *next++ this many times before reloading */ | 61 | static int left = -1; /* can *next++ this many times before reloading */ |
62 | 62 | ||
63 | void srand(unsigned int seed) | 63 | void srand(unsigned long seed) |
64 | { | 64 | { |
65 | /* | 65 | /* |
66 | * We initialize state[0..(N-1)] via the generator | 66 | * We initialize state[0..(N-1)] via the generator |
@@ -108,16 +108,16 @@ void srand(unsigned int seed) | |||
108 | * so-- that's why the only change I made is to restrict to odd seeds. | 108 | * so-- that's why the only change I made is to restrict to odd seeds. |
109 | */ | 109 | */ |
110 | 110 | ||
111 | unsigned int x = (seed | 1U) & 0xFFFFFFFFU, *s = state; | 111 | unsigned long x = (seed | 1U) & 0xFFFFFFFFU, *s = state; |
112 | int j; | 112 | int j; |
113 | 113 | ||
114 | for(left=0, *s++=x, j=N; --j; | 114 | for(left=0, *s++=x, j=N; --j; |
115 | *s++ = (x*=69069U) & 0xFFFFFFFFU); | 115 | *s++ = (x*=69069U) & 0xFFFFFFFFU); |
116 | } | 116 | } |
117 | 117 | ||
118 | static int rand_reload(void) | 118 | static long rand_reload(void) |
119 | { | 119 | { |
120 | unsigned int *p0=state, *p2=state+2, *pM=state+M, s0, s1; | 120 | unsigned long *p0=state, *p2=state+2, *pM=state+M, s0, s1; |
121 | int j; | 121 | int j; |
122 | 122 | ||
123 | if(left < -1) | 123 | if(left < -1) |
@@ -135,12 +135,12 @@ static int rand_reload(void) | |||
135 | s1 ^= (s1 >> 11); | 135 | s1 ^= (s1 >> 11); |
136 | s1 ^= (s1 << 7) & 0x9D2C5680U; | 136 | s1 ^= (s1 << 7) & 0x9D2C5680U; |
137 | s1 ^= (s1 << 15) & 0xEFC60000U; | 137 | s1 ^= (s1 << 15) & 0xEFC60000U; |
138 | return (int)s1 ^ (s1 >> 18); | 138 | return (long)s1 ^ (s1 >> 18); |
139 | } | 139 | } |
140 | 140 | ||
141 | int rand(void) | 141 | long rand(void) |
142 | { | 142 | { |
143 | unsigned int y; | 143 | unsigned long y; |
144 | 144 | ||
145 | if(--left < 0) { | 145 | if(--left < 0) { |
146 | y = rand_reload(); | 146 | y = rand_reload(); |