]> git.lizzy.rs Git - rust.git/blobdiff - library/panic_abort/src/lib.rs
Remove unused libc feature gate
[rust.git] / library / panic_abort / src / lib.rs
index ccc067a3c943d2db477da89d238542d095dc08ed..7a5c613688d42d10895db085ae9fa5182236856a 100644 (file)
 #![panic_runtime]
 #![allow(unused_features)]
 #![feature(core_intrinsics)]
-#![feature(libc)]
 #![feature(nll)]
 #![feature(panic_runtime)]
 #![feature(staged_api)]
 #![feature(rustc_attrs)]
-#![feature(llvm_asm)]
+#![feature(asm)]
 
 use core::any::Any;
 
@@ -47,7 +46,7 @@ unsafe fn abort() -> ! {
                 }
                 __rust_abort();
             }
-        } else if #[cfg(all(windows, any(target_arch = "x86", target_arch = "x86_64")))] {
+        } else if #[cfg(windows)] {
             // On Windows, use the processor-specific __fastfail mechanism. In Windows 8
             // and later, this will terminate the process immediately without running any
             // in-process exception handlers. In earlier versions of Windows, this
@@ -59,7 +58,18 @@ unsafe fn abort() -> ! {
             //
             // Note: this is the same implementation as in libstd's `abort_internal`
             unsafe fn abort() -> ! {
-                llvm_asm!("int $$0x29" :: "{ecx}"(7) ::: volatile); // 7 is FAST_FAIL_FATAL_APP_EXIT
+                const FAST_FAIL_FATAL_APP_EXIT: usize = 7;
+                cfg_if::cfg_if! {
+                    if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
+                        asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT);
+                    } else if #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))] {
+                        asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT);
+                    } else if #[cfg(target_arch = "aarch64")] {
+                        asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT);
+                    } else {
+                        core::intrinsics::abort();
+                    }
+                }
                 core::intrinsics::unreachable();
             }
         } else {
@@ -117,6 +127,17 @@ pub extern "C" fn rust_eh_personality(
         1 // `ExceptionContinueSearch`
     }
 
+    // Similar to above, this corresponds to the `eh_catch_typeinfo` lang item
+    // that's only used on Emscripten currently.
+    //
+    // Since panics don't generate exceptions and foreign exceptions are
+    // currently UB with -C panic=abort (although this may be subject to
+    // change), any catch_unwind calls will never use this typeinfo.
+    #[rustc_std_internal_symbol]
+    #[allow(non_upper_case_globals)]
+    #[cfg(target_os = "emscripten")]
+    static rust_eh_catch_typeinfo: [usize; 2] = [0; 2];
+
     // These two are called by our startup objects on i686-pc-windows-gnu, but
     // they don't need to do anything so the bodies are nops.
     #[rustc_std_internal_symbol]