diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..9fce4a3 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,28 @@ +## The Problem + +[ What are you trying to solve? Why are you trying to solve it? ] + +## The Solution + +[ How are you fixing the problem? High-level explanation. ] + +### Changes + +[ A more detailed explanation of the solution to guide reviewers. Point out tricky or magic areas. ] + +### Planned version bump + +- Which: [ `MAJOR`, `MINOR`, `PATCH` ] +- Why: [ non-breaking bug fix, doc change, test coverage, formatting, debugging, profiling, security fix, internal change, experimental change, non-breaking new functionality, breaking change, etc ] + +### Links + +* [ Any important other PRs, Issues, PRs, etc? ] + +## Notes + +[ @mentions for anyone who should be alerted to this PR ] + +[ **Please assign reviewers if you want someone specific to review this** ] + +[ **Please do not forget to add labels specific to this PR** ] diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d9597e6..fb41fc1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,40 +4,33 @@ on: push: pull_request: workflow_dispatch: - # used when called manually. - workflow_call: - # used when called by _another_ workflow (not when called on this repo!) jobs: test: runs-on: ubuntu-latest + strategy: + matrix: + rust-toolchain: + - "1.81" # minimum for this crate + - "stable" + - "nightly" steps: - - uses: actions/checkout@v4 # not pinning to commit since this is a GitHub action, which we trust - - id: cache-cargo - name: Cache Cargo toolchain - uses: actions/cache@v4 # not pinning to commit since this is a GitHub action, which we trust + - uses: actions/checkout@v4 # not pinning to commit hash since this is a GitHub action, which we trust + - uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # v1.12.0 with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-release - - if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 # not pinning to commit since this is an archived GitHub action, which we trust - with: - profile: minimal - toolchain: stable - override: true + toolchain: ${{ matrix.rust-toolchain }} + components: rustfmt, clippy + - name: Check + run: cargo check - name: Architecture check run: cargo run arch-check - name: Architecture check (Optimized) run: cargo run --features=optimize_crc32_auto arch-check - - name: Format + - if: ${{ matrix.rust-toolchain != 'nightly' }} + name: Format run: cargo fmt -- --check - - name: Clippy + - if: ${{ matrix.rust-toolchain != 'nightly' }} + name: Clippy run: cargo clippy - name: Test run: cargo test diff --git a/Cargo.lock b/Cargo.lock index ced1043..a675ed6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 4 +version = 3 [[package]] name = "aho-corasick" @@ -75,9 +75,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bindgen" -version = "0.71.1" +version = "0.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f58bf3d7db68cfbac37cfc485a8d711e87e064c3d0fe0435b92f7a407f9d6b3" +checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f" dependencies = [ "bitflags", "cexpr", @@ -141,9 +141,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.17" +version = "1.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" +checksum = "04da6a0d40b948dfc4fa8f5bbf402b0fc1a64a28dbf7d12ffd683550f2c1b63a" dependencies = [ "jobserver", "libc", @@ -205,18 +205,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.34" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e958897981290da2a852763fe9cdb89cd36977a5d729023127095fa94d95e2ff" +checksum = "eccb054f56cbd38340b380d4a8e69ef1f02f1af43db2f0cc817a4774d80ae071" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.34" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b0f35019843db2160b5bb19ae09b4e6411ac33fc6a712003c33e03090e2489" +checksum = "efd9466fac8543255d3b1fcad4762c5e116ffe808c8a3043d4263cd4fd4862a2" dependencies = [ "anstream", "anstyle", @@ -253,7 +253,7 @@ checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crc-fast" -version = "1.0.0" +version = "1.0.1" dependencies = [ "bindgen", "cbindgen", @@ -367,9 +367,9 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" dependencies = [ "libc", "windows-sys", @@ -411,9 +411,9 @@ checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" [[package]] name = "half" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7db2ff139bba50379da6aa0766b52fdcb62cb5b263009b09ed58ba604e14bbd1" +checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9" dependencies = [ "cfg-if", "crunchy", @@ -421,9 +421,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.2" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" [[package]] name = "heck" @@ -439,9 +439,9 @@ checksum = "fbd780fe5cc30f81464441920d82ac8740e2e46b29a6fad543ddd075229ce37e" [[package]] name = "indexmap" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", "hashbrown", @@ -490,10 +490,11 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jobserver" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" dependencies = [ + "getrandom", "libc", ] @@ -509,9 +510,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.171" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "libloading" @@ -525,9 +526,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" [[package]] name = "log" @@ -617,9 +618,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.31" +version = "0.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5316f57387668042f561aae71480de936257848f9c43ce528e311d89a07cadeb" +checksum = "664ec5419c51e34154eec046ebcba56312d5a2fc3b09a06da188e1ad21afadf6" dependencies = [ "proc-macro2", "syn", @@ -627,9 +628,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -651,13 +652,12 @@ checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" [[package]] name = "rand" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" dependencies = [ "rand_chacha", "rand_core", - "zerocopy", ] [[package]] @@ -730,15 +730,15 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustc-hash" -version = "2.1.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "1.0.3" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96" +checksum = "91b73dab8b4bf63c9dbf81b3d2d4ae6e54033e397c3051a3baac27f7e4e5607e" dependencies = [ "bitflags", "errno", @@ -823,9 +823,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.100" +version = "2.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" dependencies = [ "proc-macro2", "quote", @@ -857,9 +857,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.20" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" +checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae" dependencies = [ "serde", "serde_spanned", @@ -869,26 +869,33 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.24" +version = "0.22.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" +checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", + "toml_write", "winnow", ] +[[package]] +name = "toml_write" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076" + [[package]] name = "typenum" version = "1.18.0" @@ -1084,9 +1091,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.7.4" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36" +checksum = "6cb8234a863ea0e8cd7284fcdd4f145233eb00fee02bbdd9861aec44e6477bc5" dependencies = [ "memchr", ] @@ -1102,18 +1109,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.24" +version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" +checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.24" +version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" +checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 4e87487..df38e3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,17 +1,17 @@ [package] name = "crc-fast" -version = "1.0.0" +version = "1.0.1" edition = "2021" authors = ["Don MacAskill"] license = "MIT OR Apache-2.0" keywords = ["crc", "checksum", "simd", "accelerated", "fast"] categories = ["algorithms", "encoding", "hardware-support"] repository = "https://github.com/awesomized/crc-fast-rust" -description = "Hardware-accelerated CRC-32 and CRC-64 checksum calculation using SIMD" +description = "Fast, hardware-accelerated CRC-32 and CRC-64 checksum calculation using SIMD" readme = "README.md" # 1.69.0 added VPCLMULQDQ x86 detection support, 1.70.0 added LLVM 16 which supports PMULL2 on Aarch64 -rust-version = "1.70" +rust-version = "1.81" [lib] name = "crc_fast" @@ -28,7 +28,7 @@ regex = "1.11.1" [dev-dependencies] criterion = "0.5" cbindgen = "0.28" -bindgen = "0.71" +bindgen = "0.70" # 0.70 is the last version that supports Rust 1.81 due to 'unsafe extern' blocks [build-dependencies] cc = { version = "1.2", features = ["parallel"] } diff --git a/src/bindings/crc32_iscsi.rs b/src/bindings/crc32_iscsi.rs index 8eb61f4..848d748 100644 --- a/src/bindings/crc32_iscsi.rs +++ b/src/bindings/crc32_iscsi.rs @@ -1,13 +1,13 @@ -/* automatically generated by rust-bindgen 0.71.1 */ +/* automatically generated by rust-bindgen 0.70.1 */ -unsafe extern "C" { +extern "C" { pub static ISCSI_TARGET: *const ::std::os::raw::c_char; } -unsafe extern "C" { +extern "C" { #[doc = " Gets the target build properties (CPU architecture and fine-tuning parameters) for this implementation."] pub fn get_iscsi_target() -> *const ::std::os::raw::c_char; } -unsafe extern "C" { +extern "C" { #[doc = " Calculate CRC-32/ISCSI checksum using hardware acceleration\n\n @param crc0 Initial CRC value (typically 0)\n @param buf Pointer to input data buffer\n @param len Length of input data in bytes\n\n @return Calculated CRC-32/ISCSI checksum"] pub fn crc32_iscsi_impl(crc0: u32, buf: *const ::std::os::raw::c_char, len: usize) -> u32; } diff --git a/src/bindings/crc32_iso_hdlc.rs b/src/bindings/crc32_iso_hdlc.rs index 2df2a21..25de98d 100644 --- a/src/bindings/crc32_iso_hdlc.rs +++ b/src/bindings/crc32_iso_hdlc.rs @@ -1,13 +1,13 @@ -/* automatically generated by rust-bindgen 0.71.1 */ +/* automatically generated by rust-bindgen 0.70.1 */ -unsafe extern "C" { +extern "C" { pub static ISO_HDLC_TARGET: *const ::std::os::raw::c_char; } -unsafe extern "C" { +extern "C" { #[doc = " Gets the target build properties (CPU architecture and fine-tuning parameters) for this implementation."] pub fn get_iso_hdlc_target() -> *const ::std::os::raw::c_char; } -unsafe extern "C" { +extern "C" { #[doc = " Calculate CRC-32/ISO_HDLC checksum using hardware acceleration\n\n @param crc0 Initial CRC value (typically 0)\n @param buf Pointer to input data buffer\n @param len Length of input data in bytes\n\n @return Calculated CRC-32/ISO_HDLC checksum"] pub fn crc32_iso_hdlc_impl(crc0: u32, buf: *const ::std::os::raw::c_char, len: usize) -> u32; }