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 | |
Howard Hinnant | 53cf764 | 2012-02-02 20:47:05 +0000 | [diff] [blame] | 21 | #define _LIBCPPABI_VERSION 1001 |
Nick Kledzik | f72cdd5 | 2011-08-02 05:01:17 +0000 | [diff] [blame] | 22 | #define LIBCXXABI_NORETURN __attribute__((noreturn)) |
Marshall Clow | 4c2acbc | 2011-06-03 02:04:41 +0000 | [diff] [blame] | 23 | |
Nico Weber | 55d99b7 | 2014-06-25 22:49:13 +0000 | [diff] [blame] | 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 | |
Nick Kledzik | 15a6928 | 2011-08-02 05:15:26 +0000 | [diff] [blame] | 32 | #ifdef __cplusplus |
| 33 | |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 34 | namespace std { |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 35 | class type_info; // forward declaration |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 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 |
Howard Hinnant | ca00a4e | 2012-01-30 16:02:11 +0000 | [diff] [blame] | 44 | extern void * __cxa_allocate_exception(size_t thrown_size) throw(); |
| 45 | extern void __cxa_free_exception(void * thrown_exception) throw(); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 46 | |
| 47 | // 2.4.3 Throwing the Exception Object |
Marshall Clow | 703d148 | 2011-07-20 14:27:46 +0000 | [diff] [blame] | 48 | extern LIBCXXABI_NORETURN void __cxa_throw(void * thrown_exception, |
| 49 | std::type_info * tinfo, void (*dest)(void *)); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 50 | |
| 51 | // 2.5.3 Exception Handlers |
Howard Hinnant | ca00a4e | 2012-01-30 16:02:11 +0000 | [diff] [blame] | 52 | extern void * __cxa_get_exception_ptr(void * exceptionObject) throw(); |
| 53 | extern void * __cxa_begin_catch(void * exceptionObject) throw(); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 54 | extern void __cxa_end_catch(); |
Nico Weber | 55d99b7 | 2014-06-25 22:49:13 +0000 | [diff] [blame] | 55 | #if LIBCXXABI_ARM_EHABI |
Logan Chien | 05d51bc | 2014-05-10 00:42:10 +0000 | [diff] [blame] | 56 | extern bool __cxa_begin_cleanup(void * exceptionObject) throw(); |
| 57 | extern void __cxa_end_cleanup(); |
| 58 | #endif |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 59 | extern std::type_info * __cxa_current_exception_type(); |
| 60 | |
| 61 | // 2.5.4 Rethrowing Exceptions |
Marshall Clow | 703d148 | 2011-07-20 14:27:46 +0000 | [diff] [blame] | 62 | extern LIBCXXABI_NORETURN void __cxa_rethrow(); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 63 | |
| 64 | |
| 65 | |
| 66 | // 2.6 Auxiliary Runtime APIs |
Marshall Clow | 4c2acbc | 2011-06-03 02:04:41 +0000 | [diff] [blame] | 67 | extern LIBCXXABI_NORETURN void __cxa_bad_cast(void); |
| 68 | extern LIBCXXABI_NORETURN void __cxa_bad_typeid(void); |
Aaron Ballman | 68fcfa1 | 2014-09-11 17:26:43 +0000 | [diff] [blame] | 69 | extern LIBCXXABI_NORETURN void __cxa_throw_bad_array_new_length(void); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 70 | |
| 71 | |
| 72 | |
| 73 | // 3.2.6 Pure Virtual Function API |
Marshall Clow | 4c2acbc | 2011-06-03 02:04:41 +0000 | [diff] [blame] | 74 | extern LIBCXXABI_NORETURN void __cxa_pure_virtual(void); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 75 | |
Howard Hinnant | 9282718 | 2011-05-24 22:01:16 +0000 | [diff] [blame] | 76 | // 3.2.7 Deleted Virtual Function API |
Marshall Clow | 4c2acbc | 2011-06-03 02:04:41 +0000 | [diff] [blame] | 77 | extern LIBCXXABI_NORETURN void __cxa_deleted_virtual(void); |
Howard Hinnant | 9282718 | 2011-05-24 22:01:16 +0000 | [diff] [blame] | 78 | |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 79 | // 3.3.2 One-time Construction API |
Howard Hinnant | fcd21a1 | 2012-03-14 19:30:00 +0000 | [diff] [blame] | 80 | #if __arm__ |
Nick Lewycky | d8cfd65 | 2011-06-07 18:46:10 +0000 | [diff] [blame] | 81 | extern int __cxa_guard_acquire(uint32_t*); |
| 82 | extern void __cxa_guard_release(uint32_t*); |
| 83 | extern void __cxa_guard_abort(uint32_t*); |
| 84 | #else |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 85 | extern int __cxa_guard_acquire(uint64_t*); |
| 86 | extern void __cxa_guard_release(uint64_t*); |
| 87 | extern void __cxa_guard_abort(uint64_t*); |
Nick Lewycky | d8cfd65 | 2011-06-07 18:46:10 +0000 | [diff] [blame] | 88 | #endif |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 89 | |
| 90 | // 3.3.3 Array Construction and Destruction API |
| 91 | extern void* __cxa_vec_new(size_t element_count, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 92 | size_t element_size, |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 93 | size_t padding_size, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 94 | void (*constructor)(void*), |
| 95 | void (*destructor)(void*) ); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 96 | |
| 97 | extern void* __cxa_vec_new2(size_t element_count, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 98 | size_t element_size, |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 99 | size_t padding_size, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 100 | void (*constructor)(void*), |
| 101 | void (*destructor)(void*), |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 102 | void* (*alloc)(size_t), |
| 103 | void (*dealloc)(void*) ); |
| 104 | |
| 105 | extern void* __cxa_vec_new3(size_t element_count, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 106 | size_t element_size, |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 107 | size_t padding_size, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 108 | void (*constructor)(void*), |
| 109 | void (*destructor)(void*), |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 110 | void* (*alloc)(size_t), |
| 111 | void (*dealloc)(void*, size_t) ); |
| 112 | |
| 113 | extern void __cxa_vec_ctor(void* array_address, |
| 114 | size_t element_count, |
| 115 | size_t element_size, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 116 | void (*constructor)(void*), |
| 117 | void (*destructor)(void*) ); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 118 | |
| 119 | |
| 120 | extern void __cxa_vec_dtor(void* array_address, |
| 121 | size_t element_count, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 122 | size_t element_size, |
| 123 | void (*destructor)(void*) ); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 124 | |
| 125 | |
| 126 | extern void __cxa_vec_cleanup(void* array_address, |
| 127 | size_t element_count, |
| 128 | size_t element_size, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 129 | void (*destructor)(void*) ); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 130 | |
| 131 | |
| 132 | extern void __cxa_vec_delete(void* array_address, |
| 133 | size_t element_size, |
| 134 | size_t padding_size, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 135 | void (*destructor)(void*) ); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 136 | |
| 137 | |
| 138 | extern void __cxa_vec_delete2(void* array_address, |
| 139 | size_t element_size, |
| 140 | size_t padding_size, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 141 | void (*destructor)(void*), |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 142 | void (*dealloc)(void*) ); |
| 143 | |
| 144 | |
| 145 | extern void __cxa_vec_delete3(void* __array_address, |
| 146 | size_t element_size, |
| 147 | size_t padding_size, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 148 | void (*destructor)(void*), |
| 149 | void (*dealloc) (void*, size_t)); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 150 | |
| 151 | |
| 152 | extern void __cxa_vec_cctor(void* dest_array, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 153 | void* src_array, |
| 154 | size_t element_count, |
| 155 | size_t element_size, |
| 156 | void (*constructor) (void*, void*), |
| 157 | void (*destructor)(void*) ); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 158 | |
| 159 | |
| 160 | // 3.3.5.3 Runtime API |
| 161 | extern int __cxa_atexit(void (*f)(void*), void* p, void* d); |
| 162 | extern int __cxa_finalize(void*); |
| 163 | |
| 164 | |
| 165 | // 3.4 Demangler API |
| 166 | extern char* __cxa_demangle(const char* mangled_name, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 167 | char* output_buffer, |
| 168 | size_t* length, |
| 169 | int* status); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 170 | |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 171 | // Apple additions to support C++ 0x exception_ptr class |
| 172 | // These are primitives to wrap a smart pointer around an exception object |
Howard Hinnant | ca00a4e | 2012-01-30 16:02:11 +0000 | [diff] [blame] | 173 | extern void * __cxa_current_primary_exception() throw(); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 174 | extern void __cxa_rethrow_primary_exception(void* primary_exception); |
Howard Hinnant | ca00a4e | 2012-01-30 16:02:11 +0000 | [diff] [blame] | 175 | extern void __cxa_increment_exception_refcount(void* primary_exception) throw(); |
| 176 | extern void __cxa_decrement_exception_refcount(void* primary_exception) throw(); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 177 | |
| 178 | // Apple addition to support std::uncaught_exception() |
Howard Hinnant | ca00a4e | 2012-01-30 16:02:11 +0000 | [diff] [blame] | 179 | extern bool __cxa_uncaught_exception() throw(); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 180 | |
Dan Albert | efa37d1 | 2014-12-18 00:03:57 +0000 | [diff] [blame^] | 181 | #ifdef __linux__ |
| 182 | // Linux TLS support. Not yet an official part of the Itanium ABI. |
| 183 | // https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables |
| 184 | extern int __cxa_thread_atexit(void (*)(void *), void *, void *) throw(); |
| 185 | #endif |
| 186 | |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 187 | } // extern "C" |
| 188 | } // namespace __cxxabiv1 |
| 189 | |
Howard Hinnant | 3759e45 | 2012-02-17 18:45:44 +0000 | [diff] [blame] | 190 | namespace abi = __cxxabiv1; |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 191 | |
Nico Weber | 55d99b7 | 2014-06-25 22:49:13 +0000 | [diff] [blame] | 192 | #endif // __cplusplus |
| 193 | |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 194 | #endif // __CXXABI_H |