Skip to content

Commit

Permalink
Switch to external memoffset crate for compatibility with CI Rust ver…
Browse files Browse the repository at this point in the history
…sion
  • Loading branch information
brianpane committed Jan 6, 2025
1 parent 9d685dd commit fb0e521
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions zlib-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ quickcheck = { workspace = true, optional = true }

[dev-dependencies]
crc32fast = "1.3.2"
memoffset = "0.9.1"
quickcheck.workspace = true
30 changes: 17 additions & 13 deletions zlib-rs/src/deflate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1327,19 +1327,6 @@ pub(crate) struct State<'a> {
}

#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
mod _cache_lines {
use super::State;
use core::mem::offset_of;

const _: () = assert!(offset_of!(State, status) == 0);
const _: () = assert!(offset_of!(State, _cache_line_0) == 64);

// strstart, the first field after the large TreeDesc fields in the middle of the
// State structure, currently is not aligned on a 64-byte boundary. For now, this
// check verifies that the offset is as expected.
// TODO: determine whether changing the aligment of this field will improve performance.
const _: () = assert!(offset_of!(State, strstart) == 2824);
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
#[cfg_attr(feature = "__internal-fuzz", derive(arbitrary::Arbitrary))]
Expand Down Expand Up @@ -4245,4 +4232,21 @@ mod test {
}
}
}

mod _cache_lines {
use super::State;
// TODO: once zlib-rs Minimum Supported Rust Version >= 1.77, switch to core::mem::offset_of
// and move this _cache_lines module from up a level from tests to super::
use memoffset::offset_of;

const _: () = assert!(offset_of!(State, status) == 0);
const _: () = assert!(offset_of!(State, _cache_line_0) == 64);

// strstart, the first field after the large TreeDesc fields in the middle of the
// State structure, currently is not aligned on a 64-byte boundary. For now, this
// check verifies that the offset is as expected.
// TODO: determine whether changing the aligment of this field will improve performance.
const _: () = assert!(offset_of!(State, strstart) == 2824);
}

}

0 comments on commit fb0e521

Please sign in to comment.