Skip to content

Commit c8608ea

Browse files
committed
feat: add no_std support
Signed-off-by: 周睿 <zrufo747@outlook.com>
1 parent f3e68f0 commit c8608ea

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
## Upcoming version
44

55
### Added
6+
7+
- Support for no_std environments.
8+
69
### Changed
710
### Fixed
811
### Removed

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ keywords = ["resources", "allocation", "address", "virt"]
99
license = "Apache-2.0 OR BSD-3-Clause"
1010
edition = "2018"
1111

12+
[features]
13+
default = ["std"]
14+
std = []
15+
1216
[dependencies]
1317
libc = "0.2.39"
14-
thiserror = "2.0"
18+
thiserror = {version= "2.0", default-features = false}
1519
serde = { version = "1.0.137", optional = true, features = ["derive"] }

src/allocation_engine/interval_tree.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use std::cmp::{max, Ordering};
66

7+
use alloc::boxed::Box;
8+
79
use crate::{AllocPolicy, Constraint, Error, RangeInclusive, Result};
810

911
/// Returns the first multiple of `alignment` that is lower or equal to the

src/id_allocator.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
//! that can be abstracted to an integer.
99
1010
use crate::{Error, Result};
11-
use std::collections::BTreeSet;
11+
use alloc::collections::BTreeSet;
12+
1213

1314
/// An unique ID allocator that allows management of IDs in a given interval.
1415
// Internal representation of IdAllocator. Contains the ends of the interval

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@
7474
//! ```
7575
7676
#![deny(missing_docs)]
77+
#![cfg_attr(not(feature = "std"), no_std)]
78+
79+
extern crate alloc;
80+
81+
#[cfg(not(feature = "std"))]
82+
extern crate core as std;
7783

7884
mod address_allocator;
7985
/// Allocation engine used by address allocator.

0 commit comments

Comments
 (0)