Skip to content

Commit 907d2a1

Browse files
author
Jorge Aparicio
committed
make alloc and collections compilable for thumbv6m-none-eabi
by cfging away `alloc::Arc` and changing OOM to abort for this target
1 parent ea20ab1 commit 907d2a1

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/liballoc/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474

7575
#![feature(allocator)]
7676
#![feature(box_syntax)]
77+
#![feature(cfg_target_has_atomic)]
7778
#![feature(coerce_unsized)]
7879
#![feature(const_fn)]
7980
#![feature(core_intrinsics)]
@@ -117,6 +118,7 @@ mod boxed {
117118
}
118119
#[cfg(test)]
119120
mod boxed_test;
121+
#[cfg(target_has_atomic = "ptr")]
120122
pub mod arc;
121123
pub mod rc;
122124
pub mod raw_vec;

src/liballoc/oom.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[cfg(target_has_atomic = "ptr")]
1112
use core::sync::atomic::{AtomicPtr, Ordering};
13+
#[cfg(target_has_atomic = "ptr")]
1214
use core::mem;
1315
use core::intrinsics;
1416

17+
#[cfg(target_has_atomic = "ptr")]
1518
static OOM_HANDLER: AtomicPtr<()> = AtomicPtr::new(default_oom_handler as *mut ());
1619

1720
fn default_oom_handler() -> ! {
@@ -21,6 +24,7 @@ fn default_oom_handler() -> ! {
2124
}
2225

2326
/// Common out-of-memory routine
27+
#[cfg(target_has_atomic = "ptr")]
2428
#[cold]
2529
#[inline(never)]
2630
#[unstable(feature = "oom", reason = "not a scrutinized interface",
@@ -31,10 +35,21 @@ pub fn oom() -> ! {
3135
handler();
3236
}
3337

38+
/// Common out-of-memory routine
39+
#[cfg(not(target_has_atomic = "ptr"))]
40+
#[cold]
41+
#[inline(never)]
42+
#[unstable(feature = "oom", reason = "not a scrutinized interface",
43+
issue = "27700")]
44+
pub fn oom() -> ! {
45+
default_oom_handler()
46+
}
47+
3448
/// Set a custom handler for out-of-memory conditions
3549
///
3650
/// To avoid recursive OOM failures, it is critical that the OOM handler does
3751
/// not allocate any memory itself.
52+
#[cfg(target_has_atomic = "ptr")]
3853
#[unstable(feature = "oom", reason = "not a scrutinized interface",
3954
issue = "27700")]
4055
pub fn set_oom_handler(handler: fn() -> !) {

0 commit comments

Comments
 (0)