1 // new abi support -*- C++ -*-
3 // Copyright (C) 2000, 2002, 2003, 2004 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, 59 Temple Place - Suite 330,
20 // Boston, MA 02111-1307, 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. */
56 __cxa_vec_new(size_t __element_count
, size_t __element_size
,
57 size_t __padding_size
, void (*__constructor
) (void*),
58 void (*__destructor
) (void*));
61 __cxa_vec_new2(size_t __element_count
, size_t __element_size
,
62 size_t __padding_size
, void (*__constructor
) (void*),
63 void (*__destructor
) (void*), void *(*__alloc
) (size_t),
64 void (*__dealloc
) (void*));
67 __cxa_vec_new3(size_t __element_count
, size_t __element_size
,
68 size_t __padding_size
, void (*__constructor
) (void*),
69 void (*__destructor
) (void*), void *(*__alloc
) (size_t),
70 void (*__dealloc
) (void*, size_t));
74 __cxa_vec_ctor(void* __array_address
, size_t __element_count
,
75 size_t __element_size
, void (*__constructor
) (void*),
76 void (*__destructor
) (void*));
79 __cxa_vec_cctor(void* dest_array
, void* src_array
, size_t element_count
,
80 size_t element_size
, void (*constructor
) (void*, void*),
81 void (*destructor
) (void*));
85 __cxa_vec_dtor(void* __array_address
, size_t __element_count
,
86 size_t __element_size
, void (*__destructor
) (void*));
89 __cxa_vec_cleanup(void* __array_address
, size_t __element_count
,
90 size_t __element_size
, void (*__destructor
) (void*));
92 // Destruct and release array.
94 __cxa_vec_delete(void* __array_address
, size_t __element_size
,
95 size_t __padding_size
, void (*__destructor
) (void*));
98 __cxa_vec_delete2(void* __array_address
, size_t __element_size
,
99 size_t __padding_size
, void (*__destructor
) (void*),
100 void (*__dealloc
) (void*));
103 __cxa_vec_delete3(void* __array_address
, size_t __element_size
,
104 size_t __padding_size
, void (*__destructor
) (void*),
105 void (*__dealloc
) (void*, size_t));
107 // The ABI requires a 64-bit type.
108 __extension__
typedef int __guard
__attribute__((mode (__DI__
)));
111 __cxa_guard_acquire(__guard
*);
114 __cxa_guard_release(__guard
*);
117 __cxa_guard_abort(__guard
*);
119 // Pure virtual functions.
121 __cxa_pure_virtual(void);
123 // Exception handling.
132 __cxa_atexit(void (*)(void*), void*, void*);
135 __cxa_finalize(void*);
137 // Demangling routines.
139 __cxa_demangle(const char* __mangled_name
, char* __output_buffer
,
140 size_t* __length
, int* __status
);
143 } // namespace __cxxabiv1
152 // Type information for int, float etc.
153 class __fundamental_type_info
: public std::type_info
157 __fundamental_type_info(const char* __n
) : std::type_info(__n
) { }
160 ~__fundamental_type_info();
163 // Type information for array objects.
164 class __array_type_info
: public std::type_info
168 __array_type_info(const char* __n
) : std::type_info(__n
) { }
171 ~__array_type_info();
174 // Type information for functions (both member and non-member).
175 class __function_type_info
: public std::type_info
179 __function_type_info(const char* __n
) : std::type_info(__n
) { }
182 ~__function_type_info();
185 // Implementation defined member function.
187 __is_function_p() const;
190 // Type information for enumerations.
191 class __enum_type_info
: public std::type_info
195 __enum_type_info(const char* __n
) : std::type_info(__n
) { }
201 // Common type information for simple pointers and pointers to member.
202 class __pbase_type_info
: public std::type_info
205 unsigned int __flags
; // Qualification of the target object.
206 const std::type_info
* __pointee
; // Type of pointed to object.
209 __pbase_type_info(const char* __n
, int __quals
,
210 const std::type_info
* __type
)
211 : std::type_info(__n
), __flags(__quals
), __pointee(__type
)
215 ~__pbase_type_info();
217 // Implementation defined type.
221 __volatile_mask
= 0x2,
222 __restrict_mask
= 0x4,
223 __incomplete_mask
= 0x8,
224 __incomplete_class_mask
= 0x10
228 __pbase_type_info(const __pbase_type_info
&);
231 operator=(const __pbase_type_info
&);
233 // Implementation defined member functions.
235 __do_catch(const std::type_info
* __thr_type
, void** __thr_obj
,
236 unsigned int __outer
) const;
239 __pointer_catch(const __pbase_type_info
* __thr_type
, void** __thr_obj
,
240 unsigned __outer
) const;
243 // Type information for simple pointers.
244 class __pointer_type_info
: public __pbase_type_info
248 __pointer_type_info(const char* __n
, int __quals
,
249 const std::type_info
* __type
)
250 : __pbase_type_info (__n
, __quals
, __type
) { }
254 ~__pointer_type_info();
257 // Implementation defined member functions.
259 __is_pointer_p() const;
262 __pointer_catch(const __pbase_type_info
* __thr_type
, void** __thr_obj
,
263 unsigned __outer
) const;
266 class __class_type_info
;
268 // Type information for a pointer to member variable.
269 class __pointer_to_member_type_info
: public __pbase_type_info
272 __class_type_info
* __context
; // Class of the member.
275 __pointer_to_member_type_info(const char* __n
, int __quals
,
276 const std::type_info
* __type
,
277 __class_type_info
* __klass
)
278 : __pbase_type_info(__n
, __quals
, __type
), __context(__klass
) { }
281 ~__pointer_to_member_type_info();
284 __pointer_to_member_type_info(const __pointer_to_member_type_info
&);
286 __pointer_to_member_type_info
&
287 operator=(const __pointer_to_member_type_info
&);
289 // Implementation defined member function.
291 __pointer_catch(const __pbase_type_info
* __thr_type
, void** __thr_obj
,
292 unsigned __outer
) const;
295 // Helper class for __vmi_class_type.
296 class __base_class_type_info
299 const __class_type_info
* __base_type
; // Base class type.
300 long __offset_flags
; // Offset and info.
302 enum __offset_flags_masks
304 __virtual_mask
= 0x1,
307 __offset_shift
= 8 // Bits to shift offset.
310 // Implementation defined member functions.
312 __is_virtual_p() const
313 { return __offset_flags
& __virtual_mask
; }
316 __is_public_p() const
317 { return __offset_flags
& __public_mask
; }
322 // This shift, being of a signed type, is implementation
323 // defined. GCC implements such shifts as arithmetic, which is
325 return static_cast<ptrdiff_t>(__offset_flags
) >> __offset_shift
;
329 // Type information for a class.
330 class __class_type_info
: public std::type_info
334 __class_type_info (const char *__n
) : type_info(__n
) { }
337 ~__class_type_info ();
339 // Implementation defined types.
340 // The type sub_kind tells us about how a base object is contained
341 // within a derived object. We often do this lazily, hence the
342 // UNKNOWN value. At other times we may use NOT_CONTAINED to mean
343 // not publicly contained.
349 // Not contained within us (in some circumstances this might
350 // mean not contained publicly)
353 // Contained ambiguously.
356 // Via a virtual path.
357 __contained_virtual_mask
= __base_class_type_info::__virtual_mask
,
359 // Via a public path.
360 __contained_public_mask
= __base_class_type_info::__public_mask
,
362 // Contained within us.
363 __contained_mask
= 1 << __base_class_type_info::__hwm_bit
,
365 __contained_private
= __contained_mask
,
366 __contained_public
= __contained_mask
| __contained_public_mask
369 struct __upcast_result
;
370 struct __dyncast_result
;
373 // Implementation defined member functions.
375 __do_upcast(const __class_type_info
* __dst_type
, void**__obj_ptr
) const;
378 __do_catch(const type_info
* __thr_type
, void** __thr_obj
,
379 unsigned __outer
) const;
382 // Helper for upcast. See if DST is us, or one of our bases.
383 // Return false if not found, true if found.
385 __do_upcast(const __class_type_info
* __dst
, const void* __obj
,
386 __upcast_result
& __restrict __result
) const;
388 // Indicate whether SRC_PTR of type SRC_TYPE is contained publicly
389 // within OBJ_PTR. OBJ_PTR points to a base object of our type,
390 // which is the destination type. SRC2DST indicates how SRC
391 // objects might be contained within this type. If SRC_PTR is one
392 // of our SRC_TYPE bases, indicate the virtuality. Returns
393 // not_contained for non containment or private containment.
395 __find_public_src(ptrdiff_t __src2dst
, const void* __obj_ptr
,
396 const __class_type_info
* __src_type
,
397 const void* __src_ptr
) const;
399 // Helper for dynamic cast. ACCESS_PATH gives the access from the
400 // most derived object to this base. DST_TYPE indicates the
401 // desired type we want. OBJ_PTR points to a base of our type
402 // within the complete object. SRC_TYPE indicates the static type
403 // started from and SRC_PTR points to that base within the most
404 // derived object. Fill in RESULT with what we find. Return true
405 // if we have located an ambiguous match.
407 __do_dyncast(ptrdiff_t __src2dst
, __sub_kind __access_path
,
408 const __class_type_info
* __dst_type
, const void* __obj_ptr
,
409 const __class_type_info
* __src_type
, const void* __src_ptr
,
410 __dyncast_result
& __result
) const;
412 // Helper for find_public_subobj. SRC2DST indicates how SRC_TYPE
413 // bases are inherited by the type started from -- which is not
414 // necessarily the current type. The current type will be a base
415 // of the destination type. OBJ_PTR points to the current base.
417 __do_find_public_src(ptrdiff_t __src2dst
, const void* __obj_ptr
,
418 const __class_type_info
* __src_type
,
419 const void* __src_ptr
) const;
422 // Type information for a class with a single non-virtual base.
423 class __si_class_type_info
: public __class_type_info
426 const __class_type_info
* __base_type
;
429 __si_class_type_info(const char *__n
, const __class_type_info
*__base
)
430 : __class_type_info(__n
), __base_type(__base
) { }
433 ~__si_class_type_info();
436 __si_class_type_info(const __si_class_type_info
&);
438 __si_class_type_info
&
439 operator=(const __si_class_type_info
&);
441 // Implementation defined member functions.
443 __do_dyncast(ptrdiff_t __src2dst
, __sub_kind __access_path
,
444 const __class_type_info
* __dst_type
, const void* __obj_ptr
,
445 const __class_type_info
* __src_type
, const void* __src_ptr
,
446 __dyncast_result
& __result
) const;
449 __do_find_public_src(ptrdiff_t __src2dst
, const void* __obj_ptr
,
450 const __class_type_info
* __src_type
,
451 const void* __sub_ptr
) const;
454 __do_upcast(const __class_type_info
*__dst
, const void*__obj
,
455 __upcast_result
& __restrict __result
) const;
458 // Type information for a class with multiple and/or virtual bases.
459 class __vmi_class_type_info
: public __class_type_info
462 unsigned int __flags
; // Details about the class hierarchy.
463 unsigned int __base_count
; // Dumber of direct bases.
465 // The array of bases uses the trailing array struct hack so this
466 // class is not constructable with a normal constructor. It is
467 // internally generated by the compiler.
468 __base_class_type_info __base_info
[1]; // Array of bases.
471 __vmi_class_type_info(const char* __n
, int ___flags
)
472 : __class_type_info(__n
), __flags(___flags
), __base_count(0) { }
475 ~__vmi_class_type_info();
477 // Implementation defined types.
480 __non_diamond_repeat_mask
= 0x1, // Distinct instance of repeated base.
481 __diamond_shaped_mask
= 0x2, // Diamond shaped multiple inheritance.
482 __flags_unknown_mask
= 0x10
486 // Implementation defined member functions.
488 __do_dyncast(ptrdiff_t __src2dst
, __sub_kind __access_path
,
489 const __class_type_info
* __dst_type
, const void* __obj_ptr
,
490 const __class_type_info
* __src_type
, const void* __src_ptr
,
491 __dyncast_result
& __result
) const;
494 __do_find_public_src(ptrdiff_t __src2dst
, const void* __obj_ptr
,
495 const __class_type_info
* __src_type
,
496 const void* __src_ptr
) const;
499 __do_upcast(const __class_type_info
* __dst
, const void* __obj
,
500 __upcast_result
& __restrict __result
) const;
503 // Dynamic cast runtime.
504 // src2dst has the following possible values
505 // >-1: src_type is a unique public non-virtual base of dst_type
506 // dst_ptr + src2dst == src_ptr
507 // -1: unspecified relationship
508 // -2: src_type is not a public base of dst_type
509 // -3: src_type is a multiple public non-virtual base of dst_type
511 __dynamic_cast(const void* __src_ptr
, // Starting object.
512 const __class_type_info
* __src_type
, // Static type of object.
513 const __class_type_info
* __dst_type
, // Desired target type.
514 ptrdiff_t __src2dst
); // How src and dst are related.
517 // Returns the type_info for the currently handled exception [15.3/8], or
518 // null if there is none.
519 extern "C" std::type_info
*
520 __cxa_current_exception_type();
521 } // namespace __cxxabiv1
523 // User programs should use the alias `abi'.
524 namespace abi
= __cxxabiv1
;
526 #endif // __cplusplus