[RFC,2/3] Add 32-bit version of rte_rand
Checks
Commit Message
Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
---
lib/librte_eal/common/include/rte_random.h | 15 +++++++++++----
lib/librte_eal/common/rte_random.c | 10 ++++++++++
lib/librte_eal/rte_eal_version.map | 1 +
3 files changed, 22 insertions(+), 4 deletions(-)
@@ -35,11 +35,18 @@ void
rte_srand(uint64_t seedval);
/**
- * Get a pseudo-random value.
+ * Generates a 32-bit pseudo-random number.
*
- * This function generates pseudo-random numbers using the linear
- * congruential algorithm and 48-bit integer arithmetic, called twice
- * to generate a 64-bit value.
+ * If called from lcore threads, this function is thread-safe.
+ *
+ * @return
+ * A pseudo-random value between 0 and (1<<32)-1.
+ */
+uint32_t
+rte_rand32(void);
+
+/**
+ * Generates a 64-bit pseudo-random number.
*
* If called from lcore threads, this function is thread-safe.
*
@@ -83,6 +83,16 @@ struct rte_rand_state *__rte_rand_get_state(void)
return &rand_states[lcore_id];
}
+uint32_t __rte_experimental
+rte_rand32(void)
+{
+ struct rte_rand_state *state;
+
+ state = __rte_rand_get_state();
+
+ return __rte_rand32(state);
+}
+
uint64_t __rte_experimental
rte_rand(void)
{
@@ -366,6 +366,7 @@ EXPERIMENTAL {
rte_mp_request_async;
rte_mp_sendmsg;
rte_option_register;
+ rte_rand32;
rte_rand;
rte_realloc_socket;
rte_service_lcore_attr_get;