aboutsummaryrefslogtreecommitdiffstats
path: root/random.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2012-03-09 18:36:17 -0800
committerH. Peter Anvin <hpa@zytor.com>2012-03-09 18:36:17 -0800
commitb444e1737742e091339f1a7b083adc9fa4e06c08 (patch)
treeef87c6fc6563d5247574a4b7e931d951df405baf /random.c
parentc955023c984c485d19b485a2c6a74b1e66020b62 (diff)
downloadgrv-b444e1737742e091339f1a7b083adc9fa4e06c08.tar.gz
grv-b444e1737742e091339f1a7b083adc9fa4e06c08.tar.xz
grv-b444e1737742e091339f1a7b083adc9fa4e06c08.zip
sysrand: Centralize getting randomness from the operating system
Centralize getting randomness from the underlying operating system, used to seed the Mersenne Twister PRNG and to generate game IDs.
Diffstat (limited to 'random.c')
-rw-r--r--random.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/random.c b/random.c
index 1aac839..ea7de34 100644
--- a/random.c
+++ b/random.c
@@ -54,7 +54,7 @@ static unsigned long mt[N]; /* the array for the state vector */
static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
/* initializes mt[N] with a seed */
-void init_genrand(unsigned long s)
+static void init_genrand(unsigned long s)
{
mt[0]= s & 0xffffffffUL;
for (mti=1; mti<N; mti++) {
@@ -72,8 +72,7 @@ void init_genrand(unsigned long s)
/* initialize by an array with array-length */
/* init_key is the array for initializing keys */
/* key_length is its length */
-void init_by_array(init_key, key_length)
-unsigned long init_key[], key_length;
+void init_by_array(const unsigned long *init_key, unsigned long key_length)
{
int i, j, k;
init_genrand(19650218UL);
@@ -136,6 +135,7 @@ unsigned long genrand_int32(void)
return y;
}
+#if 0
/* generates a random number on [0,0x7fffffff]-interval */
long genrand_int31(void)
{
@@ -162,6 +162,7 @@ double genrand_real3(void)
return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0);
/* divided by 2^32 */
}
+#endif
/* generates a random number on [0,1) with 53-bit resolution*/
double genrand_res53(void)