2017-10-04 17:29:21 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <cstdlib>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <cstdio>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <exception>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <bits/functexcept.h>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <sdkconfig.h>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-24 15:02:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#ifndef CONFIG_COMPILER_CXX_EXCEPTIONS
							 | 
						
					
						
							
								
									
										
										
										
											2017-10-04 17:29:21 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								const char *FATAL_EXCEPTION = "Fatal C++ exception: ";
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								extern "C" void __cxx_fatal_exception(void)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    abort();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-14 19:11:21 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								extern "C" bool __cxx_fatal_exception_bool(void)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    __cxx_fatal_exception();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-10-04 17:29:21 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								extern "C" void __cxx_fatal_exception_message(const char *msg)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf("%s%s\n", FATAL_EXCEPTION, msg);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    abort();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-14 19:11:21 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								extern "C" void __cxx_fatal_exception_message_va(const char *msg, ...)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    __cxx_fatal_exception_message(msg);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-10-04 17:29:21 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								extern "C" void __cxx_fatal_exception_int(int i)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf("%s (%d)\n", FATAL_EXCEPTION, i);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    abort();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-28 12:22:12 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#if !GCC_NOT_5_2_0
							 | 
						
					
						
							
								
									
										
										
										
											2017-10-04 17:29:21 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_bad_exception(void) __attribute__((alias("__cxx_fatal_exception")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_bad_alloc(void) __attribute__((alias("__cxx_fatal_exception")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_bad_cast(void) __attribute__((alias("__cxx_fatal_exception")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_bad_typeid(void) __attribute__((alias("__cxx_fatal_exception")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_logic_error(const char*) __attribute__((alias("__cxx_fatal_exception_message")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_domain_error(const char*) __attribute__((alias("__cxx_fatal_exception_message")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_invalid_argument(const char*) __attribute__((alias("__cxx_fatal_exception_message")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_length_error(const char*) __attribute__((alias("__cxx_fatal_exception_message")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_out_of_range(const char*) __attribute__((alias("__cxx_fatal_exception_message")));
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-14 19:11:21 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void std::__throw_out_of_range_fmt(const char*, ...) __attribute__((alias("__cxx_fatal_exception_message_va")));
							 | 
						
					
						
							
								
									
										
										
										
											2017-10-04 17:29:21 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_runtime_error(const char*) __attribute__((alias("__cxx_fatal_exception_message")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_range_error(const char*) __attribute__((alias("__cxx_fatal_exception_message")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_overflow_error(const char*) __attribute__((alias("__cxx_fatal_exception_message")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_underflow_error(const char*) __attribute__((alias("__cxx_fatal_exception_message")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_ios_failure(const char*) __attribute__((alias("__cxx_fatal_exception_message")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_system_error(int) __attribute__((alias("__cxx_fatal_exception_int")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_bad_function_call(void) __attribute__((alias("__cxx_fatal_exception")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void std::__throw_future_error(int) __attribute__((alias("__cxx_fatal_exception_int")));
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-28 12:22:12 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							
								
									
										
										
										
											2017-10-04 17:29:21 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/* The following definitions are needed because libstdc++ is also compiled with
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   __throw_exception_again defined to throw, and some other exception code in a few places.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   This cause exception handler code to be emitted in the library even though it's mostly
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   unreachable (as any libstdc++ "throw" will first call one of the above stubs, which will abort).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   If these are left out, a bunch of unwanted exception handler code is linked.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   Note: these function prototypes are not correct.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								*/
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								extern "C" void __cxa_allocate_exception(void) __attribute__((alias("__cxx_fatal_exception")));
							 | 
						
					
						
							
								
									
										
										
										
											2017-11-21 12:41:49 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								extern "C" void __cxa_allocate_dependent_exception(void) __attribute__((alias("__cxx_fatal_exception")));
							 | 
						
					
						
							
								
									
										
										
										
											2017-10-04 17:29:21 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								extern "C" void __cxa_begin_catch(void) __attribute__((alias("__cxx_fatal_exception")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								extern "C" void __cxa_end_catch(void) __attribute__((alias("__cxx_fatal_exception")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								extern "C" void __cxa_get_exception_ptr(void) __attribute__((alias("__cxx_fatal_exception")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								extern "C" void __cxa_free_exception(void) __attribute__((alias("__cxx_fatal_exception")));
							 | 
						
					
						
							
								
									
										
										
										
											2017-11-21 12:41:49 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								extern "C" void __cxa_free_dependent_exception(void) __attribute__((alias("__cxx_fatal_exception")));
							 | 
						
					
						
							
								
									
										
										
										
											2017-10-04 17:29:21 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								extern "C" void __cxa_rethrow(void) __attribute__((alias("__cxx_fatal_exception")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								extern "C" void __cxa_throw(void) __attribute__((alias("__cxx_fatal_exception")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								extern "C" void __cxa_call_terminate(void) __attribute__((alias("__cxx_fatal_exception")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-14 19:11:21 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								bool std::uncaught_exception() __attribute__((alias("__cxx_fatal_exception_bool")));
							 | 
						
					
						
							
								
									
										
										
										
											2017-10-04 17:29:21 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-24 15:02:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#endif // CONFIG_COMPILER_CXX_EXCEPTIONS
							 |