Use libc abort instead intrinsic abort when available
This commit is contained in:
parent
77f8403aae
commit
a331c22665
@ -18,7 +18,7 @@ impl Drop for DropGuard {
|
||||
{
|
||||
drop_panic();
|
||||
}
|
||||
core::intrinsics::abort();
|
||||
crate::util::abort();
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ pub fn catch_unwind<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
|
||||
{
|
||||
foreign_exception();
|
||||
}
|
||||
core::intrinsics::abort();
|
||||
crate::util::abort();
|
||||
}
|
||||
Some(e) => {
|
||||
#[cfg(feature = "panic-handler")]
|
||||
|
@ -80,7 +80,7 @@ fn do_panic(msg: Box<dyn Any + Send>) -> ! {
|
||||
if PANIC_COUNT.get() >= 1 {
|
||||
stack_trace();
|
||||
eprintln!("thread panicked while processing panic. aborting.");
|
||||
core::intrinsics::abort();
|
||||
crate::util::abort();
|
||||
}
|
||||
PANIC_COUNT.set(1);
|
||||
if check_env() {
|
||||
@ -88,7 +88,7 @@ fn do_panic(msg: Box<dyn Any + Send>) -> ! {
|
||||
}
|
||||
let code = crate::panic::begin_panic(Box::new(msg));
|
||||
eprintln!("failed to initiate panic, error {}", code.0);
|
||||
core::intrinsics::abort();
|
||||
crate::util::abort();
|
||||
}
|
||||
|
||||
#[panic_handler]
|
||||
|
@ -2,5 +2,5 @@ use core::panic::PanicInfo;
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(_info: &PanicInfo<'_>) -> ! {
|
||||
core::intrinsics::abort();
|
||||
crate::util::abort();
|
||||
}
|
||||
|
16
src/util.rs
16
src/util.rs
@ -23,3 +23,19 @@ pub use libc::c_int;
|
||||
#[cfg(not(feature = "libc"))]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub type c_int = i32;
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "panicking", feature = "panic-handler-dummy"),
|
||||
feature = "libc"
|
||||
))]
|
||||
pub fn abort() -> ! {
|
||||
unsafe { libc::abort() };
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "panicking", feature = "panic-handler-dummy"),
|
||||
not(feature = "libc")
|
||||
))]
|
||||
pub fn abort() -> ! {
|
||||
core::intrinsics::abort();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user