Add support for zones of random IO, with varying frequency of access
[fio.git] / lib / rand.h
index a95bd28b49041991abb8a1713ad80c9ef086742a..49773b0d9b6bec616744fe7bc91c548f7b80aa42 100644 (file)
@@ -117,6 +117,17 @@ static inline double __rand_0_1(struct frand_state *state)
        }
 }
 
+/*
+ * Generate a random value between 'start' and 'end', both inclusive
+ */
+static inline int rand_between(struct frand_state *state, int start, int end)
+{
+       uint64_t r;
+
+       r = __rand(state);
+       return start + (int) ((double)end * (r / (rand_max(state) + 1.0)));
+}
+
 extern void init_rand(struct frand_state *, int);
 extern void init_rand_seed(struct frand_state *, unsigned int seed, int);
 extern void __fill_random_buf(void *buf, unsigned int len, unsigned long seed);