1 //===--------------------------- cxxabi.h ---------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef __CXXABI_H 11 #define __CXXABI_H 12 13 /* 14 * This header provides the interface to the C++ ABI as defined at: 15 * http://www.codesourcery.com/cxx-abi/ 16 */ 17 18 #include <stddef.h> 19 #include <stdint.h> 20 21 #define _LIBCPPABI_VERSION 1001 22 #define LIBCXXABI_NORETURN __attribute__((noreturn)) 23 24 // FIXME: This is also in unwind.h and libunwind.h, can we consolidate? 25 #if !defined(__USING_SJLJ_EXCEPTIONS__) && defined(__arm__) && \ 26 !defined(__ARM_DWARF_EH__) && !defined(__APPLE__) 27 #define LIBCXXABI_ARM_EHABI 1 28 #else 29 #define LIBCXXABI_ARM_EHABI 0 30 #endif 31 32 #ifdef __cplusplus 33 34 namespace std { 35 class type_info; // forward declaration 36 } 37 38 39 // runtime routines use C calling conventions, but are in __cxxabiv1 namespace 40 namespace __cxxabiv1 { 41 extern "C" { 42 43 // 2.4.2 Allocating the Exception Object 44 extern void * __cxa_allocate_exception(size_t thrown_size) throw(); 45 extern void __cxa_free_exception(void * thrown_exception) throw(); 46 47 // 2.4.3 Throwing the Exception Object 48 extern LIBCXXABI_NORETURN void __cxa_throw(void * thrown_exception, 49 std::type_info * tinfo, void (*dest)(void *)); 50 51 // 2.5.3 Exception Handlers 52 extern void * __cxa_get_exception_ptr(void * exceptionObject) throw(); 53 extern void * __cxa_begin_catch(void * exceptionObject) throw(); 54 extern void __cxa_end_catch(); 55 #if LIBCXXABI_ARM_EHABI 56 extern bool __cxa_begin_cleanup(void * exceptionObject) throw(); 57 extern void __cxa_end_cleanup(); 58 #endif 59 extern std::type_info * __cxa_current_exception_type(); 60 61 // 2.5.4 Rethrowing Exceptions 62 extern LIBCXXABI_NORETURN void __cxa_rethrow(); 63 64 65 66 // 2.6 Auxiliary Runtime APIs 67 extern LIBCXXABI_NORETURN void __cxa_bad_cast(void); 68 extern LIBCXXABI_NORETURN void __cxa_bad_typeid(void); 69 70 71 72 // 3.2.6 Pure Virtual Function API 73 extern LIBCXXABI_NORETURN void __cxa_pure_virtual(void); 74 75 // 3.2.7 Deleted Virtual Function API 76 extern LIBCXXABI_NORETURN void __cxa_deleted_virtual(void); 77 78 // 3.3.2 One-time Construction API 79 #if __arm__ 80 extern int __cxa_guard_acquire(uint32_t*); 81 extern void __cxa_guard_release(uint32_t*); 82 extern void __cxa_guard_abort(uint32_t*); 83 #else 84 extern int __cxa_guard_acquire(uint64_t*); 85 extern void __cxa_guard_release(uint64_t*); 86 extern void __cxa_guard_abort(uint64_t*); 87 #endif 88 89 // 3.3.3 Array Construction and Destruction API 90 extern void* __cxa_vec_new(size_t element_count, 91 size_t element_size, 92 size_t padding_size, 93 void (*constructor)(void*), 94 void (*destructor)(void*) ); 95 96 extern void* __cxa_vec_new2(size_t element_count, 97 size_t element_size, 98 size_t padding_size, 99 void (*constructor)(void*), 100 void (*destructor)(void*), 101 void* (*alloc)(size_t), 102 void (*dealloc)(void*) ); 103 104 extern void* __cxa_vec_new3(size_t element_count, 105 size_t element_size, 106 size_t padding_size, 107 void (*constructor)(void*), 108 void (*destructor)(void*), 109 void* (*alloc)(size_t), 110 void (*dealloc)(void*, size_t) ); 111 112 extern void __cxa_vec_ctor(void* array_address, 113 size_t element_count, 114 size_t element_size, 115 void (*constructor)(void*), 116 void (*destructor)(void*) ); 117 118 119 extern void __cxa_vec_dtor(void* array_address, 120 size_t element_count, 121 size_t element_size, 122 void (*destructor)(void*) ); 123 124 125 extern void __cxa_vec_cleanup(void* array_address, 126 size_t element_count, 127 size_t element_size, 128 void (*destructor)(void*) ); 129 130 131 extern void __cxa_vec_delete(void* array_address, 132 size_t element_size, 133 size_t padding_size, 134 void (*destructor)(void*) ); 135 136 137 extern void __cxa_vec_delete2(void* array_address, 138 size_t element_size, 139 size_t padding_size, 140 void (*destructor)(void*), 141 void (*dealloc)(void*) ); 142 143 144 extern void __cxa_vec_delete3(void* __array_address, 145 size_t element_size, 146 size_t padding_size, 147 void (*destructor)(void*), 148 void (*dealloc) (void*, size_t)); 149 150 151 extern void __cxa_vec_cctor(void* dest_array, 152 void* src_array, 153 size_t element_count, 154 size_t element_size, 155 void (*constructor) (void*, void*), 156 void (*destructor)(void*) ); 157 158 159 // 3.3.5.3 Runtime API 160 extern int __cxa_atexit(void (*f)(void*), void* p, void* d); 161 extern int __cxa_finalize(void*); 162 163 164 // 3.4 Demangler API 165 extern char* __cxa_demangle(const char* mangled_name, 166 char* output_buffer, 167 size_t* length, 168 int* status); 169 170 // Apple additions to support C++ 0x exception_ptr class 171 // These are primitives to wrap a smart pointer around an exception object 172 extern void * __cxa_current_primary_exception() throw(); 173 extern void __cxa_rethrow_primary_exception(void* primary_exception); 174 extern void __cxa_increment_exception_refcount(void* primary_exception) throw(); 175 extern void __cxa_decrement_exception_refcount(void* primary_exception) throw(); 176 177 // Apple addition to support std::uncaught_exception() 178 extern bool __cxa_uncaught_exception() throw(); 179 180 } // extern "C" 181 } // namespace __cxxabiv1 182 183 namespace abi = __cxxabiv1; 184 185 #endif // __cplusplus 186 187 #endif // __CXXABI_H 188