File tree Expand file tree Collapse file tree 2 files changed +26
-5
lines changed Expand file tree Collapse file tree 2 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 {
4747 }
4848 __rust_abort( ) ;
4949 }
50- } else if #[ cfg( all ( windows, any ( target_arch = "x86" , target_arch = "x86_64" ) ) ) ] {
50+ } else if #[ cfg( windows) ] {
5151 // On Windows, use the processor-specific __fastfail mechanism. In Windows 8
5252 // and later, this will terminate the process immediately without running any
5353 // in-process exception handlers. In earlier versions of Windows, this
@@ -59,7 +59,18 @@ pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 {
5959 //
6060 // Note: this is the same implementation as in libstd's `abort_internal`
6161 unsafe fn abort( ) -> ! {
62- llvm_asm!( "int $$0x29" :: "{ecx}" ( 7 ) :: : volatile) ; // 7 is FAST_FAIL_FATAL_APP_EXIT
62+ const FAST_FAIL_FATAL_APP_EXIT : usize = 7 ;
63+ cfg_if:: cfg_if! {
64+ if #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ] {
65+ llvm_asm!( "int $$0x29" :: "{ecx}" ( FAST_FAIL_FATAL_APP_EXIT ) :: : volatile) ;
66+ } else if #[ cfg( target_arch = "arm" ) ] {
67+ llvm_asm!( ".inst 0xDEFB" :: "{r0}" ( FAST_FAIL_FATAL_APP_EXIT ) :: : volatile) ;
68+ } else if #[ cfg( target_arch = "aarch64" ) ] {
69+ llvm_asm!( ".inst 0xF003" :: "{x0}" ( FAST_FAIL_FATAL_APP_EXIT ) :: : volatile) ;
70+ } else {
71+ core:: intrinsics:: abort( ) ;
72+ }
73+ }
6374 core:: intrinsics:: unreachable( ) ;
6475 }
6576 } else {
Original file line number Diff line number Diff line change @@ -306,10 +306,20 @@ pub fn dur2timeout(dur: Duration) -> c::DWORD {
306306/// that function for more information on `__fastfail`
307307#[ allow( unreachable_code) ]
308308pub fn abort_internal ( ) -> ! {
309- # [ cfg ( any ( target_arch = "x86" , target_arch = "x86_64" ) ) ]
309+ const FAST_FAIL_FATAL_APP_EXIT : usize = 7 ;
310310 unsafe {
311- llvm_asm ! ( "int $$0x29" :: "{ecx}" ( 7 ) :: : volatile) ; // 7 is FAST_FAIL_FATAL_APP_EXIT
312- crate :: intrinsics:: unreachable ( ) ;
311+ cfg_if:: cfg_if! {
312+ if #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ] {
313+ llvm_asm!( "int $$0x29" :: "{ecx}" ( FAST_FAIL_FATAL_APP_EXIT ) :: : volatile) ;
314+ crate :: intrinsics:: unreachable( ) ;
315+ } else if #[ cfg( target_arch = "arm" ) ] {
316+ llvm_asm!( ".inst 0xDEFB" :: "{r0}" ( FAST_FAIL_FATAL_APP_EXIT ) :: : volatile) ;
317+ crate :: intrinsics:: unreachable( ) ;
318+ } else if #[ cfg( target_arch = "aarch64" ) ] {
319+ llvm_asm!( ".inst 0xF003" :: "{x0}" ( FAST_FAIL_FATAL_APP_EXIT ) :: : volatile) ;
320+ crate :: intrinsics:: unreachable( ) ;
321+ }
322+ }
313323 }
314324 crate :: intrinsics:: abort ( ) ;
315325}
You can’t perform that action at this time.
0 commit comments