source: mainline/uspace/lib/cpp/src/__bits/unwind.cpp@ 8624d1f

Last change on this file since 8624d1f was b57ba05, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago

Update headers in C++ files

  • Property mode set to 100644
File size: 5.2 KB
RevLine 
[ef9d0988]1/*
[b57ba05]2 * SPDX-FileCopyrightText: 2019 Jaroslav Jindrak
[ef9d0988]3 *
[b57ba05]4 * SPDX-License-Identifier: BSD-3-Clause
[ef9d0988]5 */
6
[7dcce0a]7#include <cassert>
[858a51f]8#include <cstdint>
[e2b55ac9]9#include <cstdlib>
[858a51f]10
[ef9d0988]11namespace __cxxabiv1
12{
13 /**
14 * Stack unwinding functionality - Level 1.
15 */
16
17 enum _Unwind_Reason_Code
18 {
19 _URC_NO_REASON = 0,
20 _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
21 _URC_FATAL_PHASE2_ERROR = 2,
22 _URC_FATAL_PHASE1_ERROR = 3,
23 _URC_NORMAL_STOP = 4,
24 _URC_END_OF_STACK = 5,
25 _URC_HANDLER_FOUND = 6,
26 _URC_INSTALL_CONTEXT = 7,
27 _URC_CONTINUE_UNWIND = 8
28 };
29
30 struct _Unwind_Exception;
31 using _Unwind_Exception_Cleanup_Fn = void (*)(_Unwind_Reason_Code, _Unwind_Exception*);
32
33 struct _Unwind_Exception
34 {
35 std::uint64_t exception_class;
36 _Unwind_Exception_Cleanup_Fn exception_cleanup;
37 std::uint64_t private_1;
38 std::uint64_t private_2;
39 };
40
41 /* Opaque structure. */
42 struct _Unwind_Context;
43
[858a51f]44 using _Unwind_Action = int;
45 namespace
46 {
47 const _Unwind_Action _UA_SEARCH_PHASE = 1;
48 const _Unwind_Action _UA_CLEANUP_PHASE = 2;
49 const _Unwind_Action _UA_HANDLER_FRAME = 4;
50 const _Unwind_Action _UA_FORCE_HANDLER = 8;
51 }
52
[ef9d0988]53 /**
54 * TODO: Explain parameter semantics.
55 */
56 using _Unwind_Stop_Fn = _Unwind_Reason_Code(*)(
57 int, _Unwind_Action, std::uint64_t, _Unwind_Exception*,
58 _Unwind_Context*, void*
59 );
60
[00d9778]61 extern "C" _Unwind_Reason_Code _Unwind_ForcedUnwind(_Unwind_Exception*, _Unwind_Stop_Fn, void*)
[ef9d0988]62 {
63 // TODO: implement
[e2b55ac9]64 return _URC_NO_REASON;
[ef9d0988]65 }
66
[00d9778]67 extern "C" void _Unwind_Resume(_Unwind_Exception*)
[ef9d0988]68 {
69 // TODO: implement
70 }
71
[00d9778]72 extern "C" void _Unwind_DeleteException(_Unwind_Exception*)
[ef9d0988]73 {
74 // TODO: implement
75 }
76
[00d9778]77 extern "C" std::uint64_t _Unwind_GetGR(_Unwind_Context*, int)
[ef9d0988]78 {
79 // TODO: implement
[e2b55ac9]80 return 0;
[ef9d0988]81 }
82
[00d9778]83 extern "C" void _Unwind_SetGR(_Unwind_Context*, int, std::uint64_t)
[ef9d0988]84 {
85 // TODO: implement
86 }
87
[00d9778]88 extern "C" std::uint64_t _Unwind_GetIP(_Unwind_Context*)
[ef9d0988]89 {
90 // TODO: implement
[e2b55ac9]91 return 0;
[ef9d0988]92 }
93
[00d9778]94 extern "C" void _Unwind_SetIP(_Unwind_Context*, std::uint64_t)
[ef9d0988]95 {
96 // TODO: implement
97 }
98
[00d9778]99 extern "C" std::uint64_t _Unwind_GetLanguageSpecificData(_Unwind_Context*)
[ef9d0988]100 {
101 // TODO: implement
[e2b55ac9]102 return 0;
[ef9d0988]103 }
104
[00d9778]105 extern "C" std::uint64_t _Unwind_GetRegionStart(_Unwind_Context*)
[ef9d0988]106 {
107 // TODO: implement
[e2b55ac9]108 return 0;
[ef9d0988]109 }
110
111 /**
112 * TODO: Explain parameter semantics.
113 */
114 using __personality_routine = _Unwind_Reason_Code(*)(
115 int, _Unwind_Action, std::uint64_t, _Unwind_Exception*,
116 _Unwind_Context*, void*
117 );
118
119 /**
120 * Stack unwinding functionality - Level 2.
121 */
[e2b55ac9]122 struct __cxa_exception
123 {
124 std::type_info* exceptionType;
125 void (*exceptionDestructor)(void*);
126 // TODO: Add handler types to <exception>.
127 /* std::unexpected_handler unexpectedHandler; */
128 void (*unexpectedHandler)();
129 /* std::terminate_handler terminateHandler; */
130 void (*terminateHandler)();
131 __cxa_exception* nextException;
132
133 int handlerCount;
134 int handlerSwitchValue;
135 const char* actionRecord;
136 const char* languageSpecificData;
137 void* catchTemp;
138 void* adjujstedPtr;
139
140 _Unwind_Exception unwindHeader;
141 };
142
143 struct __cxa_eh_globals
144 {
145 __cxa_exception* caughtExceptions;
146 unsigned int uncaughtExceptions;
147 };
148
149 extern "C" __cxa_eh_globals* __cxa_get_globals();
150
151 extern "C" __cxa_eh_globals* __cxa_get_globals_fast();
152
153 extern "C" void* __cxa_allocate_exception(std::size_t thrown_size)
154 {
155 // TODO: implement
[7dcce0a]156 __unimplemented();
[e2b55ac9]157 return nullptr;
158 }
159
160 extern "C" void __cxa_free_exception(void* thrown_exception)
161 {
162 // TODO: implement
[7dcce0a]163 __unimplemented();
[e2b55ac9]164 }
165
166 extern "C" void __cxa_throw(void* thrown_exception, std::type_info* tinfo, void (*dest)(void*))
167 {
168 // TODO: implement
[7dcce0a]169 __unimplemented();
[e2b55ac9]170 }
171
172 extern "C" void* __cxa_get_exception_ptr(void* exception_object)
173 {
174 // TODO: implement
[7dcce0a]175 __unimplemented();
[e2b55ac9]176 return nullptr;
177 }
178
179 extern "C" void* __cxa_begin_catch(void* exception_object)
180 {
181 // TODO: implement
[7dcce0a]182 __unimplemented();
[e2b55ac9]183 return nullptr;
184 }
185
186 extern "C" void __cxa_end_catch()
187 {
188 // TODO: implement
[7dcce0a]189 __unimplemented();
[e2b55ac9]190 }
191
192 extern "C" void __cxa_rethrow()
193 {
194 // TODO: implement
[7dcce0a]195 __unimplemented();
[e2b55ac9]196 }
197
198 extern "C" void __cxa_bad_cast()
199 {
200 // TODO: implement
[7dcce0a]201 __unimplemented();
[e2b55ac9]202 }
203
204 extern "C" void __cxa_bad_typeid()
205 {
206 // TODO: implement
[7dcce0a]207 __unimplemented();
[e2b55ac9]208 }
[c4049e6]209
210 extern "C" void __cxa_throw_bad_array_new_length()
211 {
212 // TODO: implement
[7dcce0a]213 __unimplemented();
[c4049e6]214 }
[2e328c3]215
216 extern "C" _Unwind_Reason_Code __gxx_personality_v0(
217 int, _Unwind_Action, unsigned,
218 struct _Unwind_Exception*, struct _Unwind_Context*
219 )
220 {
221 // TODO: implement
[7dcce0a]222 __unimplemented();
[2e328c3]223 return _URC_NO_REASON;
224 }
[ef9d0988]225}
Note: See TracBrowser for help on using the repository browser.