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