#include <pthread.h>
#include <stdlib.h>
#include <exception>
#include <new>
#include "cxxabi.h"
#include "unwind-cxx.h"
#include "abort_message.h"
static __attribute__((noreturn))
void safe_handler_caller(void (*handler)())
{
try {
(*handler)();
::abort_message("handler unexpected returned");
} catch (...) {
::abort_message("handler threw exception");
}
}
static void unexpected_defaults_to_terminate()
{
safe_handler_caller(__cxxabiapple::__cxa_terminate_handler);
}
static void default_terminate()
{
if ( __cxxabiv1::__cxa_current_exception_type() != NULL )
abort_message("terminate called throwing an exception");
else
abort_message("terminate called without an active exception");
}
void (*__cxxabiapple::__cxa_terminate_handler)() = &default_terminate;
void (*__cxxabiapple::__cxa_unexpected_handler)() = &unexpected_defaults_to_terminate;
void (*__cxxabiapple::__cxa_new_handler)() = NULL;
void __cxxabiv1::__terminate(std::terminate_handler handler)
{
safe_handler_caller(handler);
}
void __cxxabiv1::__unexpected(std::unexpected_handler handler)
{
(*handler)();
safe_handler_caller(__cxxabiapple::__cxa_terminate_handler);
}
void std::terminate()
{
safe_handler_caller(__cxxabiapple::__cxa_terminate_handler);
}
void __cxxabiv1::__cxa_bad_typeid()
{
abort_message("__cxa_bad_typeid() called during dynamic cast");
}
void __cxxabiv1::__cxa_bad_cast()
{
abort_message("__cxa_bad_cast() called");
}
void operator delete(void* x) throw()
{
free(x);
}