Move Windows port to MinGW
[fio.git] / os / os.h
diff --git a/os/os.h b/os/os.h
index c10cb127a2126ab084162c4945eaba7ee7d52c41..8d2a6ae8cd0923a5b29b92bf23ba1052e7065a97 100644 (file)
--- a/os/os.h
+++ b/os/os.h
@@ -3,6 +3,7 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <fcntl.h>
 #include <pthread.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -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)
 {