File tree Expand file tree Collapse file tree 4 files changed +20
-1
lines changed Expand file tree Collapse file tree 4 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 13
13
strategy :
14
14
matrix :
15
15
rust :
16
+ - stable
16
17
- nightly-2020-09-24
17
18
18
19
steps :
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ license = "MIT"
13
13
[features ]
14
14
default = [" use_spin" ]
15
15
use_spin = [" spin" ]
16
+ const_fn = []
16
17
17
18
[dependencies .spin ]
18
19
version = " 0.5"
Original file line number Diff line number Diff line change @@ -28,6 +28,13 @@ unsafe {
28
28
29
29
You can also use ` FrameAllocator ` and ` LockedHeapWithRescue ` , see their documentation for usage.
30
30
31
+ ## Features
32
+
33
+ - ** ` use_spin ` ** (default): Provide a ` LockedHeap ` type that implements the [ ` GlobalAlloc ` ] trait by using a spinlock.
34
+ - ** ` const_fn ` ** (nightly only): Provide const fn version of ` LockedHeapWithRescue::new ` .
35
+
36
+ [ `GlobalAlloc` ] : https://doc.rust-lang.org/nightly/core/alloc/trait.GlobalAlloc.html
37
+
31
38
## License
32
39
33
40
Some code comes from phil-opp's linked-list-allocator.
Original file line number Diff line number Diff line change 1
- #![ feature( const_mut_refs, const_fn_fn_ptr_basics) ]
1
+ #![ cfg_attr ( feature = "const_fn" , feature ( const_mut_refs, const_fn_fn_ptr_basics) ) ]
2
2
#![ no_std]
3
3
4
4
#[ cfg( test) ]
@@ -287,12 +287,22 @@ pub struct LockedHeapWithRescue {
287
287
#[ cfg( feature = "use_spin" ) ]
288
288
impl LockedHeapWithRescue {
289
289
/// Creates an empty heap
290
+ #[ cfg( feature = "const_fn" ) ]
290
291
pub const fn new ( rescue : fn ( & mut Heap ) ) -> LockedHeapWithRescue {
291
292
LockedHeapWithRescue {
292
293
inner : Mutex :: new ( Heap :: new ( ) ) ,
293
294
rescue,
294
295
}
295
296
}
297
+
298
+ /// Creates an empty heap
299
+ #[ cfg( not( feature = "const_fn" ) ) ]
300
+ pub fn new ( rescue : fn ( & mut Heap ) ) -> LockedHeapWithRescue {
301
+ LockedHeapWithRescue {
302
+ inner : Mutex :: new ( Heap :: new ( ) ) ,
303
+ rescue,
304
+ }
305
+ }
296
306
}
297
307
298
308
#[ cfg( feature = "use_spin" ) ]
You can’t perform that action at this time.
0 commit comments