|
| 1 | +#![allow(nonstandard_style)] |
| 2 | + |
| 3 | +use libc::{c_int, c_void}; |
| 4 | + |
| 5 | +#[repr(C)] |
| 6 | +#[derive(Copy, Clone, PartialEq)] |
| 7 | +pub enum _Unwind_Action { |
| 8 | + _UA_SEARCH_PHASE = 1, |
| 9 | + _UA_CLEANUP_PHASE = 2, |
| 10 | + _UA_HANDLER_FRAME = 4, |
| 11 | + _UA_FORCE_UNWIND = 8, |
| 12 | + _UA_END_OF_STACK = 16, |
| 13 | +} |
| 14 | +pub use _Unwind_Action::*; |
| 15 | + |
| 16 | +#[repr(C)] |
| 17 | +#[derive(Debug, Copy, Clone, PartialEq)] |
| 18 | +pub enum _Unwind_Reason_Code { |
| 19 | + _URC_NO_REASON = 0, |
| 20 | + _URC_FOREIGN_EXCEPTION_CAUGHT = 1, |
| 21 | + _URC_FATAL_PHASE2_ERROR = 2, |
| 22 | + _URC_FATAL_PHASE1_ERROR = 3, |
| 23 | + _URC_NORMAL_STOP = 4, |
| 24 | + _URC_END_OF_STACK = 5, |
| 25 | + _URC_HANDLER_FOUND = 6, |
| 26 | + _URC_INSTALL_CONTEXT = 7, |
| 27 | + _URC_CONTINUE_UNWIND = 8, |
| 28 | + _URC_FAILURE = 9, // used only by ARM EHABI |
| 29 | +} |
| 30 | +pub use _Unwind_Reason_Code::*; |
| 31 | + |
| 32 | +pub use unwinding::abi::UnwindContext; |
| 33 | +pub use unwinding::abi::UnwindException; |
| 34 | +pub enum _Unwind_Context {} |
| 35 | + |
| 36 | +pub use unwinding::custom_eh_frame_finder::{ |
| 37 | + set_custom_eh_frame_finder, EhFrameFinder, FrameInfo, FrameInfoKind, |
| 38 | +}; |
| 39 | + |
| 40 | +pub type _Unwind_Exception_Class = u64; |
| 41 | +pub type _Unwind_Word = *const u8; |
| 42 | +pub type _Unwind_Ptr = *const u8; |
| 43 | + |
| 44 | +pub const unwinder_private_data_size: usize = core::mem::size_of::<UnwindException>() |
| 45 | + - core::mem::size_of::<_Unwind_Exception_Class>() |
| 46 | + - core::mem::size_of::<_Unwind_Exception_Cleanup_Fn>(); |
| 47 | + |
| 48 | +pub type _Unwind_Exception_Cleanup_Fn = |
| 49 | + extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception); |
| 50 | + |
| 51 | +#[repr(C)] |
| 52 | +pub struct _Unwind_Exception { |
| 53 | + pub exception_class: _Unwind_Exception_Class, |
| 54 | + pub exception_cleanup: _Unwind_Exception_Cleanup_Fn, |
| 55 | + pub private: [_Unwind_Word; unwinder_private_data_size], |
| 56 | +} |
| 57 | + |
| 58 | +pub unsafe fn _Unwind_GetDataRelBase(ctx: *mut _Unwind_Context) -> _Unwind_Ptr { |
| 59 | + let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; |
| 60 | + unwinding::abi::_Unwind_GetDataRelBase(ctx) as _Unwind_Ptr |
| 61 | +} |
| 62 | + |
| 63 | +pub unsafe fn _Unwind_GetTextRelBase(ctx: *mut _Unwind_Context) -> _Unwind_Ptr { |
| 64 | + let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; |
| 65 | + unwinding::abi::_Unwind_GetTextRelBase(ctx) as _Unwind_Ptr |
| 66 | +} |
| 67 | + |
| 68 | +pub unsafe fn _Unwind_GetRegionStart(ctx: *mut _Unwind_Context) -> _Unwind_Ptr { |
| 69 | + let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; |
| 70 | + unwinding::abi::_Unwind_GetRegionStart(ctx) as _Unwind_Ptr |
| 71 | +} |
| 72 | + |
| 73 | +pub unsafe fn _Unwind_SetGR(ctx: *mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word) { |
| 74 | + let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; |
| 75 | + unwinding::abi::_Unwind_SetGR(ctx, reg_index, value as usize) |
| 76 | +} |
| 77 | + |
| 78 | +pub unsafe fn _Unwind_SetIP(ctx: *mut _Unwind_Context, value: _Unwind_Word) { |
| 79 | + let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; |
| 80 | + unwinding::abi::_Unwind_SetIP(ctx, value as usize) |
| 81 | +} |
| 82 | + |
| 83 | +pub unsafe fn _Unwind_GetIPInfo( |
| 84 | + ctx: *mut _Unwind_Context, |
| 85 | + ip_before_insn: *mut c_int, |
| 86 | +) -> _Unwind_Word { |
| 87 | + let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; |
| 88 | + let ip_before_insn = unsafe { &mut *(ip_before_insn as *mut c_int) }; |
| 89 | + unsafe { &*(unwinding::abi::_Unwind_GetIPInfo(ctx, ip_before_insn) as _Unwind_Word) } |
| 90 | +} |
| 91 | + |
| 92 | +pub unsafe fn _Unwind_GetLanguageSpecificData(ctx: *mut _Unwind_Context) -> *mut c_void { |
| 93 | + let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; |
| 94 | + unwinding::abi::_Unwind_GetLanguageSpecificData(ctx) |
| 95 | +} |
| 96 | + |
| 97 | +pub unsafe fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code { |
| 98 | + let exception = unsafe { &mut *(exception as *mut UnwindException) }; |
| 99 | + unsafe { core::mem::transmute(unwinding::abi::_Unwind_RaiseException(exception)) } |
| 100 | +} |
| 101 | + |
| 102 | +pub unsafe fn _Unwind_DeleteException(exception: *mut _Unwind_Exception) { |
| 103 | + let exception = unsafe { &mut *(exception as *mut UnwindException) }; |
| 104 | + unsafe { unwinding::abi::_Unwind_DeleteException(exception) } |
| 105 | +} |
0 commit comments