diff options
author | Ming-Hung Tsai <mingnus@gmail.com> | 2019-04-17 12:25:10 +0800 |
---|---|---|
committer | Ming-Hung Tsai <mingnus@gmail.com> | 2019-04-17 15:34:19 +0800 |
commit | 9781c080385364d24ac18a95544484864a27611a (patch) | |
tree | 360c2a9e624398c0473f123247fa22da48943a3f /lib | |
parent | ef32da643574162c2b1aae67af38ecffb43db036 (diff) | |
download | fio-9781c080385364d24ac18a95544484864a27611a.tar.gz fio-9781c080385364d24ac18a95544484864a27611a.tar.bz2 |
rand: fix truncated rand_seed on Windows
The long data type is 32-bit on LLP64 platforms
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lfsr.c | 6 | ||||
-rw-r--r-- | lib/lfsr.h | 4 | ||||
-rw-r--r-- | lib/rand.c | 20 | ||||
-rw-r--r-- | lib/rand.h | 8 |
4 files changed, 19 insertions, 19 deletions
@@ -232,7 +232,7 @@ static int prepare_spin(struct fio_lfsr *fl, unsigned int spin) return 0; } -int lfsr_reset(struct fio_lfsr *fl, unsigned long seed) +int lfsr_reset(struct fio_lfsr *fl, uint64_t seed) { uint64_t bitmask = (fl->cached_bit << 1) - 1; @@ -246,8 +246,8 @@ int lfsr_reset(struct fio_lfsr *fl, unsigned long seed) return 0; } -int lfsr_init(struct fio_lfsr *fl, uint64_t nums, unsigned long seed, - unsigned int spin) +int lfsr_init(struct fio_lfsr *fl, uint64_t nums, uint64_t seed, + unsigned int spin) { uint8_t *taps; @@ -24,7 +24,7 @@ struct fio_lfsr { int lfsr_next(struct fio_lfsr *fl, uint64_t *off); int lfsr_init(struct fio_lfsr *fl, uint64_t size, - unsigned long seed, unsigned int spin); -int lfsr_reset(struct fio_lfsr *fl, unsigned long seed); + uint64_t seed, unsigned int spin); +int lfsr_reset(struct fio_lfsr *fl, uint64_t seed); #endif @@ -95,7 +95,7 @@ void init_rand_seed(struct frand_state *state, unsigned int seed, bool use64) __init_rand64(&state->state64, seed); } -void __fill_random_buf(void *buf, unsigned int len, unsigned long seed) +void __fill_random_buf(void *buf, unsigned int len, uint64_t seed) { void *ptr = buf; @@ -122,10 +122,10 @@ void __fill_random_buf(void *buf, unsigned int len, unsigned long seed) } } -unsigned long fill_random_buf(struct frand_state *fs, void *buf, - unsigned int len) +uint64_t fill_random_buf(struct frand_state *fs, void *buf, + unsigned int len) { - unsigned long r = __rand(fs); + uint64_t r = __rand(fs); if (sizeof(int) != sizeof(long *)) r *= (unsigned long) __rand(fs); @@ -134,7 +134,7 @@ unsigned long fill_random_buf(struct frand_state *fs, void *buf, return r; } -void __fill_random_buf_percentage(unsigned long seed, void *buf, +void __fill_random_buf_percentage(uint64_t seed, void *buf, unsigned int percentage, unsigned int segment, unsigned int len, char *pattern, unsigned int pbytes) @@ -183,12 +183,12 @@ void __fill_random_buf_percentage(unsigned long seed, void *buf, } } -unsigned long fill_random_buf_percentage(struct frand_state *fs, void *buf, - unsigned int percentage, - unsigned int segment, unsigned int len, - char *pattern, unsigned int pbytes) +uint64_t fill_random_buf_percentage(struct frand_state *fs, void *buf, + unsigned int percentage, + unsigned int segment, unsigned int len, + char *pattern, unsigned int pbytes) { - unsigned long r = __rand(fs); + uint64_t r = __rand(fs); if (sizeof(int) != sizeof(long *)) r *= (unsigned long) __rand(fs); @@ -150,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 |