Use bitmask instead of align_offset

This commit is contained in:
Philipp Oppermann
2020-01-28 10:29:53 +01:00
parent d1678f5a96
commit 93fd330ab9

View File

@@ -75,7 +75,8 @@ impl<A> Locked<A> {
} }
/// Align the given address `addr` upwards to alignment `align`. /// Align the given address `addr` upwards to alignment `align`.
///
/// Requires that `align` is a power of two.
fn align_up(addr: usize, align: usize) -> usize { fn align_up(addr: usize, align: usize) -> usize {
let offset = (addr as *const u8).align_offset(align); (addr + align - 1) & !(align - 1)
addr + offset
} }