fio: fix aio trim completion latencies
[fio.git] / lib / rand.h
index 4f10fb3c57afe6946e931b0f95233db3f68d6aaf..95d4f6d4966d88a60700a09fba7a6487c032abd5 100644 (file)
@@ -114,9 +114,6 @@ static inline double __rand_0_1(struct frand_state *state)
        }
 }
 
-/*
- * Generate a random value between 'start' and 'end', both inclusive
- */
 static inline uint32_t rand32_upto(struct frand_state *state, uint32_t end)
 {
        uint32_t r;
@@ -124,6 +121,7 @@ static inline uint32_t rand32_upto(struct frand_state *state, uint32_t end)
        assert(!state->use64);
 
        r = __rand32(&state->state32);
+       end++;
        return (int) ((double)end * (r / (FRAND32_MAX + 1.0)));
 }
 
@@ -134,9 +132,13 @@ static inline uint64_t rand64_upto(struct frand_state *state, uint64_t end)
        assert(state->use64);
 
        r = __rand64(&state->state64);
+       end++;
        return (uint64_t) ((double)end * (r / (FRAND64_MAX + 1.0)));
 }
 
+/*
+ * Generate a random value between 'start' and 'end', both inclusive
+ */
 static inline uint64_t rand_between(struct frand_state *state, uint64_t start,
                                    uint64_t end)
 {
@@ -148,9 +150,9 @@ static inline uint64_t rand_between(struct frand_state *state, uint64_t start,
 
 extern void init_rand(struct frand_state *, bool);
 extern void init_rand_seed(struct frand_state *, unsigned int seed, bool);
-extern void __fill_random_buf(void *buf, unsigned int len, unsigned long seed);
-extern unsigned long fill_random_buf(struct frand_state *, void *buf, unsigned int len);
-extern void __fill_random_buf_percentage(unsigned long, void *, unsigned int, unsigned int, unsigned int, char *, unsigned int);
-extern unsigned long fill_random_buf_percentage(struct frand_state *, void *, unsigned int, unsigned int, unsigned int, char *, unsigned int);
+extern void __fill_random_buf(void *buf, unsigned int len, uint64_t seed);
+extern uint64_t fill_random_buf(struct frand_state *, void *buf, unsigned int len);
+extern void __fill_random_buf_percentage(uint64_t, void *, unsigned int, unsigned int, unsigned int, char *, unsigned int);
+extern uint64_t fill_random_buf_percentage(struct frand_state *, void *, unsigned int, unsigned int, unsigned int, char *, unsigned int);
 
 #endif