File tree 8 files changed +22
-14
lines changed
8 files changed +22
-14
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,11 @@ impl BuddyAllocatorInner {
64
64
user : 0 ,
65
65
allocated : 0 ,
66
66
total : 0 ,
67
- gran : max ( gran, size_of :: < usize > ( ) ) ,
67
+ gran : if gran > size_of :: < usize > ( ) {
68
+ gran
69
+ } else {
70
+ size_of :: < usize > ( )
71
+ } ,
68
72
}
69
73
}
70
74
Original file line number Diff line number Diff line change 1
1
#![ no_std]
2
- #![ feature( const_cmp) ]
3
2
4
3
pub mod buddy_allocator;
5
4
pub mod linked_list;
Original file line number Diff line number Diff line change 11
11
const_trait_impl,
12
12
const_for,
13
13
const_mut_refs,
14
- const_convert,
15
- const_default_impls,
16
14
sync_unsafe_cell
17
15
) ]
18
16
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ pub struct FrameAllocatorInner {
14
14
recycled : Vec < PhyPageNum > ,
15
15
}
16
16
17
- impl const Default for FrameAllocatorInner {
17
+ impl Default for FrameAllocatorInner {
18
18
fn default ( ) -> Self {
19
19
Self {
20
20
start : PhyPageNum ( 0 ) ,
@@ -24,7 +24,7 @@ impl const Default for FrameAllocatorInner {
24
24
}
25
25
}
26
26
27
- impl const Default for FrameAllocator {
27
+ impl Default for FrameAllocator {
28
28
fn default ( ) -> Self {
29
29
Self {
30
30
inner : Spin :: new ( FrameAllocatorInner :: default ( ) ) ,
Original file line number Diff line number Diff line change 1
- use crate :: { config :: MEMORY_END , mem :: allocator :: PageAllocator } ;
1
+ use lazy_static :: lazy_static ;
2
2
3
3
use self :: allocator:: FrameAllocator ;
4
+ use crate :: { config:: MEMORY_END , mem:: allocator:: PageAllocator } ;
4
5
5
6
pub mod allocator;
6
7
pub mod page;
7
8
8
- pub static FRAME_ALLOCATOR : FrameAllocator = FrameAllocator :: default ( ) ;
9
+ lazy_static ! {
10
+ pub static ref FRAME_ALLOCATOR : FrameAllocator = FrameAllocator :: default ( ) ;
11
+ }
9
12
10
13
pub fn init_frame_allocator ( ) {
11
14
extern "C" {
Original file line number Diff line number Diff line change @@ -88,7 +88,11 @@ impl BuddyAllocatorInner {
88
88
user : 0 ,
89
89
allocated : 0 ,
90
90
total : 0 ,
91
- gran : max ( gran, size_of :: < usize > ( ) ) ,
91
+ gran : if gran > size_of :: < usize > ( ) {
92
+ gran
93
+ } else {
94
+ size_of :: < usize > ( )
95
+ } ,
92
96
}
93
97
}
94
98
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ impl MemTable {
36
36
}
37
37
}
38
38
39
- impl const Default for MemTable {
39
+ impl Default for MemTable {
40
40
fn default ( ) -> Self {
41
41
Self {
42
42
units : Default :: default ( ) ,
@@ -59,7 +59,7 @@ impl MemUnit {
59
59
}
60
60
}
61
61
62
- impl const Default for MemUnit {
62
+ impl Default for MemUnit {
63
63
fn default ( ) -> Self {
64
64
Self {
65
65
start_ppn : PhyPageNum ( 0 ) ,
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ impl From<usize> for VirAddr {
71
71
}
72
72
}
73
73
74
- impl const From < usize > for PhyPageNum {
74
+ impl From < usize > for PhyPageNum {
75
75
fn from ( value : usize ) -> Self {
76
76
Self ( truncate_page_num ! ( truncate_phy_addr!( value) ) >> PAGE_SIZE_BITS )
77
77
}
@@ -91,7 +91,7 @@ impl From<usize> for GenOffset {
91
91
92
92
// from any to usize
93
93
94
- impl const From < PhyAddr > for usize {
94
+ impl From < PhyAddr > for usize {
95
95
fn from ( value : PhyAddr ) -> Self {
96
96
value. 0
97
97
}
@@ -372,7 +372,7 @@ impl ops::Sub<usize> for PhyPageNum {
372
372
}
373
373
}
374
374
375
- impl const ops:: Sub < PhyPageNum > for PhyPageNum {
375
+ impl ops:: Sub < PhyPageNum > for PhyPageNum {
376
376
type Output = usize ;
377
377
378
378
fn sub ( self , rhs : PhyPageNum ) -> Self :: Output {
You can’t perform that action at this time.
0 commit comments