]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/libstdc++-v3/contrib/libstdc++-v3-4.3.3/libsupc++/cxxabi.h
update
[l4.git] / l4 / pkg / libstdc++-v3 / contrib / libstdc++-v3-4.3.3 / libsupc++ / cxxabi.h
1 // new abi support -*- C++ -*-
2   
3 // Copyright (C) 2000, 2002, 2003, 2004, 2006, 2007 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, 51 Franklin Street, Fifth Floor,
20 // Boston, MA 02110-1301, USA.
21
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.
30
31 // Written by Nathan Sidwell, Codesourcery LLC, <nathan@codesourcery.com>
32  
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.
37    
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.  */
41
42 /** @file cxxabi.h
43  *  The header provides an interface to the C++ ABI.
44  */
45
46 #ifndef _CXXABI_H
47 #define _CXXABI_H 1
48
49 #pragma GCC visibility push(default)
50
51 #include <stddef.h>
52 #include <bits/cxxabi_tweaks.h>
53 #include <cxxabi-forced.h>
54  
55 #ifdef __cplusplus
56 #define _GLIBCXX_NOTHROW throw() 
57 #else
58 #define _GLIBCXX_NOTHROW __attribute__((nothrow))
59 #endif
60
61 #ifdef __cplusplus
62 namespace __cxxabiv1
63 {  
64   extern "C" 
65   {
66 #endif
67
68   typedef __cxa_cdtor_return_type (*__cxa_cdtor_type)(void *);
69
70   // Allocate array.
71   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);
75
76   void*
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*));
81
82   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));
87
88   // Construct array.
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);
93
94   __cxa_vec_ctor_return_type
95   __cxa_vec_cctor(void* dest_array, void* src_array, size_t element_count, 
96                   size_t element_size, 
97                   __cxa_cdtor_return_type (*constructor) (void*, void*), 
98                   __cxa_cdtor_type destructor);
99  
100   // Destruct array.
101   void 
102   __cxa_vec_dtor(void* __array_address, size_t __element_count,
103                  size_t __element_size, __cxa_cdtor_type destructor);
104   
105   void 
106   __cxa_vec_cleanup(void* __array_address, size_t __element_count,
107                     size_t __element_size, __cxa_cdtor_type destructor);
108   
109   // Destruct and release array.
110   void 
111   __cxa_vec_delete(void* __array_address, size_t __element_size,
112                    size_t __padding_size, __cxa_cdtor_type destructor);
113
114   void 
115   __cxa_vec_delete2(void* __array_address, size_t __element_size,
116                     size_t __padding_size, __cxa_cdtor_type destructor,
117                     void (*__dealloc) (void*));
118                   
119   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));
123
124   int 
125   __cxa_guard_acquire(__guard*);
126
127   void 
128   __cxa_guard_release(__guard*);
129
130   void 
131   __cxa_guard_abort(__guard*);
132
133   // Pure virtual functions.
134   void
135   __cxa_pure_virtual(void);
136
137   // Exception handling.
138   void
139   __cxa_bad_cast();
140
141   void
142   __cxa_bad_typeid();
143
144   // DSO destruction.
145   int
146   __cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW;
147
148   int
149   __cxa_finalize(void*);
150
151   // Demangling routines. 
152   char*
153   __cxa_demangle(const char* __mangled_name, char* __output_buffer,
154                  size_t* __length, int* __status);
155 #ifdef __cplusplus
156   }
157 } // namespace __cxxabiv1
158 #endif
159
160 #ifdef __cplusplus
161
162 #include <typeinfo>
163
164 namespace __cxxabiv1
165 {
166   // Type information for int, float etc.
167   class __fundamental_type_info : public std::type_info
168   {
169   public:
170     explicit 
171     __fundamental_type_info(const char* __n) : std::type_info(__n) { }
172
173     virtual 
174     ~__fundamental_type_info();
175   };
176
177   // Type information for array objects.
178   class __array_type_info : public std::type_info
179   {
180   public:
181     explicit 
182     __array_type_info(const char* __n) : std::type_info(__n) { }
183
184     virtual 
185     ~__array_type_info();
186   };
187
188   // Type information for functions (both member and non-member).
189   class __function_type_info : public std::type_info
190   {
191   public:
192     explicit 
193     __function_type_info(const char* __n) : std::type_info(__n) { }
194
195     virtual 
196     ~__function_type_info();
197
198   protected:
199     // Implementation defined member function.
200     virtual bool 
201     __is_function_p() const;
202   };
203
204   // Type information for enumerations.
205   class __enum_type_info : public std::type_info
206   {
207   public:
208     explicit 
209     __enum_type_info(const char* __n) : std::type_info(__n) { }
210
211     virtual 
212     ~__enum_type_info();
213   };
214
215   // Common type information for simple pointers and pointers to member.
216   class __pbase_type_info : public std::type_info
217   {
218   public:
219     unsigned int                __flags; // Qualification of the target object.
220     const std::type_info*       __pointee; // Type of pointed to object.
221
222     explicit 
223     __pbase_type_info(const char* __n, int __quals, 
224                       const std::type_info* __type)
225     : std::type_info(__n), __flags(__quals), __pointee(__type)
226     { }
227     
228     virtual 
229     ~__pbase_type_info();
230
231     // Implementation defined type.
232     enum __masks 
233       {
234         __const_mask = 0x1,
235         __volatile_mask = 0x2,
236         __restrict_mask = 0x4,
237         __incomplete_mask = 0x8,
238         __incomplete_class_mask = 0x10
239       };
240
241   protected:
242     __pbase_type_info(const __pbase_type_info&);
243
244     __pbase_type_info&
245     operator=(const __pbase_type_info&);
246
247     // Implementation defined member functions.
248     virtual bool 
249     __do_catch(const std::type_info* __thr_type, void** __thr_obj, 
250                unsigned int __outer) const;
251
252     inline virtual bool 
253     __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
254                     unsigned __outer) const;
255   };
256
257   // Type information for simple pointers.
258   class __pointer_type_info : public __pbase_type_info
259   {
260   public:
261     explicit 
262     __pointer_type_info(const char* __n, int __quals, 
263                         const std::type_info* __type)
264     : __pbase_type_info (__n, __quals, __type) { }
265
266
267     virtual 
268     ~__pointer_type_info();
269
270   protected:
271     // Implementation defined member functions.
272     virtual bool 
273     __is_pointer_p() const;
274
275     virtual bool 
276     __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj, 
277                     unsigned __outer) const;
278   };
279
280   class __class_type_info;
281
282   // Type information for a pointer to member variable.
283   class __pointer_to_member_type_info : public __pbase_type_info
284   {
285   public:
286     __class_type_info* __context;   // Class of the member.
287
288     explicit 
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) { }
293
294     virtual 
295     ~__pointer_to_member_type_info();
296
297   protected:
298     __pointer_to_member_type_info(const __pointer_to_member_type_info&);
299
300     __pointer_to_member_type_info&
301     operator=(const __pointer_to_member_type_info&);
302
303     // Implementation defined member function.
304     virtual bool 
305     __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
306                     unsigned __outer) const;
307   };
308
309   // Helper class for __vmi_class_type.
310   class __base_class_type_info
311   {
312   public:
313     const __class_type_info*    __base_type;  // Base class type.
314     long                        __offset_flags;  // Offset and info.
315
316     enum __offset_flags_masks 
317       {
318         __virtual_mask = 0x1,
319         __public_mask = 0x2,
320         __hwm_bit = 2,
321         __offset_shift = 8          // Bits to shift offset.
322       };
323   
324     // Implementation defined member functions.
325     bool 
326     __is_virtual_p() const
327     { return __offset_flags & __virtual_mask; }
328
329     bool 
330     __is_public_p() const
331     { return __offset_flags & __public_mask; }
332
333     ptrdiff_t 
334     __offset() const
335     { 
336       // This shift, being of a signed type, is implementation
337       // defined. GCC implements such shifts as arithmetic, which is
338       // what we want.
339       return static_cast<ptrdiff_t>(__offset_flags) >> __offset_shift;
340     }
341   };
342
343   // Type information for a class.
344   class __class_type_info : public std::type_info
345   {
346   public:
347     explicit 
348     __class_type_info (const char *__n) : type_info(__n) { }
349
350     virtual 
351     ~__class_type_info ();
352
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.
358     enum __sub_kind
359       {
360         // We have no idea.
361         __unknown = 0, 
362
363         // Not contained within us (in some circumstances this might
364         // mean not contained publicly)
365         __not_contained, 
366
367         // Contained ambiguously.
368         __contained_ambig, 
369     
370         // Via a virtual path.
371         __contained_virtual_mask = __base_class_type_info::__virtual_mask, 
372
373         // Via a public path.
374         __contained_public_mask = __base_class_type_info::__public_mask,   
375
376         // Contained within us.
377         __contained_mask = 1 << __base_class_type_info::__hwm_bit,
378     
379         __contained_private = __contained_mask,
380         __contained_public = __contained_mask | __contained_public_mask
381       };
382
383     struct __upcast_result;
384     struct __dyncast_result;
385
386   protected:
387     // Implementation defined member functions.
388     virtual bool 
389     __do_upcast(const __class_type_info* __dst_type, void**__obj_ptr) const;
390
391     virtual bool 
392     __do_catch(const type_info* __thr_type, void** __thr_obj, 
393                unsigned __outer) const;
394
395   public:
396     // Helper for upcast. See if DST is us, or one of our bases. 
397     // Return false if not found, true if found. 
398     virtual bool 
399     __do_upcast(const __class_type_info* __dst, const void* __obj,
400                 __upcast_result& __restrict __result) const;
401
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.
408     inline __sub_kind 
409     __find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
410                       const __class_type_info* __src_type, 
411                       const void* __src_ptr) const;
412
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.
420     virtual bool 
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;
425     
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.
430     virtual __sub_kind 
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;
434   };
435
436   // Type information for a class with a single non-virtual base.
437   class __si_class_type_info : public __class_type_info
438   {
439   public:
440     const __class_type_info* __base_type;
441
442     explicit 
443     __si_class_type_info(const char *__n, const __class_type_info *__base)
444     : __class_type_info(__n), __base_type(__base) { }
445
446     virtual 
447     ~__si_class_type_info();
448
449   protected:
450     __si_class_type_info(const __si_class_type_info&);
451
452     __si_class_type_info&
453     operator=(const __si_class_type_info&);
454
455     // Implementation defined member functions.
456     virtual bool 
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;
461
462     virtual __sub_kind 
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;
466
467     virtual bool 
468     __do_upcast(const __class_type_info*__dst, const void*__obj,
469                 __upcast_result& __restrict __result) const;
470   };
471
472   // Type information for a class with multiple and/or virtual bases.
473   class __vmi_class_type_info : public __class_type_info 
474   {
475   public:
476     unsigned int                __flags;  // Details about the class hierarchy.
477     unsigned int                __base_count;  // Number of direct bases.
478
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.
483
484     explicit 
485     __vmi_class_type_info(const char* __n, int ___flags)
486     : __class_type_info(__n), __flags(___flags), __base_count(0) { }
487
488     virtual 
489     ~__vmi_class_type_info();
490
491     // Implementation defined types.
492     enum __flags_masks 
493       {
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
497       };
498
499   protected:
500     // Implementation defined member functions.
501     virtual bool 
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;
506
507     virtual __sub_kind 
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;
511     
512     virtual bool 
513     __do_upcast(const __class_type_info* __dst, const void* __obj,
514                 __upcast_result& __restrict __result) const;
515   };
516
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
524   extern "C" void*
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.
529
530
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();
535
536   // A magic placeholder class that can be caught by reference
537   // to recognize foreign exceptions.
538   class __foreign_exception
539   {
540     virtual ~__foreign_exception() throw();
541     virtual void __pure_dummy() = 0; // prevent catch by value
542   };
543
544 } // namespace __cxxabiv1
545
546 // User programs should use the alias `abi'. 
547 namespace abi = __cxxabiv1;
548
549 #endif // __cplusplus
550
551 #pragma GCC visibility pop
552
553 #endif // __CXXABI_H