projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
log: remember to free output buffer when done
[fio.git]
/
lib
/
rand.h
diff --git
a/lib/rand.h
b/lib/rand.h
index 4f10fb3c57afe6946e931b0f95233db3f68d6aaf..1676cf98ed567653cded97eaf00a1beabe808b58 100644
(file)
--- a/
lib/rand.h
+++ b/
lib/rand.h
@@
-114,9
+114,6
@@
static inline double __rand_0_1(struct frand_state *state)
}
}
}
}
-/*
- * Generate a random value between 'start' and 'end', both inclusive
- */
static inline uint32_t rand32_upto(struct frand_state *state, uint32_t end)
{
uint32_t r;
static inline uint32_t rand32_upto(struct frand_state *state, uint32_t end)
{
uint32_t r;
@@
-124,6
+121,7
@@
static inline uint32_t rand32_upto(struct frand_state *state, uint32_t end)
assert(!state->use64);
r = __rand32(&state->state32);
assert(!state->use64);
r = __rand32(&state->state32);
+ end++;
return (int) ((double)end * (r / (FRAND32_MAX + 1.0)));
}
return (int) ((double)end * (r / (FRAND32_MAX + 1.0)));
}
@@
-134,9
+132,13
@@
static inline uint64_t rand64_upto(struct frand_state *state, uint64_t end)
assert(state->use64);
r = __rand64(&state->state64);
assert(state->use64);
r = __rand64(&state->state64);
+ end++;
return (uint64_t) ((double)end * (r / (FRAND64_MAX + 1.0)));
}
return (uint64_t) ((double)end * (r / (FRAND64_MAX + 1.0)));
}
+/*
+ * Generate a random value between 'start' and 'end', both inclusive
+ */
static inline uint64_t rand_between(struct frand_state *state, uint64_t start,
uint64_t end)
{
static inline uint64_t rand_between(struct frand_state *state, uint64_t start,
uint64_t end)
{