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. */
46 #include <bits/cxxabi_tweaks.h>
57 __cxa_vec_new(size_t __element_count, size_t __element_size,
58 size_t __padding_size, void (*__constructor) (void*),
59 void (*__destructor) (void*));
62 __cxa_vec_new2(size_t __element_count, size_t __element_size,
63 size_t __padding_size, void (*__constructor) (void*),
64 void (*__destructor) (void*), void *(*__alloc) (size_t),
65 void (*__dealloc) (void*));
68 __cxa_vec_new3(size_t __element_count, size_t __element_size,
69 size_t __padding_size, void (*__constructor) (void*),
70 void (*__destructor) (void*), void *(*__alloc) (size_t),
71 void (*__dealloc) (void*, size_t));
75 __cxa_vec_ctor(void* __array_address, size_t __element_count,
76 size_t __element_size, void (*__constructor) (void*),
77 void (*__destructor) (void*));
80 __cxa_vec_cctor(void* dest_array, void* src_array, size_t element_count,
81 size_t element_size, void (*constructor) (void*, void*),
82 void (*destructor) (void*));
86 __cxa_vec_dtor(void* __array_address, size_t __element_count,
87 size_t __element_size, void (*__destructor) (void*));
90 __cxa_vec_cleanup(void* __array_address, size_t __element_count,
91 size_t __element_size, void (*__destructor) (void*));
93 // Destruct and release array.
95 __cxa_vec_delete(void* __array_address, size_t __element_size,
96 size_t __padding_size, void (*__destructor) (void*));
99 __cxa_vec_delete2(void* __array_address, size_t __element_size,
100 size_t __padding_size, void (*__destructor) (void*),
101 void (*__dealloc) (void*));
104 __cxa_vec_delete3(void* __array_address, size_t __element_size,
105 size_t __padding_size, void (*__destructor) (void*),
106 void (*__dealloc) (void*, size_t));
109 __cxa_guard_acquire(__guard*);
112 __cxa_guard_release(__guard*);
115 __cxa_guard_abort(__guard*);
117 // Pure virtual functions.
119 __cxa_pure_virtual(void);
121 // Exception handling.
130 __cxa_atexit(void (*)(void*), void*, void*);
133 __cxa_finalize(void*);
135 // Demangling routines.
137 __cxa_demangle(const char* __mangled_name, char* __output_buffer,
138 size_t* __length, int* __status);
141 } // namespace __cxxabiv1
150 // Type information for int, float etc.
151 class __fundamental_type_info : public std::type_info
155 __fundamental_type_info(const char* __n) : std::type_info(__n) { }
158 ~__fundamental_type_info();
161 // Type information for array objects.
162 class __array_type_info : public std::type_info
166 __array_type_info(const char* __n) : std::type_info(__n) { }
169 ~__array_type_info();
172 // Type information for functions (both member and non-member).
173 class __function_type_info : public std::type_info
177 __function_type_info(const char* __n) : std::type_info(__n) { }
180 ~__function_type_info();
183 // Implementation defined member function.
185 __is_function_p() const;
188 // Type information for enumerations.
189 class __enum_type_info : public std::type_info
193 __enum_type_info(const char* __n) : std::type_info(__n) { }
199 // Common type information for simple pointers and pointers to member.
200 class __pbase_type_info : public std::type_info
203 unsigned int __flags; // Qualification of the target object.
204 const std::type_info* __pointee; // Type of pointed to object.
207 __pbase_type_info(const char* __n, int __quals,
208 const std::type_info* __type)
209 : std::type_info(__n), __flags(__quals), __pointee(__type)
213 ~__pbase_type_info();
215 // Implementation defined type.
219 __volatile_mask = 0x2,
220 __restrict_mask = 0x4,
221 __incomplete_mask = 0x8,
222 __incomplete_class_mask = 0x10
226 __pbase_type_info(const __pbase_type_info&);
229 operator=(const __pbase_type_info&);
231 // Implementation defined member functions.
233 __do_catch(const std::type_info* __thr_type, void** __thr_obj,
234 unsigned int __outer) const;
237 __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
238 unsigned __outer) const;
241 // Type information for simple pointers.
242 class __pointer_type_info : public __pbase_type_info
246 __pointer_type_info(const char* __n, int __quals,
247 const std::type_info* __type)
248 : __pbase_type_info (__n, __quals, __type) { }
252 ~__pointer_type_info();
255 // Implementation defined member functions.
257 __is_pointer_p() const;
260 __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
261 unsigned __outer) const;
264 class __class_type_info;
266 // Type information for a pointer to member variable.
267 class __pointer_to_member_type_info : public __pbase_type_info
270 __class_type_info* __context; // Class of the member.
273 __pointer_to_member_type_info(const char* __n, int __quals,
274 const std::type_info* __type,
275 __class_type_info* __klass)
276 : __pbase_type_info(__n, __quals, __type), __context(__klass) { }
279 ~__pointer_to_member_type_info();
282 __pointer_to_member_type_info(const __pointer_to_member_type_info&);
284 __pointer_to_member_type_info&
285 operator=(const __pointer_to_member_type_info&);
287 // Implementation defined member function.
289 __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
290 unsigned __outer) const;
293 // Helper class for __vmi_class_type.
294 class __base_class_type_info
297 const __class_type_info* __base_type; // Base class type.
298 long __offset_flags; // Offset and info.
300 enum __offset_flags_masks
302 __virtual_mask = 0x1,
305 __offset_shift = 8 // Bits to shift offset.
308 // Implementation defined member functions.
310 __is_virtual_p() const
311 { return __offset_flags & __virtual_mask; }
314 __is_public_p() const
315 { return __offset_flags & __public_mask; }
320 // This shift, being of a signed type, is implementation
321 // defined. GCC implements such shifts as arithmetic, which is
323 return static_cast<ptrdiff_t>(__offset_flags) >> __offset_shift;
327 // Type information for a class.
328 class __class_type_info : public std::type_info
332 __class_type_info (const char *__n) : type_info(__n) { }
335 ~__class_type_info ();
337 // Implementation defined types.
338 // The type sub_kind tells us about how a base object is contained
339 // within a derived object. We often do this lazily, hence the
340 // UNKNOWN value. At other times we may use NOT_CONTAINED to mean
341 // not publicly contained.
347 // Not contained within us (in some circumstances this might
348 // mean not contained publicly)
351 // Contained ambiguously.
354 // Via a virtual path.
355 __contained_virtual_mask = __base_class_type_info::__virtual_mask,
357 // Via a public path.
358 __contained_public_mask = __base_class_type_info::__public_mask,
360 // Contained within us.
361 __contained_mask = 1 << __base_class_type_info::__hwm_bit,
363 __contained_private = __contained_mask,
364 __contained_public = __contained_mask | __contained_public_mask
367 struct __upcast_result;
368 struct __dyncast_result;
371 // Implementation defined member functions.
373 __do_upcast(const __class_type_info* __dst_type, void**__obj_ptr) const;
376 __do_catch(const type_info* __thr_type, void** __thr_obj,
377 unsigned __outer) const;
380 // Helper for upcast. See if DST is us, or one of our bases.
381 // Return false if not found, true if found.
383 __do_upcast(const __class_type_info* __dst, const void* __obj,
384 __upcast_result& __restrict __result) const;
386 // Indicate whether SRC_PTR of type SRC_TYPE is contained publicly
387 // within OBJ_PTR. OBJ_PTR points to a base object of our type,
388 // which is the destination type. SRC2DST indicates how SRC
389 // objects might be contained within this type. If SRC_PTR is one
390 // of our SRC_TYPE bases, indicate the virtuality. Returns
391 // not_contained for non containment or private containment.
393 __find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
394 const __class_type_info* __src_type,
395 const void* __src_ptr) const;
397 // Helper for dynamic cast. ACCESS_PATH gives the access from the
398 // most derived object to this base. DST_TYPE indicates the
399 // desired type we want. OBJ_PTR points to a base of our type
400 // within the complete object. SRC_TYPE indicates the static type
401 // started from and SRC_PTR points to that base within the most
402 // derived object. Fill in RESULT with what we find. Return true
403 // if we have located an ambiguous match.
405 __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path,
406 const __class_type_info* __dst_type, const void* __obj_ptr,
407 const __class_type_info* __src_type, const void* __src_ptr,
408 __dyncast_result& __result) const;
410 // Helper for find_public_subobj. SRC2DST indicates how SRC_TYPE
411 // bases are inherited by the type started from -- which is not
412 // necessarily the current type. The current type will be a base
413 // of the destination type. OBJ_PTR points to the current base.
415 __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
416 const __class_type_info* __src_type,
417 const void* __src_ptr) const;
420 // Type information for a class with a single non-virtual base.
421 class __si_class_type_info : public __class_type_info
424 const __class_type_info* __base_type;
427 __si_class_type_info(const char *__n, const __class_type_info *__base)
428 : __class_type_info(__n), __base_type(__base) { }
431 ~__si_class_type_info();
434 __si_class_type_info(const __si_class_type_info&);
436 __si_class_type_info&
437 operator=(const __si_class_type_info&);
439 // Implementation defined member functions.
441 __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path,
442 const __class_type_info* __dst_type, const void* __obj_ptr,
443 const __class_type_info* __src_type, const void* __src_ptr,
444 __dyncast_result& __result) const;
447 __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
448 const __class_type_info* __src_type,
449 const void* __sub_ptr) const;
452 __do_upcast(const __class_type_info*__dst, const void*__obj,
453 __upcast_result& __restrict __result) const;
456 // Type information for a class with multiple and/or virtual bases.
457 class __vmi_class_type_info : public __class_type_info
460 unsigned int __flags; // Details about the class hierarchy.
461 unsigned int __base_count; // Dumber of direct bases.
463 // The array of bases uses the trailing array struct hack so this
464 // class is not constructable with a normal constructor. It is
465 // internally generated by the compiler.
466 __base_class_type_info __base_info[1]; // Array of bases.
469 __vmi_class_type_info(const char* __n, int ___flags)
470 : __class_type_info(__n), __flags(___flags), __base_count(0) { }
473 ~__vmi_class_type_info();
475 // Implementation defined types.
478 __non_diamond_repeat_mask = 0x1, // Distinct instance of repeated base.
479 __diamond_shaped_mask = 0x2, // Diamond shaped multiple inheritance.
480 __flags_unknown_mask = 0x10
484 // Implementation defined member functions.
486 __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path,
487 const __class_type_info* __dst_type, const void* __obj_ptr,
488 const __class_type_info* __src_type, const void* __src_ptr,
489 __dyncast_result& __result) const;
492 __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
493 const __class_type_info* __src_type,
494 const void* __src_ptr) const;
497 __do_upcast(const __class_type_info* __dst, const void* __obj,
498 __upcast_result& __restrict __result) const;
501 // Dynamic cast runtime.
502 // src2dst has the following possible values
503 // >-1: src_type is a unique public non-virtual base of dst_type
504 // dst_ptr + src2dst == src_ptr
505 // -1: unspecified relationship
506 // -2: src_type is not a public base of dst_type
507 // -3: src_type is a multiple public non-virtual base of dst_type
509 __dynamic_cast(const void* __src_ptr, // Starting object.
510 const __class_type_info* __src_type, // Static type of object.
511 const __class_type_info* __dst_type, // Desired target type.
512 ptrdiff_t __src2dst); // How src and dst are related.
515 // Returns the type_info for the currently handled exception [15.3/8], or
516 // null if there is none.
517 extern "C" std::type_info*
518 __cxa_current_exception_type();
519 } // namespace __cxxabiv1
521 // User programs should use the alias `abi'.
522 namespace abi = __cxxabiv1;
524 #endif // __cplusplus