X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=os%2Fos.h;h=8d2a6ae8cd0923a5b29b92bf23ba1052e7065a97;hp=c10cb127a2126ab084162c4945eaba7ee7d52c41;hb=93bcfd20e37cef8cec350fe06d3a086724c9f257;hpb=16de1bf91ca80e62ce257a24cae471fab140bbe0 diff --git a/os/os.h b/os/os.h index c10cb127..8d2a6ae8 100644 --- a/os/os.h +++ b/os/os.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -34,7 +35,7 @@ enum { #include "os-aix.h" #elif defined(__hpux) #include "os-hpux.h" -#elif defined(__CYGWIN__) +#elif defined(WIN32) #include "os-windows.h" #else #error "unsupported os" @@ -267,6 +268,32 @@ static inline long os_random_long(os_random_state_t *rs) } #endif +#ifdef FIO_USE_GENERIC_INIT_RANDOM_STATE +extern void td_fill_rand_seeds(struct thread_data *td); +/* + * Initialize the various random states we need (random io, block size ranges, + * read/write mix, etc). + */ +static inline int init_random_state(struct thread_data *td, unsigned long *rand_seeds, int size) +{ + int fd; + + fd = open("/dev/urandom", O_RDONLY); + if (fd == -1) { + return 1; + } + + if (read(fd, rand_seeds, size) < size) { + close(fd); + return 1; + } + + close(fd); + td_fill_rand_seeds(td); + return 0; +} +#endif + #ifndef FIO_HAVE_FS_STAT static inline unsigned long long get_fs_size(const char *path) {