cxxabi.h revision af0683e34e707f56aa78e39f99b50c89077152a2
1// Copyright (C) 2011 The Android Open Source Project
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions
6// are met:
7// 1. Redistributions of source code must retain the above copyright
8//    notice, this list of conditions and the following disclaimer.
9// 2. Redistributions in binary form must reproduce the above copyright
10//    notice, this list of conditions and the following disclaimer in the
11//    documentation and/or other materials provided with the distribution.
12// 3. Neither the name of the project nor the names of its contributors
13//    may be used to endorse or promote products derived from this software
14//    without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
17// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19// ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
20// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26// SUCH DAMAGE.
27//
28
29#ifndef __GABIXX_CXXABI_H__
30#define __GABIXX_CXXABI_H__
31
32#include <typeinfo>
33
34namespace __cxxabiv1
35{
36  extern "C" void __cxa_pure_virtual();
37
38  // Derived types of type_info below are based on 2.9.5 of C++ ABI.
39
40  // Typeinfo for fundamental types.
41  class __fundamental_type_info : public std::type_info
42  {
43  public:
44    ~__fundamental_type_info();
45  };
46
47  // Typeinfo for array types.
48  class __array_type_info : public std::type_info
49  {
50  public:
51    ~__array_type_info();
52  };
53
54  // Typeinfo for function types.
55  class __function_type_info : public std::type_info
56  {
57  public:
58    ~__function_type_info();
59  };
60
61  // Typeinfo for enum types.
62  class __enum_type_info : public std::type_info
63  {
64  public:
65    ~__enum_type_info();
66  };
67
68  // Typeinfo for classes with no bases.
69  class __class_type_info : public std::type_info
70  {
71  public:
72    ~__class_type_info();
73
74    enum class_type_info_code
75      {
76        CLASS_TYPE_INFO_CODE,
77        SI_CLASS_TYPE_INFO_CODE,
78        VMI_CLASS_TYPE_INFO_CODE
79      };
80
81    virtual class_type_info_code
82    code() const { return CLASS_TYPE_INFO_CODE; }
83  };
84
85  // Typeinfo for classes containing only a single, public, non-virtual base at
86  // offset zero.
87  class __si_class_type_info : public __class_type_info
88  {
89  public:
90    ~__si_class_type_info();
91    const __class_type_info *__base_type;
92
93    virtual __class_type_info::class_type_info_code
94    code() const { return SI_CLASS_TYPE_INFO_CODE; }
95  };
96
97  struct __base_class_type_info
98  {
99  public:
100    const __class_type_info *__base_type;
101
102    // All but the lower __offset_shift bits of __offset_flags are a signed
103    // offset. For a non-virtual base, this is the offset in the object of the
104    // base subobject. For a virtual base, this is the offset in the virtual
105    // table of the virtual base offset for the virtual base referenced
106    // (negative).
107    long __offset_flags;
108
109    enum __offset_flags_masks
110      {
111        __virtual_mask = 0x1,
112        __public_mask = 0x2,
113        __offset_shift = 8
114      };
115
116    bool inline
117    is_virtual() const { return (__offset_flags & __virtual_mask) != 0; }
118
119    bool inline
120    is_public() const { return (__offset_flags & __public_mask) != 0; }
121
122    // FIXME: Right-shift of signed integer is implementation dependent.
123    long inline
124    offset() const { return __offset_flags >> __offset_shift; }
125
126    long inline
127    flags() const { return __offset_flags & ((1L << __offset_shift) - 1); }
128  };
129
130  // Typeinfo for classes with bases that do not satisfy the
131  // __si_class_type_info constraints.
132  class __vmi_class_type_info : public __class_type_info
133  {
134  public:
135    ~__vmi_class_type_info();
136    unsigned int __flags;
137    unsigned int __base_count;
138    __base_class_type_info __base_info[1];
139
140    enum __flags_masks
141      {
142        __non_diamond_repeat_mask = 0x1,
143        __diamond_shaped_mask = 0x2
144      };
145
146    virtual __class_type_info::class_type_info_code
147    code() const { return VMI_CLASS_TYPE_INFO_CODE; }
148  };
149
150  class __pbase_type_info : public std::type_info
151  {
152  public:
153    ~__pbase_type_info();
154    unsigned int __flags;
155    const std::type_info *__pointee;
156
157    enum __masks
158      {
159        __const_mask = 0x1,
160        __volatile_mask = 0x2,
161        __restrict_mask = 0x4,
162        __incomplete_mask = 0x8,
163        __incomplete_class_mask = 0x10
164      };
165  };
166
167  class __pointer_type_info : public __pbase_type_info
168  {
169  public:
170    ~__pointer_type_info();
171  };
172
173  class __pointer_to_member_type_info : public __pbase_type_info
174  {
175  public:
176    ~__pointer_to_member_type_info();
177  };
178}
179
180namespace abi = __cxxabiv1;
181
182#endif /* defined(__GABIXX_CXXABI_H__) */
183
184