summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2012-11-11 08:27:24 +0100
committerJens Axboe <axboe@kernel.dk>2012-11-11 08:27:24 +0100
commita5a4fdfd44ec1b55ebab7800a931c148540a7324 (patch)
treefd83eb6acf4d06319dec5517dc2ea55a184ce31a /lib
parent921d17ba00f6fa106f558ea285d1d503f3a41369 (diff)
downloadfio-a5a4fdfd44ec1b55ebab7800a931c148540a7324.tar.gz
fio-a5a4fdfd44ec1b55ebab7800a931c148540a7324.tar.bz2
zipf: use 64-bit safe hash for zipf/pareto
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'lib')
-rw-r--r--lib/zipf.c4
-rw-r--r--lib/zipf.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/zipf.c b/lib/zipf.c
index 41e20554..9b6ce633 100644
--- a/lib/zipf.c
+++ b/lib/zipf.c
@@ -69,7 +69,7 @@ unsigned long long zipf_next(struct zipf_state *zs)
else
val = 1 + (unsigned long long)(n * pow(eta*rand_uni - eta + 1.0, alpha));
- return (__hash_long(val - 1) + zs->rand_off) % zs->nranges;
+ return (__hash_u64(val - 1) + zs->rand_off) % zs->nranges;
}
void pareto_init(struct zipf_state *zs, unsigned long nranges, double h,
@@ -84,5 +84,5 @@ unsigned long long pareto_next(struct zipf_state *zs)
double rand = (double) __rand(&zs->rand) / (double) FRAND_MAX;
unsigned long long n = zs->nranges - 1;
- return (__hash_long(n * pow(rand, zs->pareto_pow)) + zs->rand_off) % zs->nranges;
+ return (__hash_u64(n * pow(rand, zs->pareto_pow)) + zs->rand_off) % zs->nranges;
}
diff --git a/lib/zipf.h b/lib/zipf.h
index dbcaffb2..f98ad818 100644
--- a/lib/zipf.h
+++ b/lib/zipf.h
@@ -11,7 +11,7 @@ struct zipf_state {
double zetan;
double pareto_pow;
struct frand_state rand;
- unsigned long rand_off;
+ uint64_t rand_off;
};
void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta, unsigned int seed);