cxxabi.h revision f72cdd5b49372fa50dbc79d712615b4b35b00796
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 LIBCXXABI_NORETURN __attribute__((noreturn)) 22 23namespace std { 24 class type_info; // forward declaration 25} 26 27 28// runtime routines use C calling conventions, but are in __cxxabiv1 namespace 29namespace __cxxabiv1 { 30 extern "C" { 31 32// 2.4.2 Allocating the Exception Object 33extern void * __cxa_allocate_exception(size_t thrown_size) throw(); 34extern void __cxa_free_exception(void * thrown_exception) throw(); 35 36// 2.4.3 Throwing the Exception Object 37extern LIBCXXABI_NORETURN void __cxa_throw(void * thrown_exception, 38 std::type_info * tinfo, void (*dest)(void *)); 39 40// 2.5.3 Exception Handlers 41extern void * __cxa_get_exception_ptr(void * exceptionObject) throw(); 42extern void * __cxa_begin_catch(void * exceptionObject) throw(); 43extern void __cxa_end_catch(); 44extern std::type_info * __cxa_current_exception_type(); 45 46// 2.5.4 Rethrowing Exceptions 47extern LIBCXXABI_NORETURN void __cxa_rethrow(); 48 49 50 51// 2.6 Auxiliary Runtime APIs 52extern LIBCXXABI_NORETURN void __cxa_bad_cast(void); 53extern LIBCXXABI_NORETURN void __cxa_bad_typeid(void); 54 55 56 57// 3.2.6 Pure Virtual Function API 58extern LIBCXXABI_NORETURN void __cxa_pure_virtual(void); 59 60// 3.2.7 Deleted Virtual Function API 61extern LIBCXXABI_NORETURN void __cxa_deleted_virtual(void); 62 63// 3.3.2 One-time Construction API 64#ifdef LIBCXXABI_ARMEABI 65extern int __cxa_guard_acquire(uint32_t*); 66extern void __cxa_guard_release(uint32_t*); 67extern void __cxa_guard_abort(uint32_t*); 68#else 69extern int __cxa_guard_acquire(uint64_t*); 70extern void __cxa_guard_release(uint64_t*); 71extern void __cxa_guard_abort(uint64_t*); 72#endif 73 74// 3.3.3 Array Construction and Destruction API 75extern void* __cxa_vec_new(size_t element_count, 76 size_t element_size, 77 size_t padding_size, 78 void (*constructor)(void*), 79 void (*destructor)(void*) ); 80 81extern void* __cxa_vec_new2(size_t element_count, 82 size_t element_size, 83 size_t padding_size, 84 void (*constructor)(void*), 85 void (*destructor)(void*), 86 void* (*alloc)(size_t), 87 void (*dealloc)(void*) ); 88 89extern void* __cxa_vec_new3(size_t element_count, 90 size_t element_size, 91 size_t padding_size, 92 void (*constructor)(void*), 93 void (*destructor)(void*), 94 void* (*alloc)(size_t), 95 void (*dealloc)(void*, size_t) ); 96 97extern void __cxa_vec_ctor(void* array_address, 98 size_t element_count, 99 size_t element_size, 100 void (*constructor)(void*), 101 void (*destructor)(void*) ); 102 103 104extern void __cxa_vec_dtor(void* array_address, 105 size_t element_count, 106 size_t element_size, 107 void (*destructor)(void*) ); 108 109 110extern void __cxa_vec_cleanup(void* array_address, 111 size_t element_count, 112 size_t element_size, 113 void (*destructor)(void*) ); 114 115 116extern void __cxa_vec_delete(void* array_address, 117 size_t element_size, 118 size_t padding_size, 119 void (*destructor)(void*) ); 120 121 122extern void __cxa_vec_delete2(void* array_address, 123 size_t element_size, 124 size_t padding_size, 125 void (*destructor)(void*), 126 void (*dealloc)(void*) ); 127 128 129extern void __cxa_vec_delete3(void* __array_address, 130 size_t element_size, 131 size_t padding_size, 132 void (*destructor)(void*), 133 void (*dealloc) (void*, size_t)); 134 135 136extern void __cxa_vec_cctor(void* dest_array, 137 void* src_array, 138 size_t element_count, 139 size_t element_size, 140 void (*constructor) (void*, void*), 141 void (*destructor)(void*) ); 142 143 144// 3.3.5.3 Runtime API 145extern int __cxa_atexit(void (*f)(void*), void* p, void* d); 146extern int __cxa_finalize(void*); 147 148 149// 3.4 Demangler API 150extern char* __cxa_demangle(const char* mangled_name, 151 char* output_buffer, 152 size_t* length, 153 int* status); 154 155 } // extern "C" 156} // namespace __cxxabiv1 157namespace abi = __cxxabiv1; 158 159 160 161 162 163// Below are Apple extensions to support implementing C++ ABI in a seperate dylib 164namespace __cxxabiapple { 165 extern "C" { 166 167// Apple additions to support multiple STL stacks that share common 168// terminate, unexpected, and new handlers 169extern void (*__cxa_terminate_handler)(); 170extern void (*__cxa_unexpected_handler)(); 171extern void (*__cxa_new_handler)(); 172 173// Apple additions to support C++ 0x exception_ptr class 174// These are primitives to wrap a smart pointer around an exception object 175extern void * __cxa_current_primary_exception() throw(); 176extern void __cxa_rethrow_primary_exception(void* primary_exception); 177extern void __cxa_increment_exception_refcount(void* primary_exception) throw(); 178extern void __cxa_decrement_exception_refcount(void* primary_exception) throw(); 179 180// Apple addition to support std::uncaught_exception() 181extern bool __cxa_uncaught_exception() throw(); 182 183 } // extern "C" 184} // namespace __cxxabiv1 185 186 187 188#endif // __CXXABI_H 189