Skip to content

Commit

Permalink
mark the AVX-512 xof_many implementation as Unix-only
Browse files Browse the repository at this point in the history
  • Loading branch information
oconnor663 committed Aug 15, 2024
1 parent bb2c530 commit cc0c9b6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions c/blake3_c_rust_bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ pub mod ffi {
flags_end: u8,
out: *mut u8,
);
#[cfg(unix)]
pub fn blake3_xof_many_avx512(
cv: *const u32,
block: *const u8,
Expand Down
1 change: 1 addition & 0 deletions c/blake3_c_rust_bindings/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ fn test_xof_many_portable() {
}

#[test]
#[cfg(unix)]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn test_xof_many_avx512() {
if !crate::avx512_detected() {
Expand Down
3 changes: 3 additions & 0 deletions src/ffi_avx512.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub unsafe fn hash_many<const N: usize>(
}

// Unsafe because this may only be called on platforms supporting AVX-512.
#[cfg(unix)]
pub unsafe fn xof_many(
cv: &CVWords,
block: &[u8; BLOCK_LEN],
Expand Down Expand Up @@ -109,6 +110,7 @@ pub mod ffi {
flags_end: u8,
out: *mut u8,
);
#[cfg(unix)]
pub fn blake3_xof_many_avx512(
cv: *const u32,
block: *const u8,
Expand Down Expand Up @@ -141,6 +143,7 @@ mod test {
crate::test::test_hash_many_fn(hash_many, hash_many);
}

#[cfg(unix)]
#[test]
fn test_xof_many() {
if !crate::platform::avx512_detected() {
Expand Down
1 change: 1 addition & 0 deletions src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ impl Platform {
match self {
// Safe because detect() checked for platform support.
#[cfg(blake3_avx512_ffi)]
#[cfg(unix)]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
Platform::AVX512 => unsafe {
crate::avx512::xof_many(cv, block, block_len, counter, flags, out)
Expand Down

0 comments on commit cc0c9b6

Please sign in to comment.