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