3 #ifndef _EXCEPTION_HANLDING_H_
4 #define _EXCEPTION_HANLDING_H_
6 typedef void *(unexpected_handler)(void);
7 typedef void *(terminate_handler)(void);
9 struct _Unwind_Context;
13 _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
14 _URC_FATAL_PHASE2_ERROR = 2,
15 _URC_FATAL_PHASE1_ERROR = 3,
17 _URC_END_OF_STACK = 5,
18 _URC_HANDLER_FOUND = 6,
19 _URC_INSTALL_CONTEXT = 7,
20 _URC_CONTINUE_UNWIND = 8
21 } _Unwind_Reason_Code;
23 typedef void (*_Unwind_Exception_Cleanup_Fn)(_Unwind_Reason_Code reason, struct _Unwind_Exception *exc);
25 struct _Unwind_Exception
27 uint64_t exception_class;
28 _Unwind_Exception_Cleanup_Fn exception_cleanup;
33 struct __cxa_exception
35 std::type_info* exceptionType;
36 void (*exceptionDestructor)(void *);
37 unexpected_handler unexpectedHandler;
38 terminate_handler terminateHandler;
39 __cxa_exception* nextException;
43 int handlerSwitchValue;
44 const char* actionRecord;
45 const char* languageSpecificData;
49 _Unwind_Exception unwindHeader;
53 extern "C" void __cxa_call_unexpected(void *);
54 extern "C" void *__cxa_allocate_exception(size_t thrown_size);
55 extern "C" void __cxa_free_exception(void *thrown_exception);
56 extern "C" void __cxa_throw(void *thrown_exception, std::type_info *tinfo, void (*dest)(void*));
57 extern "C" void *__cxa_begin_catch(void *exceptionObject);
58 extern "C" void __cxa_end_catch();
60 extern "C" void _Unwind_RaiseException(void *thrown_exception);