Move dummy panic handler to lib as well

This commit is contained in:
Gary Guo 2021-08-26 10:58:26 +01:00
parent 6e74064c7f
commit af45cc8701
5 changed files with 14 additions and 11 deletions

View File

@ -23,6 +23,7 @@ personality-dummy = []
print = ["libc"]
panic = ["alloc"]
panic-handler = ["print", "panic"]
panic-handler-dummy = []
system-alloc = []
default = ["dwarf-expr", "hide-trace", "fde-phdr", "fde-registry"]

View File

@ -8,5 +8,5 @@ edition = "2018"
crate-type = ["cdylib"]
[dependencies]
unwind = { path = "../", features = ["system-alloc", "personality-dummy"] }
unwind = { path = "../", features = ["system-alloc", "personality-dummy", "panic-handler-dummy"] }
libc = "0.2"

View File

@ -1,17 +1,8 @@
#![no_std]
#![feature(default_alloc_error_handler)]
#![feature(lang_items)]
#![warn(rust_2018_idioms)]
#![warn(unsafe_op_in_unsafe_fn)]
// Keep this explicit
#[allow(unused_extern_crates)]
extern crate unwind;
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_info: &PanicInfo<'_>) -> ! {
// `unwind` crate should never panic.
unsafe { core::hint::unreachable_unchecked() }
}

View File

@ -5,7 +5,10 @@
any(feature = "personality", feature = "personality-dummy"),
feature(lang_items)
)]
#![cfg_attr(feature = "panic", feature(core_intrinsics))]
#![cfg_attr(
any(feature = "panic", feature = "panic-handler-dummy"),
feature(core_intrinsics)
)]
#![cfg_attr(feature = "panic-handler", feature(thread_local))]
#![warn(rust_2018_idioms)]
#![warn(unsafe_op_in_unsafe_fn)]
@ -34,6 +37,8 @@ pub mod panic;
#[cfg(feature = "panic-handler")]
pub mod panic_handler;
#[cfg(feature = "panic-handler-dummy")]
pub mod panic_handler_dummy;
#[cfg(feature = "system-alloc")]
mod system_alloc;

View File

@ -0,0 +1,6 @@
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_info: &PanicInfo<'_>) -> ! {
core::intrinsics::abort();
}