diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ea7bac..ead2a6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,32 +48,22 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v5 - name: Install Rust (${{ matrix.rust }}) - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: ${{ matrix.rust }} - override: true - name: no_std - uses: actions-rs/cargo@v1 - with: - command: build - args: --no-default-features + run: cargo build --no-default-features - name: Test - uses: actions-rs/cargo@v1 - with: - command: test + run: cargo test - name: Test all benches if: matrix.benches - uses: actions-rs/cargo@v1 - with: - command: test - args: --benches + run: cargo test --benches simd: name: SIMD ${{ matrix.target_feature }} on ${{ matrix.rust }} @@ -96,72 +86,52 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v5 - name: Install Rust (${{ matrix.rust }}) - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: ${{ matrix.rust }} - override: true - name: Test - uses: actions-rs/cargo@v1 - with: - command: test env: RUSTFLAGS: -C target_feature=${{ matrix.target_feature }} CARGO_CFG_HTTPARSE_DISABLE_SIMD_COMPILETIME: ${{ matrix.disable_compiletime }} + run: cargo test check_x86: name: check x86 runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v5 - name: Setup Rust - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: - profile: minimal - toolchain: stable - override: true - target: i686-unknown-linux-musl + targets: i686-unknown-linux-musl - name: Test without SIMD - uses: actions-rs/cargo@v1 - with: - command: test - args: --target i686-unknown-linux-musl env: CARGO_CFG_HTTPARSE_DISABLE_SIMD_COMPILETIME: 1 + run: cargo test --target i686-unknown-linux-musl - name: Test - - uses: actions-rs/cargo@v1 - with: - command: test - args: --target i686-unknown-linux-musl + run: cargo test --target i686-unknown-linux-musl msrv_x64: name: msrv (x64) runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v5 - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: 1.47.0 - override: true + uses: dtolnay/rust-toolchain@1.47.0 # Only build, dev-dependencies don't compile on 1.47.0 - name: Build - uses: actions-rs/cargo@v1 - with: - command: build + run: cargo build # This tests that aarch64 gracefully fallbacks to SWAR if neon_intrinsics aren't available (<1.59) msrv_aarch64: @@ -169,7 +139,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v5 - name: Install cross-compiling dependencies run: | @@ -177,24 +147,21 @@ jobs: sudo apt-get install -y gcc-aarch64-linux-gnu - name: Setup Rust - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@1.47.0 with: - profile: minimal - toolchain: 1.47.0 - override: true target: aarch64-unknown-linux-gnu # Only build, dev-dependencies don't compile on 1.47.0 - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --target aarch64-unknown-linux-gnu + run: cargo build --target aarch64-unknown-linux-gnu clippy_check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy - name: Run clippy run: cargo clippy --all-targets --all-features @@ -204,43 +171,15 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v5 - name: Install Rust - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@nightly with: - profile: minimal - toolchain: nightly components: miri - override: true - name: Test run: cargo miri test - # - # mirai: - # name: MIRAI static analysis - # runs-on: ubuntu-latest - # - # steps: - # - name: Checkout - # uses: actions/checkout@v1 - # - # - name: Install Rust - # uses: actions-rs/toolchain@v1 - # with: - # profile: minimal - # toolchain: nightly-2023-05-09 - # components: clippy, rustfmt, rustc-dev, rust-src, rust-std, llvm-tools-preview - # override: true - # - # - name: install mirai - # run: cargo install --locked --git https://github.com/facebookexperimental/MIRAI/ mirai - # env: - # # MIRAI_FLAGS: --diag=(default|verify|library|paranoid) - # MIRAI_FLAGS: --diag=default - # - # - name: cargo mirai - # run: cargo mirai --lib aarch64: name: Test aarch64 (neon) @@ -249,15 +188,12 @@ jobs: CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v5 - name: Setup Rust - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: - profile: minimal - toolchain: stable - override: true - target: aarch64-unknown-linux-gnu + targets: aarch64-unknown-linux-gnu - name: Install QEMU and dependencies run: | diff --git a/.github/workflows/cibench.yml b/.github/workflows/cibench.yml index 83133af..647b91a 100644 --- a/.github/workflows/cibench.yml +++ b/.github/workflows/cibench.yml @@ -12,16 +12,12 @@ jobs: name: Run benchmarks runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 with: fetch-depth: 0 - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true + uses: dtolnay/rust-toolchain@stable - name: Install critcmp run: cargo install critcmp @@ -47,16 +43,12 @@ jobs: matrix: feature: [swar, sse42, avx2] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 with: fetch-depth: 0 - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true + uses: dtolnay/rust-toolchain@stable - name: Install critcmp run: cargo install critcmp @@ -88,16 +80,12 @@ jobs: matrix: feature: [swar, neon] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 with: fetch-depth: 0 - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true + uses: dtolnay/rust-toolchain@stable - name: Install critcmp run: cargo install critcmp diff --git a/Cargo.toml b/Cargo.toml index 4aee710..6cc7d42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ default = ["std"] std = [] [dev-dependencies] -criterion = "0.3.5" +criterion = { version = "0.3.5", features = ["html_reports"] } rand = "0.8.5" [lib] diff --git a/src/lib.rs b/src/lib.rs index 1a99bc9..1af4b20 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr(not(any(test, feature = "std")), no_std)] #![deny( missing_docs, clippy::missing_safety_doc, @@ -1795,7 +1795,7 @@ mod tests { let mut headers = [EMPTY_HEADER; NUM_OF_HEADERS]; let mut req = Request::new(&mut headers[..]); for i in 0..req_str.len() { - let status = req.parse(req_str[..i].as_bytes()); + let status = req.parse(&req_str.as_bytes()[..i]); assert_eq!( status, Ok(Status::Partial), diff --git a/src/simd/neon.rs b/src/simd/neon.rs index b059efb..2994a57 100644 --- a/src/simd/neon.rs +++ b/src/simd/neon.rs @@ -182,9 +182,9 @@ unsafe fn offsetnz(x: uint8x16_t) -> u32 { if low != 0 { clz(low) } else if high != 0 { - return 8 + clz(high); + 8 + clz(high) } else { - return 16; + 16 } }