Skip to content

Commit

Permalink
Remove features const_mut_refs and use_spin_nightly
Browse files Browse the repository at this point in the history
Since rust 1.61, the underlying const functions are available in
stable rust, and lock_api >= 0.4.7 automatically uses them. (Feature
const_fn_trait_bound, rust-lang/rust#93827)

To avoid a breaking change, the features are still listed in Cargo.toml,
but have no effect and are marked as deprecated.  This bumps the minimum
supported rust version to 1.61.
  • Loading branch information
jannic committed Feb 24, 2023
1 parent c2aa6ec commit 5c6a592
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 37 deletions.
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ repository = "https://github.com/phil-opp/linked-list-allocator"
documentation = "https://docs.rs/crate/linked_list_allocator"
homepage = "http://os.phil-opp.com/kernel-heap.html#a-better-allocator"

rust-version = "1.61"

[features]
default = ["use_spin_nightly"]
default = ["use_spin"]
use_spin = ["spinning_top"]
use_spin_nightly = ["use_spin", "spinning_top/nightly", "const_mut_refs"]
# deprecated - use `use_spin` instead
use_spin_nightly = ["use_spin"]
alloc_ref = []
# deprecated - no effect
const_mut_refs = []

[dependencies.spinning_top]
Expand Down
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Unreleased

- Remove features const_mut_refs and use_spin_nightly. Since rust 1.61, the underlying const functions are available in stable rust,
and lock_api >= 0.4.7 automatically uses them. (Feature const_fn_trait_bound, https://github.com/rust-lang/rust/pull/93827)
To avoid a breaking change, the features are still listed in Cargo.toml, but have no effect and are marked as deprecated.
This bumps the minimum supported rust version to 1.61.

# 0.10.4 – 2022-10-10

- Fix [memory leak of small back paddings](https://github.com/rust-osdev/linked-list-allocator/issues/66) by considering regions that would result in such small back paddings as unsuitable ([#71](https://github.com/rust-osdev/linked-list-allocator/pull/71))
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ pub fn init_heap() {
## Features

- **`use_spin`** (default): Provide a `LockedHeap` type that implements the [`GlobalAlloc`] trait by using a spinlock.
- **`const_mut_refs`** (default): Makes the `Heap::empty` function `const`; requires nightly Rust.
- **`use_spin_nightly`** (default): Makes the `LockedHeap::empty` function `const`, automatically enables `use_spin` and `const_mut_refs`; requires nightly Rust.
- **`alloc_ref`**: Provide an implementation of the unstable [`AllocRef`] trait; requires nightly Rust.
- Warning: The `AllocRef` trait is still regularly changed on the Rust side, so expect some regular breakage when using this feature.

Expand Down
15 changes: 0 additions & 15 deletions src/hole.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,21 +257,6 @@ fn check_merge_bottom(node: NonNull<Hole>, bottom: *mut u8) -> NonNull<Hole> {

impl HoleList {
/// Creates an empty `HoleList`.
#[cfg(not(feature = "const_mut_refs"))]
pub fn empty() -> HoleList {
HoleList {
first: Hole {
size: 0,
next: None,
},
bottom: null_mut(),
top: null_mut(),
pending_extend: 0,
}
}

/// Creates an empty `HoleList`.
#[cfg(feature = "const_mut_refs")]
pub const fn empty() -> HoleList {
HoleList {
first: Hole {
Expand Down
18 changes: 0 additions & 18 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![cfg_attr(feature = "const_mut_refs", feature(const_mut_refs))]
#![cfg_attr(
feature = "alloc_ref",
feature(allocator_api, alloc_layout_extra, nonnull_slice_from_raw_parts)
Expand Down Expand Up @@ -55,15 +54,6 @@ unsafe impl Send for Heap {}

impl Heap {
/// Creates an empty heap. All allocate calls will return `None`.
#[cfg(not(feature = "const_mut_refs"))]
pub fn empty() -> Heap {
Heap {
used: 0,
holes: HoleList::empty(),
}
}

#[cfg(feature = "const_mut_refs")]
pub const fn empty() -> Heap {
Heap {
used: 0,
Expand Down Expand Up @@ -300,18 +290,10 @@ pub struct LockedHeap(Spinlock<Heap>);

#[cfg(feature = "use_spin")]
impl LockedHeap {
/// Creates an empty heap. All allocate calls will return `None`.
#[cfg(feature = "use_spin_nightly")]
pub const fn empty() -> LockedHeap {
LockedHeap(Spinlock::new(Heap::empty()))
}

/// Creates an empty heap. All allocate calls will return `None`.
#[cfg(not(feature = "use_spin_nightly"))]
pub fn empty() -> LockedHeap {
LockedHeap(Spinlock::new(Heap::empty()))
}

/// Creates a new heap with the given `bottom` and `size`.
///
/// The `heap_bottom` pointer is automatically aligned, so the [`bottom()`][Heap::bottom]
Expand Down

0 comments on commit 5c6a592

Please sign in to comment.