Skip to content

use is_multiple_of to check if an addr is aligned #1847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/core_arch/src/powerpc/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ macro_rules! impl_from {
($s: ident) => {
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
impl From<$s> for s_t_l!($s) {
#[inline]
fn from (v: $s) -> Self {
unsafe {
transmute(v)
Expand All @@ -297,6 +298,7 @@ macro_rules! impl_neg {
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
impl crate::ops::Neg for s_t_l!($s) {
type Output = s_t_l!($s);
#[inline]
fn neg(self) -> Self::Output {
unsafe { simd_neg(self) }
}
Expand Down
2 changes: 2 additions & 0 deletions crates/core_arch/src/s390x/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ macro_rules! impl_from {
($s: ident) => {
#[unstable(feature = "stdarch_s390x", issue = "135681")]
impl From<$s> for s_t_l!($s) {
#[inline]
fn from (v: $s) -> Self {
unsafe {
transmute(v)
Expand All @@ -454,6 +455,7 @@ macro_rules! impl_neg {
#[unstable(feature = "stdarch_s390x", issue = "135681")]
impl crate::ops::Neg for s_t_l!($s) {
type Output = s_t_l!($s);
#[inline]
fn neg(self) -> Self::Output {
unsafe { simd_neg(self) }
}
Expand Down
4 changes: 2 additions & 2 deletions crates/core_arch/src/s390x/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ types! {
pub struct vector_double(2 x f64);
}

#[repr(packed)]
#[repr(C, packed)]
struct PackedTuple<T, U> {
x: T,
y: U,
Expand Down Expand Up @@ -4787,7 +4787,7 @@ pub unsafe fn vec_splat_s8<const IMM: i8>() -> vector_signed_char {
#[unstable(feature = "stdarch_s390x", issue = "135681")]
#[cfg_attr(test, assert_instr(vrepih, IMM = 42))]
pub unsafe fn vec_splat_s16<const IMM: i16>() -> vector_signed_short {
vector_signed_short([IMM as i16; 8])
vector_signed_short([IMM; 8])
}

/// Vector Splat Signed Word
Expand Down
2 changes: 1 addition & 1 deletion crates/core_arch/src/wasm32/simd128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ unsafe extern "unadjusted" {
fn llvm_f64x2_max(x: simd::f64x2, y: simd::f64x2) -> simd::f64x2;
}

#[repr(packed)]
#[repr(C, packed)]
#[derive(Copy)]
struct Unaligned<T>(T);

Expand Down
2 changes: 1 addition & 1 deletion crates/core_arch/src/x86_64/cmpxchg16b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub unsafe fn cmpxchg16b(
success: Ordering,
failure: Ordering,
) -> u128 {
debug_assert!(dst as usize % 16 == 0);
debug_assert!(dst.addr().is_multiple_of(16));

let res = crate::sync::atomic::atomic_compare_exchange(dst, old, new, success, failure);
res.unwrap_or_else(|x| x)
Expand Down