@@ -97,19 +97,19 @@ impl VirtAddr {
9797 /// Converts the address to a raw pointer.
9898 #[ cfg( target_pointer_width = "64" ) ]
9999 #[ inline]
100- pub fn as_ptr < T > ( self ) -> * const T {
100+ pub const fn as_ptr < T > ( self ) -> * const T {
101101 self . as_u64 ( ) as * const T
102102 }
103103
104104 /// Converts the address to a mutable raw pointer.
105105 #[ cfg( target_pointer_width = "64" ) ]
106106 #[ inline]
107- pub fn as_mut_ptr < T > ( self ) -> * mut T {
108- self . as_ptr :: < T > ( ) as * mut T
107+ pub const fn as_mut_ptr < T > ( self ) -> * mut T {
108+ self . as_ptr :: < T > ( ) . cast_mut ( )
109109 }
110110
111111 #[ inline]
112- pub fn is_zero ( self ) -> bool {
112+ pub const fn is_zero ( self ) -> bool {
113113 self . 0 == 0
114114 }
115115
@@ -360,12 +360,6 @@ impl Step for VirtAddr {
360360 }
361361}
362362
363- /// A passed `u64` was not a valid physical address.
364- ///
365- /// This means that bits 52 to 64 were not all null.
366- #[ derive( Debug ) ]
367- pub struct PhysAddrNotValid ( u64 ) ;
368-
369363impl PhysAddr {
370364 /// Creates a new physical address.
371365 ///
@@ -570,7 +564,7 @@ pub fn align_down(addr: u64, align: u64) -> u64 {
570564/// Panics if the alignment is not a power of two. Without the `const_fn`
571565/// feature, the panic message will be "index out of bounds".
572566#[ inline]
573- pub fn align_up ( addr : u64 , align : u64 ) -> u64 {
567+ pub const fn align_up ( addr : u64 , align : u64 ) -> u64 {
574568 let align_mask = align - 1 ;
575569
576570 if addr & align_mask == 0 {
@@ -581,7 +575,7 @@ pub fn align_up(addr: u64, align: u64) -> u64 {
581575}
582576
583577#[ inline]
584- pub fn is_aligned ( addr : u64 , align : u64 ) -> bool {
578+ pub const fn is_aligned ( addr : u64 , align : u64 ) -> bool {
585579 align_up ( addr, align) == addr
586580}
587581
0 commit comments