xref: /dflybsd-src/contrib/gcc-8.0/libstdc++-v3/libsupc++/cxxabi.h (revision 38fd149817dfbff97799f62fcb70be98c4e32523)
1*38fd1498Szrj // ABI Support -*- C++ -*-
2*38fd1498Szrj 
3*38fd1498Szrj // Copyright (C) 2000-2018 Free Software Foundation, Inc.
4*38fd1498Szrj //
5*38fd1498Szrj // This file is part of GCC.
6*38fd1498Szrj //
7*38fd1498Szrj // GCC is free software; you can redistribute it and/or modify
8*38fd1498Szrj // it under the terms of the GNU General Public License as published by
9*38fd1498Szrj // the Free Software Foundation; either version 3, or (at your option)
10*38fd1498Szrj // any later version.
11*38fd1498Szrj //
12*38fd1498Szrj // GCC is distributed in the hope that it will be useful,
13*38fd1498Szrj // but WITHOUT ANY WARRANTY; without even the implied warranty of
14*38fd1498Szrj // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*38fd1498Szrj // GNU General Public License for more details.
16*38fd1498Szrj //
17*38fd1498Szrj // Under Section 7 of GPL version 3, you are granted additional
18*38fd1498Szrj // permissions described in the GCC Runtime Library Exception, version
19*38fd1498Szrj // 3.1, as published by the Free Software Foundation.
20*38fd1498Szrj 
21*38fd1498Szrj // You should have received a copy of the GNU General Public License and
22*38fd1498Szrj // a copy of the GCC Runtime Library Exception along with this program;
23*38fd1498Szrj // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24*38fd1498Szrj // <http://www.gnu.org/licenses/>.
25*38fd1498Szrj 
26*38fd1498Szrj // Written by Nathan Sidwell, Codesourcery LLC, <nathan@codesourcery.com>
27*38fd1498Szrj 
28*38fd1498Szrj /* This file declares the new abi entry points into the runtime. It is not
29*38fd1498Szrj    normally necessary for user programs to include this header, or use the
30*38fd1498Szrj    entry points directly. However, this header is available should that be
31*38fd1498Szrj    needed.
32*38fd1498Szrj 
33*38fd1498Szrj    Some of the entry points are intended for both C and C++, thus this header
34*38fd1498Szrj    is includable from both C and C++. Though the C++ specific parts are not
35*38fd1498Szrj    available in C, naturally enough.  */
36*38fd1498Szrj 
37*38fd1498Szrj /** @file cxxabi.h
38*38fd1498Szrj  *  The header provides an interface to the C++ ABI.
39*38fd1498Szrj  */
40*38fd1498Szrj 
41*38fd1498Szrj #ifndef _CXXABI_H
42*38fd1498Szrj #define _CXXABI_H 1
43*38fd1498Szrj 
44*38fd1498Szrj #pragma GCC system_header
45*38fd1498Szrj 
46*38fd1498Szrj #pragma GCC visibility push(default)
47*38fd1498Szrj 
48*38fd1498Szrj #include <stddef.h>
49*38fd1498Szrj #include <bits/c++config.h>
50*38fd1498Szrj #include <bits/cxxabi_tweaks.h>
51*38fd1498Szrj #include <bits/cxxabi_forced.h>
52*38fd1498Szrj #include <bits/cxxabi_init_exception.h>
53*38fd1498Szrj 
54*38fd1498Szrj #ifdef __cplusplus
55*38fd1498Szrj namespace __cxxabiv1
56*38fd1498Szrj {
57*38fd1498Szrj   extern "C"
58*38fd1498Szrj   {
59*38fd1498Szrj #endif
60*38fd1498Szrj 
61*38fd1498Szrj   typedef __cxa_cdtor_return_type (*__cxa_cdtor_type)(void *);
62*38fd1498Szrj 
63*38fd1498Szrj   // Allocate array.
64*38fd1498Szrj   void*
65*38fd1498Szrj   __cxa_vec_new(size_t __element_count, size_t __element_size,
66*38fd1498Szrj 		size_t __padding_size, __cxa_cdtor_type __constructor,
67*38fd1498Szrj 		__cxa_cdtor_type __destructor);
68*38fd1498Szrj 
69*38fd1498Szrj   void*
70*38fd1498Szrj   __cxa_vec_new2(size_t __element_count, size_t __element_size,
71*38fd1498Szrj 		 size_t __padding_size, __cxa_cdtor_type __constructor,
72*38fd1498Szrj 		 __cxa_cdtor_type __destructor, void *(*__alloc) (size_t),
73*38fd1498Szrj 		 void (*__dealloc) (void*));
74*38fd1498Szrj 
75*38fd1498Szrj   void*
76*38fd1498Szrj   __cxa_vec_new3(size_t __element_count, size_t __element_size,
77*38fd1498Szrj 		 size_t __padding_size, __cxa_cdtor_type __constructor,
78*38fd1498Szrj 		 __cxa_cdtor_type __destructor, void *(*__alloc) (size_t),
79*38fd1498Szrj 		 void (*__dealloc) (void*, size_t));
80*38fd1498Szrj 
81*38fd1498Szrj   // Construct array.
82*38fd1498Szrj   __cxa_vec_ctor_return_type
83*38fd1498Szrj   __cxa_vec_ctor(void* __array_address, size_t __element_count,
84*38fd1498Szrj 		 size_t __element_size, __cxa_cdtor_type __constructor,
85*38fd1498Szrj 		 __cxa_cdtor_type __destructor);
86*38fd1498Szrj 
87*38fd1498Szrj   __cxa_vec_ctor_return_type
88*38fd1498Szrj   __cxa_vec_cctor(void* __dest_array, void* __src_array,
89*38fd1498Szrj 		  size_t __element_count, size_t __element_size,
90*38fd1498Szrj 		  __cxa_cdtor_return_type (*__constructor) (void*, void*),
91*38fd1498Szrj 		  __cxa_cdtor_type __destructor);
92*38fd1498Szrj 
93*38fd1498Szrj   // Destruct array.
94*38fd1498Szrj   void
95*38fd1498Szrj   __cxa_vec_dtor(void* __array_address, size_t __element_count,
96*38fd1498Szrj 		 size_t __element_size, __cxa_cdtor_type __destructor);
97*38fd1498Szrj 
98*38fd1498Szrj   void
99*38fd1498Szrj   __cxa_vec_cleanup(void* __array_address, size_t __element_count, size_t __s,
100*38fd1498Szrj 		    __cxa_cdtor_type __destructor) _GLIBCXX_NOTHROW;
101*38fd1498Szrj 
102*38fd1498Szrj   // Destruct and release array.
103*38fd1498Szrj   void
104*38fd1498Szrj   __cxa_vec_delete(void* __array_address, size_t __element_size,
105*38fd1498Szrj 		   size_t __padding_size, __cxa_cdtor_type __destructor);
106*38fd1498Szrj 
107*38fd1498Szrj   void
108*38fd1498Szrj   __cxa_vec_delete2(void* __array_address, size_t __element_size,
109*38fd1498Szrj 		    size_t __padding_size, __cxa_cdtor_type __destructor,
110*38fd1498Szrj 		    void (*__dealloc) (void*));
111*38fd1498Szrj 
112*38fd1498Szrj   void
113*38fd1498Szrj   __cxa_vec_delete3(void* __array_address, size_t __element_size,
114*38fd1498Szrj 		    size_t __padding_size, __cxa_cdtor_type __destructor,
115*38fd1498Szrj 		    void (*__dealloc) (void*, size_t));
116*38fd1498Szrj 
117*38fd1498Szrj   int
118*38fd1498Szrj   __cxa_guard_acquire(__guard*);
119*38fd1498Szrj 
120*38fd1498Szrj   void
121*38fd1498Szrj   __cxa_guard_release(__guard*) _GLIBCXX_NOTHROW;
122*38fd1498Szrj 
123*38fd1498Szrj   void
124*38fd1498Szrj   __cxa_guard_abort(__guard*) _GLIBCXX_NOTHROW;
125*38fd1498Szrj 
126*38fd1498Szrj   // DSO destruction.
127*38fd1498Szrj   int
128*38fd1498Szrj   __cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW;
129*38fd1498Szrj 
130*38fd1498Szrj   int
131*38fd1498Szrj   __cxa_finalize(void*);
132*38fd1498Szrj 
133*38fd1498Szrj   // TLS destruction.
134*38fd1498Szrj   int
135*38fd1498Szrj   __cxa_thread_atexit(void (*)(void*), void*, void *) _GLIBCXX_NOTHROW;
136*38fd1498Szrj 
137*38fd1498Szrj   // Pure virtual functions.
138*38fd1498Szrj   void
139*38fd1498Szrj   __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
140*38fd1498Szrj 
141*38fd1498Szrj   void
142*38fd1498Szrj   __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
143*38fd1498Szrj 
144*38fd1498Szrj   // Exception handling auxiliary.
145*38fd1498Szrj   void
146*38fd1498Szrj   __cxa_bad_cast() __attribute__((__noreturn__));
147*38fd1498Szrj 
148*38fd1498Szrj   void
149*38fd1498Szrj   __cxa_bad_typeid() __attribute__((__noreturn__));
150*38fd1498Szrj 
151*38fd1498Szrj   void
152*38fd1498Szrj   __cxa_throw_bad_array_new_length() __attribute__((__noreturn__));
153*38fd1498Szrj 
154*38fd1498Szrj   /**
155*38fd1498Szrj    *  @brief Demangling routine.
156*38fd1498Szrj    *  ABI-mandated entry point in the C++ runtime library for demangling.
157*38fd1498Szrj    *
158*38fd1498Szrj    *  @param __mangled_name A NUL-terminated character string
159*38fd1498Szrj    *  containing the name to be demangled.
160*38fd1498Szrj    *
161*38fd1498Szrj    *  @param __output_buffer A region of memory, allocated with
162*38fd1498Szrj    *  malloc, of @a *__length bytes, into which the demangled name is
163*38fd1498Szrj    *  stored.  If @a __output_buffer is not long enough, it is
164*38fd1498Szrj    *  expanded using realloc.  @a __output_buffer may instead be NULL;
165*38fd1498Szrj    *  in that case, the demangled name is placed in a region of memory
166*38fd1498Szrj    *  allocated with malloc.
167*38fd1498Szrj    *
168*38fd1498Szrj    *  @param __length If @a __length is non-NULL, the length of the
169*38fd1498Szrj    *  buffer containing the demangled name is placed in @a *__length.
170*38fd1498Szrj    *
171*38fd1498Szrj    *  @param __status @a *__status is set to one of the following values:
172*38fd1498Szrj    *   0: The demangling operation succeeded.
173*38fd1498Szrj    *  -1: A memory allocation failure occurred.
174*38fd1498Szrj    *  -2: @a mangled_name is not a valid name under the C++ ABI mangling rules.
175*38fd1498Szrj    *  -3: One of the arguments is invalid.
176*38fd1498Szrj    *
177*38fd1498Szrj    *  @return A pointer to the start of the NUL-terminated demangled
178*38fd1498Szrj    *  name, or NULL if the demangling fails.  The caller is
179*38fd1498Szrj    *  responsible for deallocating this memory using @c free.
180*38fd1498Szrj    *
181*38fd1498Szrj    *  The demangling is performed using the C++ ABI mangling rules,
182*38fd1498Szrj    *  with GNU extensions. For example, this function is used in
183*38fd1498Szrj    *  __gnu_cxx::__verbose_terminate_handler.
184*38fd1498Szrj    *
185*38fd1498Szrj    *  See https://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_demangling.html
186*38fd1498Szrj    *  for other examples of use.
187*38fd1498Szrj    *
188*38fd1498Szrj    *  @note The same demangling functionality is available via
189*38fd1498Szrj    *  libiberty (@c <libiberty/demangle.h> and @c libiberty.a) in GCC
190*38fd1498Szrj    *  3.1 and later, but that requires explicit installation (@c
191*38fd1498Szrj    *  --enable-install-libiberty) and uses a different API, although
192*38fd1498Szrj    *  the ABI is unchanged.
193*38fd1498Szrj    */
194*38fd1498Szrj   char*
195*38fd1498Szrj   __cxa_demangle(const char* __mangled_name, char* __output_buffer,
196*38fd1498Szrj 		 size_t* __length, int* __status);
197*38fd1498Szrj 
198*38fd1498Szrj #ifdef __cplusplus
199*38fd1498Szrj   }
200*38fd1498Szrj } // namespace __cxxabiv1
201*38fd1498Szrj #endif
202*38fd1498Szrj 
203*38fd1498Szrj #ifdef __cplusplus
204*38fd1498Szrj 
205*38fd1498Szrj #include <typeinfo>
206*38fd1498Szrj 
207*38fd1498Szrj namespace __cxxabiv1
208*38fd1498Szrj {
209*38fd1498Szrj   // Type information for int, float etc.
210*38fd1498Szrj   class __fundamental_type_info : public std::type_info
211*38fd1498Szrj   {
212*38fd1498Szrj   public:
213*38fd1498Szrj     explicit
__fundamental_type_info(const char * __n)214*38fd1498Szrj     __fundamental_type_info(const char* __n) : std::type_info(__n) { }
215*38fd1498Szrj 
216*38fd1498Szrj     virtual
217*38fd1498Szrj     ~__fundamental_type_info();
218*38fd1498Szrj   };
219*38fd1498Szrj 
220*38fd1498Szrj   // Type information for array objects.
221*38fd1498Szrj   class __array_type_info : public std::type_info
222*38fd1498Szrj   {
223*38fd1498Szrj   public:
224*38fd1498Szrj     explicit
__array_type_info(const char * __n)225*38fd1498Szrj     __array_type_info(const char* __n) : std::type_info(__n) { }
226*38fd1498Szrj 
227*38fd1498Szrj     virtual
228*38fd1498Szrj     ~__array_type_info();
229*38fd1498Szrj   };
230*38fd1498Szrj 
231*38fd1498Szrj   // Type information for functions (both member and non-member).
232*38fd1498Szrj   class __function_type_info : public std::type_info
233*38fd1498Szrj   {
234*38fd1498Szrj   public:
235*38fd1498Szrj     explicit
__function_type_info(const char * __n)236*38fd1498Szrj     __function_type_info(const char* __n) : std::type_info(__n) { }
237*38fd1498Szrj 
238*38fd1498Szrj     virtual
239*38fd1498Szrj     ~__function_type_info();
240*38fd1498Szrj 
241*38fd1498Szrj   protected:
242*38fd1498Szrj     // Implementation defined member function.
243*38fd1498Szrj     virtual bool
244*38fd1498Szrj     __is_function_p() const;
245*38fd1498Szrj   };
246*38fd1498Szrj 
247*38fd1498Szrj   // Type information for enumerations.
248*38fd1498Szrj   class __enum_type_info : public std::type_info
249*38fd1498Szrj   {
250*38fd1498Szrj   public:
251*38fd1498Szrj     explicit
__enum_type_info(const char * __n)252*38fd1498Szrj     __enum_type_info(const char* __n) : std::type_info(__n) { }
253*38fd1498Szrj 
254*38fd1498Szrj     virtual
255*38fd1498Szrj     ~__enum_type_info();
256*38fd1498Szrj   };
257*38fd1498Szrj 
258*38fd1498Szrj   // Common type information for simple pointers and pointers to member.
259*38fd1498Szrj   class __pbase_type_info : public std::type_info
260*38fd1498Szrj   {
261*38fd1498Szrj   public:
262*38fd1498Szrj     unsigned int 		__flags; // Qualification of the target object.
263*38fd1498Szrj     const std::type_info* 	__pointee; // Type of pointed to object.
264*38fd1498Szrj 
265*38fd1498Szrj     explicit
__pbase_type_info(const char * __n,int __quals,const std::type_info * __type)266*38fd1498Szrj     __pbase_type_info(const char* __n, int __quals,
267*38fd1498Szrj 		      const std::type_info* __type)
268*38fd1498Szrj     : std::type_info(__n), __flags(__quals), __pointee(__type)
269*38fd1498Szrj     { }
270*38fd1498Szrj 
271*38fd1498Szrj     virtual
272*38fd1498Szrj     ~__pbase_type_info();
273*38fd1498Szrj 
274*38fd1498Szrj     // Implementation defined type.
275*38fd1498Szrj     enum __masks
276*38fd1498Szrj       {
277*38fd1498Szrj 	__const_mask = 0x1,
278*38fd1498Szrj 	__volatile_mask = 0x2,
279*38fd1498Szrj 	__restrict_mask = 0x4,
280*38fd1498Szrj 	__incomplete_mask = 0x8,
281*38fd1498Szrj 	__incomplete_class_mask = 0x10,
282*38fd1498Szrj 	__transaction_safe_mask = 0x20,
283*38fd1498Szrj 	__noexcept_mask = 0x40
284*38fd1498Szrj       };
285*38fd1498Szrj 
286*38fd1498Szrj   protected:
287*38fd1498Szrj     __pbase_type_info(const __pbase_type_info&);
288*38fd1498Szrj 
289*38fd1498Szrj     __pbase_type_info&
290*38fd1498Szrj     operator=(const __pbase_type_info&);
291*38fd1498Szrj 
292*38fd1498Szrj     // Implementation defined member functions.
293*38fd1498Szrj     virtual bool
294*38fd1498Szrj     __do_catch(const std::type_info* __thr_type, void** __thr_obj,
295*38fd1498Szrj 	       unsigned int __outer) const;
296*38fd1498Szrj 
297*38fd1498Szrj     inline virtual bool
298*38fd1498Szrj     __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
299*38fd1498Szrj 		    unsigned __outer) const;
300*38fd1498Szrj   };
301*38fd1498Szrj 
302*38fd1498Szrj   inline bool __pbase_type_info::
__pointer_catch(const __pbase_type_info * thrown_type,void ** thr_obj,unsigned outer)303*38fd1498Szrj   __pointer_catch (const __pbase_type_info *thrown_type,
304*38fd1498Szrj 		   void **thr_obj,
305*38fd1498Szrj 		   unsigned outer) const
306*38fd1498Szrj   {
307*38fd1498Szrj     return __pointee->__do_catch (thrown_type->__pointee, thr_obj, outer + 2);
308*38fd1498Szrj   }
309*38fd1498Szrj 
310*38fd1498Szrj   // Type information for simple pointers.
311*38fd1498Szrj   class __pointer_type_info : public __pbase_type_info
312*38fd1498Szrj   {
313*38fd1498Szrj   public:
314*38fd1498Szrj     explicit
__pointer_type_info(const char * __n,int __quals,const std::type_info * __type)315*38fd1498Szrj     __pointer_type_info(const char* __n, int __quals,
316*38fd1498Szrj 			const std::type_info* __type)
317*38fd1498Szrj     : __pbase_type_info (__n, __quals, __type) { }
318*38fd1498Szrj 
319*38fd1498Szrj 
320*38fd1498Szrj     virtual
321*38fd1498Szrj     ~__pointer_type_info();
322*38fd1498Szrj 
323*38fd1498Szrj   protected:
324*38fd1498Szrj     // Implementation defined member functions.
325*38fd1498Szrj     virtual bool
326*38fd1498Szrj     __is_pointer_p() const;
327*38fd1498Szrj 
328*38fd1498Szrj     virtual bool
329*38fd1498Szrj     __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
330*38fd1498Szrj 		    unsigned __outer) const;
331*38fd1498Szrj   };
332*38fd1498Szrj 
333*38fd1498Szrj   class __class_type_info;
334*38fd1498Szrj 
335*38fd1498Szrj   // Type information for a pointer to member variable.
336*38fd1498Szrj   class __pointer_to_member_type_info : public __pbase_type_info
337*38fd1498Szrj   {
338*38fd1498Szrj   public:
339*38fd1498Szrj     __class_type_info* __context;   // Class of the member.
340*38fd1498Szrj 
341*38fd1498Szrj     explicit
__pointer_to_member_type_info(const char * __n,int __quals,const std::type_info * __type,__class_type_info * __klass)342*38fd1498Szrj     __pointer_to_member_type_info(const char* __n, int __quals,
343*38fd1498Szrj 				  const std::type_info* __type,
344*38fd1498Szrj 				  __class_type_info* __klass)
345*38fd1498Szrj     : __pbase_type_info(__n, __quals, __type), __context(__klass) { }
346*38fd1498Szrj 
347*38fd1498Szrj     virtual
348*38fd1498Szrj     ~__pointer_to_member_type_info();
349*38fd1498Szrj 
350*38fd1498Szrj   protected:
351*38fd1498Szrj     __pointer_to_member_type_info(const __pointer_to_member_type_info&);
352*38fd1498Szrj 
353*38fd1498Szrj     __pointer_to_member_type_info&
354*38fd1498Szrj     operator=(const __pointer_to_member_type_info&);
355*38fd1498Szrj 
356*38fd1498Szrj     // Implementation defined member function.
357*38fd1498Szrj     virtual bool
358*38fd1498Szrj     __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
359*38fd1498Szrj 		    unsigned __outer) const;
360*38fd1498Szrj   };
361*38fd1498Szrj 
362*38fd1498Szrj   // Helper class for __vmi_class_type.
363*38fd1498Szrj   class __base_class_type_info
364*38fd1498Szrj   {
365*38fd1498Szrj   public:
366*38fd1498Szrj     const __class_type_info* 	__base_type;  // Base class type.
367*38fd1498Szrj #ifdef _GLIBCXX_LLP64
368*38fd1498Szrj     long long			__offset_flags;  // Offset and info.
369*38fd1498Szrj #else
370*38fd1498Szrj     long 			__offset_flags;  // Offset and info.
371*38fd1498Szrj #endif
372*38fd1498Szrj 
373*38fd1498Szrj     enum __offset_flags_masks
374*38fd1498Szrj       {
375*38fd1498Szrj 	__virtual_mask = 0x1,
376*38fd1498Szrj 	__public_mask = 0x2,
377*38fd1498Szrj 	__hwm_bit = 2,
378*38fd1498Szrj 	__offset_shift = 8          // Bits to shift offset.
379*38fd1498Szrj       };
380*38fd1498Szrj 
381*38fd1498Szrj     // Implementation defined member functions.
382*38fd1498Szrj     bool
__is_virtual_p()383*38fd1498Szrj     __is_virtual_p() const
384*38fd1498Szrj     { return __offset_flags & __virtual_mask; }
385*38fd1498Szrj 
386*38fd1498Szrj     bool
__is_public_p()387*38fd1498Szrj     __is_public_p() const
388*38fd1498Szrj     { return __offset_flags & __public_mask; }
389*38fd1498Szrj 
390*38fd1498Szrj     ptrdiff_t
__offset()391*38fd1498Szrj     __offset() const
392*38fd1498Szrj     {
393*38fd1498Szrj       // This shift, being of a signed type, is implementation
394*38fd1498Szrj       // defined. GCC implements such shifts as arithmetic, which is
395*38fd1498Szrj       // what we want.
396*38fd1498Szrj       return static_cast<ptrdiff_t>(__offset_flags) >> __offset_shift;
397*38fd1498Szrj     }
398*38fd1498Szrj   };
399*38fd1498Szrj 
400*38fd1498Szrj   // Type information for a class.
401*38fd1498Szrj   class __class_type_info : public std::type_info
402*38fd1498Szrj   {
403*38fd1498Szrj   public:
404*38fd1498Szrj     explicit
__class_type_info(const char * __n)405*38fd1498Szrj     __class_type_info (const char *__n) : type_info(__n) { }
406*38fd1498Szrj 
407*38fd1498Szrj     virtual
408*38fd1498Szrj     ~__class_type_info ();
409*38fd1498Szrj 
410*38fd1498Szrj     // Implementation defined types.
411*38fd1498Szrj     // The type sub_kind tells us about how a base object is contained
412*38fd1498Szrj     // within a derived object. We often do this lazily, hence the
413*38fd1498Szrj     // UNKNOWN value. At other times we may use NOT_CONTAINED to mean
414*38fd1498Szrj     // not publicly contained.
415*38fd1498Szrj     enum __sub_kind
416*38fd1498Szrj       {
417*38fd1498Szrj 	// We have no idea.
418*38fd1498Szrj 	__unknown = 0,
419*38fd1498Szrj 
420*38fd1498Szrj 	// Not contained within us (in some circumstances this might
421*38fd1498Szrj 	// mean not contained publicly)
422*38fd1498Szrj 	__not_contained,
423*38fd1498Szrj 
424*38fd1498Szrj 	// Contained ambiguously.
425*38fd1498Szrj 	__contained_ambig,
426*38fd1498Szrj 
427*38fd1498Szrj 	// Via a virtual path.
428*38fd1498Szrj 	__contained_virtual_mask = __base_class_type_info::__virtual_mask,
429*38fd1498Szrj 
430*38fd1498Szrj 	// Via a public path.
431*38fd1498Szrj 	__contained_public_mask = __base_class_type_info::__public_mask,
432*38fd1498Szrj 
433*38fd1498Szrj 	// Contained within us.
434*38fd1498Szrj 	__contained_mask = 1 << __base_class_type_info::__hwm_bit,
435*38fd1498Szrj 
436*38fd1498Szrj 	__contained_private = __contained_mask,
437*38fd1498Szrj 	__contained_public = __contained_mask | __contained_public_mask
438*38fd1498Szrj       };
439*38fd1498Szrj 
440*38fd1498Szrj     struct __upcast_result;
441*38fd1498Szrj     struct __dyncast_result;
442*38fd1498Szrj 
443*38fd1498Szrj   protected:
444*38fd1498Szrj     // Implementation defined member functions.
445*38fd1498Szrj     virtual bool
446*38fd1498Szrj     __do_upcast(const __class_type_info* __dst_type, void**__obj_ptr) const;
447*38fd1498Szrj 
448*38fd1498Szrj     virtual bool
449*38fd1498Szrj     __do_catch(const type_info* __thr_type, void** __thr_obj,
450*38fd1498Szrj 	       unsigned __outer) const;
451*38fd1498Szrj 
452*38fd1498Szrj   public:
453*38fd1498Szrj     // Helper for upcast. See if DST is us, or one of our bases.
454*38fd1498Szrj     // Return false if not found, true if found.
455*38fd1498Szrj     virtual bool
456*38fd1498Szrj     __do_upcast(const __class_type_info* __dst, const void* __obj,
457*38fd1498Szrj 		__upcast_result& __restrict __result) const;
458*38fd1498Szrj 
459*38fd1498Szrj     // Indicate whether SRC_PTR of type SRC_TYPE is contained publicly
460*38fd1498Szrj     // within OBJ_PTR. OBJ_PTR points to a base object of our type,
461*38fd1498Szrj     // which is the destination type. SRC2DST indicates how SRC
462*38fd1498Szrj     // objects might be contained within this type.  If SRC_PTR is one
463*38fd1498Szrj     // of our SRC_TYPE bases, indicate the virtuality. Returns
464*38fd1498Szrj     // not_contained for non containment or private containment.
465*38fd1498Szrj     inline __sub_kind
466*38fd1498Szrj     __find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
467*38fd1498Szrj 		      const __class_type_info* __src_type,
468*38fd1498Szrj 		      const void* __src_ptr) const;
469*38fd1498Szrj 
470*38fd1498Szrj     // Helper for dynamic cast. ACCESS_PATH gives the access from the
471*38fd1498Szrj     // most derived object to this base. DST_TYPE indicates the
472*38fd1498Szrj     // desired type we want. OBJ_PTR points to a base of our type
473*38fd1498Szrj     // within the complete object. SRC_TYPE indicates the static type
474*38fd1498Szrj     // started from and SRC_PTR points to that base within the most
475*38fd1498Szrj     // derived object. Fill in RESULT with what we find. Return true
476*38fd1498Szrj     // if we have located an ambiguous match.
477*38fd1498Szrj     virtual bool
478*38fd1498Szrj     __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path,
479*38fd1498Szrj 		 const __class_type_info* __dst_type, const void* __obj_ptr,
480*38fd1498Szrj 		 const __class_type_info* __src_type, const void* __src_ptr,
481*38fd1498Szrj 		 __dyncast_result& __result) const;
482*38fd1498Szrj 
483*38fd1498Szrj     // Helper for find_public_subobj. SRC2DST indicates how SRC_TYPE
484*38fd1498Szrj     // bases are inherited by the type started from -- which is not
485*38fd1498Szrj     // necessarily the current type. The current type will be a base
486*38fd1498Szrj     // of the destination type.  OBJ_PTR points to the current base.
487*38fd1498Szrj     virtual __sub_kind
488*38fd1498Szrj     __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
489*38fd1498Szrj 			 const __class_type_info* __src_type,
490*38fd1498Szrj 			 const void* __src_ptr) const;
491*38fd1498Szrj   };
492*38fd1498Szrj 
493*38fd1498Szrj   // Type information for a class with a single non-virtual base.
494*38fd1498Szrj   class __si_class_type_info : public __class_type_info
495*38fd1498Szrj   {
496*38fd1498Szrj   public:
497*38fd1498Szrj     const __class_type_info* __base_type;
498*38fd1498Szrj 
499*38fd1498Szrj     explicit
__si_class_type_info(const char * __n,const __class_type_info * __base)500*38fd1498Szrj     __si_class_type_info(const char *__n, const __class_type_info *__base)
501*38fd1498Szrj     : __class_type_info(__n), __base_type(__base) { }
502*38fd1498Szrj 
503*38fd1498Szrj     virtual
504*38fd1498Szrj     ~__si_class_type_info();
505*38fd1498Szrj 
506*38fd1498Szrj   protected:
507*38fd1498Szrj     __si_class_type_info(const __si_class_type_info&);
508*38fd1498Szrj 
509*38fd1498Szrj     __si_class_type_info&
510*38fd1498Szrj     operator=(const __si_class_type_info&);
511*38fd1498Szrj 
512*38fd1498Szrj     // Implementation defined member functions.
513*38fd1498Szrj     virtual bool
514*38fd1498Szrj     __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path,
515*38fd1498Szrj 		 const __class_type_info* __dst_type, const void* __obj_ptr,
516*38fd1498Szrj 		 const __class_type_info* __src_type, const void* __src_ptr,
517*38fd1498Szrj 		 __dyncast_result& __result) const;
518*38fd1498Szrj 
519*38fd1498Szrj     virtual __sub_kind
520*38fd1498Szrj     __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
521*38fd1498Szrj 			 const __class_type_info* __src_type,
522*38fd1498Szrj 			 const void* __sub_ptr) const;
523*38fd1498Szrj 
524*38fd1498Szrj     virtual bool
525*38fd1498Szrj     __do_upcast(const __class_type_info*__dst, const void*__obj,
526*38fd1498Szrj 		__upcast_result& __restrict __result) const;
527*38fd1498Szrj   };
528*38fd1498Szrj 
529*38fd1498Szrj   // Type information for a class with multiple and/or virtual bases.
530*38fd1498Szrj   class __vmi_class_type_info : public __class_type_info
531*38fd1498Szrj   {
532*38fd1498Szrj   public:
533*38fd1498Szrj     unsigned int 		__flags;  // Details about the class hierarchy.
534*38fd1498Szrj     unsigned int 		__base_count;  // Number of direct bases.
535*38fd1498Szrj 
536*38fd1498Szrj     // The array of bases uses the trailing array struct hack so this
537*38fd1498Szrj     // class is not constructable with a normal constructor. It is
538*38fd1498Szrj     // internally generated by the compiler.
539*38fd1498Szrj     __base_class_type_info 	__base_info[1];  // Array of bases.
540*38fd1498Szrj 
541*38fd1498Szrj     explicit
__vmi_class_type_info(const char * __n,int ___flags)542*38fd1498Szrj     __vmi_class_type_info(const char* __n, int ___flags)
543*38fd1498Szrj     : __class_type_info(__n), __flags(___flags), __base_count(0) { }
544*38fd1498Szrj 
545*38fd1498Szrj     virtual
546*38fd1498Szrj     ~__vmi_class_type_info();
547*38fd1498Szrj 
548*38fd1498Szrj     // Implementation defined types.
549*38fd1498Szrj     enum __flags_masks
550*38fd1498Szrj       {
551*38fd1498Szrj 	__non_diamond_repeat_mask = 0x1, // Distinct instance of repeated base.
552*38fd1498Szrj 	__diamond_shaped_mask = 0x2, // Diamond shaped multiple inheritance.
553*38fd1498Szrj 	__flags_unknown_mask = 0x10
554*38fd1498Szrj       };
555*38fd1498Szrj 
556*38fd1498Szrj   protected:
557*38fd1498Szrj     // Implementation defined member functions.
558*38fd1498Szrj     virtual bool
559*38fd1498Szrj     __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path,
560*38fd1498Szrj 		 const __class_type_info* __dst_type, const void* __obj_ptr,
561*38fd1498Szrj 		 const __class_type_info* __src_type, const void* __src_ptr,
562*38fd1498Szrj 		 __dyncast_result& __result) const;
563*38fd1498Szrj 
564*38fd1498Szrj     virtual __sub_kind
565*38fd1498Szrj     __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
566*38fd1498Szrj 			 const __class_type_info* __src_type,
567*38fd1498Szrj 			 const void* __src_ptr) const;
568*38fd1498Szrj 
569*38fd1498Szrj     virtual bool
570*38fd1498Szrj     __do_upcast(const __class_type_info* __dst, const void* __obj,
571*38fd1498Szrj 		__upcast_result& __restrict __result) const;
572*38fd1498Szrj   };
573*38fd1498Szrj 
574*38fd1498Szrj   // Exception handling forward declarations.
575*38fd1498Szrj   struct __cxa_exception;
576*38fd1498Szrj   struct __cxa_refcounted_exception;
577*38fd1498Szrj   struct __cxa_dependent_exception;
578*38fd1498Szrj   struct __cxa_eh_globals;
579*38fd1498Szrj 
580*38fd1498Szrj   extern "C"
581*38fd1498Szrj   {
582*38fd1498Szrj   // Dynamic cast runtime.
583*38fd1498Szrj 
584*38fd1498Szrj   // src2dst has the following possible values
585*38fd1498Szrj   //  >-1: src_type is a unique public non-virtual base of dst_type
586*38fd1498Szrj   //       dst_ptr + src2dst == src_ptr
587*38fd1498Szrj   //   -1: unspecified relationship
588*38fd1498Szrj   //   -2: src_type is not a public base of dst_type
589*38fd1498Szrj   //   -3: src_type is a multiple public non-virtual base of dst_type
590*38fd1498Szrj   void*
591*38fd1498Szrj   __dynamic_cast(const void* __src_ptr, // Starting object.
592*38fd1498Szrj 		 const __class_type_info* __src_type, // Static type of object.
593*38fd1498Szrj 		 const __class_type_info* __dst_type, // Desired target type.
594*38fd1498Szrj 		 ptrdiff_t __src2dst); // How src and dst are related.
595*38fd1498Szrj 
596*38fd1498Szrj 
597*38fd1498Szrj   // Exception handling runtime.
598*38fd1498Szrj 
599*38fd1498Szrj   // The __cxa_eh_globals for the current thread can be obtained by using
600*38fd1498Szrj   // either of the following functions.  The "fast" version assumes at least
601*38fd1498Szrj   // one prior call of __cxa_get_globals has been made from the current
602*38fd1498Szrj   // thread, so no initialization is necessary.
603*38fd1498Szrj   __cxa_eh_globals*
604*38fd1498Szrj   __cxa_get_globals() _GLIBCXX_NOTHROW __attribute__ ((__const__));
605*38fd1498Szrj 
606*38fd1498Szrj   __cxa_eh_globals*
607*38fd1498Szrj   __cxa_get_globals_fast() _GLIBCXX_NOTHROW __attribute__ ((__const__));
608*38fd1498Szrj 
609*38fd1498Szrj   // Free the space allocated for the primary exception.
610*38fd1498Szrj   void
611*38fd1498Szrj   __cxa_free_exception(void*) _GLIBCXX_NOTHROW;
612*38fd1498Szrj 
613*38fd1498Szrj   // Throw the exception.
614*38fd1498Szrj   void
615*38fd1498Szrj   __cxa_throw(void*, std::type_info*, void (_GLIBCXX_CDTOR_CALLABI *) (void *))
616*38fd1498Szrj   __attribute__((__noreturn__));
617*38fd1498Szrj 
618*38fd1498Szrj   // Used to implement exception handlers.
619*38fd1498Szrj   void*
620*38fd1498Szrj   __cxa_get_exception_ptr(void*) _GLIBCXX_NOTHROW __attribute__ ((__pure__));
621*38fd1498Szrj 
622*38fd1498Szrj   void*
623*38fd1498Szrj   __cxa_begin_catch(void*) _GLIBCXX_NOTHROW;
624*38fd1498Szrj 
625*38fd1498Szrj   void
626*38fd1498Szrj   __cxa_end_catch();
627*38fd1498Szrj 
628*38fd1498Szrj   void
629*38fd1498Szrj   __cxa_rethrow() __attribute__((__noreturn__));
630*38fd1498Szrj 
631*38fd1498Szrj   // Returns the type_info for the currently handled exception [15.3/8], or
632*38fd1498Szrj   // null if there is none.
633*38fd1498Szrj   std::type_info*
634*38fd1498Szrj   __cxa_current_exception_type() _GLIBCXX_NOTHROW __attribute__ ((__pure__));
635*38fd1498Szrj 
636*38fd1498Szrj   // GNU Extensions.
637*38fd1498Szrj 
638*38fd1498Szrj   // Allocate memory for a dependent exception.
639*38fd1498Szrj   __cxa_dependent_exception*
640*38fd1498Szrj   __cxa_allocate_dependent_exception() _GLIBCXX_NOTHROW;
641*38fd1498Szrj 
642*38fd1498Szrj   // Free the space allocated for the dependent exception.
643*38fd1498Szrj   void
644*38fd1498Szrj   __cxa_free_dependent_exception(__cxa_dependent_exception*) _GLIBCXX_NOTHROW;
645*38fd1498Szrj 
646*38fd1498Szrj   } // extern "C"
647*38fd1498Szrj 
648*38fd1498Szrj   // A magic placeholder class that can be caught by reference
649*38fd1498Szrj   // to recognize foreign exceptions.
650*38fd1498Szrj   class __foreign_exception
651*38fd1498Szrj   {
652*38fd1498Szrj     virtual ~__foreign_exception() throw();
653*38fd1498Szrj     virtual void __pure_dummy() = 0; // prevent catch by value
654*38fd1498Szrj   };
655*38fd1498Szrj 
656*38fd1498Szrj } // namespace __cxxabiv1
657*38fd1498Szrj 
658*38fd1498Szrj /** @namespace abi
659*38fd1498Szrj  *  @brief The cross-vendor C++ Application Binary Interface. A
660*38fd1498Szrj  *  namespace alias to __cxxabiv1, but user programs should use the
661*38fd1498Szrj  *  alias 'abi'.
662*38fd1498Szrj  *
663*38fd1498Szrj  *  A brief overview of an ABI is given in the libstdc++ FAQ, question
664*38fd1498Szrj  *  5.8 (you may have a copy of the FAQ locally, or you can view the online
665*38fd1498Szrj  *  version at http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#5_8 ).
666*38fd1498Szrj  *
667*38fd1498Szrj  *  GCC subscribes to a cross-vendor ABI for C++, sometimes
668*38fd1498Szrj  *  called the IA64 ABI because it happens to be the native ABI for that
669*38fd1498Szrj  *  platform.  It is summarized at http://www.codesourcery.com/cxx-abi/
670*38fd1498Szrj  *  along with the current specification.
671*38fd1498Szrj  *
672*38fd1498Szrj  *  For users of GCC greater than or equal to 3.x, entry points are
673*38fd1498Szrj  *  available in <cxxabi.h>, which notes, <em>'It is not normally
674*38fd1498Szrj  *  necessary for user programs to include this header, or use the
675*38fd1498Szrj  *  entry points directly.  However, this header is available should
676*38fd1498Szrj  *  that be needed.'</em>
677*38fd1498Szrj */
678*38fd1498Szrj namespace abi = __cxxabiv1;
679*38fd1498Szrj 
680*38fd1498Szrj namespace __gnu_cxx
681*38fd1498Szrj {
682*38fd1498Szrj   /**
683*38fd1498Szrj    *  @brief Exception thrown by __cxa_guard_acquire.
684*38fd1498Szrj    *  @ingroup exceptions
685*38fd1498Szrj    *
686*38fd1498Szrj    *  6.7[stmt.dcl]/4: If control re-enters the declaration (recursively)
687*38fd1498Szrj    *  while the object is being initialized, the behavior is undefined.
688*38fd1498Szrj    *
689*38fd1498Szrj    *  Since we already have a library function to handle locking, we might
690*38fd1498Szrj    *  as well check for this situation and throw an exception.
691*38fd1498Szrj    *  We use the second byte of the guard variable to remember that we're
692*38fd1498Szrj    *  in the middle of an initialization.
693*38fd1498Szrj    */
694*38fd1498Szrj   class recursive_init_error: public std::exception
695*38fd1498Szrj   {
696*38fd1498Szrj   public:
recursive_init_error()697*38fd1498Szrj     recursive_init_error() throw() { }
698*38fd1498Szrj     virtual ~recursive_init_error() throw ();
699*38fd1498Szrj   };
700*38fd1498Szrj }
701*38fd1498Szrj #endif // __cplusplus
702*38fd1498Szrj 
703*38fd1498Szrj #pragma GCC visibility pop
704*38fd1498Szrj 
705*38fd1498Szrj #endif // __CXXABI_H
706