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