randomx4r/flags.rs
1use randomx4r_sys::*;
2
3bitflags! {
4 /// Represents options that can be used when allocating the
5 /// RandomX dataset or VM.
6 pub struct RandomxFlags: u32 {
7 /// Use defaults.
8 const DEFAULT = randomx_flags_RANDOMX_FLAG_DEFAULT;
9
10 /// Allocate memory in large pages.
11 const LARGEPAGES = randomx_flags_RANDOMX_FLAG_LARGE_PAGES;
12
13 /// The RandomX VM will use hardware accelerated AES.
14 const HARDAES = randomx_flags_RANDOMX_FLAG_HARD_AES;
15
16 /// The RandomX VM will use the full dataset.
17 const FULLMEM = randomx_flags_RANDOMX_FLAG_FULL_MEM;
18
19 /// The RandomX VM will use a JIT compiler.
20 const JIT = randomx_flags_RANDOMX_FLAG_JIT;
21
22 /// Make sure that JIT pages are never writable and executable
23 /// at the same time.
24 const SECURE = randomx_flags_RANDOMX_FLAG_SECURE;
25
26 /// Use the SSSE3 extension to speed up Argon2 operations.
27 const ARGON2_SSSE3 = randomx_flags_RANDOMX_FLAG_ARGON2_SSSE3;
28
29 /// Use the AVX2 extension to speed up Argon2 operations.
30 const ARGON2_AVX2 = randomx_flags_RANDOMX_FLAG_ARGON2_AVX2;
31
32 /// Do not use SSSE3 or AVX2 extensions.
33 const ARGON2 = randomx_flags_RANDOMX_FLAG_ARGON2;
34 }
35}
36
37impl Default for RandomxFlags {
38 /// Get the recommended flags to use on the current machine.
39 ///
40 /// Does not include any of the following flags:
41 /// * LARGEPAGES
42 /// * JIT
43 /// * SECURE
44 fn default() -> RandomxFlags {
45 // Explode if bits do not match up.
46 unsafe { RandomxFlags::from_bits(randomx_get_flags()).unwrap() }
47 }
48}