mirror of https://github.com/rust-lang/rust.git
Fix up docs
This commit is contained in:
parent
57572cf809
commit
6778baf516
|
@ -27,16 +27,7 @@ pub unsafe extern "C" fn __rust_panic_cleanup(_: *mut u8) -> *mut (dyn Any + Sen
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Leak" the payload and shim to the relevant abort on the platform in
|
// "Leak" the payload and shim to the relevant abort on the platform in question.
|
||||||
// question.
|
|
||||||
//
|
|
||||||
// For Unix we just use `abort` from libc as it'll trigger debuggers, core
|
|
||||||
// dumps, etc, as one might expect. On Windows, however, the best option we have
|
|
||||||
// is the `__fastfail` intrinsics, but that's unfortunately not defined in LLVM,
|
|
||||||
// and the `RaiseFailFastException` function isn't available until Windows 7
|
|
||||||
// which would break compat with XP. For now just use `intrinsics::abort` which
|
|
||||||
// will kill us with an illegal instruction, which will do a good enough job for
|
|
||||||
// now hopefully.
|
|
||||||
#[rustc_std_internal_symbol]
|
#[rustc_std_internal_symbol]
|
||||||
pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 {
|
pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 {
|
||||||
abort();
|
abort();
|
||||||
|
@ -57,14 +48,16 @@ pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 {
|
||||||
__rust_abort();
|
__rust_abort();
|
||||||
}
|
}
|
||||||
} else if #[cfg(all(windows, any(target_arch = "x86", target_arch = "x86_64")))] {
|
} else if #[cfg(all(windows, any(target_arch = "x86", target_arch = "x86_64")))] {
|
||||||
// On Windows, use the processor-specific __fastfail mechanism. In Windows 8
|
// On Windows, use the processor-specific __fastfail mechanism. In Windows 8
|
||||||
// and later, this will terminate the process immediately without running any
|
// and later, this will terminate the process immediately without running any
|
||||||
// in-process exception handlers. In earlier versions of Windows, this
|
// in-process exception handlers. In earlier versions of Windows, this
|
||||||
// sequence of instructions will be treated as an access violation,
|
// sequence of instructions will be treated as an access violation,
|
||||||
// terminating the process but without necessarily bypassing all exception
|
// terminating the process but without necessarily bypassing all exception
|
||||||
// handlers.
|
// handlers.
|
||||||
//
|
//
|
||||||
// https://docs.microsoft.com/en-us/cpp/intrinsics/fastfail
|
// https://docs.microsoft.com/en-us/cpp/intrinsics/fastfail
|
||||||
|
//
|
||||||
|
// Note: this is the same implementation as in libstd's `abort_internal`
|
||||||
unsafe fn abort() -> ! {
|
unsafe fn abort() -> ! {
|
||||||
llvm_asm!("int $$0x29" :: "{ecx}"(7) ::: volatile); // 7 is FAST_FAIL_FATAL_APP_EXIT
|
llvm_asm!("int $$0x29" :: "{ecx}"(7) ::: volatile); // 7 is FAST_FAIL_FATAL_APP_EXIT
|
||||||
core::intrinsics::unreachable();
|
core::intrinsics::unreachable();
|
||||||
|
|
|
@ -281,7 +281,11 @@ macro_rules! impl_is_zero {
|
||||||
impl_is_zero! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
|
impl_is_zero! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
|
||||||
|
|
||||||
pub fn cvt<I: IsZero>(i: I) -> crate::io::Result<I> {
|
pub fn cvt<I: IsZero>(i: I) -> crate::io::Result<I> {
|
||||||
if i.is_zero() { Err(crate::io::Error::last_os_error()) } else { Ok(i) }
|
if i.is_zero() {
|
||||||
|
Err(crate::io::Error::last_os_error())
|
||||||
|
} else {
|
||||||
|
Ok(i)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dur2timeout(dur: Duration) -> c::DWORD {
|
pub fn dur2timeout(dur: Duration) -> c::DWORD {
|
||||||
|
@ -300,14 +304,10 @@ pub fn dur2timeout(dur: Duration) -> c::DWORD {
|
||||||
.unwrap_or(c::INFINITE)
|
.unwrap_or(c::INFINITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
// On Windows, use the processor-specific __fastfail mechanism. In Windows 8
|
/// Use `__fastfail` to abort the process
|
||||||
// and later, this will terminate the process immediately without running any
|
///
|
||||||
// in-process exception handlers. In earlier versions of Windows, this
|
/// This is the same implementation as in libpanic_abort's `__rust_start_panic`. See
|
||||||
// sequence of instructions will be treated as an access violation,
|
/// that function for more information on `__fastfail`
|
||||||
// terminating the process but without necessarily bypassing all exception
|
|
||||||
// handlers.
|
|
||||||
//
|
|
||||||
// https://docs.microsoft.com/en-us/cpp/intrinsics/fastfail
|
|
||||||
#[allow(unreachable_code)]
|
#[allow(unreachable_code)]
|
||||||
pub fn abort_internal() -> ! {
|
pub fn abort_internal() -> ! {
|
||||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||||
|
|
Loading…
Reference in New Issue