#![allow(nonstandard_style)]
-#[cfg(not(target_os = "hermit"))]
use libc::{c_int, c_void, uintptr_t};
-#[cfg(target_os = "hermit")]
-pub type c_int = i32;
-
-#[cfg(target_os = "hermit")]
-pub type uintptr_t = usize;
-
-#[cfg(target_os = "hermit")]
-#[repr(u8)]
-#[allow(missing_copy_implementations)]
-#[allow(missing_debug_implementations)]
-pub enum c_void {
- // Two dummy variants so the #[repr] attribute can be used.
- #[doc(hidden)]
- __variant1,
- #[doc(hidden)]
- __variant2,
-}
-
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum _Unwind_Reason_Code {
pub type _Unwind_Exception_Class = u64;
pub type _Unwind_Word = uintptr_t;
pub type _Unwind_Ptr = uintptr_t;
-pub type _Unwind_Trace_Fn = extern "C" fn(ctx: *mut _Unwind_Context, arg: *mut c_void)
- -> _Unwind_Reason_Code;
+pub type _Unwind_Trace_Fn =
+ extern "C" fn(ctx: *mut _Unwind_Context, arg: *mut c_void) -> _Unwind_Reason_Code;
+
#[cfg(target_arch = "x86")]
pub const unwinder_private_data_size: usize = 5;
pub enum _Unwind_Context {}
-pub type _Unwind_Exception_Cleanup_Fn = extern "C" fn(unwind_code: _Unwind_Reason_Code,
- exception: *mut _Unwind_Exception);
-#[cfg_attr(all(feature = "llvm-libunwind",
- any(target_os = "fuchsia", target_os = "linux")),
- link(name = "unwind", kind = "static"))]
+pub type _Unwind_Exception_Cleanup_Fn =
+ extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception);
+#[cfg_attr(
+ all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")),
+ link(name = "unwind", kind = "static")
+)]
extern "C" {
#[unwind(allowed)]
pub fn _Unwind_Resume(exception: *mut _Unwind_Exception) -> !;
use _Unwind_VRS_DataRepresentation::*;
pub const UNWIND_POINTER_REG: c_int = 12;
+ pub const UNWIND_SP_REG: c_int = 13;
pub const UNWIND_IP_REG: c_int = 15;
#[cfg_attr(all(feature = "llvm-libunwind",
}
}
} // cfg_if!
+
+cfg_if::cfg_if! {
+if #[cfg(all(windows, target_arch = "x86_64", target_env = "gnu"))] {
+ // We declare these as opaque types. This is fine since you just need to
+ // pass them to _GCC_specific_handler and forget about them.
+ pub enum EXCEPTION_RECORD {}
+ pub type LPVOID = *mut c_void;
+ pub enum CONTEXT {}
+ pub enum DISPATCHER_CONTEXT {}
+ pub type EXCEPTION_DISPOSITION = c_int;
+ type PersonalityFn = unsafe extern "C" fn(version: c_int,
+ actions: _Unwind_Action,
+ exception_class: _Unwind_Exception_Class,
+ exception_object: *mut _Unwind_Exception,
+ context: *mut _Unwind_Context)
+ -> _Unwind_Reason_Code;
+
+ extern "C" {
+ pub fn _GCC_specific_handler(exceptionRecord: *mut EXCEPTION_RECORD,
+ establisherFrame: LPVOID,
+ contextRecord: *mut CONTEXT,
+ dispatcherContext: *mut DISPATCHER_CONTEXT,
+ personality: PersonalityFn)
+ -> EXCEPTION_DISPOSITION;
+ }
+}
+} // cfg_if!