]>
git.proxmox.com Git - rustc.git/blob - vendor/unwinding/src/abi.rs
6 #[cfg(not(feature = "unwinder"))]
8 #[cfg(feature = "unwinder")]
9 pub use crate::unwinder
::*;
12 #[derive(Clone, Copy, PartialEq, Eq)]
13 pub struct UnwindReasonCode(pub c_int
);
16 impl UnwindReasonCode
{
17 pub const NO_REASON
: Self = Self(0);
18 pub const FOREIGN_EXCEPTION_CAUGHT
: Self = Self(1);
19 pub const FATAL_PHASE2_ERROR
: Self = Self(2);
20 pub const FATAL_PHASE1_ERROR
: Self = Self(3);
21 pub const NORMAL_STOP
: Self = Self(4);
22 pub const END_OF_STACK
: Self = Self(5);
23 pub const HANDLER_FOUND
: Self = Self(6);
24 pub const INSTALL_CONTEXT
: Self = Self(7);
25 pub const CONTINUE_UNWIND
: Self = Self(8);
29 #[derive(Clone, Copy, PartialEq, Eq)]
30 pub struct UnwindAction(pub c_int
);
33 pub const SEARCH_PHASE
: Self = Self(1);
34 pub const CLEANUP_PHASE
: Self = Self(2);
35 pub const HANDLER_FRAME
: Self = Self(4);
36 pub const FORCE_UNWIND
: Self = Self(8);
37 pub const END_OF_STACK
: Self = Self(16);
40 impl ops
::BitOr
for UnwindAction
{
44 fn bitor(self, rhs
: Self) -> Self {
51 pub const fn empty() -> Self {
56 pub const fn contains(&self, other
: Self) -> bool
{
61 pub type UnwindExceptionCleanupFn
= unsafe extern "C" fn(UnwindReasonCode
, *mut UnwindException
);
63 pub type UnwindStopFn
= unsafe extern "C" fn(
68 &mut UnwindContext
<'_
>,
70 ) -> UnwindReasonCode
;
72 #[cfg(not(feature = "unwinder"))]
74 pub struct UnwindException
{
75 pub exception_class
: u64,
76 pub exception_cleanup
: Option
<UnwindExceptionCleanupFn
>,
77 private
: [usize; Arch
::UNWIND_PRIVATE_DATA_SIZE
],
80 pub type UnwindTraceFn
=
81 extern "C" fn(ctx
: &UnwindContext
<'_
>, arg
: *mut c_void
) -> UnwindReasonCode
;
83 #[cfg(not(feature = "unwinder"))]
85 pub struct UnwindContext
<'a
> {
87 phantom
: core
::marker
::PhantomData
<&'
a ()>,
90 pub type PersonalityRoutine
= unsafe extern "C" fn(
95 &mut UnwindContext
<'_
>,
96 ) -> UnwindReasonCode
;
98 #[cfg(not(feature = "unwinder"))]
99 macro_rules
! binding
{
101 (unsafe extern $abi
: literal
fn $name
: ident ($
($arg
: ident
: $arg_ty
: ty
),*$
(,)?
) $
(-> $ret
: ty
)?
; $
($rest
: tt
)*) => {
103 pub fn $
name($
($arg
: $arg_ty
),*) $
(-> $ret
)?
;
108 (extern $abi
: literal
fn $name
: ident ($
($arg
: ident
: $arg_ty
: ty
),*$
(,)?
) $
(-> $ret
: ty
)?
; $
($rest
: tt
)*) => {
109 #[allow(non_snake_case)]
111 pub fn $
name($
($arg
: $arg_ty
),*) $
(-> $ret
)?
{
113 fn $
name($
($arg
: $arg_ty
),*) $
(-> $ret
)?
;
115 unsafe { $name($($arg),*) }
121 #[cfg(feature = "unwinder")]
122 macro_rules
! binding
{
124 (unsafe extern $abi
: literal
fn $name
: ident ($
($arg
: ident
: $arg_ty
: ty
),*$
(,)?
) $
(-> $ret
: ty
)?
; $
($rest
: tt
)*) => {
125 const _
: unsafe extern $abi
fn($
($arg_ty
),*) $
(-> $ret
)?
= $name
;
128 (extern $abi
: literal
fn $name
: ident ($
($arg
: ident
: $arg_ty
: ty
),*$
(,)?
) $
(-> $ret
: ty
)?
; $
($rest
: tt
)*) => {
129 const _
: extern $abi
fn($
($arg_ty
),*) $
(-> $ret
)?
= $name
;
134 extern "C" fn _Unwind_GetGR(unwind_ctx
: &UnwindContext
<'_
>, index
: c_int
) -> usize;
135 extern "C" fn _Unwind_GetCFA(unwind_ctx
: &UnwindContext
<'_
>) -> usize;
136 extern "C" fn _Unwind_SetGR(
137 unwind_ctx
: &mut UnwindContext
<'_
>,
141 extern "C" fn _Unwind_GetIP(unwind_ctx
: &UnwindContext
<'_
>) -> usize;
142 extern "C" fn _Unwind_GetIPInfo(
143 unwind_ctx
: &UnwindContext
<'_
>,
144 ip_before_insn
: &mut c_int
,
146 extern "C" fn _Unwind_SetIP(
147 unwind_ctx
: &mut UnwindContext
<'_
>,
150 extern "C" fn _Unwind_GetLanguageSpecificData(unwind_ctx
: &UnwindContext
<'_
>) -> *mut c_void
;
151 extern "C" fn _Unwind_GetRegionStart(unwind_ctx
: &UnwindContext
<'_
>) -> usize;
152 extern "C" fn _Unwind_GetTextRelBase(unwind_ctx
: &UnwindContext
<'_
>) -> usize;
153 extern "C" fn _Unwind_GetDataRelBase(unwind_ctx
: &UnwindContext
<'_
>) -> usize;
154 extern "C" fn _Unwind_FindEnclosingFunction(pc
: *mut c_void
) -> *mut c_void
;
155 unsafe extern "C-unwind" fn _Unwind_RaiseException(
156 exception
: *mut UnwindException
,
157 ) -> UnwindReasonCode
;
158 unsafe extern "C-unwind" fn _Unwind_ForcedUnwind(
159 exception
: *mut UnwindException
,
161 stop_arg
: *mut c_void
,
162 ) -> UnwindReasonCode
;
163 unsafe extern "C-unwind" fn _Unwind_Resume(exception
: *mut UnwindException
) -> !;
164 unsafe extern "C-unwind" fn _Unwind_Resume_or_Rethrow(
165 exception
: *mut UnwindException
,
166 ) -> UnwindReasonCode
;
167 unsafe extern "C" fn _Unwind_DeleteException(exception
: *mut UnwindException
);
168 extern "C-unwind" fn _Unwind_Backtrace(
169 trace
: UnwindTraceFn
,
170 trace_argument
: *mut c_void
,
171 ) -> UnwindReasonCode
;