mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Use bitmask instead of align_offset
This commit is contained in:
@@ -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
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user