1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5//
6// Definition of the Unwind API functions.
7// Taken from the ABI documentation.
8//
9
10
11
12#ifndef __PAL_UNWIND_H__
13#define __PAL_UNWIND_H__
14
15#if FEATURE_PAL_SXS
16
17#ifdef __cplusplus
18extern "C"
19{
20#endif // __cplusplus
21
22 //
23 // Exception Handling ABI Level I: Base ABI
24 //
25
26 typedef enum
27 {
28 _URC_NO_REASON = 0,
29 _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
30 _URC_FATAL_PHASE2_ERROR = 2,
31 _URC_FATAL_PHASE1_ERROR = 3,
32 _URC_NORMAL_STOP = 4,
33 _URC_END_OF_STACK = 5,
34 _URC_HANDLER_FOUND = 6,
35 _URC_INSTALL_CONTEXT = 7,
36 _URC_CONTINUE_UNWIND = 8,
37 } _Unwind_Reason_Code;
38
39 typedef enum
40 {
41 _UA_SEARCH_PHASE = 1,
42 _UA_CLEANUP_PHASE = 2,
43 _UA_HANDLER_FRAME = 4,
44 _UA_FORCE_UNWIND = 8,
45 } _Unwind_Action;
46 #define _UA_PHASE_MASK (_UA_SEARCH_PHASE|_UA_CLEANUP_PHASE)
47
48 struct _Unwind_Context;
49
50 void *_Unwind_GetIP(struct _Unwind_Context *context);
51 void _Unwind_SetIP(struct _Unwind_Context *context, void *new_value);
52 void *_Unwind_GetCFA(struct _Unwind_Context *context);
53 void *_Unwind_GetGR(struct _Unwind_Context *context, int index);
54 void _Unwind_SetGR(struct _Unwind_Context *context, int index, void *new_value);
55
56 struct _Unwind_Exception;
57
58 typedef void (*_Unwind_Exception_Cleanup_Fn)(
59 _Unwind_Reason_Code urc,
60 struct _Unwind_Exception *exception_object);
61
62 struct _Unwind_Exception
63 {
64 ULONG64 exception_class;
65 _Unwind_Exception_Cleanup_Fn exception_cleanup;
66 UINT_PTR private_1;
67 UINT_PTR private_2;
68 } __attribute__((aligned));
69
70 void _Unwind_DeleteException(struct _Unwind_Exception *exception_object);
71
72 typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context *context, void *pvParam);
73 _Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn pfnTrace, void *pvParam);
74
75 _Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception *exception_object);
76 __attribute__((noreturn)) void _Unwind_Resume(struct _Unwind_Exception *exception_object);
77
78 //
79 // Exception Handling ABI Level II: C++ ABI
80 //
81
82 void *__cxa_begin_catch(void *exceptionObject);
83 void __cxa_end_catch();
84
85#ifdef __cplusplus
86};
87#endif // __cplusplus
88
89#endif // FEATURE_PAL_SXS
90
91#endif // __PAL_UNWIND_H__
92