Changes to Random Number Generation between r2 and r3

'''Using a Computer to Generate Random Numbers'''


Sample C implementation: --> Sample C implementation [http://www.rkeene.org/projects/info/resources/rng/rng.c]
#include <sys/time.h>
#include <inttypes.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
(blank line)
uint32_t ms_to_run(const char *pathname) {
struct timeval start, finish;
uint32_t ret;

gettimeofday(&start, NULL);
system(pathname);
gettimeofday(&finish, NULL);

if (finish.tv_usec < start.tv_usec) {
ret = finish.tv_usec + 1000000 - start.tv_usec;
} else {
ret = finish.tv_usec - start.tv_usec;
}

return(ret);
}
(blank line)
int generate_random_values(unsigned char *destarray, int destarray_len, int freq) {
uint32_t x;
unsigned char val;
int i;

for (i = 0; i < destarray_len; i++) {
if ((i % freq) == 0) {
x = ms_to_run("/bin/true");
srand((x << 14) + rand());
}

if (destarray) {
val = (int) (256.0 * rand() / (RAND_MAX + 1.0));
destarray[i] = val;
}
}
(blank line)
return(0);
}

int main(void) {
char buf[1024 * 4];
int ret;

ret = generate_random_values(buf, sizeof(buf), 3);
if (ret < 0) {
fprintf(stderr, "Error generating random numbers, aborting.\n");
return(EXIT_FAILURE);
}

fwrite(buf, sizeof(buf), sizeof(buf[0]), stdout);

return(EXIT_SUCCESS);
}

Legend

     Only in r2
     Only in r3
     -->      Modified slightly between r2 and r3