]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/lib/librte_eal/include/rte_random.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / dpdk / lib / librte_eal / include / rte_random.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
3 */
4
5 #ifndef _RTE_RANDOM_H_
6 #define _RTE_RANDOM_H_
7
8 /**
9 * @file
10 *
11 * Pseudo-random Generators in RTE
12 */
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 #include <stdint.h>
19
20 #include <rte_compat.h>
21
22 /**
23 * Seed the pseudo-random generator.
24 *
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
27 * value.
28 *
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()
31 * calls.
32 *
33 * @param seedval
34 * The value of the seed.
35 */
36 void
37 rte_srand(uint64_t seedval);
38
39 /**
40 * Get a pseudo-random value.
41 *
42 * The generator is not cryptographically secure.
43 *
44 * If called from lcore threads, this function is thread-safe.
45 *
46 * @return
47 * A pseudo-random value between 0 and (1<<64)-1.
48 */
49 uint64_t
50 rte_rand(void);
51
52 /**
53 * Generates a pseudo-random number with an upper bound.
54 *
55 * This function returns an uniformly distributed (unbiased) random
56 * number less than a user-specified maximum value.
57 *
58 * If called from lcore threads, this function is thread-safe.
59 *
60 * @param upper_bound
61 * The upper bound of the generated number.
62 * @return
63 * A pseudo-random value between 0 and (upper_bound-1).
64 */
65 __rte_experimental
66 uint64_t
67 rte_rand_max(uint64_t upper_bound);
68
69 #ifdef __cplusplus
70 }
71 #endif
72
73
74 #endif /* _RTE_RANDOM_H_ */