1use crate::{CVWords, IncrementCounter, BLOCK_LEN, OUT_LEN};
2
3pub unsafe fn hash_many<const N: usize>(
8 inputs: &[&[u8; N]],
9 key: &CVWords,
10 counter: u64,
11 increment_counter: IncrementCounter,
12 flags: u8,
13 flags_start: u8,
14 flags_end: u8,
15 out: &mut [u8],
16) {
17 unsafe {
18 assert!(out.len() >= inputs.len() * OUT_LEN);
22 ffi::blake3_hash_many_avx2(
23 inputs.as_ptr() as *const *const u8,
24 inputs.len(),
25 N / BLOCK_LEN,
26 key.as_ptr(),
27 counter,
28 increment_counter.yes(),
29 flags,
30 flags_start,
31 flags_end,
32 out.as_mut_ptr(),
33 )
34 }
35}
36
37pub mod ffi {
38 extern "C" {
39 pub fn blake3_hash_many_avx2(
40 inputs: *const *const u8,
41 num_inputs: usize,
42 blocks: usize,
43 key: *const u32,
44 counter: u64,
45 increment_counter: bool,
46 flags: u8,
47 flags_start: u8,
48 flags_end: u8,
49 out: *mut u8,
50 );
51 }
52}
53
54#[cfg(test)]
55mod test {
56 use super::*;
57
58 #[test]
59 fn test_hash_many() {
60 if !crate::platform::avx2_detected() {
61 return;
62 }
63 crate::test::test_hash_many_fn(hash_many, hash_many);
64 }
65}