eal: replace libc-based random generation with LFSR
[dpdk.git] / lib / librte_eal / common / 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 /**
21  * Seed the pseudo-random generator.
22  *
23  * The generator is automatically seeded by the EAL init with a timer
24  * value. It may need to be re-seeded by the user with a real random
25  * value.
26  *
27  * This function is not multi-thread safe in regards to other
28  * rte_srand() calls, nor is it in relation to concurrent rte_rand()
29  * calls.
30  *
31  * @param seedval
32  *   The value of the seed.
33  */
34 void
35 rte_srand(uint64_t seedval);
36
37 /**
38  * Get a pseudo-random value.
39  *
40  * The generator is not cryptographically secure.
41  *
42  * If called from lcore threads, this function is thread-safe.
43  *
44  * @return
45  *   A pseudo-random value between 0 and (1<<64)-1.
46  */
47 uint64_t
48 rte_rand(void);
49
50 #ifdef __cplusplus
51 }
52 #endif
53
54
55 #endif /* _RTE_RANDOM_H_ */