Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / include / ipxe / null_entropy.h
1 #ifndef _IPXE_NULL_ENTROPY_H
2 #define _IPXE_NULL_ENTROPY_H
3
4 /** @file
5  *
6  * Nonexistent entropy source
7  *
8  * This source provides no entropy and must NOT be used in a
9  * security-sensitive environment.
10  */
11
12 FILE_LICENCE ( GPL2_OR_LATER );
13
14 #include <stdint.h>
15
16 #ifdef ENTROPY_NULL
17 #define ENTROPY_PREFIX_null
18 #else
19 #define ENTROPY_PREFIX_null __null_
20 #endif
21
22 static inline __always_inline int
23 ENTROPY_INLINE ( null, entropy_enable ) ( void ) {
24         /* Do nothing */
25         return 0;
26 }
27
28 static inline __always_inline void
29 ENTROPY_INLINE ( null, entropy_disable ) ( void ) {
30         /* Do nothing */
31 }
32
33 static inline __always_inline double
34 ENTROPY_INLINE ( null, min_entropy_per_sample ) ( void ) {
35         /* Actual amount of min-entropy is zero.  To avoid
36          * division-by-zero errors and to allow compilation of
37          * entropy-consuming code, pretend to have 1 bit of entropy in
38          * each sample.
39          */
40         return 1.0;
41 }
42
43 static inline __always_inline int
44 ENTROPY_INLINE ( null, get_noise ) ( noise_sample_t *noise ) {
45
46         /* All sample values are constant */
47         *noise = 0x01;
48
49         return 0;
50 }
51
52 #endif /* _IPXE_NULL_ENTROPY_H */