]>
Commit | Line | Data |
---|---|---|
7c3e9502 BK |
1 | // ABI Support -*- C++ -*- |
2 | ||
5624e564 | 3 | // Copyright (C) 2000-2015 Free Software Foundation, Inc. |
e2c09482 | 4 | // |
cbecceb9 | 5 | // This file is part of GCC. |
6305f20a | 6 | // |
cbecceb9 | 7 | // GCC is free software; you can redistribute it and/or modify |
6305f20a | 8 | // it under the terms of the GNU General Public License as published by |
748086b7 | 9 | // the Free Software Foundation; either version 3, or (at your option) |
6305f20a | 10 | // any later version. |
7c3e9502 | 11 | // |
cbecceb9 | 12 | // GCC is distributed in the hope that it will be useful, |
6305f20a BK |
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | // GNU General Public License for more details. | |
7c3e9502 | 16 | // |
748086b7 JJ |
17 | // Under Section 7 of GPL version 3, you are granted additional |
18 | // permissions described in the GCC Runtime Library Exception, version | |
19 | // 3.1, as published by the Free Software Foundation. | |
6305f20a | 20 | |
748086b7 JJ |
21 | // You should have received a copy of the GNU General Public License and |
22 | // a copy of the GCC Runtime Library Exception along with this program; | |
23 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
24 | // <http://www.gnu.org/licenses/>. | |
6305f20a | 25 | |
e2c09482 | 26 | // Written by Nathan Sidwell, Codesourcery LLC, <nathan@codesourcery.com> |
7c3e9502 | 27 | |
6305f20a BK |
28 | /* This file declares the new abi entry points into the runtime. It is not |
29 | normally necessary for user programs to include this header, or use the | |
30 | entry points directly. However, this header is available should that be | |
31 | needed. | |
7c3e9502 | 32 | |
6305f20a BK |
33 | Some of the entry points are intended for both C and C++, thus this header |
34 | is includable from both C and C++. Though the C++ specific parts are not | |
35 | available in C, naturally enough. */ | |
36 | ||
0aa06b18 BK |
37 | /** @file cxxabi.h |
38 | * The header provides an interface to the C++ ABI. | |
39 | */ | |
40 | ||
3d7c150e BK |
41 | #ifndef _CXXABI_H |
42 | #define _CXXABI_H 1 | |
6305f20a | 43 | |
584fd146 PC |
44 | #pragma GCC system_header |
45 | ||
723acbd5 MM |
46 | #pragma GCC visibility push(default) |
47 | ||
fba10f59 | 48 | #include <stddef.h> |
7c3e9502 | 49 | #include <bits/c++config.h> |
fba10f59 | 50 | #include <bits/cxxabi_tweaks.h> |
7c3e9502 | 51 | #include <bits/cxxabi_forced.h> |
357480ce | 52 | |
2ecb85c8 KT |
53 | #ifndef _GLIBCXX_CDTOR_CALLABI |
54 | #define _GLIBCXX_CDTOR_CALLABI | |
55 | #endif | |
56 | ||
6305f20a | 57 | #ifdef __cplusplus |
fba10f59 | 58 | namespace __cxxabiv1 |
7c3e9502 BK |
59 | { |
60 | extern "C" | |
fba10f59 JM |
61 | { |
62 | #endif | |
63 | ||
64 | typedef __cxa_cdtor_return_type (*__cxa_cdtor_type)(void *); | |
65 | ||
66 | // Allocate array. | |
7c3e9502 BK |
67 | void* |
68 | __cxa_vec_new(size_t __element_count, size_t __element_size, | |
61356c15 PC |
69 | size_t __padding_size, __cxa_cdtor_type __constructor, |
70 | __cxa_cdtor_type __destructor); | |
fba10f59 JM |
71 | |
72 | void* | |
73 | __cxa_vec_new2(size_t __element_count, size_t __element_size, | |
61356c15 | 74 | size_t __padding_size, __cxa_cdtor_type __constructor, |
7c3e9502 | 75 | __cxa_cdtor_type __destructor, void *(*__alloc) (size_t), |
fba10f59 JM |
76 | void (*__dealloc) (void*)); |
77 | ||
78 | void* | |
79 | __cxa_vec_new3(size_t __element_count, size_t __element_size, | |
61356c15 | 80 | size_t __padding_size, __cxa_cdtor_type __constructor, |
7c3e9502 | 81 | __cxa_cdtor_type __destructor, void *(*__alloc) (size_t), |
fba10f59 JM |
82 | void (*__dealloc) (void*, size_t)); |
83 | ||
84 | // Construct array. | |
85 | __cxa_vec_ctor_return_type | |
86 | __cxa_vec_ctor(void* __array_address, size_t __element_count, | |
61356c15 PC |
87 | size_t __element_size, __cxa_cdtor_type __constructor, |
88 | __cxa_cdtor_type __destructor); | |
fba10f59 JM |
89 | |
90 | __cxa_vec_ctor_return_type | |
61356c15 | 91 | __cxa_vec_cctor(void* __dest_array, void* __src_array, |
7c3e9502 BK |
92 | size_t __element_count, size_t __element_size, |
93 | __cxa_cdtor_return_type (*__constructor) (void*, void*), | |
61356c15 | 94 | __cxa_cdtor_type __destructor); |
7c3e9502 | 95 | |
fba10f59 | 96 | // Destruct array. |
7c3e9502 | 97 | void |
fba10f59 | 98 | __cxa_vec_dtor(void* __array_address, size_t __element_count, |
61356c15 | 99 | size_t __element_size, __cxa_cdtor_type __destructor); |
7c3e9502 BK |
100 | |
101 | void | |
61356c15 PC |
102 | __cxa_vec_cleanup(void* __array_address, size_t __element_count, size_t __s, |
103 | __cxa_cdtor_type __destructor) _GLIBCXX_NOTHROW; | |
7c3e9502 | 104 | |
fba10f59 | 105 | // Destruct and release array. |
7c3e9502 | 106 | void |
fba10f59 | 107 | __cxa_vec_delete(void* __array_address, size_t __element_size, |
61356c15 | 108 | size_t __padding_size, __cxa_cdtor_type __destructor); |
fba10f59 | 109 | |
7c3e9502 | 110 | void |
fba10f59 | 111 | __cxa_vec_delete2(void* __array_address, size_t __element_size, |
61356c15 | 112 | size_t __padding_size, __cxa_cdtor_type __destructor, |
fba10f59 | 113 | void (*__dealloc) (void*)); |
7c3e9502 BK |
114 | |
115 | void | |
fba10f59 | 116 | __cxa_vec_delete3(void* __array_address, size_t __element_size, |
61356c15 | 117 | size_t __padding_size, __cxa_cdtor_type __destructor, |
fba10f59 JM |
118 | void (*__dealloc) (void*, size_t)); |
119 | ||
7c3e9502 | 120 | int |
fba10f59 JM |
121 | __cxa_guard_acquire(__guard*); |
122 | ||
7c3e9502 | 123 | void |
5cf217ff | 124 | __cxa_guard_release(__guard*) _GLIBCXX_NOTHROW; |
fba10f59 | 125 | |
7c3e9502 | 126 | void |
5cf217ff | 127 | __cxa_guard_abort(__guard*) _GLIBCXX_NOTHROW; |
fba10f59 | 128 | |
50da34bb BK |
129 | // DSO destruction. |
130 | int | |
131 | __cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW; | |
132 | ||
133 | int | |
134 | __cxa_finalize(void*); | |
135 | ||
5b031b9b JM |
136 | // TLS destruction. |
137 | int | |
138 | __cxa_thread_atexit(void (*)(void*), void*, void *) _GLIBCXX_NOTHROW; | |
139 | ||
fba10f59 JM |
140 | // Pure virtual functions. |
141 | void | |
5cf217ff | 142 | __cxa_pure_virtual(void) __attribute__ ((__noreturn__)); |
fba10f59 | 143 | |
fba10f59 | 144 | void |
50da34bb | 145 | __cxa_deleted_virtual(void) __attribute__ ((__noreturn__)); |
fba10f59 | 146 | |
64e1ab11 | 147 | // Exception handling auxiliary. |
50da34bb BK |
148 | void |
149 | __cxa_bad_cast() __attribute__((__noreturn__)); | |
fba10f59 | 150 | |
50da34bb BK |
151 | void |
152 | __cxa_bad_typeid() __attribute__((__noreturn__)); | |
fba10f59 | 153 | |
7d5e76c8 JM |
154 | void |
155 | __cxa_throw_bad_array_new_length() __attribute__((__noreturn__)); | |
156 | ||
5b9daa7e | 157 | /** |
7c3e9502 | 158 | * @brief Demangling routine. |
5b9daa7e BK |
159 | * ABI-mandated entry point in the C++ runtime library for demangling. |
160 | * | |
161 | * @param __mangled_name A NUL-terminated character string | |
162 | * containing the name to be demangled. | |
163 | * | |
164 | * @param __output_buffer A region of memory, allocated with | |
165 | * malloc, of @a *__length bytes, into which the demangled name is | |
166 | * stored. If @a __output_buffer is not long enough, it is | |
167 | * expanded using realloc. @a __output_buffer may instead be NULL; | |
168 | * in that case, the demangled name is placed in a region of memory | |
169 | * allocated with malloc. | |
170 | * | |
171 | * @param __length If @a __length is non-NULL, the length of the | |
172 | * buffer containing the demangled name is placed in @a *__length. | |
173 | * | |
174 | * @param __status @a *__status is set to one of the following values: | |
175 | * 0: The demangling operation succeeded. | |
ceaaa5ce | 176 | * -1: A memory allocation failure occurred. |
5b9daa7e BK |
177 | * -2: @a mangled_name is not a valid name under the C++ ABI mangling rules. |
178 | * -3: One of the arguments is invalid. | |
179 | * | |
180 | * @return A pointer to the start of the NUL-terminated demangled | |
181 | * name, or NULL if the demangling fails. The caller is | |
182 | * responsible for deallocating this memory using @c free. | |
183 | * | |
184 | * The demangling is performed using the C++ ABI mangling rules, | |
185 | * with GNU extensions. For example, this function is used in | |
186 | * __gnu_cxx::__verbose_terminate_handler. | |
7c3e9502 | 187 | * |
5b9daa7e BK |
188 | * See http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt12ch39.html |
189 | * for other examples of use. | |
190 | * | |
191 | * @note The same demangling functionality is available via | |
192 | * libiberty (@c <libiberty/demangle.h> and @c libiberty.a) in GCC | |
193 | * 3.1 and later, but that requires explicit installation (@c | |
194 | * --enable-install-libiberty) and uses a different API, although | |
195 | * the ABI is unchanged. | |
196 | */ | |
fba10f59 JM |
197 | char* |
198 | __cxa_demangle(const char* __mangled_name, char* __output_buffer, | |
199 | size_t* __length, int* __status); | |
50da34bb | 200 | |
fba10f59 JM |
201 | #ifdef __cplusplus |
202 | } | |
203 | } // namespace __cxxabiv1 | |
204 | #endif | |
205 | ||
206 | #ifdef __cplusplus | |
207 | ||
208 | #include <typeinfo> | |
209 | ||
210 | namespace __cxxabiv1 | |
211 | { | |
212 | // Type information for int, float etc. | |
213 | class __fundamental_type_info : public std::type_info | |
214 | { | |
215 | public: | |
7c3e9502 | 216 | explicit |
fba10f59 JM |
217 | __fundamental_type_info(const char* __n) : std::type_info(__n) { } |
218 | ||
7c3e9502 | 219 | virtual |
fba10f59 JM |
220 | ~__fundamental_type_info(); |
221 | }; | |
222 | ||
223 | // Type information for array objects. | |
224 | class __array_type_info : public std::type_info | |
225 | { | |
226 | public: | |
7c3e9502 | 227 | explicit |
fba10f59 JM |
228 | __array_type_info(const char* __n) : std::type_info(__n) { } |
229 | ||
7c3e9502 | 230 | virtual |
fba10f59 JM |
231 | ~__array_type_info(); |
232 | }; | |
233 | ||
234 | // Type information for functions (both member and non-member). | |
235 | class __function_type_info : public std::type_info | |
236 | { | |
237 | public: | |
7c3e9502 | 238 | explicit |
fba10f59 JM |
239 | __function_type_info(const char* __n) : std::type_info(__n) { } |
240 | ||
7c3e9502 | 241 | virtual |
fba10f59 JM |
242 | ~__function_type_info(); |
243 | ||
244 | protected: | |
245 | // Implementation defined member function. | |
7c3e9502 | 246 | virtual bool |
fba10f59 JM |
247 | __is_function_p() const; |
248 | }; | |
249 | ||
250 | // Type information for enumerations. | |
251 | class __enum_type_info : public std::type_info | |
252 | { | |
253 | public: | |
7c3e9502 | 254 | explicit |
fba10f59 JM |
255 | __enum_type_info(const char* __n) : std::type_info(__n) { } |
256 | ||
7c3e9502 | 257 | virtual |
fba10f59 JM |
258 | ~__enum_type_info(); |
259 | }; | |
260 | ||
261 | // Common type information for simple pointers and pointers to member. | |
262 | class __pbase_type_info : public std::type_info | |
263 | { | |
264 | public: | |
265 | unsigned int __flags; // Qualification of the target object. | |
266 | const std::type_info* __pointee; // Type of pointed to object. | |
267 | ||
7c3e9502 BK |
268 | explicit |
269 | __pbase_type_info(const char* __n, int __quals, | |
fba10f59 JM |
270 | const std::type_info* __type) |
271 | : std::type_info(__n), __flags(__quals), __pointee(__type) | |
272 | { } | |
7c3e9502 BK |
273 | |
274 | virtual | |
fba10f59 JM |
275 | ~__pbase_type_info(); |
276 | ||
277 | // Implementation defined type. | |
7c3e9502 | 278 | enum __masks |
fba10f59 JM |
279 | { |
280 | __const_mask = 0x1, | |
281 | __volatile_mask = 0x2, | |
282 | __restrict_mask = 0x4, | |
283 | __incomplete_mask = 0x8, | |
b8fd7909 JM |
284 | __incomplete_class_mask = 0x10, |
285 | __transaction_safe_mask = 0x20 | |
fba10f59 JM |
286 | }; |
287 | ||
288 | protected: | |
289 | __pbase_type_info(const __pbase_type_info&); | |
290 | ||
291 | __pbase_type_info& | |
292 | operator=(const __pbase_type_info&); | |
293 | ||
294 | // Implementation defined member functions. | |
7c3e9502 BK |
295 | virtual bool |
296 | __do_catch(const std::type_info* __thr_type, void** __thr_obj, | |
fba10f59 JM |
297 | unsigned int __outer) const; |
298 | ||
a6ea72bf | 299 | inline virtual bool |
fba10f59 | 300 | __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj, |
a6ea72bf | 301 | unsigned __outer) const; |
fba10f59 JM |
302 | }; |
303 | ||
a6ea72bf JM |
304 | inline bool __pbase_type_info:: |
305 | __pointer_catch (const __pbase_type_info *thrown_type, | |
306 | void **thr_obj, | |
307 | unsigned outer) const | |
308 | { | |
309 | return __pointee->__do_catch (thrown_type->__pointee, thr_obj, outer + 2); | |
310 | } | |
311 | ||
fba10f59 JM |
312 | // Type information for simple pointers. |
313 | class __pointer_type_info : public __pbase_type_info | |
314 | { | |
315 | public: | |
7c3e9502 BK |
316 | explicit |
317 | __pointer_type_info(const char* __n, int __quals, | |
fba10f59 JM |
318 | const std::type_info* __type) |
319 | : __pbase_type_info (__n, __quals, __type) { } | |
320 | ||
321 | ||
7c3e9502 | 322 | virtual |
fba10f59 JM |
323 | ~__pointer_type_info(); |
324 | ||
325 | protected: | |
326 | // Implementation defined member functions. | |
7c3e9502 | 327 | virtual bool |
fba10f59 JM |
328 | __is_pointer_p() const; |
329 | ||
7c3e9502 BK |
330 | virtual bool |
331 | __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj, | |
fba10f59 JM |
332 | unsigned __outer) const; |
333 | }; | |
334 | ||
335 | class __class_type_info; | |
336 | ||
337 | // Type information for a pointer to member variable. | |
338 | class __pointer_to_member_type_info : public __pbase_type_info | |
339 | { | |
340 | public: | |
341 | __class_type_info* __context; // Class of the member. | |
342 | ||
7c3e9502 | 343 | explicit |
fba10f59 | 344 | __pointer_to_member_type_info(const char* __n, int __quals, |
7c3e9502 | 345 | const std::type_info* __type, |
fba10f59 JM |
346 | __class_type_info* __klass) |
347 | : __pbase_type_info(__n, __quals, __type), __context(__klass) { } | |
348 | ||
7c3e9502 | 349 | virtual |
fba10f59 JM |
350 | ~__pointer_to_member_type_info(); |
351 | ||
352 | protected: | |
353 | __pointer_to_member_type_info(const __pointer_to_member_type_info&); | |
354 | ||
355 | __pointer_to_member_type_info& | |
356 | operator=(const __pointer_to_member_type_info&); | |
357 | ||
358 | // Implementation defined member function. | |
7c3e9502 | 359 | virtual bool |
fba10f59 JM |
360 | __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj, |
361 | unsigned __outer) const; | |
362 | }; | |
363 | ||
364 | // Helper class for __vmi_class_type. | |
365 | class __base_class_type_info | |
366 | { | |
367 | public: | |
368 | const __class_type_info* __base_type; // Base class type. | |
3cc6dd4d KT |
369 | #ifdef _GLIBCXX_LLP64 |
370 | long long __offset_flags; // Offset and info. | |
371 | #else | |
fba10f59 | 372 | long __offset_flags; // Offset and info. |
3cc6dd4d | 373 | #endif |
fba10f59 | 374 | |
7c3e9502 | 375 | enum __offset_flags_masks |
fba10f59 JM |
376 | { |
377 | __virtual_mask = 0x1, | |
378 | __public_mask = 0x2, | |
379 | __hwm_bit = 2, | |
380 | __offset_shift = 8 // Bits to shift offset. | |
381 | }; | |
7c3e9502 | 382 | |
fba10f59 | 383 | // Implementation defined member functions. |
7c3e9502 | 384 | bool |
fba10f59 JM |
385 | __is_virtual_p() const |
386 | { return __offset_flags & __virtual_mask; } | |
387 | ||
7c3e9502 | 388 | bool |
fba10f59 JM |
389 | __is_public_p() const |
390 | { return __offset_flags & __public_mask; } | |
391 | ||
7c3e9502 | 392 | ptrdiff_t |
fba10f59 | 393 | __offset() const |
7c3e9502 | 394 | { |
fba10f59 JM |
395 | // This shift, being of a signed type, is implementation |
396 | // defined. GCC implements such shifts as arithmetic, which is | |
397 | // what we want. | |
398 | return static_cast<ptrdiff_t>(__offset_flags) >> __offset_shift; | |
399 | } | |
400 | }; | |
401 | ||
402 | // Type information for a class. | |
403 | class __class_type_info : public std::type_info | |
404 | { | |
405 | public: | |
7c3e9502 | 406 | explicit |
fba10f59 JM |
407 | __class_type_info (const char *__n) : type_info(__n) { } |
408 | ||
7c3e9502 | 409 | virtual |
fba10f59 JM |
410 | ~__class_type_info (); |
411 | ||
412 | // Implementation defined types. | |
413 | // The type sub_kind tells us about how a base object is contained | |
414 | // within a derived object. We often do this lazily, hence the | |
415 | // UNKNOWN value. At other times we may use NOT_CONTAINED to mean | |
416 | // not publicly contained. | |
417 | enum __sub_kind | |
418 | { | |
419 | // We have no idea. | |
7c3e9502 | 420 | __unknown = 0, |
fba10f59 JM |
421 | |
422 | // Not contained within us (in some circumstances this might | |
423 | // mean not contained publicly) | |
7c3e9502 | 424 | __not_contained, |
fba10f59 JM |
425 | |
426 | // Contained ambiguously. | |
7c3e9502 BK |
427 | __contained_ambig, |
428 | ||
fba10f59 | 429 | // Via a virtual path. |
7c3e9502 | 430 | __contained_virtual_mask = __base_class_type_info::__virtual_mask, |
fba10f59 JM |
431 | |
432 | // Via a public path. | |
7c3e9502 | 433 | __contained_public_mask = __base_class_type_info::__public_mask, |
fba10f59 JM |
434 | |
435 | // Contained within us. | |
436 | __contained_mask = 1 << __base_class_type_info::__hwm_bit, | |
7c3e9502 | 437 | |
fba10f59 JM |
438 | __contained_private = __contained_mask, |
439 | __contained_public = __contained_mask | __contained_public_mask | |
440 | }; | |
441 | ||
442 | struct __upcast_result; | |
443 | struct __dyncast_result; | |
444 | ||
445 | protected: | |
446 | // Implementation defined member functions. | |
7c3e9502 | 447 | virtual bool |
fba10f59 JM |
448 | __do_upcast(const __class_type_info* __dst_type, void**__obj_ptr) const; |
449 | ||
7c3e9502 BK |
450 | virtual bool |
451 | __do_catch(const type_info* __thr_type, void** __thr_obj, | |
fba10f59 JM |
452 | unsigned __outer) const; |
453 | ||
454 | public: | |
7c3e9502 BK |
455 | // Helper for upcast. See if DST is us, or one of our bases. |
456 | // Return false if not found, true if found. | |
457 | virtual bool | |
fba10f59 JM |
458 | __do_upcast(const __class_type_info* __dst, const void* __obj, |
459 | __upcast_result& __restrict __result) const; | |
460 | ||
461 | // Indicate whether SRC_PTR of type SRC_TYPE is contained publicly | |
462 | // within OBJ_PTR. OBJ_PTR points to a base object of our type, | |
463 | // which is the destination type. SRC2DST indicates how SRC | |
464 | // objects might be contained within this type. If SRC_PTR is one | |
465 | // of our SRC_TYPE bases, indicate the virtuality. Returns | |
466 | // not_contained for non containment or private containment. | |
7c3e9502 | 467 | inline __sub_kind |
fba10f59 | 468 | __find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr, |
7c3e9502 | 469 | const __class_type_info* __src_type, |
fba10f59 JM |
470 | const void* __src_ptr) const; |
471 | ||
472 | // Helper for dynamic cast. ACCESS_PATH gives the access from the | |
473 | // most derived object to this base. DST_TYPE indicates the | |
474 | // desired type we want. OBJ_PTR points to a base of our type | |
475 | // within the complete object. SRC_TYPE indicates the static type | |
476 | // started from and SRC_PTR points to that base within the most | |
477 | // derived object. Fill in RESULT with what we find. Return true | |
478 | // if we have located an ambiguous match. | |
7c3e9502 | 479 | virtual bool |
fba10f59 | 480 | __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path, |
7c3e9502 BK |
481 | const __class_type_info* __dst_type, const void* __obj_ptr, |
482 | const __class_type_info* __src_type, const void* __src_ptr, | |
fba10f59 | 483 | __dyncast_result& __result) const; |
7c3e9502 | 484 | |
fba10f59 JM |
485 | // Helper for find_public_subobj. SRC2DST indicates how SRC_TYPE |
486 | // bases are inherited by the type started from -- which is not | |
487 | // necessarily the current type. The current type will be a base | |
488 | // of the destination type. OBJ_PTR points to the current base. | |
7c3e9502 | 489 | virtual __sub_kind |
fba10f59 JM |
490 | __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr, |
491 | const __class_type_info* __src_type, | |
492 | const void* __src_ptr) const; | |
493 | }; | |
494 | ||
495 | // Type information for a class with a single non-virtual base. | |
496 | class __si_class_type_info : public __class_type_info | |
497 | { | |
498 | public: | |
499 | const __class_type_info* __base_type; | |
500 | ||
7c3e9502 | 501 | explicit |
fba10f59 JM |
502 | __si_class_type_info(const char *__n, const __class_type_info *__base) |
503 | : __class_type_info(__n), __base_type(__base) { } | |
504 | ||
7c3e9502 | 505 | virtual |
fba10f59 JM |
506 | ~__si_class_type_info(); |
507 | ||
508 | protected: | |
509 | __si_class_type_info(const __si_class_type_info&); | |
510 | ||
511 | __si_class_type_info& | |
512 | operator=(const __si_class_type_info&); | |
513 | ||
514 | // Implementation defined member functions. | |
7c3e9502 | 515 | virtual bool |
fba10f59 JM |
516 | __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path, |
517 | const __class_type_info* __dst_type, const void* __obj_ptr, | |
518 | const __class_type_info* __src_type, const void* __src_ptr, | |
519 | __dyncast_result& __result) const; | |
520 | ||
7c3e9502 | 521 | virtual __sub_kind |
fba10f59 JM |
522 | __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr, |
523 | const __class_type_info* __src_type, | |
524 | const void* __sub_ptr) const; | |
525 | ||
7c3e9502 | 526 | virtual bool |
fba10f59 JM |
527 | __do_upcast(const __class_type_info*__dst, const void*__obj, |
528 | __upcast_result& __restrict __result) const; | |
529 | }; | |
530 | ||
531 | // Type information for a class with multiple and/or virtual bases. | |
7c3e9502 | 532 | class __vmi_class_type_info : public __class_type_info |
fba10f59 JM |
533 | { |
534 | public: | |
535 | unsigned int __flags; // Details about the class hierarchy. | |
536 | unsigned int __base_count; // Number of direct bases. | |
537 | ||
538 | // The array of bases uses the trailing array struct hack so this | |
539 | // class is not constructable with a normal constructor. It is | |
540 | // internally generated by the compiler. | |
541 | __base_class_type_info __base_info[1]; // Array of bases. | |
542 | ||
7c3e9502 | 543 | explicit |
fba10f59 JM |
544 | __vmi_class_type_info(const char* __n, int ___flags) |
545 | : __class_type_info(__n), __flags(___flags), __base_count(0) { } | |
546 | ||
7c3e9502 | 547 | virtual |
fba10f59 JM |
548 | ~__vmi_class_type_info(); |
549 | ||
550 | // Implementation defined types. | |
7c3e9502 | 551 | enum __flags_masks |
fba10f59 JM |
552 | { |
553 | __non_diamond_repeat_mask = 0x1, // Distinct instance of repeated base. | |
554 | __diamond_shaped_mask = 0x2, // Diamond shaped multiple inheritance. | |
555 | __flags_unknown_mask = 0x10 | |
556 | }; | |
557 | ||
558 | protected: | |
559 | // Implementation defined member functions. | |
7c3e9502 | 560 | virtual bool |
fba10f59 JM |
561 | __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path, |
562 | const __class_type_info* __dst_type, const void* __obj_ptr, | |
563 | const __class_type_info* __src_type, const void* __src_ptr, | |
564 | __dyncast_result& __result) const; | |
565 | ||
7c3e9502 BK |
566 | virtual __sub_kind |
567 | __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr, | |
fba10f59 JM |
568 | const __class_type_info* __src_type, |
569 | const void* __src_ptr) const; | |
7c3e9502 BK |
570 | |
571 | virtual bool | |
fba10f59 JM |
572 | __do_upcast(const __class_type_info* __dst, const void* __obj, |
573 | __upcast_result& __restrict __result) const; | |
574 | }; | |
575 | ||
50da34bb BK |
576 | // Exception handling forward declarations. |
577 | struct __cxa_exception; | |
578 | struct __cxa_refcounted_exception; | |
579 | struct __cxa_dependent_exception; | |
580 | struct __cxa_eh_globals; | |
581 | ||
582 | extern "C" | |
583 | { | |
fba10f59 | 584 | // Dynamic cast runtime. |
50da34bb | 585 | |
fba10f59 JM |
586 | // src2dst has the following possible values |
587 | // >-1: src_type is a unique public non-virtual base of dst_type | |
588 | // dst_ptr + src2dst == src_ptr | |
589 | // -1: unspecified relationship | |
590 | // -2: src_type is not a public base of dst_type | |
591 | // -3: src_type is a multiple public non-virtual base of dst_type | |
50da34bb | 592 | void* |
fba10f59 JM |
593 | __dynamic_cast(const void* __src_ptr, // Starting object. |
594 | const __class_type_info* __src_type, // Static type of object. | |
595 | const __class_type_info* __dst_type, // Desired target type. | |
596 | ptrdiff_t __src2dst); // How src and dst are related. | |
597 | ||
598 | ||
50da34bb BK |
599 | // Exception handling runtime. |
600 | ||
601 | // The __cxa_eh_globals for the current thread can be obtained by using | |
602 | // either of the following functions. The "fast" version assumes at least | |
603 | // one prior call of __cxa_get_globals has been made from the current | |
604 | // thread, so no initialization is necessary. | |
605 | __cxa_eh_globals* | |
606 | __cxa_get_globals() _GLIBCXX_NOTHROW __attribute__ ((__const__)); | |
607 | ||
608 | __cxa_eh_globals* | |
609 | __cxa_get_globals_fast() _GLIBCXX_NOTHROW __attribute__ ((__const__)); | |
610 | ||
611 | // Allocate memory for the primary exception plus the thrown object. | |
612 | void* | |
613 | __cxa_allocate_exception(size_t) _GLIBCXX_NOTHROW; | |
614 | ||
615 | // Free the space allocated for the primary exception. | |
616 | void | |
617 | __cxa_free_exception(void*) _GLIBCXX_NOTHROW; | |
618 | ||
619 | // Throw the exception. | |
620 | void | |
2ecb85c8 | 621 | __cxa_throw(void*, std::type_info*, void (_GLIBCXX_CDTOR_CALLABI *) (void *)) |
50da34bb BK |
622 | __attribute__((__noreturn__)); |
623 | ||
624 | // Used to implement exception handlers. | |
625 | void* | |
626 | __cxa_get_exception_ptr(void*) _GLIBCXX_NOTHROW __attribute__ ((__pure__)); | |
627 | ||
628 | void* | |
629 | __cxa_begin_catch(void*) _GLIBCXX_NOTHROW; | |
630 | ||
631 | void | |
632 | __cxa_end_catch(); | |
633 | ||
634 | void | |
635 | __cxa_rethrow() __attribute__((__noreturn__)); | |
636 | ||
fba10f59 JM |
637 | // Returns the type_info for the currently handled exception [15.3/8], or |
638 | // null if there is none. | |
50da34bb | 639 | std::type_info* |
5cf217ff | 640 | __cxa_current_exception_type() _GLIBCXX_NOTHROW __attribute__ ((__pure__)); |
fba10f59 | 641 | |
50da34bb BK |
642 | // GNU Extensions. |
643 | ||
644 | // Allocate memory for a dependent exception. | |
645 | __cxa_dependent_exception* | |
646 | __cxa_allocate_dependent_exception() _GLIBCXX_NOTHROW; | |
647 | ||
648 | // Free the space allocated for the dependent exception. | |
649 | void | |
650 | __cxa_free_dependent_exception(__cxa_dependent_exception*) _GLIBCXX_NOTHROW; | |
651 | ||
652 | } // extern "C" | |
653 | ||
fba10f59 JM |
654 | // A magic placeholder class that can be caught by reference |
655 | // to recognize foreign exceptions. | |
656 | class __foreign_exception | |
657 | { | |
50da34bb | 658 | virtual ~__foreign_exception() throw(); |
fba10f59 JM |
659 | virtual void __pure_dummy() = 0; // prevent catch by value |
660 | }; | |
661 | ||
662 | } // namespace __cxxabiv1 | |
52ceb039 | 663 | |
5b9daa7e BK |
664 | /** @namespace abi |
665 | * @brief The cross-vendor C++ Application Binary Interface. A | |
666 | * namespace alias to __cxxabiv1, but user programs should use the | |
8e32aa11 | 667 | * alias 'abi'. |
5b9daa7e BK |
668 | * |
669 | * A brief overview of an ABI is given in the libstdc++ FAQ, question | |
670 | * 5.8 (you may have a copy of the FAQ locally, or you can view the online | |
f172dd9a | 671 | * version at http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#5_8 ). |
5b9daa7e BK |
672 | * |
673 | * GCC subscribes to a cross-vendor ABI for C++, sometimes | |
674 | * called the IA64 ABI because it happens to be the native ABI for that | |
675 | * platform. It is summarized at http://www.codesourcery.com/cxx-abi/ | |
676 | * along with the current specification. | |
677 | * | |
678 | * For users of GCC greater than or equal to 3.x, entry points are | |
8e32aa11 | 679 | * available in <cxxabi.h>, which notes, <em>'It is not normally |
5b9daa7e BK |
680 | * necessary for user programs to include this header, or use the |
681 | * entry points directly. However, this header is available should | |
8e32aa11 | 682 | * that be needed.'</em> |
5b9daa7e | 683 | */ |
6305f20a BK |
684 | namespace abi = __cxxabiv1; |
685 | ||
8eead16e BK |
686 | namespace __gnu_cxx |
687 | { | |
688 | /** | |
689 | * @brief Exception thrown by __cxa_guard_acquire. | |
690 | * @ingroup exceptions | |
691 | * | |
692 | * 6.7[stmt.dcl]/4: If control re-enters the declaration (recursively) | |
693 | * while the object is being initialized, the behavior is undefined. | |
694 | * | |
695 | * Since we already have a library function to handle locking, we might | |
696 | * as well check for this situation and throw an exception. | |
697 | * We use the second byte of the guard variable to remember that we're | |
698 | * in the middle of an initialization. | |
699 | */ | |
700 | class recursive_init_error: public std::exception | |
701 | { | |
702 | public: | |
703 | recursive_init_error() throw() { } | |
704 | virtual ~recursive_init_error() throw (); | |
705 | }; | |
706 | } | |
52ceb039 | 707 | #endif // __cplusplus |
6305f20a | 708 | |
723acbd5 MM |
709 | #pragma GCC visibility pop |
710 | ||
7c3e9502 | 711 | #endif // __CXXABI_H |