* config/rs6000/rs6000.c (spe_init_builtins,
[official-gcc.git] / libstdc++-v3 / libsupc++ / cxxabi.h
blob371b77ef2b8736cd870e1e7925e249ab260f4687
1 // new abi support -*- C++ -*-
3 // Copyright (C) 2000, 2002 Free Software Foundation, Inc.
4 //
5 // This file is part of GNU CC.
6 //
7 // GNU CC 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 // GNU CC 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 GNU CC; 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 #ifdef __cplusplus
47 // We use the compiler builtins __SIZE_TYPE__ and __PTRDIFF_TYPE__ instead of
48 // std::size_t and std::ptrdiff_t respectively. This makes us independent of
49 // the conformance level of <cstddef> and whether -fhonor-std was supplied.
50 // <cstddef> is not currently available during compiler building anyway.
51 // Including <stddef.h> would be wrong, as that would rudely place size_t in
52 // the global namespace.
54 #include <typeinfo>
56 namespace __cxxabiv1
59 /* type information for int, float etc */
60 class __fundamental_type_info
61 : public std::type_info
63 public:
64 virtual ~__fundamental_type_info ();
65 public:
66 explicit __fundamental_type_info (const char *__n)
67 : std::type_info (__n)
68 { }
71 /* type information for array objects */
72 class __array_type_info
73 : public std::type_info
75 /* abi defined member functions */
76 protected:
77 virtual ~__array_type_info ();
78 public:
79 explicit __array_type_info (const char *__n)
80 : std::type_info (__n)
81 { }
84 /* type information for functions (both member and non-member) */
85 class __function_type_info
86 : public std::type_info
88 /* abi defined member functions */
89 public:
90 virtual ~__function_type_info ();
91 public:
92 explicit __function_type_info (const char *__n)
93 : std::type_info (__n)
94 { }
96 /* implementation defined member functions */
97 protected:
98 virtual bool __is_function_p () const;
101 /* type information for enumerations */
102 class __enum_type_info
103 : public std::type_info
105 /* abi defined member functions */
106 public:
107 virtual ~__enum_type_info ();
108 public:
109 explicit __enum_type_info (const char *__n)
110 : std::type_info (__n)
114 /* common type information for simple pointers and pointers to member */
115 class __pbase_type_info
116 : public std::type_info
118 /* abi defined member variables */
119 public:
120 unsigned int __flags; /* qualification of the target object */
121 const std::type_info *__pointee; /* type of pointed to object */
123 /* abi defined member functions */
124 public:
125 virtual ~__pbase_type_info ();
126 public:
127 explicit __pbase_type_info (const char *__n,
128 int __quals,
129 const std::type_info *__type)
130 : std::type_info (__n), __flags (__quals), __pointee (__type)
133 /* implementation defined types */
134 public:
135 enum __masks {
136 __const_mask = 0x1,
137 __volatile_mask = 0x2,
138 __restrict_mask = 0x4,
139 __incomplete_mask = 0x8,
140 __incomplete_class_mask = 0x10
143 /* implementation defined member functions */
144 protected:
145 virtual bool __do_catch (const std::type_info *__thr_type,
146 void **__thr_obj,
147 unsigned __outer) const;
148 protected:
149 inline virtual bool __pointer_catch (const __pbase_type_info *__thr_type,
150 void **__thr_obj,
151 unsigned __outer) const;
154 /* type information for simple pointers */
155 class __pointer_type_info
156 : public __pbase_type_info
158 /* abi defined member functions */
159 public:
160 virtual ~__pointer_type_info ();
161 public:
162 explicit __pointer_type_info (const char *__n,
163 int __quals,
164 const std::type_info *__type)
165 : __pbase_type_info (__n, __quals, __type)
168 /* implementation defined member functions */
169 protected:
170 virtual bool __is_pointer_p () const;
172 protected:
173 virtual bool __pointer_catch (const __pbase_type_info *__thr_type,
174 void **__thr_obj,
175 unsigned __outer) const;
178 /* type information for a pointer to member variable */
179 class __pointer_to_member_type_info
180 : public __pbase_type_info
182 /* abi defined member variables */
183 public:
184 __class_type_info *__context; /* class of the member */
186 /* abi defined member functions */
187 public:
188 virtual ~__pointer_to_member_type_info ();
189 public:
190 explicit __pointer_to_member_type_info (const char *__n,
191 int __quals,
192 const std::type_info *__type,
193 __class_type_info *__klass)
194 : __pbase_type_info (__n, __quals, __type), __context (__klass)
197 /* implementation defined member functions */
198 protected:
199 virtual bool __pointer_catch (const __pbase_type_info *__thr_type,
200 void **__thr_obj,
201 unsigned __outer) const;
204 class __class_type_info;
206 /* helper class for __vmi_class_type */
207 class __base_class_type_info
209 /* abi defined member variables */
210 public:
211 const __class_type_info* __base_type; /* base class type */
212 long __offset_flags; /* offset and info */
214 /* implementation defined types */
215 public:
216 enum __offset_flags_masks {
217 __virtual_mask = 0x1,
218 __public_mask = 0x2,
219 __hwm_bit = 2,
220 __offset_shift = 8 /* bits to shift offset by */
223 /* implementation defined member functions */
224 public:
225 bool __is_virtual_p () const
226 { return __offset_flags & __virtual_mask; }
227 bool __is_public_p () const
228 { return __offset_flags & __public_mask; }
229 __PTRDIFF_TYPE__ __offset () const
231 // This shift, being of a signed type, is implementation defined. GCC
232 // implements such shifts as arithmetic, which is what we want.
233 return static_cast<__PTRDIFF_TYPE__> (__offset_flags) >> __offset_shift;
237 /* type information for a class */
238 class __class_type_info
239 : public std::type_info
241 /* abi defined member functions */
242 public:
243 virtual ~__class_type_info ();
244 public:
245 explicit __class_type_info (const char *__n)
246 : type_info (__n)
249 /* implementation defined types */
250 public:
251 /* sub_kind tells us about how a base object is contained within a derived
252 object. We often do this lazily, hence the UNKNOWN value. At other times
253 we may use NOT_CONTAINED to mean not publicly contained. */
254 enum __sub_kind
256 __unknown = 0, /* we have no idea */
257 __not_contained, /* not contained within us (in some */
258 /* circumstances this might mean not contained */
259 /* publicly) */
260 __contained_ambig, /* contained ambiguously */
262 __contained_virtual_mask = __base_class_type_info::__virtual_mask, /* via a virtual path */
263 __contained_public_mask = __base_class_type_info::__public_mask, /* via a public path */
264 __contained_mask = 1 << __base_class_type_info::__hwm_bit, /* contained within us */
266 __contained_private = __contained_mask,
267 __contained_public = __contained_mask | __contained_public_mask
270 public:
271 struct __upcast_result;
272 struct __dyncast_result;
274 /* implementation defined member functions */
275 protected:
276 virtual bool __do_upcast (const __class_type_info *__dst_type, void **__obj_ptr) const;
278 protected:
279 virtual bool __do_catch (const type_info *__thr_type, void **__thr_obj,
280 unsigned __outer) const;
283 public:
284 /* Helper for upcast. See if DST is us, or one of our bases. */
285 /* Return false if not found, true if found. */
286 virtual bool __do_upcast (const __class_type_info *__dst,
287 const void *__obj,
288 __upcast_result &__restrict __result) const;
290 public:
291 /* Indicate whether SRC_PTR of type SRC_TYPE is contained publicly within
292 OBJ_PTR. OBJ_PTR points to a base object of our type, which is the
293 destination type. SRC2DST indicates how SRC objects might be contained
294 within this type. If SRC_PTR is one of our SRC_TYPE bases, indicate the
295 virtuality. Returns not_contained for non containment or private
296 containment. */
297 inline __sub_kind __find_public_src (__PTRDIFF_TYPE__ __src2dst,
298 const void *__obj_ptr,
299 const __class_type_info *__src_type,
300 const void *__src_ptr) const;
302 public:
303 /* dynamic cast helper. ACCESS_PATH gives the access from the most derived
304 object to this base. DST_TYPE indicates the desired type we want. OBJ_PTR
305 points to a base of our type within the complete object. SRC_TYPE
306 indicates the static type started from and SRC_PTR points to that base
307 within the most derived object. Fill in RESULT with what we find. Return
308 true if we have located an ambiguous match. */
309 virtual bool __do_dyncast (__PTRDIFF_TYPE__ __src2dst,
310 __sub_kind __access_path,
311 const __class_type_info *__dst_type,
312 const void *__obj_ptr,
313 const __class_type_info *__src_type,
314 const void *__src_ptr,
315 __dyncast_result &__result) const;
316 public:
317 /* Helper for find_public_subobj. SRC2DST indicates how SRC_TYPE bases are
318 inherited by the type started from -- which is not necessarily the
319 current type. The current type will be a base of the destination type.
320 OBJ_PTR points to the current base. */
321 virtual __sub_kind __do_find_public_src (__PTRDIFF_TYPE__ __src2dst,
322 const void *__obj_ptr,
323 const __class_type_info *__src_type,
324 const void *__src_ptr) const;
327 /* type information for a class with a single non-virtual base */
328 class __si_class_type_info
329 : public __class_type_info
331 /* abi defined member variables */
332 public:
333 const __class_type_info *__base_type;
335 /* abi defined member functions */
336 public:
337 virtual ~__si_class_type_info ();
338 public:
339 explicit __si_class_type_info (const char *__n,
340 const __class_type_info *__base)
341 : __class_type_info (__n), __base_type (__base)
344 /* implementation defined member functions */
345 protected:
346 virtual bool __do_dyncast (__PTRDIFF_TYPE__ __src2dst,
347 __sub_kind __access_path,
348 const __class_type_info *__dst_type,
349 const void *__obj_ptr,
350 const __class_type_info *__src_type,
351 const void *__src_ptr,
352 __dyncast_result &__result) const;
353 virtual __sub_kind __do_find_public_src (__PTRDIFF_TYPE__ __src2dst,
354 const void *__obj_ptr,
355 const __class_type_info *__src_type,
356 const void *__sub_ptr) const;
357 virtual bool __do_upcast (const __class_type_info *__dst,
358 const void *__obj,
359 __upcast_result &__restrict __result) const;
362 /* type information for a class with multiple and/or virtual bases */
363 class __vmi_class_type_info : public __class_type_info {
364 /* abi defined member variables */
365 public:
366 unsigned int __flags; /* details about the class hierarchy */
367 unsigned int __base_count; /* number of direct bases */
368 __base_class_type_info __base_info[1]; /* array of bases */
369 /* The array of bases uses the trailing array struct hack
370 so this class is not constructable with a normal constructor. It is
371 internally generated by the compiler. */
373 /* abi defined member functions */
374 public:
375 virtual ~__vmi_class_type_info ();
376 public:
377 explicit __vmi_class_type_info (const char *__n,
378 int ___flags)
379 : __class_type_info (__n), __flags (___flags), __base_count (0)
382 /* implementation defined types */
383 public:
384 enum __flags_masks {
385 __non_diamond_repeat_mask = 0x1, /* distinct instance of repeated base */
386 __diamond_shaped_mask = 0x2, /* diamond shaped multiple inheritance */
387 non_public_base_mask = 0x4, /* has non-public direct or indirect base */
388 public_base_mask = 0x8, /* has public base (direct) */
390 __flags_unknown_mask = 0x10
393 /* implementation defined member functions */
394 protected:
395 virtual bool __do_dyncast (__PTRDIFF_TYPE__ __src2dst,
396 __sub_kind __access_path,
397 const __class_type_info *__dst_type,
398 const void *__obj_ptr,
399 const __class_type_info *__src_type,
400 const void *__src_ptr,
401 __dyncast_result &__result) const;
402 virtual __sub_kind __do_find_public_src (__PTRDIFF_TYPE__ __src2dst,
403 const void *__obj_ptr,
404 const __class_type_info *__src_type,
405 const void *__src_ptr) const;
406 virtual bool __do_upcast (const __class_type_info *__dst,
407 const void *__obj,
408 __upcast_result &__restrict __result) const;
411 /* dynamic cast runtime */
412 extern "C"
413 void *__dynamic_cast (const void *__src_ptr, /* object started from */
414 const __class_type_info *__src_type, /* static type of object */
415 const __class_type_info *__dst_type, /* desired target type */
416 __PTRDIFF_TYPE__ __src2dst); /* how src and dst are related */
418 /* src2dst has the following possible values
419 >= 0: src_type is a unique public non-virtual base of dst_type
420 dst_ptr + src2dst == src_ptr
421 -1: unspecified relationship
422 -2: src_type is not a public base of dst_type
423 -3: src_type is a multiple public non-virtual base of dst_type */
425 /* array ctor/dtor routines */
427 /* allocate and construct array */
428 extern "C"
429 void *__cxa_vec_new (__SIZE_TYPE__ __element_count,
430 __SIZE_TYPE__ __element_size,
431 __SIZE_TYPE__ __padding_size,
432 void (*__constructor) (void *),
433 void (*__destructor) (void *));
435 extern "C"
436 void *__cxa_vec_new2 (__SIZE_TYPE__ __element_count,
437 __SIZE_TYPE__ __element_size,
438 __SIZE_TYPE__ __padding_size,
439 void (*__constructor) (void *),
440 void (*__destructor) (void *),
441 void *(*__alloc) (__SIZE_TYPE__),
442 void (*__dealloc) (void *));
444 extern "C"
445 void *__cxa_vec_new3 (__SIZE_TYPE__ __element_count,
446 __SIZE_TYPE__ __element_size,
447 __SIZE_TYPE__ __padding_size,
448 void (*__constructor) (void *),
449 void (*__destructor) (void *),
450 void *(*__alloc) (__SIZE_TYPE__),
451 void (*__dealloc) (void *, __SIZE_TYPE__));
453 /* construct array */
454 extern "C"
455 void __cxa_vec_ctor (void *__array_address,
456 __SIZE_TYPE__ __element_count,
457 __SIZE_TYPE__ __element_size,
458 void (*__constructor) (void *),
459 void (*__destructor) (void *));
461 extern "C"
462 void __cxa_vec_cctor (void *dest_array,
463 void *src_array,
464 __SIZE_TYPE__ element_count,
465 __SIZE_TYPE__ element_size,
466 void (*constructor) (void *, void *),
467 void (*destructor) (void *));
469 /* destruct array */
470 extern "C"
471 void __cxa_vec_dtor (void *__array_address,
472 __SIZE_TYPE__ __element_count,
473 __SIZE_TYPE__ __element_size,
474 void (*__destructor) (void *));
476 /* destruct array */
477 extern "C"
478 void __cxa_vec_cleanup (void *__array_address,
479 __SIZE_TYPE__ __element_count,
480 __SIZE_TYPE__ __element_size,
481 void (*__destructor) (void *));
483 /* destruct and release array */
484 extern "C"
485 void __cxa_vec_delete (void *__array_address,
486 __SIZE_TYPE__ __element_size,
487 __SIZE_TYPE__ __padding_size,
488 void (*__destructor) (void *));
490 extern "C"
491 void __cxa_vec_delete2 (void *__array_address,
492 __SIZE_TYPE__ __element_size,
493 __SIZE_TYPE__ __padding_size,
494 void (*__destructor) (void *),
495 void (*__dealloc) (void *));
497 extern "C"
498 void __cxa_vec_delete3 (void *__array_address,
499 __SIZE_TYPE__ __element_size,
500 __SIZE_TYPE__ __padding_size,
501 void (*__destructor) (void *),
502 void (*__dealloc) (void *, __SIZE_TYPE__));
504 /* demangling routines */
506 extern "C"
507 char *__cxa_demangle (const char *__mangled_name,
508 char *__output_buffer,
509 __SIZE_TYPE__ *__length,
510 int *__status);
512 // Returns the type_info for the currently handled exception [15.3/8], or
513 // null if there is none.
514 extern "C"
515 std::type_info *__cxa_current_exception_type ();
517 } /* namespace __cxxabiv1 */
519 /* User programs should use the alias `abi'. */
520 namespace abi = __cxxabiv1;
522 #else
523 #endif /* __cplusplus */
526 #endif /* __CXXABI_H */