X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fcommon%2Finclude%2Frte_random.h;h=2b30ec85c1da8cb846b2ff3866ee2da76b1ad107;hb=df3ff6be2b33faea3edf3c112b9bdc5b74d6f684;hp=66dfe8ae75aa163a5770606b7555431bc05ec72b;hpb=3f002f06961262667694171c20cb3443be6017c1;p=dpdk.git diff --git a/lib/librte_eal/common/include/rte_random.h b/lib/librte_eal/common/include/rte_random.h index 66dfe8ae75..2b30ec85c1 100644 --- a/lib/librte_eal/common/include/rte_random.h +++ b/lib/librte_eal/common/include/rte_random.h @@ -17,6 +17,8 @@ extern "C" { #include +#include + /** * Seed the pseudo-random generator. * @@ -47,6 +49,23 @@ rte_srand(uint64_t seedval); uint64_t rte_rand(void); +/** + * Generates a pseudo-random number with an upper bound. + * + * This function returns an uniformly distributed (unbiased) random + * number less than a user-specified maximum value. + * + * If called from lcore threads, this function is thread-safe. + * + * @param upper_bound + * The upper bound of the generated number. + * @return + * A pseudo-random value between 0 and (upper_bound-1). + */ +__rte_experimental +uint64_t +rte_rand_max(uint64_t upper_bound); + #ifdef __cplusplus } #endif