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