xref: /freebsd-src/contrib/llvm-project/libunwind/include/unwind_itanium.h (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
1*349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
2*349cc55cSDimitry Andric //
3*349cc55cSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*349cc55cSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*349cc55cSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*349cc55cSDimitry Andric //
7*349cc55cSDimitry Andric //
8*349cc55cSDimitry Andric // C++ ABI Level 1 ABI documented at:
9*349cc55cSDimitry Andric //   https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
10*349cc55cSDimitry Andric //
11*349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
12*349cc55cSDimitry Andric 
13*349cc55cSDimitry Andric #ifndef __ITANIUM_UNWIND_H__
14*349cc55cSDimitry Andric #define __ITANIUM_UNWIND_H__
15*349cc55cSDimitry Andric 
16*349cc55cSDimitry Andric struct _Unwind_Context;   // opaque
17*349cc55cSDimitry Andric struct _Unwind_Exception; // forward declaration
18*349cc55cSDimitry Andric typedef struct _Unwind_Exception _Unwind_Exception;
19*349cc55cSDimitry Andric typedef uint64_t _Unwind_Exception_Class;
20*349cc55cSDimitry Andric 
21*349cc55cSDimitry Andric struct _Unwind_Exception {
22*349cc55cSDimitry Andric   _Unwind_Exception_Class exception_class;
23*349cc55cSDimitry Andric   void (*exception_cleanup)(_Unwind_Reason_Code reason,
24*349cc55cSDimitry Andric                             _Unwind_Exception *exc);
25*349cc55cSDimitry Andric #if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)
26*349cc55cSDimitry Andric   uintptr_t private_[6];
27*349cc55cSDimitry Andric #else
28*349cc55cSDimitry Andric   uintptr_t private_1; // non-zero means forced unwind
29*349cc55cSDimitry Andric   uintptr_t private_2; // holds sp that phase1 found for phase2 to use
30*349cc55cSDimitry Andric #endif
31*349cc55cSDimitry Andric #if __SIZEOF_POINTER__ == 4
32*349cc55cSDimitry Andric   // The implementation of _Unwind_Exception uses an attribute mode on the
33*349cc55cSDimitry Andric   // above fields which has the side effect of causing this whole struct to
34*349cc55cSDimitry Andric   // round up to 32 bytes in size (48 with SEH). To be more explicit, we add
35*349cc55cSDimitry Andric   // pad fields added for binary compatibility.
36*349cc55cSDimitry Andric   uint32_t reserved[3];
37*349cc55cSDimitry Andric #endif
38*349cc55cSDimitry Andric   // The Itanium ABI requires that _Unwind_Exception objects are "double-word
39*349cc55cSDimitry Andric   // aligned".  GCC has interpreted this to mean "use the maximum useful
40*349cc55cSDimitry Andric   // alignment for the target"; so do we.
41*349cc55cSDimitry Andric } __attribute__((__aligned__));
42*349cc55cSDimitry Andric 
43*349cc55cSDimitry Andric typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(
44*349cc55cSDimitry Andric     int version, _Unwind_Action actions, uint64_t exceptionClass,
45*349cc55cSDimitry Andric     _Unwind_Exception *exceptionObject, struct _Unwind_Context *context);
46*349cc55cSDimitry Andric 
47*349cc55cSDimitry Andric #ifdef __cplusplus
48*349cc55cSDimitry Andric extern "C" {
49*349cc55cSDimitry Andric #endif
50*349cc55cSDimitry Andric 
51*349cc55cSDimitry Andric //
52*349cc55cSDimitry Andric // The following are the base functions documented by the C++ ABI
53*349cc55cSDimitry Andric //
54*349cc55cSDimitry Andric #ifdef __USING_SJLJ_EXCEPTIONS__
55*349cc55cSDimitry Andric extern _Unwind_Reason_Code
56*349cc55cSDimitry Andric     _Unwind_SjLj_RaiseException(_Unwind_Exception *exception_object);
57*349cc55cSDimitry Andric extern void _Unwind_SjLj_Resume(_Unwind_Exception *exception_object);
58*349cc55cSDimitry Andric #else
59*349cc55cSDimitry Andric extern _Unwind_Reason_Code
60*349cc55cSDimitry Andric     _Unwind_RaiseException(_Unwind_Exception *exception_object);
61*349cc55cSDimitry Andric extern void _Unwind_Resume(_Unwind_Exception *exception_object);
62*349cc55cSDimitry Andric #endif
63*349cc55cSDimitry Andric extern void _Unwind_DeleteException(_Unwind_Exception *exception_object);
64*349cc55cSDimitry Andric 
65*349cc55cSDimitry Andric 
66*349cc55cSDimitry Andric extern uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, int index);
67*349cc55cSDimitry Andric extern void _Unwind_SetGR(struct _Unwind_Context *context, int index,
68*349cc55cSDimitry Andric                           uintptr_t new_value);
69*349cc55cSDimitry Andric extern uintptr_t _Unwind_GetIP(struct _Unwind_Context *context);
70*349cc55cSDimitry Andric extern void _Unwind_SetIP(struct _Unwind_Context *, uintptr_t new_value);
71*349cc55cSDimitry Andric 
72*349cc55cSDimitry Andric #ifdef __cplusplus
73*349cc55cSDimitry Andric }
74*349cc55cSDimitry Andric #endif
75*349cc55cSDimitry Andric 
76*349cc55cSDimitry Andric #endif // __ITANIUM_UNWIND_H__
77