steadystate: use uint64_t for storing bw and iops calculations and related values...
[fio.git] / lib / rand.h
index 49773b0d9b6bec616744fe7bc91c548f7b80aa42..bff4a35167cbbfc95dc9258c54b5bbec3f1400e4 100644 (file)
@@ -2,6 +2,8 @@
 #define FIO_RAND_H
 
 #include <inttypes.h>
+#include <assert.h>
+#include "types.h"
 #include "../arch/arch.h"
 
 #define FRAND32_MAX    (-1U)
@@ -23,10 +25,6 @@ struct frand_state {
        };
 };
 
-struct frand64_state {
-       uint64_t s1, s2, s3, s4, s5;
-};
-
 static inline uint64_t rand_max(struct frand_state *state)
 {
        if (state->use64)
@@ -120,16 +118,18 @@ 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)
+static inline int rand32_between(struct frand_state *state, int start, int end)
 {
-       uint64_t r;
+       uint32_t r;
+
+       assert(!state->use64);
 
-       r = __rand(state);
-       return start + (int) ((double)end * (r / (rand_max(state) + 1.0)));
+       r = __rand32(&state->state32);
+       return start + (int) ((double)end * (r / (FRAND32_MAX + 1.0)));
 }
 
-extern void init_rand(struct frand_state *, int);
-extern void init_rand_seed(struct frand_state *, unsigned int seed, int);
+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);