Skip to content

Commit

Permalink
fix test compilation of swar on 32bit
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Jun 10, 2024
1 parent 26611e1 commit 22e6415
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
14 changes: 2 additions & 12 deletions src/simd/avx2.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#[cfg(target_arch = "x86")]
pub(crate) unsafe fn match_uri_vectored(_: &[u8]) -> usize {
unreachable!("AVX2 detection should be disabled for x86");
}

#[inline]
#[cfg(target_arch = "x86_64")]
#[target_feature(enable = "avx2", enable = "sse4.2")]
pub(crate) unsafe fn match_uri_vectored(bytes: &[u8]) -> usize {
let mut len = 0usize;
Expand All @@ -26,6 +20,7 @@ pub(crate) unsafe fn match_uri_vectored(bytes: &[u8]) -> usize {

#[inline(always)]
#[allow(non_snake_case, overflowing_literals)]
#[allow(unused)]
unsafe fn match_url_char_32_avx(buf: &[u8]) -> usize {
debug_assert!(buf.len() >= 32);

Expand Down Expand Up @@ -64,12 +59,6 @@ unsafe fn match_url_char_32_avx(buf: &[u8]) -> usize {
r.trailing_zeros() as usize
}

#[cfg(target_arch = "x86")]
pub(crate) unsafe fn match_header_value_vectored(_: &[u8]) -> usize {
unreachable!("AVX2 detection should be disabled for x86");
}

#[cfg(target_arch = "x86_64")]
#[target_feature(enable = "avx2", enable = "sse4.2")]
pub(crate) unsafe fn match_header_value_vectored(bytes: &[u8]) -> usize {
let mut len = 0usize;
Expand All @@ -91,6 +80,7 @@ pub(crate) unsafe fn match_header_value_vectored(bytes: &[u8]) -> usize {

#[inline(always)]
#[allow(non_snake_case)]
#[allow(unused)]
unsafe fn match_header_value_char_32_avx(buf: &[u8]) -> usize {
debug_assert!(buf.len() >= 32);

Expand Down
10 changes: 7 additions & 3 deletions src/simd/swar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,13 @@ fn test_is_header_value_block() {
assert!(!is_header_value_block([b; BLOCK_SIZE]), "b={}", b);
}

// A few sanity checks on non-uniform bytes for safe-measure
assert!(!is_header_value_block(*b"foo.com\n"));
assert!(!is_header_value_block(*b"o.com\r\nU"));

#[cfg(target_pointer_width = "64")]
{
// A few sanity checks on non-uniform bytes for safe-measure
assert!(!is_header_value_block(*b"foo.com\n"));
assert!(!is_header_value_block(*b"o.com\r\nU"));
}
}

#[test]
Expand Down

0 comments on commit 22e6415

Please sign in to comment.