File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,11 @@ impl VirtAddr {
100100 }
101101 ///`VirtAddr`->`VirtPageNum`
102102 pub fn ceil ( & self ) -> VirtPageNum {
103- VirtPageNum ( ( self . 0 - 1 + PAGE_SIZE ) / PAGE_SIZE )
103+ if self . 0 == 0 {
104+ VirtPageNum ( 0 )
105+ } else {
106+ VirtPageNum ( ( self . 0 - 1 + PAGE_SIZE ) / PAGE_SIZE )
107+ }
104108 }
105109 ///Get page offset
106110 pub fn page_offset ( & self ) -> usize {
@@ -129,7 +133,11 @@ impl PhysAddr {
129133 }
130134 ///`PhysAddr`->`PhysPageNum`
131135 pub fn ceil ( & self ) -> PhysPageNum {
132- PhysPageNum ( ( self . 0 - 1 + PAGE_SIZE ) / PAGE_SIZE )
136+ if self . 0 == 0 {
137+ PhysPageNum ( 0 )
138+ } else {
139+ PhysPageNum ( ( self . 0 - 1 + PAGE_SIZE ) / PAGE_SIZE )
140+ }
133141 }
134142 ///Get page offset
135143 pub fn page_offset ( & self ) -> usize {
You can’t perform that action at this time.
0 commit comments