[PATCH] Let thread exit cleanup the small allocs
[fio.git] / os-freebsd.h
index 31fa01071aaf283410a4059bcd40cdb670cd8268..41672d4e10231b3be0a8d3be4e92aa8c45478fe1 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef FIO_OS_FREEBSD_H
 #define FIO_OS_FREEBSD_H
 
+#include <sys/sysctl.h>
+
 #undef FIO_HAVE_LIBAIO
 #define FIO_HAVE_POSIXAIO
 #undef FIO_HAVE_FADVISE
@@ -11,6 +13,7 @@
 #define OS_MAP_ANON            (MAP_ANON)
 
 typedef unsigned long os_cpu_mask_t;
+typedef unsigned int os_random_state_t;
 
 /*
  * FIXME
@@ -30,4 +33,24 @@ static inline unsigned long long os_phys_mem(void)
        return mem;
 }
 
+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;
+}
+
+static inline double os_random_double(os_random_state_t *rs)
+{
+       double val;
+
+       val = (double) rand_r(rs);
+       return val;
+}
 #endif