Skip to content

Conversation

@onethumb
Copy link
Contributor

The Problem

The library currently only supports CRC-32 and CRC-64 widths, but there was a request for CRC-16 in #18.

The Solution

Implement CRC-16 in a relatively future-proof way to enable future widths to be added more easily as well.

Changes

  • Adds CRC-16 support for all known variants and custom parameters
  • Adds CrcCustom that's width-agnostic, which supports 16, 32, and 64 bit widths today, but can support more in the future

Planned version bump

  • Which: MINOR
  • Why: non-breaking new functionality

Links

Notes

Should enable other future widths if anyone desires them.

Begins adding CRC-16 support using known good values.
Add CRC-16 exponents constant and update keys() function
1.1 Add CRC-16 exponents constant and update keys() function
Write property test for CRC-16 computation matches reference
No idea how this got left behind. :(
Includes notes on CRC-16 support plus helper functions for the most
popular variants, among other small improvements.
Better future proofing, easier for consumers to use.

Marks Crc32Custom and Crc64Custom as deprecated.
Matches the aarch64 approach more closely, avoiding stack
overflows on x86_64
No target features gate against this
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds hardware-accelerated CRC-16 support to the crc-fast library, addressing issue #18. The implementation extends the existing CRC-32 and CRC-64 infrastructure to support all known CRC-16 variants plus custom parameters.

Key Changes:

  • Adds CRC-16 support for 31 known variants with hardware acceleration
  • Introduces CrcCustom algorithm variant that's width-agnostic (replaces Crc32Custom and Crc64Custom)
  • Adds init_algorithm field to CrcParams for pre-computed bit-reversed init values for reflected CRC-16
  • Refactors CRC-16 and CRC-32 to share common 32-bit-space SIMD operations

Reviewed changes

Copilot reviewed 40 out of 42 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/crc16/* New CRC-16 module with algorithm implementation and constants for 31 variants
src/structs.rs Adds Width16 implementation and init_algorithm computation in CrcParams::new()
src/lib.rs Updates checksum functions to use init_algorithm and handle CRC-16 enum variants
src/traits.rs Changes keys parameter from by-value to by-reference (&[u64; 23])
src/generate.rs Adds CRC-16 key generation functions with polynomial formatting and Barrett reduction
src/crc32/width32_ops.rs New shared module for 32-bit-space operations used by both CRC-16 and CRC-32
src/ffi.rs Adds CRC-16 FFI enum variants and CrcCustom support
src/combine.rs Updates to use init_algorithm instead of init
src/arch/mod.rs Adds Width16 dispatch routing for all architecture targets
test files Adds comprehensive tests for CRC-16 with property-based testing
README.md, Cargo.toml Updates documentation and dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@onethumb onethumb merged commit 0e0062a into awesomized:main Dec 22, 2025
212 of 214 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant