Skip to content

Commit 0d6f827

Browse files
committed
Port std library to RTEMS
1 parent a4ce33c commit 0d6f827

File tree

20 files changed

+540
-13
lines changed

20 files changed

+540
-13
lines changed

library/core/src/ffi/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ mod c_char_definition {
101101
all(target_os = "android", any(target_arch = "aarch64", target_arch = "arm")),
102102
all(target_os = "l4re", target_arch = "x86_64"),
103103
all(
104-
any(target_os = "freebsd", target_os = "openbsd"),
104+
any(target_os = "freebsd", target_os = "openbsd", target_os = "rtems"),
105105
any(
106106
target_arch = "aarch64",
107107
target_arch = "arm",

library/panic_unwind/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ cfg_if::cfg_if! {
5353
target_os = "psp",
5454
target_os = "xous",
5555
target_os = "solid_asp3",
56-
all(target_family = "unix", not(target_os = "espidf")),
56+
all(target_family = "unix", not(any(target_os = "espidf", target_os = "rtems"))),
5757
all(target_vendor = "fortanix", target_env = "sgx"),
5858
target_family = "wasm",
5959
))] {

library/panic_unwind/src/rtems.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//! Unwinding for *rtems* target.
2+
//!
3+
//! Right now we don't support this, so this is just stubs.
4+
5+
use alloc::boxed::Box;
6+
use core::any::Any;
7+
8+
pub unsafe fn cleanup(_ptr: *mut u8) -> Box<dyn Any + Send> {
9+
extern "C" {
10+
pub fn rtems_panic(fmt: *const ::std::os::raw::c_char, ...) -> !;
11+
}
12+
13+
rtems_panic("Error during Rust execution".into_raw());
14+
}
15+
16+
pub unsafe fn panic(_data: Box<dyn Any + Send>) -> u32 {
17+
extern "C" {
18+
pub fn rtems_panic(fmt: *const ::std::os::raw::c_char, ...) -> !;
19+
}
20+
21+
rtems_panic("Error during Rust execution".into_raw());
22+
}

library/std/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ fn main() {
5252
|| target_os == "uefi"
5353
|| target_os == "teeos"
5454
|| target_os == "zkvm"
55+
|| target_os == "rtems"
5556

5657
// See src/bootstrap/src/core/build_steps/synthetic_targets.rs
5758
|| env::var("RUSTC_BOOTSTRAP_SYNTHETIC_TARGET").is_ok()

library/std/src/os/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ pub mod nto;
140140
pub mod openbsd;
141141
#[cfg(target_os = "redox")]
142142
pub mod redox;
143+
#[cfg(target_os = "rtems")]
144+
pub mod rtems;
143145
#[cfg(target_os = "solaris")]
144146
pub mod solaris;
145147
#[cfg(target_os = "solid_asp3")]

0 commit comments

Comments
 (0)