Reinstate a lot of the original build environment
[msysgit.git] / mingw / include / c++ / 3.4.2 / cxxabi.h
blob35535491035b733623a370decd4b5d550f52ce7e
1 // new abi support -*- C++ -*-
3 // Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
4 //
5 // This file is part of GCC.
6 //
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)
10 // any later version.
11 //
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.
16 //
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
36 needed.
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. */
42 #ifndef _CXXABI_H
43 #define _CXXABI_H 1
45 #include <stddef.h>
47 #ifdef __cplusplus
48 namespace __cxxabiv1
50 extern "C"
52 #endif
54 // Allocate array.
55 void*
56 __cxa_vec_new(size_t __element_count, size_t __element_size,
57 size_t __padding_size, void (*__constructor) (void*),
58 void (*__destructor) (void*));
60 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*));
66 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));
72 // Construct array.
73 void
74 __cxa_vec_ctor(void* __array_address, size_t __element_count,
75 size_t __element_size, void (*__constructor) (void*),
76 void (*__destructor) (void*));
78 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*));
83 // Destruct array.
84 void
85 __cxa_vec_dtor(void* __array_address, size_t __element_count,
86 size_t __element_size, void (*__destructor) (void*));
88 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.
93 void
94 __cxa_vec_delete(void* __array_address, size_t __element_size,
95 size_t __padding_size, void (*__destructor) (void*));
97 void
98 __cxa_vec_delete2(void* __array_address, size_t __element_size,
99 size_t __padding_size, void (*__destructor) (void*),
100 void (*__dealloc) (void*));
102 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__)));
110 int
111 __cxa_guard_acquire(__guard*);
113 void
114 __cxa_guard_release(__guard*);
116 void
117 __cxa_guard_abort(__guard*);
119 // Pure virtual functions.
120 void
121 __cxa_pure_virtual(void);
123 // Exception handling.
124 void
125 __cxa_bad_cast();
127 void
128 __cxa_bad_typeid();
130 // DSO destruction.
132 __cxa_atexit(void (*)(void*), void*, void*);
135 __cxa_finalize(void*);
137 // Demangling routines.
138 char*
139 __cxa_demangle(const char* __mangled_name, char* __output_buffer,
140 size_t* __length, int* __status);
141 #ifdef __cplusplus
143 } // namespace __cxxabiv1
144 #endif
146 #ifdef __cplusplus
148 #include <typeinfo>
150 namespace __cxxabiv1
152 // Type information for int, float etc.
153 class __fundamental_type_info : public std::type_info
155 public:
156 explicit
157 __fundamental_type_info(const char* __n) : std::type_info(__n) { }
159 virtual
160 ~__fundamental_type_info();
163 // Type information for array objects.
164 class __array_type_info : public std::type_info
166 public:
167 explicit
168 __array_type_info(const char* __n) : std::type_info(__n) { }
170 virtual
171 ~__array_type_info();
174 // Type information for functions (both member and non-member).
175 class __function_type_info : public std::type_info
177 public:
178 explicit
179 __function_type_info(const char* __n) : std::type_info(__n) { }
181 virtual
182 ~__function_type_info();
184 protected:
185 // Implementation defined member function.
186 virtual bool
187 __is_function_p() const;
190 // Type information for enumerations.
191 class __enum_type_info : public std::type_info
193 public:
194 explicit
195 __enum_type_info(const char* __n) : std::type_info(__n) { }
197 virtual
198 ~__enum_type_info();
201 // Common type information for simple pointers and pointers to member.
202 class __pbase_type_info : public std::type_info
204 public:
205 unsigned int __flags; // Qualification of the target object.
206 const std::type_info* __pointee; // Type of pointed to object.
208 explicit
209 __pbase_type_info(const char* __n, int __quals,
210 const std::type_info* __type)
211 : std::type_info(__n), __flags(__quals), __pointee(__type)
214 virtual
215 ~__pbase_type_info();
217 // Implementation defined type.
218 enum __masks
220 __const_mask = 0x1,
221 __volatile_mask = 0x2,
222 __restrict_mask = 0x4,
223 __incomplete_mask = 0x8,
224 __incomplete_class_mask = 0x10
227 protected:
228 __pbase_type_info(const __pbase_type_info&);
230 __pbase_type_info&
231 operator=(const __pbase_type_info&);
233 // Implementation defined member functions.
234 virtual bool
235 __do_catch(const std::type_info* __thr_type, void** __thr_obj,
236 unsigned int __outer) const;
238 inline virtual bool
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
246 public:
247 explicit
248 __pointer_type_info(const char* __n, int __quals,
249 const std::type_info* __type)
250 : __pbase_type_info (__n, __quals, __type) { }
253 virtual
254 ~__pointer_type_info();
256 protected:
257 // Implementation defined member functions.
258 virtual bool
259 __is_pointer_p() const;
261 virtual bool
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
271 public:
272 __class_type_info* __context; // Class of the member.
274 explicit
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) { }
280 virtual
281 ~__pointer_to_member_type_info();
283 protected:
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.
290 virtual bool
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
298 public:
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,
305 __public_mask = 0x2,
306 __hwm_bit = 2,
307 __offset_shift = 8 // Bits to shift offset.
310 // Implementation defined member functions.
311 bool
312 __is_virtual_p() const
313 { return __offset_flags & __virtual_mask; }
315 bool
316 __is_public_p() const
317 { return __offset_flags & __public_mask; }
319 ptrdiff_t
320 __offset() const
322 // This shift, being of a signed type, is implementation
323 // defined. GCC implements such shifts as arithmetic, which is
324 // what we want.
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
332 public:
333 explicit
334 __class_type_info (const char *__n) : type_info(__n) { }
336 virtual
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.
344 enum __sub_kind
346 // We have no idea.
347 __unknown = 0,
349 // Not contained within us (in some circumstances this might
350 // mean not contained publicly)
351 __not_contained,
353 // Contained ambiguously.
354 __contained_ambig,
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;
372 protected:
373 // Implementation defined member functions.
374 virtual bool
375 __do_upcast(const __class_type_info* __dst_type, void**__obj_ptr) const;
377 virtual bool
378 __do_catch(const type_info* __thr_type, void** __thr_obj,
379 unsigned __outer) const;
381 public:
382 // Helper for upcast. See if DST is us, or one of our bases.
383 // Return false if not found, true if found.
384 virtual bool
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.
394 inline __sub_kind
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.
406 virtual bool
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.
416 virtual __sub_kind
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
425 public:
426 const __class_type_info* __base_type;
428 explicit
429 __si_class_type_info(const char *__n, const __class_type_info *__base)
430 : __class_type_info(__n), __base_type(__base) { }
432 virtual
433 ~__si_class_type_info();
435 protected:
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.
442 virtual bool
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;
448 virtual __sub_kind
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;
453 virtual bool
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
461 public:
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.
470 explicit
471 __vmi_class_type_info(const char* __n, int ___flags)
472 : __class_type_info(__n), __flags(___flags), __base_count(0) { }
474 virtual
475 ~__vmi_class_type_info();
477 // Implementation defined types.
478 enum __flags_masks
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
485 protected:
486 // Implementation defined member functions.
487 virtual bool
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;
493 virtual __sub_kind
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;
498 virtual bool
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
510 extern "C" void*
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
528 #endif // __CXXABI_H