OXYGENHUB
# 7bd805ffb418 oxygen / vendor / crc-fast / src / crc32 / fusion / mod.rs
1011 B · Rust · last changed Strata: the cloud stores send through ureq, so every release target links 1 month ago source blame history raw
1
// Copyright 2025 Don MacAskill. Licensed under MIT or Apache-2.0.
2
3
//! This module provides support for calculating CRC-32/ISO-HDLC and CRC-32/ISCSI using
4
//! fusion techniques.
5
//!
6
//! https://www.corsix.org/content/fast-crc32c-4k
7
//! https://www.corsix.org/content/alternative-exposition-crc32_4k_pclmulqdq
8
//! https://dougallj.wordpress.com/2022/05/22/faster-crc32-on-the-apple-m1/
9
//! https://github.com/corsix/fast-crc32/
10
11
mod aarch64;
12
mod x86;
13
14
/// Only AArch64 has native CRC-32/ISO-HDLC instructions
15
#[inline(always)]
16
#[cfg(target_arch = "aarch64")]
17
pub(crate) fn crc32_iso_hdlc(state: u32, data: &[u8]) -> u32 {
18
    aarch64::crc32_iso_hdlc(state, data)
19
}
20
21
/// Both AArch64 and x86 have native CRC-32/ISCSI instructions
22
#[inline(always)]
23
pub(crate) fn crc32_iscsi(state: u32, data: &[u8]) -> u32 {
24
    #[cfg(target_arch = "aarch64")]
25
    {
26
        aarch64::crc32_iscsi(state, data)
27
    }
28
29
    #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
30
    {
31
        x86::crc32_iscsi(state, data)
32
    }
33
}