summaryrefslogtreecommitdiff
path: root/os/os.h
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2009-12-15 10:28:37 +0100
committerJens Axboe <jens.axboe@oracle.com>2009-12-15 10:28:37 +0100
commit535313705d69dc16f27ca38acf2f9bf7205e410d (patch)
treedb57c488c22530b5031924fd066f307cc4535306 /os/os.h
parent3b2e1464ae58caf42c74ab4bdeaa5eae7c38a23f (diff)
downloadfio-535313705d69dc16f27ca38acf2f9bf7205e410d.tar.gz
fio-535313705d69dc16f27ca38acf2f9bf7205e410d.tar.bz2
Add generic random helpers
FreeBSD and OSX can both use these. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'os/os.h')
-rw-r--r--os/os.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/os/os.h b/os/os.h
index a14c4857..9a48c603 100644
--- a/os/os.h
+++ b/os/os.h
@@ -124,4 +124,21 @@ static inline int blockdev_size(int fd, unsigned long long *bytes)
}
#endif
+#ifdef FIO_USE_GENERIC_RAND
+typedef unsigned int os_random_state_t;
+
+static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
+{
+ srand(seed);
+}
+
+static inline long os_random_long(os_random_state_t *rs)
+{
+ long val;
+
+ val = rand_r(rs);
+ return val;
+}
+#endif
+
#endif