1*38fd1498Szrj // Copyright (C) 2001-2018 Free Software Foundation, Inc. 2*38fd1498Szrj // 3*38fd1498Szrj // This file is part of the GNU ISO C++ Library. This library is free 4*38fd1498Szrj // software; you can redistribute it and/or modify it under the 5*38fd1498Szrj // terms of the GNU General Public License as published by the 6*38fd1498Szrj // Free Software Foundation; either version 3, or (at your option) 7*38fd1498Szrj // any later version. 8*38fd1498Szrj 9*38fd1498Szrj // This library is distributed in the hope that it will be useful, 10*38fd1498Szrj // but WITHOUT ANY WARRANTY; without even the implied warranty of 11*38fd1498Szrj // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12*38fd1498Szrj // GNU General Public License for more details. 13*38fd1498Szrj 14*38fd1498Szrj // Under Section 7 of GPL version 3, you are granted additional 15*38fd1498Szrj // permissions described in the GCC Runtime Library Exception, version 16*38fd1498Szrj // 3.1, as published by the Free Software Foundation. 17*38fd1498Szrj 18*38fd1498Szrj // You should have received a copy of the GNU General Public License and 19*38fd1498Szrj // a copy of the GCC Runtime Library Exception along with this program; 20*38fd1498Szrj // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 21*38fd1498Szrj // <http://www.gnu.org/licenses/>. 22*38fd1498Szrj 23*38fd1498Szrj #include <bits/functexcept.h> 24*38fd1498Szrj #include <cstdlib> 25*38fd1498Szrj #include <exception> 26*38fd1498Szrj #include <stdexcept> 27*38fd1498Szrj #include <new> 28*38fd1498Szrj #include <typeinfo> 29*38fd1498Szrj #include <stdarg.h> 30*38fd1498Szrj 31*38fd1498Szrj #ifdef _GLIBCXX_USE_NLS 32*38fd1498Szrj # include <libintl.h> 33*38fd1498Szrj # define _(msgid) gettext (msgid) 34*38fd1498Szrj #else 35*38fd1498Szrj # define _(msgid) (msgid) 36*38fd1498Szrj #endif 37*38fd1498Szrj 38*38fd1498Szrj namespace __gnu_cxx 39*38fd1498Szrj { 40*38fd1498Szrj int __snprintf_lite(char *__buf, size_t __bufsize, const char *__fmt, 41*38fd1498Szrj va_list __ap); 42*38fd1498Szrj } 43*38fd1498Szrj 44*38fd1498Szrj namespace std _GLIBCXX_VISIBILITY(default) 45*38fd1498Szrj { 46*38fd1498Szrj _GLIBCXX_BEGIN_NAMESPACE_VERSION 47*38fd1498Szrj 48*38fd1498Szrj void __throw_bad_exception()49*38fd1498Szrj __throw_bad_exception() 50*38fd1498Szrj { _GLIBCXX_THROW_OR_ABORT(bad_exception()); } 51*38fd1498Szrj 52*38fd1498Szrj void __throw_bad_alloc()53*38fd1498Szrj __throw_bad_alloc() 54*38fd1498Szrj { _GLIBCXX_THROW_OR_ABORT(bad_alloc()); } 55*38fd1498Szrj 56*38fd1498Szrj void __throw_bad_cast()57*38fd1498Szrj __throw_bad_cast() 58*38fd1498Szrj { _GLIBCXX_THROW_OR_ABORT(bad_cast()); } 59*38fd1498Szrj 60*38fd1498Szrj void __throw_bad_typeid()61*38fd1498Szrj __throw_bad_typeid() 62*38fd1498Szrj { _GLIBCXX_THROW_OR_ABORT(bad_typeid()); } 63*38fd1498Szrj 64*38fd1498Szrj void __throw_logic_error(const char * __s)65*38fd1498Szrj __throw_logic_error(const char* __s __attribute__((unused))) 66*38fd1498Szrj { _GLIBCXX_THROW_OR_ABORT(logic_error(_(__s))); } 67*38fd1498Szrj 68*38fd1498Szrj void __throw_domain_error(const char * __s)69*38fd1498Szrj __throw_domain_error(const char* __s __attribute__((unused))) 70*38fd1498Szrj { _GLIBCXX_THROW_OR_ABORT(domain_error(_(__s))); } 71*38fd1498Szrj 72*38fd1498Szrj void __throw_invalid_argument(const char * __s)73*38fd1498Szrj __throw_invalid_argument(const char* __s __attribute__((unused))) 74*38fd1498Szrj { _GLIBCXX_THROW_OR_ABORT(invalid_argument(_(__s))); } 75*38fd1498Szrj 76*38fd1498Szrj void __throw_length_error(const char * __s)77*38fd1498Szrj __throw_length_error(const char* __s __attribute__((unused))) 78*38fd1498Szrj { _GLIBCXX_THROW_OR_ABORT(length_error(_(__s))); } 79*38fd1498Szrj 80*38fd1498Szrj void __throw_out_of_range(const char * __s)81*38fd1498Szrj __throw_out_of_range(const char* __s __attribute__((unused))) 82*38fd1498Szrj { _GLIBCXX_THROW_OR_ABORT(out_of_range(_(__s))); } 83*38fd1498Szrj 84*38fd1498Szrj void __throw_out_of_range_fmt(const char * __fmt,...)85*38fd1498Szrj __throw_out_of_range_fmt(const char* __fmt, ...) 86*38fd1498Szrj { 87*38fd1498Szrj const size_t __len = __builtin_strlen(__fmt); 88*38fd1498Szrj // We expect at most 2 numbers, and 1 short string. The additional 89*38fd1498Szrj // 512 bytes should provide more than enough space for expansion. 90*38fd1498Szrj const size_t __alloca_size = __len + 512; 91*38fd1498Szrj char *const __s = static_cast<char*>(__builtin_alloca(__alloca_size)); 92*38fd1498Szrj va_list __ap; 93*38fd1498Szrj 94*38fd1498Szrj va_start(__ap, __fmt); 95*38fd1498Szrj __gnu_cxx::__snprintf_lite(__s, __alloca_size, __fmt, __ap); 96*38fd1498Szrj _GLIBCXX_THROW_OR_ABORT(out_of_range(_(__s))); 97*38fd1498Szrj va_end(__ap); // Not reached. 98*38fd1498Szrj } 99*38fd1498Szrj 100*38fd1498Szrj void __throw_runtime_error(const char * __s)101*38fd1498Szrj __throw_runtime_error(const char* __s __attribute__((unused))) 102*38fd1498Szrj { _GLIBCXX_THROW_OR_ABORT(runtime_error(_(__s))); } 103*38fd1498Szrj 104*38fd1498Szrj void __throw_range_error(const char * __s)105*38fd1498Szrj __throw_range_error(const char* __s __attribute__((unused))) 106*38fd1498Szrj { _GLIBCXX_THROW_OR_ABORT(range_error(_(__s))); } 107*38fd1498Szrj 108*38fd1498Szrj void __throw_overflow_error(const char * __s)109*38fd1498Szrj __throw_overflow_error(const char* __s __attribute__((unused))) 110*38fd1498Szrj { _GLIBCXX_THROW_OR_ABORT(overflow_error(_(__s))); } 111*38fd1498Szrj 112*38fd1498Szrj void __throw_underflow_error(const char * __s)113*38fd1498Szrj __throw_underflow_error(const char* __s __attribute__((unused))) 114*38fd1498Szrj { _GLIBCXX_THROW_OR_ABORT(underflow_error(_(__s))); } 115*38fd1498Szrj 116*38fd1498Szrj _GLIBCXX_END_NAMESPACE_VERSION 117*38fd1498Szrj } // namespace 118