Switch to asm! macro and use brk instruction on ARM

This commit is contained in:
Ryan Levick 2020-08-28 11:22:16 +02:00
parent 970e7793bf
commit 8bcc4d6178
2 changed files with 7 additions and 7 deletions

View File

@ -17,7 +17,7 @@
#![feature(panic_runtime)] #![feature(panic_runtime)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(llvm_asm)] #![feature(asm)]
use core::any::Any; use core::any::Any;
@ -62,11 +62,11 @@ unsafe fn abort() -> ! {
const FAST_FAIL_FATAL_APP_EXIT: usize = 7; const FAST_FAIL_FATAL_APP_EXIT: usize = 7;
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
llvm_asm!("int $$0x29" :: "{ecx}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT);
} else if #[cfg(target_arch = "arm")] { } else if #[cfg(target_arch = "arm")] {
llvm_asm!(".inst 0xDEFB" :: "{r0}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); asm!("brk 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT);
} else if #[cfg(target_arch = "aarch64")] { } else if #[cfg(target_arch = "aarch64")] {
llvm_asm!(".inst 0xF003" :: "{x0}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT);
} else { } else {
core::intrinsics::abort(); core::intrinsics::abort();
} }

View File

@ -310,13 +310,13 @@ pub fn abort_internal() -> ! {
unsafe { unsafe {
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
llvm_asm!("int $$0x29" :: "{ecx}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT);
crate::intrinsics::unreachable(); crate::intrinsics::unreachable();
} else if #[cfg(target_arch = "arm")] { } else if #[cfg(target_arch = "arm")] {
llvm_asm!(".inst 0xDEFB" :: "{r0}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); asm!("brk 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT);
crate::intrinsics::unreachable(); crate::intrinsics::unreachable();
} else if #[cfg(target_arch = "aarch64")] { } else if #[cfg(target_arch = "aarch64")] {
llvm_asm!(".inst 0xF003" :: "{x0}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT);
crate::intrinsics::unreachable(); crate::intrinsics::unreachable();
} }
} }