Skip to content

Commit c870a37

Browse files
authored
Merge branch 'rust-embedded:master' into allocator_api
2 parents d9fc9d8 + a385370 commit c870a37

File tree

8 files changed

+41
-16
lines changed

8 files changed

+41
-16
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions-rs/toolchain@v1
2020
with:
2121
profile: minimal
22-
toolchain: nightly
22+
toolchain: stable
2323
target: ${{ matrix.target }}
2424
override: true
2525
- uses: actions-rs/cargo@v1

.github/workflows/clippy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- uses: actions-rs/toolchain@v1
1919
with:
2020
profile: minimal
21-
toolchain: nightly
21+
toolchain: stable
2222
override: true
2323
components: clippy
2424
- uses: actions-rs/clippy-check@v1

.github/workflows/cron.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions-rs/toolchain@v1
1414
with:
1515
profile: minimal
16-
toolchain: nightly
16+
toolchain: stable
1717
target: thumbv6m-none-eabi
1818
override: true
1919
- uses: actions-rs/cargo@v1

.github/workflows/rustfmt.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions-rs/toolchain@v1
1414
with:
1515
profile: minimal
16-
toolchain: nightly
16+
toolchain: stable
1717
override: true
1818
components: rustfmt
1919
- uses: actions-rs/cargo@v1

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
- Updated `linked_list_allocator` dependency to 0.10.5, which allows
11+
compiling with stable rust.
12+
1013
## [v0.5.0] - 2022-12-06
1114

1215
### Changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ critical-section = "1.0"
3131

3232
[dependencies.linked_list_allocator]
3333
default-features = false
34-
version = "0.10.4"
34+
version = "0.10.5"
3535
features = ["const_mut_refs"]
3636

3737
[dev-dependencies]

README.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,50 @@
11
[![crates.io](https://img.shields.io/crates/d/embedded-alloc.svg)](https://crates.io/crates/embedded-alloc)
22
[![crates.io](https://img.shields.io/crates/v/embedded-alloc.svg)](https://crates.io/crates/embedded-alloc)
3+
![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.68+-blue.svg) -
4+
[Documentation](https://docs.rs/embedded-alloc) - [Change log](https://github.com/rust-embedded/embedded-alloc/blob/master/CHANGELOG.md)
35

46
# `embedded-alloc`
57

68
> A heap allocator for embedded systems.
79
8-
Note that using this as your global allocator requires nightly Rust.
10+
Note that using this as your global allocator requires Rust 1.68 or later.
11+
(With earlier versions, you need the unstable feature `#![feature(default_alloc_error_handler)]`)
912

1013
This project is developed and maintained by the [Cortex-M team][team].
1114

1215
## Example
1316

14-
For a usage example, see `examples/global_alloc.rs`.
17+
Starting with Rust 1.68, this crate can be used as a global allocator on stable Rust:
1518

16-
## [Documentation](https://docs.rs/embedded-alloc)
19+
```rust
20+
#![no_std]
21+
#![no_main]
1722

18-
## [Change log](CHANGELOG.md)
23+
extern crate alloc;
24+
25+
use cortex_m_rt::entry;
26+
use embedded_alloc::Heap;
27+
28+
#[global_allocator]
29+
static HEAP: Heap = Heap::empty();
30+
31+
#[entry]
32+
fn main() -> ! {
33+
// Initialize the allocator BEFORE you use it
34+
{
35+
use core::mem::MaybeUninit;
36+
const HEAP_SIZE: usize = 1024;
37+
static mut HEAP_MEM: [MaybeUninit<u8>; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE];
38+
unsafe { HEAP.init(HEAP_MEM.as_ptr() as usize, HEAP_SIZE) }
39+
}
40+
41+
// now the allocator is ready types like Box, Vec can be used.
42+
43+
loop { /* .. */ }
44+
}
45+
```
46+
47+
For a full usage example, see [`examples/global_alloc.rs`](https://github.com/rust-embedded/embedded-alloc/blob/master/examples/global_alloc.rs).
1948

2049
## License
2150

examples/global_alloc.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#![no_std]
22
#![no_main]
3-
#![feature(alloc_error_handler)]
43

54
extern crate alloc;
65

76
use alloc::vec::Vec;
8-
use core::alloc::Layout;
97
use core::panic::PanicInfo;
108
use cortex_m_rt::entry;
119
use embedded_alloc::Heap;
@@ -29,11 +27,6 @@ fn main() -> ! {
2927
loop { /* .. */ }
3028
}
3129

32-
#[alloc_error_handler]
33-
fn oom(_: Layout) -> ! {
34-
loop {}
35-
}
36-
3730
#[panic_handler]
3831
fn panic(_: &PanicInfo) -> ! {
3932
loop {}

0 commit comments

Comments
 (0)