Whole document tree
    

Whole document tree

cxxabi.h Source File
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

cxxabi.h

Go to the documentation of this file.
00001 // new abi support -*- C++ -*-
00002   
00003 // Copyright (C) 2000 Free Software Foundation, Inc.
00004 //
00005 // This file is part of GNU CC.
00006 //
00007 // GNU CC is free software; you can redistribute it and/or modify
00008 // it under the terms of the GNU General Public License as published by
00009 // the Free Software Foundation; either version 2, or (at your option)
00010 // any later version.
00011 // 
00012 // GNU CC is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 // 
00017 // You should have received a copy of the GNU General Public License
00018 // along with GNU CC; see the file COPYING.  If not, write to
00019 // the Free Software Foundation, 59 Temple Place - Suite 330,
00020 // Boston, MA 02111-1307, USA.
00021 
00022 // As a special exception, you may use this file as part of a free software
00023 // library without restriction.  Specifically, if other files instantiate
00024 // templates or use macros or inline functions from this file, or you compile
00025 // this file and link it with other files to produce an executable, this
00026 // file does not by itself cause the resulting executable to be covered by
00027 // the GNU General Public License.  This exception does not however
00028 // invalidate any other reasons why the executable file might be covered by
00029 // the GNU General Public License.
00030 
00031 // Written by Nathan Sidwell, Codesourcery LLC, <nathan@codesourcery.com>
00032  
00033 /* This file declares the new abi entry points into the runtime. It is not
00034    normally necessary for user programs to include this header, or use the
00035    entry points directly. However, this header is available should that be
00036    needed.
00037    
00038    Some of the entry points are intended for both C and C++, thus this header
00039    is includable from both C and C++. Though the C++ specific parts are not
00040    available in C, naturally enough.  */
00041 
00042 #ifndef __CXXABI_H
00043 #define __CXXABI_H 1
00044 
00045 #ifdef __cplusplus
00046 
00047 // We use the compiler builtins __SIZE_TYPE__ and __PTRDIFF_TYPE__ instead of
00048 // std::size_t and std::ptrdiff_t respectively. This makes us independant of
00049 // the conformance level of <cstddef> and whether -fhonor-std was supplied.
00050 // <cstddef> is not currently available during compiler building anyway.
00051 // Including <stddef.h> would be wrong, as that would rudely place size_t in
00052 // the global namespace.
00053 
00054 #include <typeinfo>
00055 
00056 namespace __cxxabiv1
00057 {
00058 
00059 /* type information for int, float etc */
00060 class __fundamental_type_info
00061   : public std::type_info
00062 {
00063 public:
00064   virtual ~__fundamental_type_info ();
00065 public:
00066   explicit __fundamental_type_info (const char *__n)
00067     : std::type_info (__n)
00068     { }
00069 };
00070 
00071 /* type information for array objects */
00072 class __array_type_info
00073   : public std::type_info
00074 {
00075 /* abi defined member functions */
00076 protected:
00077   virtual ~__array_type_info ();
00078 public:
00079   explicit __array_type_info (const char *__n)
00080     : std::type_info (__n)
00081     { }
00082 };
00083 
00084 /* type information for functions (both member and non-member) */
00085 class __function_type_info
00086   : public std::type_info
00087 {
00088 /* abi defined member functions */
00089 public:
00090   virtual ~__function_type_info ();
00091 public:
00092   explicit __function_type_info (const char *__n)
00093     : std::type_info (__n)
00094     { }
00095   
00096 /* implementation defined member functions */
00097 protected:
00098   virtual bool __is_function_p () const;
00099 };
00100 
00101 /* type information for enumerations */
00102 class __enum_type_info
00103   : public std::type_info
00104 {
00105 /* abi defined member functions */
00106 public:
00107   virtual ~__enum_type_info ();
00108 public:
00109   explicit __enum_type_info (const char *__n)
00110     : std::type_info (__n)
00111     { }
00112 };
00113 
00114 /* common type information for simple pointers and pointers to member */
00115 class __pbase_type_info
00116   : public std::type_info
00117 {
00118 /* abi defined member variables */
00119 public:
00120   unsigned int __qualifier_flags; /* qualification of the target object */
00121   const std::type_info *__pointee;   /* type of pointed to object */
00122 
00123 /* abi defined member functions */
00124 public:
00125   virtual ~__pbase_type_info ();
00126 public:
00127   explicit __pbase_type_info (const char *__n,
00128                                 int __quals,
00129                                 const std::type_info *__type)
00130     : std::type_info (__n), __qualifier_flags (__quals), __pointee (__type)
00131     { }
00132 
00133 /* implementation defined types */
00134 public:
00135   enum __qualifier_masks {
00136     __const_mask = 0x1,
00137     __volatile_mask = 0x2,
00138     __restrict_mask = 0x4,
00139     __incomplete_mask = 0x8,
00140     __incomplete_class_mask = 0x10
00141   };
00142 
00143 /* implementation defined member functions */
00144 protected:
00145   virtual bool __do_catch (const std::type_info *__thr_type,
00146                            void **__thr_obj,
00147                            unsigned __outer) const;
00148 protected:
00149   inline virtual bool __pointer_catch (const __pbase_type_info *__thr_type,
00150                                        void **__thr_obj,
00151                                        unsigned __outer) const;
00152 };
00153 
00154 /* type information for simple pointers */
00155 class __pointer_type_info
00156   : public __pbase_type_info
00157 {
00158 /* abi defined member functions */
00159 public:
00160   virtual ~__pointer_type_info ();
00161 public:
00162   explicit __pointer_type_info (const char *__n,
00163                                 int __quals,
00164                                 const std::type_info *__type)
00165     : __pbase_type_info (__n, __quals, __type)
00166     { }
00167 
00168 /* implementation defined member functions */
00169 protected:
00170   virtual bool __is_pointer_p () const;
00171 
00172 protected:
00173   virtual bool __pointer_catch (const __pbase_type_info *__thr_type,
00174                                 void **__thr_obj,
00175                                 unsigned __outer) const;
00176 };
00177 
00178 /* type information for a pointer to member variable */
00179 class __pointer_to_member_type_info
00180   : public __pbase_type_info
00181 {
00182 /* abi defined member variables */
00183 public:
00184   __class_type_info *__context_class;   /* class of the member */
00185 
00186 /* abi defined member functions */
00187 public:
00188   virtual ~__pointer_to_member_type_info ();
00189 public:
00190   explicit __pointer_to_member_type_info (const char *__n,
00191                                           int __quals,
00192                                           const std::type_info *__type,
00193                                           __class_type_info *__klass)
00194     : __pbase_type_info (__n, __quals, __type), __context_class (__klass)
00195     { }
00196 
00197 /* implementation defined member functions */
00198 protected:
00199   virtual bool __pointer_catch (const __pbase_type_info *__thr_type,
00200                                 void **__thr_obj,
00201                                 unsigned __outer) const;
00202 };
00203 
00204 class __class_type_info;
00205 
00206 /* helper class for __vmi_class_type */
00207 class __base_class_info
00208 {
00209 /* abi defined member variables */
00210 public:
00211   const __class_type_info *__base;    /* base class type */
00212   long __offset_flags;            /* offset and info */
00213 
00214 /* implementation defined types */
00215 public:
00216   enum __offset_flags_masks {
00217     __virtual_mask = 0x1,
00218     __public_mask = 0x2,
00219     hwm_bit = 2,
00220     offset_shift = 8          /* bits to shift offset by */
00221   };
00222   
00223 /* implementation defined member functions */
00224 public:
00225   bool __is_virtual_p () const
00226     { return __offset_flags & __virtual_mask; }
00227   bool __is_public_p () const
00228     { return __offset_flags & __public_mask; }
00229   __PTRDIFF_TYPE__ __offset () const
00230     { 
00231       // This shift, being of a signed type, is implementation defined. GCC
00232       // implements such shifts as arithmetic, which is what we want.
00233       return static_cast<__PTRDIFF_TYPE__> (__offset_flags) >> offset_shift;
00234     }
00235 };
00236 
00237 /* type information for a class */
00238 class __class_type_info
00239   : public std::type_info
00240 {
00241 /* abi defined member functions */
00242 public:
00243   virtual ~__class_type_info ();
00244 public:
00245   explicit __class_type_info (const char *__n)
00246     : type_info (__n)
00247     { }
00248 
00249 /* implementation defined types */
00250 public:
00251   /* sub_kind tells us about how a base object is contained within a derived
00252      object. We often do this lazily, hence the UNKNOWN value. At other times
00253      we may use NOT_CONTAINED to mean not publicly contained. */
00254   enum __sub_kind
00255   {
00256     __unknown = 0,              /* we have no idea */
00257     __not_contained,            /* not contained within us (in some */
00258                                 /* circumstances this might mean not contained */
00259                                 /* publicly) */
00260     __contained_ambig,          /* contained ambiguously */
00261     
00262     __contained_virtual_mask = __base_class_info::__virtual_mask, /* via a virtual path */
00263     __contained_public_mask = __base_class_info::__public_mask,   /* via a public path */
00264     __contained_mask = 1 << __base_class_info::hwm_bit,         /* contained within us */
00265     
00266     __contained_private = __contained_mask,
00267     __contained_public = __contained_mask | __contained_public_mask
00268   };
00269 
00270 public:  
00271   struct __upcast_result;
00272   struct __dyncast_result;
00273 
00274 /* implementation defined member functions */
00275 protected:
00276   virtual bool __do_upcast (const __class_type_info *__dst_type, void **__obj_ptr) const;
00277 
00278 protected:
00279   virtual bool __do_catch (const type_info *__thr_type, void **__thr_obj,
00280                            unsigned __outer) const;
00281 
00282 
00283 public:
00284   /* Helper for upcast. See if DST is us, or one of our bases. */
00285   /* Return false if not found, true if found. */
00286   virtual bool __do_upcast (const __class_type_info *__dst,
00287                             const void *__obj,
00288                             __upcast_result &__restrict __result) const;
00289 
00290 public:
00291   /* Indicate whether SRC_PTR of type SRC_TYPE is contained publicly within
00292      OBJ_PTR. OBJ_PTR points to a base object of our type, which is the
00293      destination type. SRC2DST indicates how SRC objects might be contained
00294      within this type.  If SRC_PTR is one of our SRC_TYPE bases, indicate the
00295      virtuality. Returns not_contained for non containment or private
00296      containment. */
00297   inline __sub_kind __find_public_src (__PTRDIFF_TYPE__ __src2dst,
00298                                        const void *__obj_ptr,
00299                                        const __class_type_info *__src_type,
00300                                        const void *__src_ptr) const;
00301 
00302 public:
00303   /* dynamic cast helper. ACCESS_PATH gives the access from the most derived
00304      object to this base. DST_TYPE indicates the desired type we want. OBJ_PTR
00305      points to a base of our type within the complete object. SRC_TYPE
00306      indicates the static type started from and SRC_PTR points to that base
00307      within the most derived object. Fill in RESULT with what we find. Return
00308      true if we have located an ambiguous match. */
00309   virtual bool __do_dyncast (__PTRDIFF_TYPE__ __src2dst,
00310                              __sub_kind __access_path,
00311                              const __class_type_info *__dst_type,
00312                              const void *__obj_ptr,
00313                              const __class_type_info *__src_type,
00314                              const void *__src_ptr,
00315                              __dyncast_result &__result) const;
00316 public:
00317   /* Helper for find_public_subobj. SRC2DST indicates how SRC_TYPE bases are
00318      inherited by the type started from -- which is not necessarily the
00319      current type. The current type will be a base of the destination type.
00320      OBJ_PTR points to the current base. */
00321   virtual __sub_kind __do_find_public_src (__PTRDIFF_TYPE__ __src2dst,
00322                                            const void *__obj_ptr,
00323                                            const __class_type_info *__src_type,
00324                                            const void *__src_ptr) const;
00325 };
00326 
00327 /* type information for a class with a single non-virtual base */
00328 class __si_class_type_info
00329   : public __class_type_info
00330 {
00331 /* abi defined member variables */
00332 public:
00333   const __class_type_info *__base_type;
00334 
00335 /* abi defined member functions */
00336 public:
00337   virtual ~__si_class_type_info ();
00338 public:
00339   explicit __si_class_type_info (const char *__n,
00340                                  const __class_type_info *__base)
00341     : __class_type_info (__n), __base_type (__base)
00342     { }
00343 
00344 /* implementation defined member functions */
00345 protected:
00346   virtual bool __do_dyncast (__PTRDIFF_TYPE__ __src2dst,
00347                              __sub_kind __access_path,
00348                              const __class_type_info *__dst_type,
00349                              const void *__obj_ptr,
00350                              const __class_type_info *__src_type,
00351                              const void *__src_ptr,
00352                              __dyncast_result &__result) const;
00353   virtual __sub_kind __do_find_public_src (__PTRDIFF_TYPE__ __src2dst,
00354                                            const void *__obj_ptr,
00355                                            const __class_type_info *__src_type,
00356                                            const void *__sub_ptr) const;
00357   virtual bool __do_upcast (const __class_type_info *__dst,
00358                             const void *__obj,
00359                             __upcast_result &__restrict __result) const;
00360 };
00361 
00362 /* type information for a class with multiple and/or virtual bases */
00363 class __vmi_class_type_info : public __class_type_info {
00364 /* abi defined member variables */
00365 public:
00366   unsigned int __flags;         /* details about the class heirarchy */
00367   unsigned int __base_count;    /* number of direct bases */
00368   __base_class_info const __base_info[1]; /* array of bases */
00369   /* The array of bases uses the trailing array struct hack
00370      so this class is not constructable with a normal constructor. It is
00371      internally generated by the compiler. */
00372 
00373 /* abi defined member functions */
00374 public:
00375   virtual ~__vmi_class_type_info ();
00376 public:
00377   explicit __vmi_class_type_info (const char *__n,
00378                                   int ___flags)
00379     : __class_type_info (__n), __flags (___flags), __base_count (0)
00380     { }
00381 
00382 /* implementation defined types */
00383 public:
00384   enum __flags_masks {
00385     __non_diamond_repeat_mask = 0x1,   /* distinct instance of repeated base */
00386     __diamond_shaped_mask = 0x2,       /* diamond shaped multiple inheritance */
00387     non_public_base_mask = 0x4,      /* has non-public direct or indirect base */
00388     public_base_mask = 0x8,          /* has public base (direct) */
00389     
00390     __flags_unknown_mask = 0x10
00391   };
00392 
00393 /* implementation defined member functions */
00394 protected:
00395   virtual bool __do_dyncast (__PTRDIFF_TYPE__ __src2dst,
00396                              __sub_kind __access_path,
00397                              const __class_type_info *__dst_type,
00398                              const void *__obj_ptr,
00399                              const __class_type_info *__src_type,
00400                              const void *__src_ptr,
00401                              __dyncast_result &__result) const;
00402   virtual __sub_kind __do_find_public_src (__PTRDIFF_TYPE__ __src2dst,
00403                                            const void *__obj_ptr,
00404                                            const __class_type_info *__src_type,
00405                                            const void *__src_ptr) const;
00406   virtual bool __do_upcast (const __class_type_info *__dst,
00407                             const void *__obj,
00408                             __upcast_result &__restrict __result) const;
00409 };
00410 
00411 /* dynamic cast runtime */
00412 extern "C"
00413 void *__dynamic_cast (const void *__src_ptr,    /* object started from */
00414                       const __class_type_info *__src_type, /* static type of object */
00415                       const __class_type_info *__dst_type, /* desired target type */
00416                       __PTRDIFF_TYPE__ __src2dst); /* how src and dst are related */
00417 
00418     /* src2dst has the following possible values
00419        >= 0: src_type is a unique public non-virtual base of dst_type
00420              dst_ptr + src2dst == src_ptr
00421        -1: unspecified relationship
00422        -2: src_type is not a public base of dst_type
00423        -3: src_type is a multiple public non-virtual base of dst_type */
00424 
00425 /* array ctor/dtor routines */
00426 
00427 /* allocate and construct array */
00428 extern "C"
00429 void *__cxa_vec_new (__SIZE_TYPE__ __element_count,
00430                      __SIZE_TYPE__ __element_size,
00431                      __SIZE_TYPE__ __padding_size,
00432                      void (*__constructor) (void *),
00433                      void (*__destructor) (void *));
00434 
00435 extern "C"
00436 void *__cxa_vec_new2 (__SIZE_TYPE__ __element_count,
00437                       __SIZE_TYPE__ __element_size,
00438                       __SIZE_TYPE__ __padding_size,
00439                       void (*__constructor) (void *),
00440                       void (*__destructor) (void *),
00441                       void *(*__alloc) (__SIZE_TYPE__),
00442                       void (*__dealloc) (void *));
00443 
00444 extern "C"
00445 void *__cxa_vec_new3 (__SIZE_TYPE__ __element_count,
00446                       __SIZE_TYPE__ __element_size,
00447                       __SIZE_TYPE__ __padding_size,
00448                       void (*__constructor) (void *),
00449                       void (*__destructor) (void *),
00450                       void *(*__alloc) (__SIZE_TYPE__),
00451                       void (*__dealloc) (void *, __SIZE_TYPE__));
00452 
00453 /* construct array */
00454 extern "C"
00455 void __cxa_vec_ctor (void *__array_address,
00456                      __SIZE_TYPE__ __element_count,
00457                      __SIZE_TYPE__ __element_size,
00458                      void (*__constructor) (void *),
00459                      void (*__destructor) (void *));
00460 
00461 extern "C"
00462 void __cxa_vec_cctor (void *dest_array,
00463               void *src_array,
00464               __SIZE_TYPE__ element_count,
00465               __SIZE_TYPE__ element_size,
00466               void (*constructor) (void *, void *),
00467               void (*destructor) (void *));
00468  
00469 /* destruct array */
00470 extern "C"
00471 void __cxa_vec_dtor (void *__array_address,
00472                      __SIZE_TYPE__ __element_count,
00473                      __SIZE_TYPE__ __element_size,
00474                      void (*__destructor) (void *));
00475 
00476 /* destruct array */
00477 extern "C"
00478 void __cxa_vec_cleanup (void *__array_address,
00479             __SIZE_TYPE__ __element_count,
00480             __SIZE_TYPE__ __element_size,
00481             void (*__destructor) (void *));
00482 
00483 /* destruct and release array */
00484 extern "C"
00485 void __cxa_vec_delete (void *__array_address,
00486                        __SIZE_TYPE__ __element_size,
00487                        __SIZE_TYPE__ __padding_size,
00488                        void (*__destructor) (void *));
00489 
00490 extern "C"
00491 void __cxa_vec_delete2 (void *__array_address,
00492                         __SIZE_TYPE__ __element_size,
00493                         __SIZE_TYPE__ __padding_size,
00494                         void (*__destructor) (void *),
00495                         void (*__dealloc) (void *));
00496                   
00497 extern "C"
00498 void __cxa_vec_delete3 (void *__array_address,
00499                         __SIZE_TYPE__ __element_size,
00500                         __SIZE_TYPE__ __padding_size,
00501                         void (*__destructor) (void *),
00502                         void (*__dealloc) (void *, __SIZE_TYPE__));
00503                   
00504 /* demangling routines */
00505 
00506 extern "C" 
00507 char *__cxa_demangle (const char *__mangled_name,
00508               char *__output_buffer,
00509               __SIZE_TYPE__ *__length,
00510               int *__status);
00511 
00512 } /* namespace __cxxabiv1 */
00513 
00514 /* User programs should use the alias `abi'. */
00515 namespace abi = __cxxabiv1;
00516 
00517 #else
00518 #endif /* __cplusplus */
00519 
00520 
00521 #endif /* __CXXABI_H */

Generated on Mon Apr 8 03:11:24 2002 for libstdc++-v3 Source by doxygen1.2.15