eh_terminate.cc revision 97403
197403Sobrien// -*- C++ -*- std::terminate, std::unexpected and friends. 297403Sobrien// Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 397403Sobrien// Free Software Foundation 497403Sobrien// 597403Sobrien// This file is part of GNU CC. 697403Sobrien// 797403Sobrien// GNU CC is free software; you can redistribute it and/or modify 897403Sobrien// it under the terms of the GNU General Public License as published by 997403Sobrien// the Free Software Foundation; either version 2, or (at your option) 1097403Sobrien// any later version. 1197403Sobrien// 1297403Sobrien// GNU CC is distributed in the hope that it will be useful, 1397403Sobrien// but WITHOUT ANY WARRANTY; without even the implied warranty of 1497403Sobrien// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1597403Sobrien// GNU General Public License for more details. 1697403Sobrien// 1797403Sobrien// You should have received a copy of the GNU General Public License 1897403Sobrien// along with GNU CC; see the file COPYING. If not, write to 1997403Sobrien// the Free Software Foundation, 59 Temple Place - Suite 330, 2097403Sobrien// Boston, MA 02111-1307, USA. 2197403Sobrien 2297403Sobrien// As a special exception, you may use this file as part of a free software 2397403Sobrien// library without restriction. Specifically, if other files instantiate 2497403Sobrien// templates or use macros or inline functions from this file, or you compile 2597403Sobrien// this file and link it with other files to produce an executable, this 2697403Sobrien// file does not by itself cause the resulting executable to be covered by 2797403Sobrien// the GNU General Public License. This exception does not however 2897403Sobrien// invalidate any other reasons why the executable file might be covered by 2997403Sobrien// the GNU General Public License. 3097403Sobrien 3197403Sobrien#include "typeinfo" 3297403Sobrien#include "exception" 3397403Sobrien#include <cstdlib> 3497403Sobrien#include "unwind-cxx.h" 3597403Sobrien#include "exception_defines.h" 3697403Sobrien 3797403Sobrienusing namespace __cxxabiv1; 3897403Sobrien 3997403Sobrien/* The current installed user handlers. */ 4097403Sobrienstd::terminate_handler __cxxabiv1::__terminate_handler = std::abort; 4197403Sobrienstd::unexpected_handler __cxxabiv1::__unexpected_handler = std::terminate; 4297403Sobrien 4397403Sobrienvoid 4497403Sobrien__cxxabiv1::__terminate (std::terminate_handler handler) 4597403Sobrien{ 4697403Sobrien try { 4797403Sobrien handler (); 4897403Sobrien std::abort (); 4997403Sobrien } catch (...) { 5097403Sobrien std::abort (); 5197403Sobrien } 5297403Sobrien} 5397403Sobrien 5497403Sobrienvoid 5597403Sobrienstd::terminate () 5697403Sobrien{ 5797403Sobrien __terminate (__terminate_handler); 5897403Sobrien} 5997403Sobrien 6097403Sobrienvoid 6197403Sobrien__cxxabiv1::__unexpected (std::unexpected_handler handler) 6297403Sobrien{ 6397403Sobrien handler(); 6497403Sobrien std::terminate (); 6597403Sobrien} 6697403Sobrien 6797403Sobrienvoid 6897403Sobrienstd::unexpected () 6997403Sobrien{ 7097403Sobrien __unexpected (__unexpected_handler); 7197403Sobrien} 7297403Sobrien 7397403Sobrienstd::terminate_handler 7497403Sobrienstd::set_terminate (std::terminate_handler func) throw() 7597403Sobrien{ 7697403Sobrien std::terminate_handler old = __terminate_handler; 7797403Sobrien __terminate_handler = func; 7897403Sobrien return old; 7997403Sobrien} 8097403Sobrien 8197403Sobrienstd::unexpected_handler 8297403Sobrienstd::set_unexpected (std::unexpected_handler func) throw() 8397403Sobrien{ 8497403Sobrien std::unexpected_handler old = __unexpected_handler; 8597403Sobrien __unexpected_handler = func; 8697403Sobrien return old; 8797403Sobrien} 88