cxxabi.h revision ca00a4e83ed1adcdc6f34ae25c5e705315168a26
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 21f72cdd5b49372fa50dbc79d712615b4b35b00796Nick Kledzik#define LIBCXXABI_NORETURN __attribute__((noreturn)) 224c2acbcfc928a7d4f18b2c9202288abdf0131219Marshall Clow 2315a6928f197d9bdce3284fb1588820989abdc1e5Nick Kledzik 2415a6928f197d9bdce3284fb1588820989abdc1e5Nick Kledzik#ifdef __cplusplus 2515a6928f197d9bdce3284fb1588820989abdc1e5Nick Kledzik 26d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantnamespace std { 2725f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant class type_info; // forward declaration 28d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant} 29d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 30d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 31d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// runtime routines use C calling conventions, but are in __cxxabiv1 namespace 32d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantnamespace __cxxabiv1 { 33d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant extern "C" { 34d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 35d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 2.4.2 Allocating the Exception Object 36ca00a4e83ed1adcdc6f34ae25c5e705315168a26Howard Hinnantextern void * __cxa_allocate_exception(size_t thrown_size) throw(); 37ca00a4e83ed1adcdc6f34ae25c5e705315168a26Howard Hinnantextern void __cxa_free_exception(void * thrown_exception) throw(); 38d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 39d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 2.4.3 Throwing the Exception Object 40703d148d5994d7a1cd189dc57acc7704f48fbd13Marshall Clowextern LIBCXXABI_NORETURN void __cxa_throw(void * thrown_exception, 41703d148d5994d7a1cd189dc57acc7704f48fbd13Marshall Clow std::type_info * tinfo, void (*dest)(void *)); 42d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 43d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 2.5.3 Exception Handlers 44ca00a4e83ed1adcdc6f34ae25c5e705315168a26Howard Hinnantextern void * __cxa_get_exception_ptr(void * exceptionObject) throw(); 45ca00a4e83ed1adcdc6f34ae25c5e705315168a26Howard Hinnantextern void * __cxa_begin_catch(void * exceptionObject) throw(); 46d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void __cxa_end_catch(); 47d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern std::type_info * __cxa_current_exception_type(); 48d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 49d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 2.5.4 Rethrowing Exceptions 50703d148d5994d7a1cd189dc57acc7704f48fbd13Marshall Clowextern LIBCXXABI_NORETURN void __cxa_rethrow(); 51d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 52d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 53d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 54d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 2.6 Auxiliary Runtime APIs 554c2acbcfc928a7d4f18b2c9202288abdf0131219Marshall Clowextern LIBCXXABI_NORETURN void __cxa_bad_cast(void); 564c2acbcfc928a7d4f18b2c9202288abdf0131219Marshall Clowextern LIBCXXABI_NORETURN void __cxa_bad_typeid(void); 57d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 58d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 59d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 60d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 3.2.6 Pure Virtual Function API 614c2acbcfc928a7d4f18b2c9202288abdf0131219Marshall Clowextern LIBCXXABI_NORETURN void __cxa_pure_virtual(void); 62d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 6392827189cbb1e63dfebf0a46aac4372c3089ff11Howard Hinnant// 3.2.7 Deleted Virtual Function API 644c2acbcfc928a7d4f18b2c9202288abdf0131219Marshall Clowextern LIBCXXABI_NORETURN void __cxa_deleted_virtual(void); 6592827189cbb1e63dfebf0a46aac4372c3089ff11Howard Hinnant 66d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 3.3.2 One-time Construction API 67d8cfd659b70bcf65a9c810ebe525632af38726f0Nick Lewycky#ifdef LIBCXXABI_ARMEABI 68d8cfd659b70bcf65a9c810ebe525632af38726f0Nick Lewyckyextern int __cxa_guard_acquire(uint32_t*); 69d8cfd659b70bcf65a9c810ebe525632af38726f0Nick Lewyckyextern void __cxa_guard_release(uint32_t*); 70d8cfd659b70bcf65a9c810ebe525632af38726f0Nick Lewyckyextern void __cxa_guard_abort(uint32_t*); 71d8cfd659b70bcf65a9c810ebe525632af38726f0Nick Lewycky#else 72d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern int __cxa_guard_acquire(uint64_t*); 73d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void __cxa_guard_release(uint64_t*); 74d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void __cxa_guard_abort(uint64_t*); 75d8cfd659b70bcf65a9c810ebe525632af38726f0Nick Lewycky#endif 76d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 77d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 3.3.3 Array Construction and Destruction API 78d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void* __cxa_vec_new(size_t element_count, 7925f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant size_t element_size, 80d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant size_t padding_size, 8125f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void (*constructor)(void*), 8225f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void (*destructor)(void*) ); 83d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 84d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void* __cxa_vec_new2(size_t element_count, 8525f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant size_t element_size, 86d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant size_t padding_size, 8725f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void (*constructor)(void*), 8825f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void (*destructor)(void*), 89d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant void* (*alloc)(size_t), 90d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant void (*dealloc)(void*) ); 91d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 92d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void* __cxa_vec_new3(size_t element_count, 9325f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant size_t element_size, 94d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant size_t padding_size, 9525f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void (*constructor)(void*), 9625f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void (*destructor)(void*), 97d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant void* (*alloc)(size_t), 98d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant void (*dealloc)(void*, size_t) ); 99d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 100d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void __cxa_vec_ctor(void* array_address, 101d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant size_t element_count, 102d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant size_t element_size, 10325f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void (*constructor)(void*), 10425f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void (*destructor)(void*) ); 105d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 106d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 107d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void __cxa_vec_dtor(void* array_address, 108d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant size_t element_count, 10925f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant size_t element_size, 11025f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void (*destructor)(void*) ); 111d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 112d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 113d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void __cxa_vec_cleanup(void* array_address, 114d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant size_t element_count, 115d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant size_t element_size, 11625f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void (*destructor)(void*) ); 117d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 118d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 119d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void __cxa_vec_delete(void* array_address, 120d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant size_t element_size, 121d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant size_t padding_size, 12225f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void (*destructor)(void*) ); 123d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 124d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 125d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void __cxa_vec_delete2(void* array_address, 126d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant size_t element_size, 127d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant size_t padding_size, 12825f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void (*destructor)(void*), 129d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant void (*dealloc)(void*) ); 130d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 131d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 132d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void __cxa_vec_delete3(void* __array_address, 133d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant size_t element_size, 134d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant size_t padding_size, 13525f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void (*destructor)(void*), 13625f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void (*dealloc) (void*, size_t)); 137d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 138d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 139d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void __cxa_vec_cctor(void* dest_array, 14025f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void* src_array, 14125f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant size_t element_count, 14225f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant size_t element_size, 14325f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void (*constructor) (void*, void*), 14425f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant void (*destructor)(void*) ); 145d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 146d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 147d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 3.3.5.3 Runtime API 148d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern int __cxa_atexit(void (*f)(void*), void* p, void* d); 149d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern int __cxa_finalize(void*); 150d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 151d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 152d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 3.4 Demangler API 153d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern char* __cxa_demangle(const char* mangled_name, 15425f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant char* output_buffer, 15525f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant size_t* length, 15625f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant int* status); 157d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 158d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// Apple additions to support C++ 0x exception_ptr class 159d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// These are primitives to wrap a smart pointer around an exception object 160ca00a4e83ed1adcdc6f34ae25c5e705315168a26Howard Hinnantextern void * __cxa_current_primary_exception() throw(); 161d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void __cxa_rethrow_primary_exception(void* primary_exception); 162ca00a4e83ed1adcdc6f34ae25c5e705315168a26Howard Hinnantextern void __cxa_increment_exception_refcount(void* primary_exception) throw(); 163ca00a4e83ed1adcdc6f34ae25c5e705315168a26Howard Hinnantextern void __cxa_decrement_exception_refcount(void* primary_exception) throw(); 164d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 165d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// Apple addition to support std::uncaught_exception() 166ca00a4e83ed1adcdc6f34ae25c5e705315168a26Howard Hinnantextern bool __cxa_uncaught_exception() throw(); 167d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 168d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant } // extern "C" 169d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant} // namespace __cxxabiv1 1701b0aed9312dca7ffd27522864b9101ca816112b1Howard Hinnantnamespace abi = __cxxabiv1; 171d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 17215a6928f197d9bdce3284fb1588820989abdc1e5Nick Kledzik#endif // __cplusplus 173d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 174d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant 175d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant#endif // __CXXABI_H 176