1 // new abi support -*- C++ -*-
3 // Copyright (C) 2000, 2002, 2003, 2004, 2006, 2007 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>
53 #include <cxxabi-forced.h>
56 #define _GLIBCXX_NOTHROW throw()
58 #define _GLIBCXX_NOTHROW __attribute__((nothrow))
68 typedef __cxa_cdtor_return_type (*__cxa_cdtor_type
)(void *);
72 __cxa_vec_new(size_t __element_count
, size_t __element_size
,
73 size_t __padding_size
, __cxa_cdtor_type constructor
,
74 __cxa_cdtor_type destructor
);
77 __cxa_vec_new2(size_t __element_count
, size_t __element_size
,
78 size_t __padding_size
, __cxa_cdtor_type constructor
,
79 __cxa_cdtor_type destructor
, void *(*__alloc
) (size_t),
80 void (*__dealloc
) (void*));
83 __cxa_vec_new3(size_t __element_count
, size_t __element_size
,
84 size_t __padding_size
, __cxa_cdtor_type constructor
,
85 __cxa_cdtor_type destructor
, void *(*__alloc
) (size_t),
86 void (*__dealloc
) (void*, size_t));
89 __cxa_vec_ctor_return_type
90 __cxa_vec_ctor(void* __array_address
, size_t __element_count
,
91 size_t __element_size
, __cxa_cdtor_type constructor
,
92 __cxa_cdtor_type destructor
);
94 __cxa_vec_ctor_return_type
95 __cxa_vec_cctor(void* dest_array
, void* src_array
, size_t element_count
,
97 __cxa_cdtor_return_type (*constructor
) (void*, void*),
98 __cxa_cdtor_type destructor
);
102 __cxa_vec_dtor(void* __array_address
, size_t __element_count
,
103 size_t __element_size
, __cxa_cdtor_type destructor
);
106 __cxa_vec_cleanup(void* __array_address
, size_t __element_count
,
107 size_t __element_size
, __cxa_cdtor_type destructor
);
109 // Destruct and release array.
111 __cxa_vec_delete(void* __array_address
, size_t __element_size
,
112 size_t __padding_size
, __cxa_cdtor_type destructor
);
115 __cxa_vec_delete2(void* __array_address
, size_t __element_size
,
116 size_t __padding_size
, __cxa_cdtor_type destructor
,
117 void (*__dealloc
) (void*));
120 __cxa_vec_delete3(void* __array_address
, size_t __element_size
,
121 size_t __padding_size
, __cxa_cdtor_type destructor
,
122 void (*__dealloc
) (void*, size_t));
125 __cxa_guard_acquire(__guard
*);
128 __cxa_guard_release(__guard
*);
131 __cxa_guard_abort(__guard
*);
133 // Pure virtual functions.
135 __cxa_pure_virtual(void);
137 // Exception handling.
146 __cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW
;
149 __cxa_finalize(void*);
151 // Demangling routines.
153 __cxa_demangle(const char* __mangled_name
, char* __output_buffer
,
154 size_t* __length
, int* __status
);
157 } // namespace __cxxabiv1
166 // Type information for int, float etc.
167 class __fundamental_type_info
: public std::type_info
171 __fundamental_type_info(const char* __n
) : std::type_info(__n
) { }
174 ~__fundamental_type_info();
177 // Type information for array objects.
178 class __array_type_info
: public std::type_info
182 __array_type_info(const char* __n
) : std::type_info(__n
) { }
185 ~__array_type_info();
188 // Type information for functions (both member and non-member).
189 class __function_type_info
: public std::type_info
193 __function_type_info(const char* __n
) : std::type_info(__n
) { }
196 ~__function_type_info();
199 // Implementation defined member function.
201 __is_function_p() const;
204 // Type information for enumerations.
205 class __enum_type_info
: public std::type_info
209 __enum_type_info(const char* __n
) : std::type_info(__n
) { }
215 // Common type information for simple pointers and pointers to member.
216 class __pbase_type_info
: public std::type_info
219 unsigned int __flags
; // Qualification of the target object.
220 const std::type_info
* __pointee
; // Type of pointed to object.
223 __pbase_type_info(const char* __n
, int __quals
,
224 const std::type_info
* __type
)
225 : std::type_info(__n
), __flags(__quals
), __pointee(__type
)
229 ~__pbase_type_info();
231 // Implementation defined type.
235 __volatile_mask
= 0x2,
236 __restrict_mask
= 0x4,
237 __incomplete_mask
= 0x8,
238 __incomplete_class_mask
= 0x10
242 __pbase_type_info(const __pbase_type_info
&);
245 operator=(const __pbase_type_info
&);
247 // Implementation defined member functions.
249 __do_catch(const std::type_info
* __thr_type
, void** __thr_obj
,
250 unsigned int __outer
) const;
253 __pointer_catch(const __pbase_type_info
* __thr_type
, void** __thr_obj
,
254 unsigned __outer
) const;
257 // Type information for simple pointers.
258 class __pointer_type_info
: public __pbase_type_info
262 __pointer_type_info(const char* __n
, int __quals
,
263 const std::type_info
* __type
)
264 : __pbase_type_info (__n
, __quals
, __type
) { }
268 ~__pointer_type_info();
271 // Implementation defined member functions.
273 __is_pointer_p() const;
276 __pointer_catch(const __pbase_type_info
* __thr_type
, void** __thr_obj
,
277 unsigned __outer
) const;
280 class __class_type_info
;
282 // Type information for a pointer to member variable.
283 class __pointer_to_member_type_info
: public __pbase_type_info
286 __class_type_info
* __context
; // Class of the member.
289 __pointer_to_member_type_info(const char* __n
, int __quals
,
290 const std::type_info
* __type
,
291 __class_type_info
* __klass
)
292 : __pbase_type_info(__n
, __quals
, __type
), __context(__klass
) { }
295 ~__pointer_to_member_type_info();
298 __pointer_to_member_type_info(const __pointer_to_member_type_info
&);
300 __pointer_to_member_type_info
&
301 operator=(const __pointer_to_member_type_info
&);
303 // Implementation defined member function.
305 __pointer_catch(const __pbase_type_info
* __thr_type
, void** __thr_obj
,
306 unsigned __outer
) const;
309 // Helper class for __vmi_class_type.
310 class __base_class_type_info
313 const __class_type_info
* __base_type
; // Base class type.
314 long __offset_flags
; // Offset and info.
316 enum __offset_flags_masks
318 __virtual_mask
= 0x1,
321 __offset_shift
= 8 // Bits to shift offset.
324 // Implementation defined member functions.
326 __is_virtual_p() const
327 { return __offset_flags
& __virtual_mask
; }
330 __is_public_p() const
331 { return __offset_flags
& __public_mask
; }
336 // This shift, being of a signed type, is implementation
337 // defined. GCC implements such shifts as arithmetic, which is
339 return static_cast<ptrdiff_t>(__offset_flags
) >> __offset_shift
;
343 // Type information for a class.
344 class __class_type_info
: public std::type_info
348 __class_type_info (const char *__n
) : type_info(__n
) { }
351 ~__class_type_info ();
353 // Implementation defined types.
354 // The type sub_kind tells us about how a base object is contained
355 // within a derived object. We often do this lazily, hence the
356 // UNKNOWN value. At other times we may use NOT_CONTAINED to mean
357 // not publicly contained.
363 // Not contained within us (in some circumstances this might
364 // mean not contained publicly)
367 // Contained ambiguously.
370 // Via a virtual path.
371 __contained_virtual_mask
= __base_class_type_info::__virtual_mask
,
373 // Via a public path.
374 __contained_public_mask
= __base_class_type_info::__public_mask
,
376 // Contained within us.
377 __contained_mask
= 1 << __base_class_type_info::__hwm_bit
,
379 __contained_private
= __contained_mask
,
380 __contained_public
= __contained_mask
| __contained_public_mask
383 struct __upcast_result
;
384 struct __dyncast_result
;
387 // Implementation defined member functions.
389 __do_upcast(const __class_type_info
* __dst_type
, void**__obj_ptr
) const;
392 __do_catch(const type_info
* __thr_type
, void** __thr_obj
,
393 unsigned __outer
) const;
396 // Helper for upcast. See if DST is us, or one of our bases.
397 // Return false if not found, true if found.
399 __do_upcast(const __class_type_info
* __dst
, const void* __obj
,
400 __upcast_result
& __restrict __result
) const;
402 // Indicate whether SRC_PTR of type SRC_TYPE is contained publicly
403 // within OBJ_PTR. OBJ_PTR points to a base object of our type,
404 // which is the destination type. SRC2DST indicates how SRC
405 // objects might be contained within this type. If SRC_PTR is one
406 // of our SRC_TYPE bases, indicate the virtuality. Returns
407 // not_contained for non containment or private containment.
409 __find_public_src(ptrdiff_t __src2dst
, const void* __obj_ptr
,
410 const __class_type_info
* __src_type
,
411 const void* __src_ptr
) const;
413 // Helper for dynamic cast. ACCESS_PATH gives the access from the
414 // most derived object to this base. DST_TYPE indicates the
415 // desired type we want. OBJ_PTR points to a base of our type
416 // within the complete object. SRC_TYPE indicates the static type
417 // started from and SRC_PTR points to that base within the most
418 // derived object. Fill in RESULT with what we find. Return true
419 // if we have located an ambiguous match.
421 __do_dyncast(ptrdiff_t __src2dst
, __sub_kind __access_path
,
422 const __class_type_info
* __dst_type
, const void* __obj_ptr
,
423 const __class_type_info
* __src_type
, const void* __src_ptr
,
424 __dyncast_result
& __result
) const;
426 // Helper for find_public_subobj. SRC2DST indicates how SRC_TYPE
427 // bases are inherited by the type started from -- which is not
428 // necessarily the current type. The current type will be a base
429 // of the destination type. OBJ_PTR points to the current base.
431 __do_find_public_src(ptrdiff_t __src2dst
, const void* __obj_ptr
,
432 const __class_type_info
* __src_type
,
433 const void* __src_ptr
) const;
436 // Type information for a class with a single non-virtual base.
437 class __si_class_type_info
: public __class_type_info
440 const __class_type_info
* __base_type
;
443 __si_class_type_info(const char *__n
, const __class_type_info
*__base
)
444 : __class_type_info(__n
), __base_type(__base
) { }
447 ~__si_class_type_info();
450 __si_class_type_info(const __si_class_type_info
&);
452 __si_class_type_info
&
453 operator=(const __si_class_type_info
&);
455 // Implementation defined member functions.
457 __do_dyncast(ptrdiff_t __src2dst
, __sub_kind __access_path
,
458 const __class_type_info
* __dst_type
, const void* __obj_ptr
,
459 const __class_type_info
* __src_type
, const void* __src_ptr
,
460 __dyncast_result
& __result
) const;
463 __do_find_public_src(ptrdiff_t __src2dst
, const void* __obj_ptr
,
464 const __class_type_info
* __src_type
,
465 const void* __sub_ptr
) const;
468 __do_upcast(const __class_type_info
*__dst
, const void*__obj
,
469 __upcast_result
& __restrict __result
) const;
472 // Type information for a class with multiple and/or virtual bases.
473 class __vmi_class_type_info
: public __class_type_info
476 unsigned int __flags
; // Details about the class hierarchy.
477 unsigned int __base_count
; // Number of direct bases.
479 // The array of bases uses the trailing array struct hack so this
480 // class is not constructable with a normal constructor. It is
481 // internally generated by the compiler.
482 __base_class_type_info __base_info
[1]; // Array of bases.
485 __vmi_class_type_info(const char* __n
, int ___flags
)
486 : __class_type_info(__n
), __flags(___flags
), __base_count(0) { }
489 ~__vmi_class_type_info();
491 // Implementation defined types.
494 __non_diamond_repeat_mask
= 0x1, // Distinct instance of repeated base.
495 __diamond_shaped_mask
= 0x2, // Diamond shaped multiple inheritance.
496 __flags_unknown_mask
= 0x10
500 // Implementation defined member functions.
502 __do_dyncast(ptrdiff_t __src2dst
, __sub_kind __access_path
,
503 const __class_type_info
* __dst_type
, const void* __obj_ptr
,
504 const __class_type_info
* __src_type
, const void* __src_ptr
,
505 __dyncast_result
& __result
) const;
508 __do_find_public_src(ptrdiff_t __src2dst
, const void* __obj_ptr
,
509 const __class_type_info
* __src_type
,
510 const void* __src_ptr
) const;
513 __do_upcast(const __class_type_info
* __dst
, const void* __obj
,
514 __upcast_result
& __restrict __result
) const;
517 // Dynamic cast runtime.
518 // src2dst has the following possible values
519 // >-1: src_type is a unique public non-virtual base of dst_type
520 // dst_ptr + src2dst == src_ptr
521 // -1: unspecified relationship
522 // -2: src_type is not a public base of dst_type
523 // -3: src_type is a multiple public non-virtual base of dst_type
525 __dynamic_cast(const void* __src_ptr
, // Starting object.
526 const __class_type_info
* __src_type
, // Static type of object.
527 const __class_type_info
* __dst_type
, // Desired target type.
528 ptrdiff_t __src2dst
); // How src and dst are related.
531 // Returns the type_info for the currently handled exception [15.3/8], or
532 // null if there is none.
533 extern "C" std::type_info
*
534 __cxa_current_exception_type();
536 // A magic placeholder class that can be caught by reference
537 // to recognize foreign exceptions.
538 class __foreign_exception
540 virtual ~__foreign_exception() throw();
541 virtual void __pure_dummy() = 0; // prevent catch by value
544 } // namespace __cxxabiv1
546 // User programs should use the alias `abi'.
547 namespace abi
= __cxxabiv1
;
549 #endif // __cplusplus
551 #pragma GCC visibility pop