X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=lib%2Frand.c;h=06812823994d45cfe744351095af015d5858fbae;hp=839a6a9476c82cedad1de30067ab06c776d750bd;hb=7d9fb455aadc0c0363489591775496f27f4a560a;hpb=3f46e64fbd2c76cc89ef8ddfc9189bac285ef638 diff --git a/lib/rand.c b/lib/rand.c index 839a6a94..06812823 100644 --- a/lib/rand.c +++ b/lib/rand.c @@ -59,18 +59,25 @@ void init_rand(struct frand_state *state) __rand(state); } -void fill_random_buf(void *buf, unsigned int len) +void __fill_random_buf(void *buf, unsigned int len, unsigned long seed) { - unsigned long r = __rand(&__fio_rand_state); long *ptr = buf; - if (sizeof(int) != sizeof(*ptr)) - r *= (unsigned long) __rand(&__fio_rand_state); - while ((void *) ptr - buf < len) { - *ptr = r; + *ptr = seed; ptr++; - r *= GOLDEN_RATIO_PRIME; - r >>= 3; + seed *= GOLDEN_RATIO_PRIME; + seed >>= 3; } } + +unsigned long fill_random_buf(void *buf, unsigned int len) +{ + unsigned long r = __rand(&__fio_rand_state); + + if (sizeof(int) != sizeof(long *)) + r *= (unsigned long) __rand(&__fio_rand_state); + + __fill_random_buf(buf, len, r); + return r; +}