1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
11 * Pseudo-random Generators in RTE
20 #include <rte_compat.h>
23 * Seed the pseudo-random generator.
25 * The generator is automatically seeded by the EAL init with a timer
26 * value. It may need to be re-seeded by the user with a real random
29 * This function is not multi-thread safe in regards to other
30 * rte_srand() calls, nor is it in relation to concurrent rte_rand()
34 * The value of the seed.
37 rte_srand(uint64_t seedval);
40 * Get a pseudo-random value.
42 * The generator is not cryptographically secure.
44 * If called from lcore threads, this function is thread-safe.
47 * A pseudo-random value between 0 and (1<<64)-1.
53 * Generates a pseudo-random number with an upper bound.
55 * This function returns an uniformly distributed (unbiased) random
56 * number less than a user-specified maximum value.
58 * If called from lcore threads, this function is thread-safe.
61 * The upper bound of the generated number.
63 * A pseudo-random value between 0 and (upper_bound-1).
66 rte_rand_max(uint64_t upper_bound);
70 * @b EXPERIMENTAL: this API may change without prior notice
72 * Generates a pseudo-random floating point number.
74 * This function returns a non-negative double-precision floating random
75 * number uniformly distributed over the interval [0.0, 1.0).
77 * The generator is not cryptographically secure.
78 * If called from lcore threads, this function is thread-safe.
81 * A pseudo-random value between 0 and 1.0.
84 double rte_drand(void);
91 #endif /* _RTE_RANDOM_H_ */