mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-22 09:26:26 +04:00
VirtAddr: fix add with overflow when debug mode
This commit is contained in:
parent
00084f5165
commit
84a55c17c4
@ -73,7 +73,7 @@ impl From<VirtPageNum> for usize {
|
||||
|
||||
impl VirtAddr {
|
||||
pub fn floor(&self) -> VirtPageNum { VirtPageNum(self.0 / PAGE_SIZE) }
|
||||
pub fn ceil(&self) -> VirtPageNum { VirtPageNum((self.0 + PAGE_SIZE - 1) / PAGE_SIZE) }
|
||||
pub fn ceil(&self) -> VirtPageNum { VirtPageNum((self.0 - 1 + PAGE_SIZE) / PAGE_SIZE) }
|
||||
pub fn page_offset(&self) -> usize { self.0 & (PAGE_SIZE - 1) }
|
||||
pub fn aligned(&self) -> bool { self.page_offset() == 0 }
|
||||
}
|
||||
@ -88,7 +88,7 @@ impl From<VirtPageNum> for VirtAddr {
|
||||
}
|
||||
impl PhysAddr {
|
||||
pub fn floor(&self) -> PhysPageNum { PhysPageNum(self.0 / PAGE_SIZE) }
|
||||
pub fn ceil(&self) -> PhysPageNum { PhysPageNum((self.0 + PAGE_SIZE - 1) / PAGE_SIZE) }
|
||||
pub fn ceil(&self) -> PhysPageNum { PhysPageNum((self.0 - 1 + PAGE_SIZE) / PAGE_SIZE) }
|
||||
pub fn page_offset(&self) -> usize { self.0 & (PAGE_SIZE - 1) }
|
||||
pub fn aligned(&self) -> bool { self.page_offset() == 0 }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user