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 34 namespace abi = __cxxabiv1; 35 36 namespace __cxxabiv1 37 { 38 extern "C" void __cxa_pure_virtual(); 39 40 // Derived types of type_info below are based on 2.9.5 of C++ ABI. 41 42 // Typeinfo for fundamental types. 43 class __fundamental_type_info : public std::type_info 44 { 45 public: 46 ~__fundamental_type_info(); 47 }; 48 49 // Typeinfo for array types. 50 class __array_type_info : public std::type_info 51 { 52 public: 53 ~__array_type_info(); 54 }; 55 56 // Typeinfo for function types. 57 class __function_type_info : public std::type_info 58 { 59 public: 60 ~__function_type_info(); 61 }; 62 63 // Typeinfo for enum types. 64 class __enum_type_info : public std::type_info 65 { 66 public: 67 ~__enum_type_info(); 68 }; 69 70 // Typeinfo for classes with no bases. 71 class __class_type_info : public std::type_info 72 { 73 public: 74 ~__class_type_info(); 75 76 enum class_type_info_code 77 { 78 CLASS_TYPE_INFO_CODE, 79 SI_CLASS_TYPE_INFO_CODE, 80 VMI_CLASS_TYPE_INFO_CODE 81 }; 82 83 virtual class_type_info_code 84 code() const { return CLASS_TYPE_INFO_CODE; } 85 }; 86 87 // Typeinfo for classes containing only a single, public, non-virtual base at 88 // offset zero. 89 class __si_class_type_info : public __class_type_info 90 { 91 public: 92 ~__si_class_type_info(); 93 const __class_type_info *__base_type; 94 95 virtual __class_type_info::class_type_info_code 96 code() const { return SI_CLASS_TYPE_INFO_CODE; } 97 }; 98 99 struct __base_class_type_info 100 { 101 public: 102 const __class_type_info *__base_type; 103 104 // All but the lower __offset_shift bits of __offset_flags are a signed 105 // offset. For a non-virtual base, this is the offset in the object of the 106 // base subobject. For a virtual base, this is the offset in the virtual 107 // table of the virtual base offset for the virtual base referenced 108 // (negative). 109 long __offset_flags; 110 111 enum __offset_flags_masks 112 { 113 __virtual_mask = 0x1, 114 __public_mask = 0x2, 115 __offset_shift = 8 116 }; 117 118 bool inline 119 is_virtual() const { return (__offset_flags & __virtual_mask) != 0; } 120 121 bool inline 122 is_public() const { return (__offset_flags & __public_mask) != 0; } 123 124 // FIXME: Right-shift of signed integer is implementation dependent. 125 long inline 126 offset() const { return __offset_flags >> __offset_shift; } 127 128 long inline 129 flags() const { return __offset_flags & ((1L << __offset_shift) - 1); } 130 }; 131 132 // Typeinfo for classes with bases that do not satisfy the 133 // __si_class_type_info constraints. 134 class __vmi_class_type_info : public __class_type_info 135 { 136 public: 137 ~__vmi_class_type_info(); 138 unsigned int __flags; 139 unsigned int __base_count; 140 __base_class_type_info __base_info[1]; 141 142 enum __flags_masks 143 { 144 __non_diamond_repeat_mask = 0x1, 145 __diamond_shaped_mask = 0x2 146 }; 147 148 virtual __class_type_info::class_type_info_code 149 code() const { return VMI_CLASS_TYPE_INFO_CODE; } 150 }; 151 152 class __pbase_type_info : public std::type_info 153 { 154 public: 155 ~__pbase_type_info(); 156 unsigned int __flags; 157 const std::type_info *__pointee; 158 159 enum __masks 160 { 161 __const_mask = 0x1, 162 __volatile_mask = 0x2, 163 __restrict_mask = 0x4, 164 __incomplete_mask = 0x8, 165 __incomplete_class_mask = 0x10 166 }; 167 }; 168 169 class __pointer_type_info : public __pbase_type_info 170 { 171 public: 172 ~__pointer_type_info(); 173 }; 174 175 class __pointer_to_member_type_info : public __pbase_type_info 176 { 177 public: 178 ~__pointer_to_member_type_info(); 179 }; 180 } 181 182 #endif /* defined(__GABIXX_CXXABI_H__) */ 183 184