about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-03-03 04:26:34 +0000
committerbors <bors@rust-lang.org>2024-03-03 04:26:34 +0000
commit3793e5ba23ca6a57ace8e3e267c22001cc5ef794 (patch)
treef2fc91a40ed8e5daa9802f4b62299d67ff52a694 /library/std/src
parentda02fff3b6e4e27156054dcdda6675fe2a2591a6 (diff)
parentce26c7882024874bacf05bedf0e8de692e6f6d13 (diff)
downloadrust-3793e5ba23ca6a57ace8e3e267c22001cc5ef794.tar.gz
rust-3793e5ba23ca6a57ace8e3e267c22001cc5ef794.zip
Auto merge of #121856 - ChrisDenton:abort, r=joboet
Cleanup windows `abort_internal`

As the comments on the functions say, we define abort in both in panic_abort and in libstd. This PR makes the two implementation (mostly) the same.

Additionally it:
* uses `options(noreturn)` on the asm instead of using `core::intrinsics::unreachable`.
* removed unnecessary allow lints
* added `FAST_FAIL_FATAL_APP_EXIT` to our generated Windows API bindings instead of defining it manually (std only)
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/sys/pal/windows/c/bindings.txt1
-rw-r--r--library/std/src/sys/pal/windows/c/windows_sys.rs1
-rw-r--r--library/std/src/sys/pal/windows/mod.rs21
3 files changed, 13 insertions, 10 deletions
diff --git a/library/std/src/sys/pal/windows/c/bindings.txt b/library/std/src/sys/pal/windows/c/bindings.txt
index d0081411530..7667f761106 100644
--- a/library/std/src/sys/pal/windows/c/bindings.txt
+++ b/library/std/src/sys/pal/windows/c/bindings.txt
@@ -2482,6 +2482,7 @@ Windows.Win32.System.SystemInformation.SYSTEM_INFO
 Windows.Win32.System.SystemServices.DLL_PROCESS_DETACH
 Windows.Win32.System.SystemServices.DLL_THREAD_DETACH
 Windows.Win32.System.SystemServices.EXCEPTION_MAXIMUM_PARAMETERS
+Windows.Win32.System.SystemServices.FAST_FAIL_FATAL_APP_EXIT
 Windows.Win32.System.SystemServices.IO_REPARSE_TAG_MOUNT_POINT
 Windows.Win32.System.SystemServices.IO_REPARSE_TAG_SYMLINK
 Windows.Win32.System.Threading.ABOVE_NORMAL_PRIORITY_CLASS
diff --git a/library/std/src/sys/pal/windows/c/windows_sys.rs b/library/std/src/sys/pal/windows/c/windows_sys.rs
index 96773d91e99..7b751079afb 100644
--- a/library/std/src/sys/pal/windows/c/windows_sys.rs
+++ b/library/std/src/sys/pal/windows/c/windows_sys.rs
@@ -3090,6 +3090,7 @@ pub type FACILITY_CODE = u32;
 pub const FACILITY_NT_BIT: FACILITY_CODE = 268435456u32;
 pub const FALSE: BOOL = 0i32;
 pub type FARPROC = ::core::option::Option<unsafe extern "system" fn() -> isize>;
+pub const FAST_FAIL_FATAL_APP_EXIT: u32 = 7u32;
 #[repr(C)]
 pub struct FD_SET {
     pub fd_count: u32,
diff --git a/library/std/src/sys/pal/windows/mod.rs b/library/std/src/sys/pal/windows/mod.rs
index 831cb04c566..a53c4034d06 100644
--- a/library/std/src/sys/pal/windows/mod.rs
+++ b/library/std/src/sys/pal/windows/mod.rs
@@ -321,25 +321,26 @@ pub fn dur2timeout(dur: Duration) -> c::DWORD {
 ///
 /// This is the same implementation as in libpanic_abort's `__rust_start_panic`. See
 /// that function for more information on `__fastfail`
-#[allow(unreachable_code)]
+#[cfg(not(miri))] // inline assembly does not work in Miri
 pub fn abort_internal() -> ! {
-    #[allow(unused)]
-    const FAST_FAIL_FATAL_APP_EXIT: usize = 7;
-    #[cfg(not(miri))] // inline assembly does not work in Miri
     unsafe {
         cfg_if::cfg_if! {
             if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
-                core::arch::asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT);
-                crate::intrinsics::unreachable();
+                core::arch::asm!("int $$0x29", in("ecx") c::FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack));
             } else if #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))] {
-                core::arch::asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT);
-                crate::intrinsics::unreachable();
+                core::arch::asm!(".inst 0xDEFB", in("r0") c::FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack));
             } else if #[cfg(target_arch = "aarch64")] {
-                core::arch::asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT);
-                crate::intrinsics::unreachable();
+                core::arch::asm!("brk 0xF003", in("x0") c::FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack));
+            } else {
+                core::intrinsics::abort();
             }
         }
     }
+}
+
+// miri is sensitive to changes here so check that miri is happy if touching this
+#[cfg(miri)]
+pub fn abort_internal() -> ! {
     crate::intrinsics::abort();
 }