1 // new abi support -*- C++ -*-
3 // Copyright (C) 2000, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
5 // This file is part of GCC.
7 // GCC is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2, or (at your option)
12 // GCC is distributed in the hope that it will be useful,
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.
17 // You should have received a copy of the GNU General Public License
18 // along with GCC; see the file COPYING. If not, write to
19 // the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 // Boston, MA 02110-1301, USA.
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction. Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License. This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
31 // Written by Nathan Sidwell, Codesourcery LLC, <nathan@codesourcery.com>
33 /* This file declares the new abi entry points into the runtime. It is not
34 normally necessary for user programs to include this header, or use the
35 entry points directly. However, this header is available should that be
38 Some of the entry points are intended for both C and C++, thus this header
39 is includable from both C and C++. Though the C++ specific parts are not
40 available in C, naturally enough. */
43 * The header provides an interface to the C++ ABI.
49 #pragma GCC visibility push(default)
52 #include <bits/cxxabi_tweaks.h>
61 typedef __cxa_cdtor_return_type (*__cxa_cdtor_type
)(void *);
65 __cxa_vec_new(size_t __element_count
, size_t __element_size
,
66 size_t __padding_size
, __cxa_cdtor_type constructor
,
67 __cxa_cdtor_type destructor
);
70 __cxa_vec_new2(size_t __element_count
, size_t __element_size
,
71 size_t __padding_size
, __cxa_cdtor_type constructor
,
72 __cxa_cdtor_type destructor
, void *(*__alloc
) (size_t),
73 void (*__dealloc
) (void*));
76 __cxa_vec_new3(size_t __element_count
, size_t __element_size
,
77 size_t __padding_size
, __cxa_cdtor_type constructor
,
78 __cxa_cdtor_type destructor
, void *(*__alloc
) (size_t),
79 void (*__dealloc
) (void*, size_t));
82 __cxa_vec_ctor_return_type
83 __cxa_vec_ctor(void* __array_address
, size_t __element_count
,
84 size_t __element_size
, __cxa_cdtor_type constructor
,
85 __cxa_cdtor_type destructor
);
87 __cxa_vec_ctor_return_type
88 __cxa_vec_cctor(void* dest_array
, void* src_array
, size_t element_count
,
90 __cxa_cdtor_return_type (*constructor
) (void*, void*),
91 __cxa_cdtor_type destructor
);
95 __cxa_vec_dtor(void* __array_address
, size_t __element_count
,
96 size_t __element_size
, __cxa_cdtor_type destructor
);
99 __cxa_vec_cleanup(void* __array_address
, size_t __element_count
,
100 size_t __element_size
, __cxa_cdtor_type destructor
);
102 // Destruct and release array.
104 __cxa_vec_delete(void* __array_address
, size_t __element_size
,
105 size_t __padding_size
, __cxa_cdtor_type destructor
);
108 __cxa_vec_delete2(void* __array_address
, size_t __element_size
,
109 size_t __padding_size
, __cxa_cdtor_type destructor
,
110 void (*__dealloc
) (void*));
113 __cxa_vec_delete3(void* __array_address
, size_t __element_size
,
114 size_t __padding_size
, __cxa_cdtor_type destructor
,
115 void (*__dealloc
) (void*, size_t));
118 __cxa_guard_acquire(__guard
*);
121 __cxa_guard_release(__guard
*);
124 __cxa_guard_abort(__guard
*);
126 // Pure virtual functions.
128 __cxa_pure_virtual(void);
130 // Exception handling.
139 __cxa_atexit(void (*)(void*), void*, void*);
142 __cxa_finalize(void*);
144 // Demangling routines.
146 __cxa_demangle(const char* __mangled_name
, char* __output_buffer
,
147 size_t* __length
, int* __status
);
150 } // namespace __cxxabiv1
159 // Type information for int, float etc.
160 class __fundamental_type_info
: public std::type_info
164 __fundamental_type_info(const char* __n
) : std::type_info(__n
) { }
167 ~__fundamental_type_info();
170 // Type information for array objects.
171 class __array_type_info
: public std::type_info
175 __array_type_info(const char* __n
) : std::type_info(__n
) { }
178 ~__array_type_info();
181 // Type information for functions (both member and non-member).
182 class __function_type_info
: public std::type_info
186 __function_type_info(const char* __n
) : std::type_info(__n
) { }
189 ~__function_type_info();
192 // Implementation defined member function.
194 __is_function_p() const;
197 // Type information for enumerations.
198 class __enum_type_info
: public std::type_info
202 __enum_type_info(const char* __n
) : std::type_info(__n
) { }
208 // Common type information for simple pointers and pointers to member.
209 class __pbase_type_info
: public std::type_info
212 unsigned int __flags
; // Qualification of the target object.
213 const std::type_info
* __pointee
; // Type of pointed to object.
216 __pbase_type_info(const char* __n
, int __quals
,
217 const std::type_info
* __type
)
218 : std::type_info(__n
), __flags(__quals
), __pointee(__type
)
222 ~__pbase_type_info();
224 // Implementation defined type.
228 __volatile_mask
= 0x2,
229 __restrict_mask
= 0x4,
230 __incomplete_mask
= 0x8,
231 __incomplete_class_mask
= 0x10
235 __pbase_type_info(const __pbase_type_info
&);
238 operator=(const __pbase_type_info
&);
240 // Implementation defined member functions.
242 __do_catch(const std::type_info
* __thr_type
, void** __thr_obj
,
243 unsigned int __outer
) const;
246 __pointer_catch(const __pbase_type_info
* __thr_type
, void** __thr_obj
,
247 unsigned __outer
) const;
250 // Type information for simple pointers.
251 class __pointer_type_info
: public __pbase_type_info
255 __pointer_type_info(const char* __n
, int __quals
,
256 const std::type_info
* __type
)
257 : __pbase_type_info (__n
, __quals
, __type
) { }
261 ~__pointer_type_info();
264 // Implementation defined member functions.
266 __is_pointer_p() const;
269 __pointer_catch(const __pbase_type_info
* __thr_type
, void** __thr_obj
,
270 unsigned __outer
) const;
273 class __class_type_info
;
275 // Type information for a pointer to member variable.
276 class __pointer_to_member_type_info
: public __pbase_type_info
279 __class_type_info
* __context
; // Class of the member.
282 __pointer_to_member_type_info(const char* __n
, int __quals
,
283 const std::type_info
* __type
,
284 __class_type_info
* __klass
)
285 : __pbase_type_info(__n
, __quals
, __type
), __context(__klass
) { }
288 ~__pointer_to_member_type_info();
291 __pointer_to_member_type_info(const __pointer_to_member_type_info
&);
293 __pointer_to_member_type_info
&
294 operator=(const __pointer_to_member_type_info
&);
296 // Implementation defined member function.
298 __pointer_catch(const __pbase_type_info
* __thr_type
, void** __thr_obj
,
299 unsigned __outer
) const;
302 // Helper class for __vmi_class_type.
303 class __base_class_type_info
306 const __class_type_info
* __base_type
; // Base class type.
307 long __offset_flags
; // Offset and info.
309 enum __offset_flags_masks
311 __virtual_mask
= 0x1,
314 __offset_shift
= 8 // Bits to shift offset.
317 // Implementation defined member functions.
319 __is_virtual_p() const
320 { return __offset_flags
& __virtual_mask
; }
323 __is_public_p() const
324 { return __offset_flags
& __public_mask
; }
329 // This shift, being of a signed type, is implementation
330 // defined. GCC implements such shifts as arithmetic, which is
332 return static_cast<ptrdiff_t>(__offset_flags
) >> __offset_shift
;
336 // Type information for a class.
337 class __class_type_info
: public std::type_info
341 __class_type_info (const char *__n
) : type_info(__n
) { }
344 ~__class_type_info ();
346 // Implementation defined types.
347 // The type sub_kind tells us about how a base object is contained
348 // within a derived object. We often do this lazily, hence the
349 // UNKNOWN value. At other times we may use NOT_CONTAINED to mean
350 // not publicly contained.
356 // Not contained within us (in some circumstances this might
357 // mean not contained publicly)
360 // Contained ambiguously.
363 // Via a virtual path.
364 __contained_virtual_mask
= __base_class_type_info::__virtual_mask
,
366 // Via a public path.
367 __contained_public_mask
= __base_class_type_info::__public_mask
,
369 // Contained within us.
370 __contained_mask
= 1 << __base_class_type_info::__hwm_bit
,
372 __contained_private
= __contained_mask
,
373 __contained_public
= __contained_mask
| __contained_public_mask
376 struct __upcast_result
;
377 struct __dyncast_result
;
380 // Implementation defined member functions.
382 __do_upcast(const __class_type_info
* __dst_type
, void**__obj_ptr
) const;
385 __do_catch(const type_info
* __thr_type
, void** __thr_obj
,
386 unsigned __outer
) const;
389 // Helper for upcast. See if DST is us, or one of our bases.
390 // Return false if not found, true if found.
392 __do_upcast(const __class_type_info
* __dst
, const void* __obj
,
393 __upcast_result
& __restrict __result
) const;
395 // Indicate whether SRC_PTR of type SRC_TYPE is contained publicly
396 // within OBJ_PTR. OBJ_PTR points to a base object of our type,
397 // which is the destination type. SRC2DST indicates how SRC
398 // objects might be contained within this type. If SRC_PTR is one
399 // of our SRC_TYPE bases, indicate the virtuality. Returns
400 // not_contained for non containment or private containment.
402 __find_public_src(ptrdiff_t __src2dst
, const void* __obj_ptr
,
403 const __class_type_info
* __src_type
,
404 const void* __src_ptr
) const;
406 // Helper for dynamic cast. ACCESS_PATH gives the access from the
407 // most derived object to this base. DST_TYPE indicates the
408 // desired type we want. OBJ_PTR points to a base of our type
409 // within the complete object. SRC_TYPE indicates the static type
410 // started from and SRC_PTR points to that base within the most
411 // derived object. Fill in RESULT with what we find. Return true
412 // if we have located an ambiguous match.
414 __do_dyncast(ptrdiff_t __src2dst
, __sub_kind __access_path
,
415 const __class_type_info
* __dst_type
, const void* __obj_ptr
,
416 const __class_type_info
* __src_type
, const void* __src_ptr
,
417 __dyncast_result
& __result
) const;
419 // Helper for find_public_subobj. SRC2DST indicates how SRC_TYPE
420 // bases are inherited by the type started from -- which is not
421 // necessarily the current type. The current type will be a base
422 // of the destination type. OBJ_PTR points to the current base.
424 __do_find_public_src(ptrdiff_t __src2dst
, const void* __obj_ptr
,
425 const __class_type_info
* __src_type
,
426 const void* __src_ptr
) const;
429 // Type information for a class with a single non-virtual base.
430 class __si_class_type_info
: public __class_type_info
433 const __class_type_info
* __base_type
;
436 __si_class_type_info(const char *__n
, const __class_type_info
*__base
)
437 : __class_type_info(__n
), __base_type(__base
) { }
440 ~__si_class_type_info();
443 __si_class_type_info(const __si_class_type_info
&);
445 __si_class_type_info
&
446 operator=(const __si_class_type_info
&);
448 // Implementation defined member functions.
450 __do_dyncast(ptrdiff_t __src2dst
, __sub_kind __access_path
,
451 const __class_type_info
* __dst_type
, const void* __obj_ptr
,
452 const __class_type_info
* __src_type
, const void* __src_ptr
,
453 __dyncast_result
& __result
) const;
456 __do_find_public_src(ptrdiff_t __src2dst
, const void* __obj_ptr
,
457 const __class_type_info
* __src_type
,
458 const void* __sub_ptr
) const;
461 __do_upcast(const __class_type_info
*__dst
, const void*__obj
,
462 __upcast_result
& __restrict __result
) const;
465 // Type information for a class with multiple and/or virtual bases.
466 class __vmi_class_type_info
: public __class_type_info
469 unsigned int __flags
; // Details about the class hierarchy.
470 unsigned int __base_count
; // Dumber of direct bases.
472 // The array of bases uses the trailing array struct hack so this
473 // class is not constructable with a normal constructor. It is
474 // internally generated by the compiler.
475 __base_class_type_info __base_info
[1]; // Array of bases.
478 __vmi_class_type_info(const char* __n
, int ___flags
)
479 : __class_type_info(__n
), __flags(___flags
), __base_count(0) { }
482 ~__vmi_class_type_info();
484 // Implementation defined types.
487 __non_diamond_repeat_mask
= 0x1, // Distinct instance of repeated base.
488 __diamond_shaped_mask
= 0x2, // Diamond shaped multiple inheritance.
489 __flags_unknown_mask
= 0x10
493 // Implementation defined member functions.
495 __do_dyncast(ptrdiff_t __src2dst
, __sub_kind __access_path
,
496 const __class_type_info
* __dst_type
, const void* __obj_ptr
,
497 const __class_type_info
* __src_type
, const void* __src_ptr
,
498 __dyncast_result
& __result
) const;
501 __do_find_public_src(ptrdiff_t __src2dst
, const void* __obj_ptr
,
502 const __class_type_info
* __src_type
,
503 const void* __src_ptr
) const;
506 __do_upcast(const __class_type_info
* __dst
, const void* __obj
,
507 __upcast_result
& __restrict __result
) const;
510 // Dynamic cast runtime.
511 // src2dst has the following possible values
512 // >-1: src_type is a unique public non-virtual base of dst_type
513 // dst_ptr + src2dst == src_ptr
514 // -1: unspecified relationship
515 // -2: src_type is not a public base of dst_type
516 // -3: src_type is a multiple public non-virtual base of dst_type
518 __dynamic_cast(const void* __src_ptr
, // Starting object.
519 const __class_type_info
* __src_type
, // Static type of object.
520 const __class_type_info
* __dst_type
, // Desired target type.
521 ptrdiff_t __src2dst
); // How src and dst are related.
524 // Returns the type_info for the currently handled exception [15.3/8], or
525 // null if there is none.
526 extern "C" std::type_info
*
527 __cxa_current_exception_type();
528 } // namespace __cxxabiv1
530 // User programs should use the alias `abi'.
531 namespace abi
= __cxxabiv1
;
533 #endif // __cplusplus
535 #pragma GCC visibility pop