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