()
| 108 | } |
| 109 | |
| 110 | fn main() { |
| 111 | #[cfg(target_feature = "avx2")] |
| 112 | println!("AVX2 enabled."); |
| 113 | #[cfg(not(target_feature = "avx2"))] |
| 114 | println!("AVX2 disabled."); |
| 115 | |
| 116 | let args: Vec<String> = env::args().collect(); |
| 117 | if args.len() < 4 { |
| 118 | println!("Usage: <function name> <function params> <target selector> [num_threads]"); |
| 119 | process::exit(-1); |
| 120 | } |
| 121 | |
| 122 | // Remove any leading 0x. |
| 123 | let selector = args[3].to_lowercase(); |
| 124 | let selector = selector.trim_start_matches("0x"); |
| 125 | let selector = u32::from_str_radix(selector, 16) |
| 126 | .expect("Invalid number.") |
| 127 | .to_be(); |
| 128 | let function_name = SmallString::new(&args[1]); |
| 129 | let function_params = SmallString::new(&args[2]); |
| 130 | |
| 131 | if function_name.length + function_params.length >= 115 { |
| 132 | println!("Total length of <function name> and <function params> must be under 115 bytes."); |
| 133 | process::exit(-1); |
| 134 | } |
| 135 | |
| 136 | if std::mem::size_of::<u64>() != 8 { |
| 137 | println!("Incompatible architecture."); |
| 138 | println!("u64: {}", std::mem::size_of::<u64>()); |
| 139 | process::exit(-1); |
| 140 | } |
| 141 | |
| 142 | println!("Function name: {}", args[1]); |
| 143 | println!("Function params: {}", args[2]); |
| 144 | println!( |
| 145 | "Target selector: 0x{}", |
| 146 | &(&format!("{:x}", (selector.to_be() as u64) | 0x0100000000))[1..] |
| 147 | ); |
| 148 | |
| 149 | let num_threads: usize = match args.get(4) { |
| 150 | Some(value) => value |
| 151 | .parse::<usize>() |
| 152 | .expect("Failed to parse number of threads"), |
| 153 | None => num_cpus::get(), // If args[4] is None, use the default value |
| 154 | }; |
| 155 | |
| 156 | if function_name.length <= 64 && function_params.length <= 64 { |
| 157 | mine::<64>(&function_name, &function_params, selector, num_threads); |
| 158 | } else { |
| 159 | mine::<0>(&function_name, &function_params, selector, num_threads); |
| 160 | } |
| 161 | } |
nothing calls this directly
no outgoing calls
no test coverage detected