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 | |
Nick Kledzik | f72cdd5 | 2011-08-02 05:01:17 +0000 | [diff] [blame] | 21 | #define LIBCXXABI_NORETURN __attribute__((noreturn)) |
Marshall Clow | 4c2acbc | 2011-06-03 02:04:41 +0000 | [diff] [blame] | 22 | |
Nick Kledzik | 15a6928 | 2011-08-02 05:15:26 +0000 | [diff] [blame] | 23 | |
| 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(); |
| 47 | extern std::type_info * __cxa_current_exception_type(); |
| 48 | |
| 49 | // 2.5.4 Rethrowing Exceptions |
Marshall Clow | 703d148 | 2011-07-20 14:27:46 +0000 | [diff] [blame] | 50 | extern LIBCXXABI_NORETURN void __cxa_rethrow(); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 51 | |
| 52 | |
| 53 | |
| 54 | // 2.6 Auxiliary Runtime APIs |
Marshall Clow | 4c2acbc | 2011-06-03 02:04:41 +0000 | [diff] [blame] | 55 | extern LIBCXXABI_NORETURN void __cxa_bad_cast(void); |
| 56 | extern LIBCXXABI_NORETURN void __cxa_bad_typeid(void); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 57 | |
| 58 | |
| 59 | |
| 60 | // 3.2.6 Pure Virtual Function API |
Marshall Clow | 4c2acbc | 2011-06-03 02:04:41 +0000 | [diff] [blame] | 61 | extern LIBCXXABI_NORETURN void __cxa_pure_virtual(void); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 62 | |
Howard Hinnant | 9282718 | 2011-05-24 22:01:16 +0000 | [diff] [blame] | 63 | // 3.2.7 Deleted Virtual Function API |
Marshall Clow | 4c2acbc | 2011-06-03 02:04:41 +0000 | [diff] [blame] | 64 | extern LIBCXXABI_NORETURN void __cxa_deleted_virtual(void); |
Howard Hinnant | 9282718 | 2011-05-24 22:01:16 +0000 | [diff] [blame] | 65 | |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 66 | // 3.3.2 One-time Construction API |
Nick Lewycky | d8cfd65 | 2011-06-07 18:46:10 +0000 | [diff] [blame] | 67 | #ifdef LIBCXXABI_ARMEABI |
| 68 | extern int __cxa_guard_acquire(uint32_t*); |
| 69 | extern void __cxa_guard_release(uint32_t*); |
| 70 | extern void __cxa_guard_abort(uint32_t*); |
| 71 | #else |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 72 | extern int __cxa_guard_acquire(uint64_t*); |
| 73 | extern void __cxa_guard_release(uint64_t*); |
| 74 | extern void __cxa_guard_abort(uint64_t*); |
Nick Lewycky | d8cfd65 | 2011-06-07 18:46:10 +0000 | [diff] [blame] | 75 | #endif |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 76 | |
| 77 | // 3.3.3 Array Construction and Destruction API |
| 78 | extern void* __cxa_vec_new(size_t element_count, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 79 | size_t element_size, |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 80 | size_t padding_size, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 81 | void (*constructor)(void*), |
| 82 | void (*destructor)(void*) ); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 83 | |
| 84 | extern void* __cxa_vec_new2(size_t element_count, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 85 | size_t element_size, |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 86 | size_t padding_size, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 87 | void (*constructor)(void*), |
| 88 | void (*destructor)(void*), |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 89 | void* (*alloc)(size_t), |
| 90 | void (*dealloc)(void*) ); |
| 91 | |
| 92 | extern void* __cxa_vec_new3(size_t element_count, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 93 | size_t element_size, |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 94 | size_t padding_size, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 95 | void (*constructor)(void*), |
| 96 | void (*destructor)(void*), |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 97 | void* (*alloc)(size_t), |
| 98 | void (*dealloc)(void*, size_t) ); |
| 99 | |
| 100 | extern void __cxa_vec_ctor(void* array_address, |
| 101 | size_t element_count, |
| 102 | size_t element_size, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 103 | void (*constructor)(void*), |
| 104 | void (*destructor)(void*) ); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 105 | |
| 106 | |
| 107 | extern void __cxa_vec_dtor(void* array_address, |
| 108 | size_t element_count, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 109 | size_t element_size, |
| 110 | void (*destructor)(void*) ); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 111 | |
| 112 | |
| 113 | extern void __cxa_vec_cleanup(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 (*destructor)(void*) ); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 117 | |
| 118 | |
| 119 | extern void __cxa_vec_delete(void* array_address, |
| 120 | size_t element_size, |
| 121 | size_t padding_size, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 122 | void (*destructor)(void*) ); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 123 | |
| 124 | |
| 125 | extern void __cxa_vec_delete2(void* array_address, |
| 126 | size_t element_size, |
| 127 | size_t padding_size, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 128 | void (*destructor)(void*), |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 129 | void (*dealloc)(void*) ); |
| 130 | |
| 131 | |
| 132 | extern void __cxa_vec_delete3(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*), |
| 136 | void (*dealloc) (void*, size_t)); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 137 | |
| 138 | |
| 139 | extern void __cxa_vec_cctor(void* dest_array, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 140 | void* src_array, |
| 141 | size_t element_count, |
| 142 | size_t element_size, |
| 143 | void (*constructor) (void*, void*), |
| 144 | void (*destructor)(void*) ); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 145 | |
| 146 | |
| 147 | // 3.3.5.3 Runtime API |
| 148 | extern int __cxa_atexit(void (*f)(void*), void* p, void* d); |
| 149 | extern int __cxa_finalize(void*); |
| 150 | |
| 151 | |
| 152 | // 3.4 Demangler API |
| 153 | extern char* __cxa_demangle(const char* mangled_name, |
Howard Hinnant | 25f1807 | 2011-06-07 19:56:49 +0000 | [diff] [blame] | 154 | char* output_buffer, |
| 155 | size_t* length, |
| 156 | int* status); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 157 | |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 158 | // Apple additions to support C++ 0x exception_ptr class |
| 159 | // These are primitives to wrap a smart pointer around an exception object |
Howard Hinnant | ca00a4e | 2012-01-30 16:02:11 +0000 | [diff] [blame^] | 160 | extern void * __cxa_current_primary_exception() throw(); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 161 | extern void __cxa_rethrow_primary_exception(void* primary_exception); |
Howard Hinnant | ca00a4e | 2012-01-30 16:02:11 +0000 | [diff] [blame^] | 162 | extern void __cxa_increment_exception_refcount(void* primary_exception) throw(); |
| 163 | extern void __cxa_decrement_exception_refcount(void* primary_exception) throw(); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 164 | |
| 165 | // Apple addition to support std::uncaught_exception() |
Howard Hinnant | ca00a4e | 2012-01-30 16:02:11 +0000 | [diff] [blame^] | 166 | extern bool __cxa_uncaught_exception() throw(); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 167 | |
| 168 | } // extern "C" |
| 169 | } // namespace __cxxabiv1 |
Howard Hinnant | 1b0aed9 | 2011-12-21 23:32:11 +0000 | [diff] [blame] | 170 | namespace abi = __cxxabiv1; |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 171 | |
Nick Kledzik | 15a6928 | 2011-08-02 05:15:26 +0000 | [diff] [blame] | 172 | #endif // __cplusplus |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 173 | |
| 174 | |
| 175 | #endif // __CXXABI_H |