Skip to content

Commit

Permalink
Fix test for architecture used in CI environment
Browse files Browse the repository at this point in the history
**Description**
 - Add `target_arch = "x86_64"` to conditional section of alignment test
 - Run `cargo fmt`

**Motivation**
This was breaking the CI tests in Github Actions because the `cfg!(...)`
condition was wrong.

**Testing Done**
 - `cargo test`
 - `cargo miri test`
 - `cargo fmt`
 - `cargo clippy`
  • Loading branch information
Declan Kelly authored and declanvk committed Nov 21, 2022
1 parent 4f6eb98 commit 044d058
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/tagged_pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ impl<P> TaggedPointer<P> {
);
let data = data & Self::DATA_MASK;

let ptr_with_new_data = self.0.as_ptr().map_addr(|ptr_addr| {
(ptr_addr & Self::POINTER_MASK) | data
});
let ptr_with_new_data = self
.0
.as_ptr()
.map_addr(|ptr_addr| (ptr_addr & Self::POINTER_MASK) | data);

// The `ptr_with_new_data` is guaranteed to be non-null because it's pointer
// address was derived from a non-null pointer using operations that would not
Expand Down Expand Up @@ -431,18 +432,28 @@ mod tests {
0b11111111_11111111_11111111_11111111_11111111_11111111_11111111_11111000usize
);

// Something weird about the representation of u128 on x86 vs aarch64 platforms:
// Something weird about the representation of u128 on intel architectures:
// https://github.com/rust-lang/rust/issues/54341
if cfg!(target_arch = "x86") {
assert_eq!(TaggedPointer::<u128>::ALIGNMENT, 8);
if cfg!(any(target_arch = "x86", target_arch = "x86_64")) {
assert_eq!(
TaggedPointer::<u128>::ALIGNMENT,
8,
"Target architecture [{}]",
std::env::consts::ARCH
);
assert_eq!(TaggedPointer::<u128>::NUM_BITS, 3);

assert_eq!(
TaggedPointer::<u128>::POINTER_MASK,
0b11111111_11111111_11111111_11111111_11111111_11111111_11111111_11111000usize
);
} else {
assert_eq!(TaggedPointer::<u128>::ALIGNMENT, 16);
assert_eq!(
TaggedPointer::<u128>::ALIGNMENT,
16,
"Target architecture [{}]",
std::env::consts::ARCH
);
assert_eq!(TaggedPointer::<u128>::NUM_BITS, 4);

assert_eq!(
Expand Down

0 comments on commit 044d058

Please sign in to comment.