X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=lib%2Fzipf.c;h=321a4fb9645e8995e1145758ec75530aeea75a16;hb=36833fb04b5f9a734e96a571dfb52fc54b5b95e7;hp=3d535c79d3b371ba1ee150567a307629b8d9d067;hpb=b58e3cee98842a9333de90202dc217e421e6c8f2;p=fio.git diff --git a/lib/zipf.c b/lib/zipf.c index 3d535c79..321a4fb9 100644 --- a/lib/zipf.c +++ b/lib/zipf.c @@ -1,11 +1,5 @@ #include #include -#include -#include -#include -#include -#include -#include "ieee754.h" #include "zipf.h" #include "../minmax.h" #include "../hash.h" @@ -14,7 +8,7 @@ static void zipf_update(struct zipf_state *zs) { - unsigned long to_gen; + uint64_t to_gen; unsigned int i; /* @@ -28,7 +22,7 @@ static void zipf_update(struct zipf_state *zs) zs->zetan += pow(1.0 / (double) (i + 1), zs->theta); } -static void shared_rand_init(struct zipf_state *zs, unsigned long nranges, +static void shared_rand_init(struct zipf_state *zs, uint64_t nranges, unsigned int seed) { memset(zs, 0, sizeof(*zs)); @@ -38,7 +32,7 @@ static void shared_rand_init(struct zipf_state *zs, unsigned long nranges, zs->rand_off = __rand(&zs->rand); } -void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta, +void zipf_init(struct zipf_state *zs, uint64_t nranges, double theta, unsigned int seed) { shared_rand_init(zs, nranges, seed); @@ -49,7 +43,7 @@ void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta, zipf_update(zs); } -unsigned long long zipf_next(struct zipf_state *zs) +uint64_t zipf_next(struct zipf_state *zs) { double alpha, eta, rand_uni, rand_z; unsigned long long n = zs->nranges; @@ -76,14 +70,14 @@ unsigned long long zipf_next(struct zipf_state *zs) return (val + zs->rand_off) % zs->nranges; } -void pareto_init(struct zipf_state *zs, unsigned long nranges, double h, +void pareto_init(struct zipf_state *zs, uint64_t nranges, double h, unsigned int seed) { shared_rand_init(zs, nranges, seed); zs->pareto_pow = log(h) / log(1.0 - h); } -unsigned long long pareto_next(struct zipf_state *zs) +uint64_t pareto_next(struct zipf_state *zs) { double rand = (double) __rand(&zs->rand) / (double) FRAND32_MAX; unsigned long long n;