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