1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
#![no_std] #![cfg_attr(feature = "simd", feature(cfg_target_feature))] #[cfg(feature = "simd")] #[macro_use] extern crate coresimd; pub mod portable; #[cfg(feature = "simd")] #[cfg(feature = "W32")] #[cfg(target_feature = "ssse3")] #[path = "x32_ssse3.rs"] pub mod ssse3; #[cfg(feature = "simd")] #[cfg(feature = "W64")] #[cfg(target_feature = "ssse3")] #[path = "x64_ssse3.rs"] pub mod ssse3; #[cfg(feature = "simd")] #[cfg(feature = "W64")] #[cfg(target_feature = "avx2")] #[path = "x64_avx2.rs"] pub mod avx2; #[cfg(feature = "W8")] pub type U = u8; #[cfg(feature = "W16")] pub type U = u16; #[cfg(feature = "W32")] pub type U = u32; #[cfg(feature = "W64")] pub type U = u64; #[cfg(feature = "L4")] pub const L: usize = 4; #[cfg(feature = "L6")] pub const L: usize = 6; pub const S: usize = 16; #[inline] pub fn norx(state: &mut [U; S]) { #[cfg(feature = "simd")] #[cfg(feature = "W64")] #[cfg(target_feature = "avx2")] unsafe { if cfg_feature_enabled!("avx2") { return avx2::norx(state); } } #[cfg(feature = "simd")] #[cfg(any(feature = "W32", feature = "W64"))] #[cfg(target_feature = "ssse3")] unsafe { if cfg_feature_enabled!("ssse3") { return ssse3::norx(state); } } portable::norx(state) } #[inline] pub fn norx_x4(state1: &mut [U; S], state2: &mut [U; S], state3: &mut [U; S], state4: &mut [U; S]) { #[cfg(feature = "simd")] #[cfg(feature = "W64")] #[cfg(target_feature = "avx2")] unsafe { if cfg_feature_enabled!("avx2") { return avx2::norx_x4(state1, state2, state3, state4); } } norx(state1); norx(state2); norx(state3); norx(state4); } #[cfg(feature = "W8")] mod rot_const { pub const R0: u32 = 1; pub const R1: u32 = 3; pub const R2: u32 = 5; pub const R3: u32 = 7; } #[cfg(feature = "W16")] mod rot_const { pub const R0: u32 = 8; pub const R1: u32 = 11; pub const R2: u32 = 12; pub const R3: u32 = 15; } #[cfg(feature = "W32")] mod rot_const { pub const R0: u32 = 8; pub const R1: u32 = 11; pub const R2: u32 = 16; pub const R3: u32 = 31; } #[cfg(feature = "W64")] mod rot_const { pub const R0: u32 = 8; pub const R1: u32 = 19; pub const R2: u32 = 40; pub const R3: u32 = 63; }