Fix issue #123
This commit is contained in:
parent
45477b345f
commit
90e969c0ae
1 changed files with 10 additions and 2 deletions
|
@ -103,8 +103,12 @@ impl VirtAddr {
|
|||
VirtPageNum(self.0 / PAGE_SIZE)
|
||||
}
|
||||
pub fn ceil(&self) -> VirtPageNum {
|
||||
if self.0 == 0 {
|
||||
VirtPageNum(0)
|
||||
} else {
|
||||
VirtPageNum((self.0 - 1 + PAGE_SIZE) / PAGE_SIZE)
|
||||
}
|
||||
}
|
||||
pub fn page_offset(&self) -> usize {
|
||||
self.0 & (PAGE_SIZE - 1)
|
||||
}
|
||||
|
@ -128,8 +132,12 @@ impl PhysAddr {
|
|||
PhysPageNum(self.0 / PAGE_SIZE)
|
||||
}
|
||||
pub fn ceil(&self) -> PhysPageNum {
|
||||
if self.0 == 0 {
|
||||
PhysPageNum(0)
|
||||
} else {
|
||||
PhysPageNum((self.0 - 1 + PAGE_SIZE) / PAGE_SIZE)
|
||||
}
|
||||
}
|
||||
pub fn page_offset(&self) -> usize {
|
||||
self.0 & (PAGE_SIZE - 1)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue