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