Coverage Report

Created: 2026-03-23 07:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/blake3-1.8.3/src/ffi_avx2.rs
Line
Count
Source
1
use crate::{CVWords, IncrementCounter, BLOCK_LEN, OUT_LEN};
2
3
// Note that there is no AVX2 implementation of compress_in_place or
4
// compress_xof.
5
6
// Unsafe because this may only be called on platforms supporting AVX2.
7
0
pub unsafe fn hash_many<const N: usize>(
8
0
    inputs: &[&[u8; N]],
9
0
    key: &CVWords,
10
0
    counter: u64,
11
0
    increment_counter: IncrementCounter,
12
0
    flags: u8,
13
0
    flags_start: u8,
14
0
    flags_end: u8,
15
0
    out: &mut [u8],
16
0
) {
17
    unsafe {
18
        // The Rust hash_many implementations do bounds checking on the `out`
19
        // array, but the C implementations don't. Even though this is an unsafe
20
        // function, assert the bounds here.
21
0
        assert!(out.len() >= inputs.len() * OUT_LEN);
22
0
        ffi::blake3_hash_many_avx2(
23
0
            inputs.as_ptr() as *const *const u8,
24
0
            inputs.len(),
25
0
            N / BLOCK_LEN,
26
0
            key.as_ptr(),
27
0
            counter,
28
0
            increment_counter.yes(),
29
0
            flags,
30
0
            flags_start,
31
0
            flags_end,
32
0
            out.as_mut_ptr(),
33
        )
34
    }
35
0
}
Unexecuted instantiation: blake3::avx2::hash_many::<1024>
Unexecuted instantiation: blake3::avx2::hash_many::<64>
36
37
pub mod ffi {
38
    unsafe 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)]
55
mod 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
}