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