Changes to Random Number Generation between r0 and r1
#include <sys/time.h> --> #include <sys/time.h>
#include <inttypes.h> --> #include <inttypes.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
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);
}
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;
}
}
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);
}
Only in r0
Only in r1 --> Modified slightly between r0 and r1