Skip to content

Commit

Permalink
Apply formatting suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
onethumb committed Sep 7, 2024
1 parent 18dcbf5 commit 46a519f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 28 deletions.
30 changes: 8 additions & 22 deletions src/bin/calculate_pclmulqdq_artifacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,13 @@
/// Linux's implementations: https://github.com/torvalds/linux/blob/786c8248dbd33a5a7a07f7c6e55a7bfc68d2ca48/lib/crc64.c
///
/// Intel white paper: https://web.archive.org/web/20131224125630/https://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf
extern crate core;

use std::env;

// the key sizes to calculate, given this is a CRC-64 (rather than a CRC-32, as in the Intel paper)
/// the key sizes to calculate, given this is a CRC-64 (rather than a CRC-32, as in the Intel paper)
static KEY_SIZES: [u32; 16] = [
128,
192,
256,
320,
384,
448,
512,
576,
640,
704,
768,
832,
896,
960,
1024,
1088,
128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, 1088,
];

/// Reverses the bits of a 64-bit unsigned integer.
Expand Down Expand Up @@ -250,16 +234,18 @@ fn main() {
return;
}

let polynomial = u64::from_str_radix(
args[1].trim_start_matches("0x"), 16
).expect("Failed to parse polynomial");
let polynomial = u64::from_str_radix(args[1].trim_start_matches("0x"), 16)
.expect("Failed to parse polynomial");

for &size in KEY_SIZES.iter() {
println!("k_{} = 0x{:x}", size, generate_key(size as u64, polynomial));
}

println!("mu = 0x{:x}", generate_mu(polynomial));
println!("reciprocal = 0x{:x}", generate_reciprocal_polynomial(polynomial));
println!(
"reciprocal = 0x{:x}",
generate_reciprocal_polynomial(polynomial)
);
}

#[cfg(test)]
Expand Down
7 changes: 3 additions & 4 deletions src/bin/crc_64_nvme_checksum.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crc64fast_nvme::Digest;
/// Generates CRC-64/NVME checksums, using SIMD-accelerated
/// carryless-multiplication, from a file on disk.
use std::env;
use std::fs;
use std::process::ExitCode;
use crc64fast_nvme::Digest;

const CRC_NVME: crc::Algorithm<u64> = crc::Algorithm {
width: 64,
Expand All @@ -14,7 +13,7 @@ const CRC_NVME: crc::Algorithm<u64> = crc::Algorithm {
refout: true,
xorout: 0xFFFFFFFFFFFFFFFF,
check: 0xae8b14860a799888,
residue: 0x0000000000000000
residue: 0x0000000000000000,
};

fn calculate_crc_64_simd_from_file(file: &str) -> u64 {
Expand Down Expand Up @@ -108,4 +107,4 @@ fn main() -> ExitCode {
println!("An error occurred, likely due to bad command-line arguments.");

ExitCode::from(1)
}
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ mod tests {
refout: true,
xorout: 0xFFFFFFFFFFFFFFFF,
check: 0xae8b14860a799888,
residue: 0x0000000000000000
residue: 0x0000000000000000,
};

#[test]
Expand Down
1 change: 0 additions & 1 deletion src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1904,7 +1904,6 @@ static TABLE_6: [u64; 256] = [
0xe0afe6b4079dfaba,
];


// CRC table for the NVME polynomial in the range (`1 = x¹²⁷, …, 128 = x¹²⁰`).
// Generated by running `./build_table 7`.
static TABLE_7: [u64; 256] = [
Expand Down

0 comments on commit 46a519f

Please sign in to comment.