@@ -69,6 +69,7 @@ impl VirtAddr {
6969 /// This function performs sign extension of bit 47 to make the address canonical, so
7070 /// bits 48 to 64 are overwritten. If you want to check that these bits contain no data,
7171 /// use `new` or `try_new`.
72+ #[ inline]
7273 pub const fn new_unchecked ( addr : u64 ) -> VirtAddr {
7374 // Rust doesn't accept shift operators in const functions at the moment,
7475 // so we use a multiplication and division by 0x1_0000 instead of `<< 16` and `>> 16`.
@@ -78,11 +79,13 @@ impl VirtAddr {
7879 }
7980
8081 /// Creates a virtual address that points to `0`.
82+ #[ inline]
8183 pub const fn zero ( ) -> VirtAddr {
8284 VirtAddr ( 0 )
8385 }
8486
8587 /// Converts the address to an `u64`.
88+ #[ inline]
8689 pub const fn as_u64 ( self ) -> u64 {
8790 self . 0
8891 }
@@ -93,25 +96,29 @@ impl VirtAddr {
9396 // on this function. At least for 32- and 64-bit we know the `as u64` cast
9497 // doesn't truncate.
9598 #[ cfg( any( target_pointer_width = "32" , target_pointer_width = "64" ) ) ]
99+ #[ inline]
96100 pub fn from_ptr < T > ( ptr : * const T ) -> Self {
97101 Self :: new ( ptr as u64 )
98102 }
99103
100104 /// Converts the address to a raw pointer.
101105 #[ cfg( target_pointer_width = "64" ) ]
106+ #[ inline]
102107 pub fn as_ptr < T > ( self ) -> * const T {
103108 self . as_u64 ( ) as * const T
104109 }
105110
106111 /// Converts the address to a mutable raw pointer.
107112 #[ cfg( target_pointer_width = "64" ) ]
113+ #[ inline]
108114 pub fn as_mut_ptr < T > ( self ) -> * mut T {
109115 self . as_ptr :: < T > ( ) as * mut T
110116 }
111117
112118 /// Aligns the virtual address upwards to the given alignment.
113119 ///
114120 /// See the `align_up` function for more information.
121+ #[ inline]
115122 pub fn align_up < U > ( self , align : U ) -> Self
116123 where
117124 U : Into < u64 > ,
@@ -122,6 +129,7 @@ impl VirtAddr {
122129 /// Aligns the virtual address downwards to the given alignment.
123130 ///
124131 /// See the `align_down` function for more information.
132+ #[ inline]
125133 pub fn align_down < U > ( self , align : U ) -> Self
126134 where
127135 U : Into < u64 > ,
@@ -130,6 +138,7 @@ impl VirtAddr {
130138 }
131139
132140 /// Checks whether the virtual address has the demanded alignment.
141+ #[ inline]
133142 pub fn is_aligned < U > ( self , align : U ) -> bool
134143 where
135144 U : Into < u64 > ,
@@ -138,26 +147,31 @@ impl VirtAddr {
138147 }
139148
140149 /// Returns the 12-bit page offset of this virtual address.
150+ #[ inline]
141151 pub fn page_offset ( & self ) -> PageOffset {
142152 PageOffset :: new_truncate ( self . 0 as u16 )
143153 }
144154
145155 /// Returns the 9-bit level 1 page table index.
156+ #[ inline]
146157 pub fn p1_index ( & self ) -> PageTableIndex {
147158 PageTableIndex :: new_truncate ( ( self . 0 >> 12 ) as u16 )
148159 }
149160
150161 /// Returns the 9-bit level 2 page table index.
162+ #[ inline]
151163 pub fn p2_index ( & self ) -> PageTableIndex {
152164 PageTableIndex :: new_truncate ( ( self . 0 >> 12 >> 9 ) as u16 )
153165 }
154166
155167 /// Returns the 9-bit level 3 page table index.
168+ #[ inline]
156169 pub fn p3_index ( & self ) -> PageTableIndex {
157170 PageTableIndex :: new_truncate ( ( self . 0 >> 12 >> 9 >> 9 ) as u16 )
158171 }
159172
160173 /// Returns the 9-bit level 4 page table index.
174+ #[ inline]
161175 pub fn p4_index ( & self ) -> PageTableIndex {
162176 PageTableIndex :: new_truncate ( ( self . 0 >> 12 >> 9 >> 9 >> 9 ) as u16 )
163177 }
@@ -252,6 +266,7 @@ impl PhysAddr {
252266 }
253267
254268 /// Creates a new physical address, throwing bits 52..64 away.
269+ #[ inline]
255270 pub const fn new_truncate ( addr : u64 ) -> PhysAddr {
256271 PhysAddr ( addr % ( 1 << 52 ) )
257272 }
@@ -267,18 +282,21 @@ impl PhysAddr {
267282 }
268283
269284 /// Converts the address to an `u64`.
285+ #[ inline]
270286 pub fn as_u64 ( self ) -> u64 {
271287 self . 0
272288 }
273289
274290 /// Convenience method for checking if a physical address is null.
291+ #[ inline]
275292 pub fn is_null ( & self ) -> bool {
276293 self . 0 == 0
277294 }
278295
279296 /// Aligns the physical address upwards to the given alignment.
280297 ///
281298 /// See the `align_up` function for more information.
299+ #[ inline]
282300 pub fn align_up < U > ( self , align : U ) -> Self
283301 where
284302 U : Into < u64 > ,
@@ -289,6 +307,7 @@ impl PhysAddr {
289307 /// Aligns the physical address downwards to the given alignment.
290308 ///
291309 /// See the `align_down` function for more information.
310+ #[ inline]
292311 pub fn align_down < U > ( self , align : U ) -> Self
293312 where
294313 U : Into < u64 > ,
@@ -297,6 +316,7 @@ impl PhysAddr {
297316 }
298317
299318 /// Checks whether the physical address has the demanded alignment.
319+ #[ inline]
300320 pub fn is_aligned < U > ( self , align : U ) -> bool
301321 where
302322 U : Into < u64 > ,
@@ -402,6 +422,7 @@ impl Sub<PhysAddr> for PhysAddr {
402422///
403423/// Returns the greatest x with alignment `align` so that x <= addr. The alignment must be
404424/// a power of 2.
425+ #[ inline]
405426pub fn align_down ( addr : u64 , align : u64 ) -> u64 {
406427 assert ! ( align. is_power_of_two( ) , "`align` must be a power of two" ) ;
407428 addr & !( align - 1 )
0 commit comments