Skip to content

Commit

Permalink
utils: use stabilized <ptr>::is_aligned()
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxVerevkin committed Jan 14, 2025
1 parent 52d2cef commit a3f4c7e
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions wayrs-utils/src/dmabuf_feedback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fn dmabuf_feedback_cb<D: DmabufFeedbackHandler>(ctx: EventCtx<D, ZwpLinuxDmabufF
.expect("mmap failed")
};
assert!(
ptr_is_aligned(mmap.as_ptr().cast::<FormatTableEntry>()),
mmap.as_ptr().cast::<FormatTableEntry>().is_aligned(),
"memory map is not alligned"
);
feedback.format_table = Some(mmap);
Expand Down Expand Up @@ -192,8 +192,3 @@ impl fmt::Debug for FormatTableEntry {
)
}
}

// TODO: remove when MSRV is 1.79
fn ptr_is_aligned<T>(ptr: *const T) -> bool {
(ptr as usize) & (std::mem::align_of::<T>() - 1) == 0
}

0 comments on commit a3f4c7e

Please sign in to comment.