Commit 92d5270a authored by Robert Schmidt's avatar Robert Schmidt

Use get_random_seed() in set_taus_seed(), used by taus()

parent 2ec0b4b8
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
//#include "SIMULATION/TOOLS/sim.h" #include "sim.h"
static unsigned int s0, s1, s2; static unsigned int s0, s1, s2;
...@@ -52,20 +52,9 @@ void set_taus_seed(unsigned int seed_init) ...@@ -52,20 +52,9 @@ void set_taus_seed(unsigned int seed_init)
unsigned long result = 0; unsigned long result = 0;
if (seed_init == 0) { if (seed_init == 0) {
unsigned int data[3]; s0 = (unsigned int) get_random_seed();
int fd = open("/dev/urandom", O_RDONLY); s1 = (unsigned int) get_random_seed();
if (fd == -1) s2 = (unsigned int) get_random_seed();
{
abort();
}
if (read(fd, data, sizeof(data)) != sizeof(data))
{
abort();
}
close(fd);
s0 = data[0];
s1 = data[1];
s2 = data[2];
} else { } else {
/* Use reentrant version of rand48 to ensure that no conflicts with other generators occur */ /* Use reentrant version of rand48 to ensure that no conflicts with other generators occur */
srand48_r((long int)seed_init, &buffer); srand48_r((long int)seed_init, &buffer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment