eal: introduce random generator with upper bound
authorMattias Rönnblom <mattias.ronnblom@ericsson.com>
Fri, 28 Jun 2019 09:01:23 +0000 (11:01 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 28 Jun 2019 13:23:55 +0000 (15:23 +0200)
commit5f4ed3f058493552658e914815f58e784755a1b3
tree86925c07d598cf0e6c683983a16f9b5f0e34920e
parentfaf8fd252785ee8b181d11c3aea7e0b2b0ed3f56
eal: introduce random generator with upper bound

Add a function rte_rand_max() which generates an uniformly distributed
pseudo-random number less than a user-specified upper bound.

The commonly used pattern rte_rand() % SOME_VALUE creates biased
results (as in some values in the range are more frequently occurring
than others) if SOME_VALUE is not a power of 2.

Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
app/test/test_rand_perf.c
doc/guides/rel_notes/release_19_08.rst
lib/librte_eal/common/include/rte_random.h
lib/librte_eal/common/rte_random.c
lib/librte_eal/rte_eal_version.map