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