diff options
| author | Amanieu d'Antras <amanieu@gmail.com> | 2019-10-21 02:46:04 +0100 |
|---|---|---|
| committer | Amanieu d'Antras <amanieu@gmail.com> | 2019-11-03 14:03:21 +0000 |
| commit | 5f1a0afd22c7f1e26782467503d32d026c55fc0c (patch) | |
| tree | 7e7fc14e9dadb4770e40294ec56cdc54642e7db4 /src/libunwind/libunwind.rs | |
| parent | 9a8bb3a26e8a058be64a0d778b3b168bc9b74caa (diff) | |
Allow foreign exceptions to unwind through Rust code
Diffstat (limited to 'src/libunwind/libunwind.rs')
| -rw-r--r-- | src/libunwind/libunwind.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/libunwind/libunwind.rs b/src/libunwind/libunwind.rs index 7c9eaa51fd9..0b39503c0d0 100644 --- a/src/libunwind/libunwind.rs +++ b/src/libunwind/libunwind.rs @@ -244,3 +244,30 @@ if #[cfg(not(all(target_os = "ios", target_arch = "arm")))] { } } } // 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! |
