#include "typeinfo"
#include "exception"
#include <cstdlib>
#include "unwind-cxx.h"
#include "exception_defines.h"
#if defined(__APPLE__) && defined(__ppc__) && defined(PIC)
#include "bits/os_defines.h"
#endif
using namespace __cxxabiv1;
void
__cxxabiv1::__terminate (std::terminate_handler handler)
{
try {
handler ();
std::abort ();
} catch (...) {
std::abort ();
}
}
void
std::terminate ()
{
#if defined(__APPLE__) && defined(__ppc__) && defined(PIC)
std::terminate_handler __keymgr_terminate_func = (std::terminate_handler)
_keymgr_get_per_thread_data (KEYMGR_TERMINATE_HANDLER_KEY);
if (__keymgr_terminate_func)
__terminate_handler = __keymgr_terminate_func;
#endif
__terminate (__terminate_handler);
}
void
__cxxabiv1::__unexpected (std::unexpected_handler handler)
{
handler();
std::terminate ();
}
void
std::unexpected ()
{
#if defined(__APPLE__) && defined(__ppc__) && defined(PIC)
std::unexpected_handler __keymgr_unexpected_func = (std::unexpected_handler)
_keymgr_get_per_thread_data (KEYMGR_UNEXPECTED_HANDLER_KEY);
if (__keymgr_unexpected_func)
__unexpected_handler = __keymgr_unexpected_func;
#endif
__unexpected (__unexpected_handler);
}
std::terminate_handler
std::set_terminate (std::terminate_handler func) throw()
{
#if defined(__APPLE__) && defined(__ppc__) && defined(PIC)
std::terminate_handler old =
(std::terminate_handler) _keymgr_get_per_thread_data (KEYMGR_TERMINATE_HANDLER_KEY);
_keymgr_set_per_thread_data (KEYMGR_TERMINATE_HANDLER_KEY, (void *) func) ;
if ( ! old)
old = __terminate_handler;
#else
std::terminate_handler old = __terminate_handler;
#endif
__terminate_handler = func;
return old;
}
std::unexpected_handler
std::set_unexpected (std::unexpected_handler func) throw()
{
#if defined(__APPLE__) && defined(__ppc__) && defined(PIC)
std::unexpected_handler old =
(std::unexpected_handler) _keymgr_get_per_thread_data (KEYMGR_UNEXPECTED_HANDLER_KEY);
_keymgr_set_per_thread_data (KEYMGR_UNEXPECTED_HANDLER_KEY, (void *) func);
if ( ! old)
old = __unexpected_handler;
#else
std::unexpected_handler old = __unexpected_handler;
#endif
__unexpected_handler = func;
return old;
}