unwind_itanium.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifndef __ITANIUM_UNWIND_H__
  13. #define __ITANIUM_UNWIND_H__
  14. struct _Unwind_Context; // opaque
  15. struct _Unwind_Exception; // forward declaration
  16. typedef struct _Unwind_Exception _Unwind_Exception;
  17. typedef uint64_t _Unwind_Exception_Class;
  18. struct _Unwind_Exception {
  19. _Unwind_Exception_Class exception_class;
  20. void (*exception_cleanup)(_Unwind_Reason_Code reason,
  21. _Unwind_Exception *exc);
  22. #if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)
  23. uintptr_t private_[6];
  24. #else
  25. uintptr_t private_1; // non-zero means forced unwind
  26. uintptr_t private_2; // holds sp that phase1 found for phase2 to use
  27. #endif
  28. #if __SIZEOF_POINTER__ == 4
  29. // The implementation of _Unwind_Exception uses an attribute mode on the
  30. // above fields which has the side effect of causing this whole struct to
  31. // round up to 32 bytes in size (48 with SEH). To be more explicit, we add
  32. // pad fields added for binary compatibility.
  33. uint32_t reserved[3];
  34. #endif
  35. // The Itanium ABI requires that _Unwind_Exception objects are "double-word
  36. // aligned". GCC has interpreted this to mean "use the maximum useful
  37. // alignment for the target"; so do we.
  38. } __attribute__((__aligned__));
  39. typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(
  40. int version, _Unwind_Action actions, uint64_t exceptionClass,
  41. _Unwind_Exception *exceptionObject, struct _Unwind_Context *context);
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45. //
  46. // The following are the base functions documented by the C++ ABI
  47. //
  48. #ifdef __USING_SJLJ_EXCEPTIONS__
  49. extern _Unwind_Reason_Code
  50. _Unwind_SjLj_RaiseException(_Unwind_Exception *exception_object);
  51. extern void _Unwind_SjLj_Resume(_Unwind_Exception *exception_object);
  52. #else
  53. extern _Unwind_Reason_Code
  54. _Unwind_RaiseException(_Unwind_Exception *exception_object);
  55. extern void _Unwind_Resume(_Unwind_Exception *exception_object);
  56. #endif
  57. extern void _Unwind_DeleteException(_Unwind_Exception *exception_object);
  58. extern uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, int index);
  59. extern void _Unwind_SetGR(struct _Unwind_Context *context, int index,
  60. uintptr_t new_value);
  61. extern uintptr_t _Unwind_GetIP(struct _Unwind_Context *context);
  62. extern void _Unwind_SetIP(struct _Unwind_Context *, uintptr_t new_value);
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66. #endif // __ITANIUM_UNWIND_H__