crc/test: fix potential div by zero
[fio.git] / lib / rand.h
index 573116cbc2f7ec097bda77d97a3a0d669d30558f..8c35ab1fa2636655ca17cd0f868b8c2ffafd0336 100644 (file)
@@ -1,11 +1,19 @@
 #ifndef FIO_RAND_H
 #define FIO_RAND_H
 
+#define FRAND_MAX      (-1U)
+
 struct frand_state {
        unsigned int s1, s2, s3;
 };
 
-extern struct frand_state __fio_rand_state;
+static inline void frand_copy(struct frand_state *dst,
+                             struct frand_state *src)
+{
+       dst->s1 = src->s1;
+       dst->s2 = src->s2;
+       dst->s3 = src->s3;
+}
 
 static inline unsigned int __rand(struct frand_state *state)
 {
@@ -19,6 +27,9 @@ static inline unsigned int __rand(struct frand_state *state)
 }
 
 extern void init_rand(struct frand_state *);
-extern void fill_random_buf(void *buf, unsigned int len);
+extern void init_rand_seed(struct frand_state *, unsigned int seed);
+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 unsigned long fill_random_buf_percentage(struct frand_state *, void *buf, unsigned int percentage, unsigned int segment, unsigned int len);
 
 #endif