| 1 | //===--------------------------- cxxabi.h ---------------------------------===// | 
|---|
| 2 | // | 
|---|
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | 
|---|
| 4 | // See https://llvm.org/LICENSE.txt for license information. | 
|---|
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | 
|---|
| 6 | // | 
|---|
| 7 | //===----------------------------------------------------------------------===// | 
|---|
| 8 |  | 
|---|
| 9 | #ifndef __CXXABI_H | 
|---|
| 10 | #define __CXXABI_H | 
|---|
| 11 |  | 
|---|
| 12 | /* | 
|---|
| 13 | * This header provides the interface to the C++ ABI as defined at: | 
|---|
| 14 | *       http://www.codesourcery.com/cxx-abi/ | 
|---|
| 15 | */ | 
|---|
| 16 |  | 
|---|
| 17 | #include <stddef.h> | 
|---|
| 18 | #include <stdint.h> | 
|---|
| 19 |  | 
|---|
| 20 | #include <__cxxabi_config.h> | 
|---|
| 21 |  | 
|---|
| 22 | #define _LIBCPPABI_VERSION 1002 | 
|---|
| 23 | #define _LIBCXXABI_NORETURN  __attribute__((noreturn)) | 
|---|
| 24 |  | 
|---|
| 25 | #ifdef __cplusplus | 
|---|
| 26 |  | 
|---|
| 27 | namespace std { | 
|---|
| 28 | #if defined(_WIN32) | 
|---|
| 29 | class _LIBCXXABI_TYPE_VIS type_info; // forward declaration | 
|---|
| 30 | #else | 
|---|
| 31 | class type_info; // forward declaration | 
|---|
| 32 | #endif | 
|---|
| 33 | } | 
|---|
| 34 |  | 
|---|
| 35 |  | 
|---|
| 36 | // runtime routines use C calling conventions, but are in __cxxabiv1 namespace | 
|---|
| 37 | namespace __cxxabiv1 { | 
|---|
| 38 | extern "C"{ | 
|---|
| 39 |  | 
|---|
| 40 | // 2.4.2 Allocating the Exception Object | 
|---|
| 41 | extern _LIBCXXABI_FUNC_VIS void * | 
|---|
| 42 | __cxa_allocate_exception(size_t thrown_size) throw(); | 
|---|
| 43 | extern _LIBCXXABI_FUNC_VIS void | 
|---|
| 44 | __cxa_free_exception(void *thrown_exception) throw(); | 
|---|
| 45 |  | 
|---|
| 46 | // 2.4.3 Throwing the Exception Object | 
|---|
| 47 | extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void | 
|---|
| 48 | __cxa_throw(void *thrown_exception, std::type_info *tinfo, | 
|---|
| 49 | void (*dest)(void *)); | 
|---|
| 50 |  | 
|---|
| 51 | // 2.5.3 Exception Handlers | 
|---|
| 52 | extern _LIBCXXABI_FUNC_VIS void * | 
|---|
| 53 | __cxa_get_exception_ptr(void *exceptionObject) throw(); | 
|---|
| 54 | extern _LIBCXXABI_FUNC_VIS void * | 
|---|
| 55 | __cxa_begin_catch(void *exceptionObject) throw(); | 
|---|
| 56 | extern _LIBCXXABI_FUNC_VIS void __cxa_end_catch(); | 
|---|
| 57 | #if defined(_LIBCXXABI_ARM_EHABI) | 
|---|
| 58 | extern _LIBCXXABI_FUNC_VIS bool | 
|---|
| 59 | __cxa_begin_cleanup(void *exceptionObject) throw(); | 
|---|
| 60 | extern _LIBCXXABI_FUNC_VIS void __cxa_end_cleanup(); | 
|---|
| 61 | #endif | 
|---|
| 62 | extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type(); | 
|---|
| 63 |  | 
|---|
| 64 | // 2.5.4 Rethrowing Exceptions | 
|---|
| 65 | extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_rethrow(); | 
|---|
| 66 |  | 
|---|
| 67 | // 2.6 Auxiliary Runtime APIs | 
|---|
| 68 | extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_cast(void); | 
|---|
| 69 | extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_typeid(void); | 
|---|
| 70 | extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void | 
|---|
| 71 | __cxa_throw_bad_array_new_length(void); | 
|---|
| 72 |  | 
|---|
| 73 | // 3.2.6 Pure Virtual Function API | 
|---|
| 74 | extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_pure_virtual(void); | 
|---|
| 75 |  | 
|---|
| 76 | // 3.2.7 Deleted Virtual Function API | 
|---|
| 77 | extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_deleted_virtual(void); | 
|---|
| 78 |  | 
|---|
| 79 | // 3.3.2 One-time Construction API | 
|---|
| 80 | #if defined(_LIBCXXABI_GUARD_ABI_ARM) | 
|---|
| 81 | extern _LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(uint32_t *); | 
|---|
| 82 | extern _LIBCXXABI_FUNC_VIS void __cxa_guard_release(uint32_t *); | 
|---|
| 83 | extern _LIBCXXABI_FUNC_VIS void __cxa_guard_abort(uint32_t *); | 
|---|
| 84 | #else | 
|---|
| 85 | extern _LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(uint64_t *); | 
|---|
| 86 | extern _LIBCXXABI_FUNC_VIS void __cxa_guard_release(uint64_t *); | 
|---|
| 87 | extern _LIBCXXABI_FUNC_VIS void __cxa_guard_abort(uint64_t *); | 
|---|
| 88 | #endif | 
|---|
| 89 |  | 
|---|
| 90 | // 3.3.3 Array Construction and Destruction API | 
|---|
| 91 | extern _LIBCXXABI_FUNC_VIS void * | 
|---|
| 92 | __cxa_vec_new(size_t element_count, size_t element_size, size_t padding_size, | 
|---|
| 93 | void (*constructor)(void *), void (*destructor)(void *)); | 
|---|
| 94 |  | 
|---|
| 95 | extern _LIBCXXABI_FUNC_VIS void * | 
|---|
| 96 | __cxa_vec_new2(size_t element_count, size_t element_size, size_t padding_size, | 
|---|
| 97 | void (*constructor)(void *), void (*destructor)(void *), | 
|---|
| 98 | void *(*alloc)(size_t), void (*dealloc)(void *)); | 
|---|
| 99 |  | 
|---|
| 100 | extern _LIBCXXABI_FUNC_VIS void * | 
|---|
| 101 | __cxa_vec_new3(size_t element_count, size_t element_size, size_t padding_size, | 
|---|
| 102 | void (*constructor)(void *), void (*destructor)(void *), | 
|---|
| 103 | void *(*alloc)(size_t), void (*dealloc)(void *, size_t)); | 
|---|
| 104 |  | 
|---|
| 105 | extern _LIBCXXABI_FUNC_VIS void | 
|---|
| 106 | __cxa_vec_ctor(void *array_address, size_t element_count, size_t element_size, | 
|---|
| 107 | void (*constructor)(void *), void (*destructor)(void *)); | 
|---|
| 108 |  | 
|---|
| 109 | extern _LIBCXXABI_FUNC_VIS void __cxa_vec_dtor(void *array_address, | 
|---|
| 110 | size_t element_count, | 
|---|
| 111 | size_t element_size, | 
|---|
| 112 | void (*destructor)(void *)); | 
|---|
| 113 |  | 
|---|
| 114 | extern _LIBCXXABI_FUNC_VIS void __cxa_vec_cleanup(void *array_address, | 
|---|
| 115 | size_t element_count, | 
|---|
| 116 | size_t element_size, | 
|---|
| 117 | void (*destructor)(void *)); | 
|---|
| 118 |  | 
|---|
| 119 | extern _LIBCXXABI_FUNC_VIS void __cxa_vec_delete(void *array_address, | 
|---|
| 120 | size_t element_size, | 
|---|
| 121 | size_t padding_size, | 
|---|
| 122 | void (*destructor)(void *)); | 
|---|
| 123 |  | 
|---|
| 124 | extern _LIBCXXABI_FUNC_VIS void | 
|---|
| 125 | __cxa_vec_delete2(void *array_address, size_t element_size, size_t padding_size, | 
|---|
| 126 | void (*destructor)(void *), void (*dealloc)(void *)); | 
|---|
| 127 |  | 
|---|
| 128 | extern _LIBCXXABI_FUNC_VIS void | 
|---|
| 129 | __cxa_vec_delete3(void *__array_address, size_t element_size, | 
|---|
| 130 | size_t padding_size, void (*destructor)(void *), | 
|---|
| 131 | void (*dealloc)(void *, size_t)); | 
|---|
| 132 |  | 
|---|
| 133 | extern _LIBCXXABI_FUNC_VIS void | 
|---|
| 134 | __cxa_vec_cctor(void *dest_array, void *src_array, size_t element_count, | 
|---|
| 135 | size_t element_size, void (*constructor)(void *, void *), | 
|---|
| 136 | void (*destructor)(void *)); | 
|---|
| 137 |  | 
|---|
| 138 | // 3.3.5.3 Runtime API | 
|---|
| 139 | extern _LIBCXXABI_FUNC_VIS int __cxa_atexit(void (*f)(void *), void *p, | 
|---|
| 140 | void *d); | 
|---|
| 141 | extern _LIBCXXABI_FUNC_VIS int __cxa_finalize(void *); | 
|---|
| 142 |  | 
|---|
| 143 | // 3.4 Demangler API | 
|---|
| 144 | extern _LIBCXXABI_FUNC_VIS char *__cxa_demangle(const char *mangled_name, | 
|---|
| 145 | char *output_buffer, | 
|---|
| 146 | size_t *length, int *status); | 
|---|
| 147 |  | 
|---|
| 148 | // Apple additions to support C++ 0x exception_ptr class | 
|---|
| 149 | // These are primitives to wrap a smart pointer around an exception object | 
|---|
| 150 | extern _LIBCXXABI_FUNC_VIS void *__cxa_current_primary_exception() throw(); | 
|---|
| 151 | extern _LIBCXXABI_FUNC_VIS void | 
|---|
| 152 | __cxa_rethrow_primary_exception(void *primary_exception); | 
|---|
| 153 | extern _LIBCXXABI_FUNC_VIS void | 
|---|
| 154 | __cxa_increment_exception_refcount(void *primary_exception) throw(); | 
|---|
| 155 | extern _LIBCXXABI_FUNC_VIS void | 
|---|
| 156 | __cxa_decrement_exception_refcount(void *primary_exception) throw(); | 
|---|
| 157 |  | 
|---|
| 158 | // Apple extension to support std::uncaught_exception() | 
|---|
| 159 | extern _LIBCXXABI_FUNC_VIS bool __cxa_uncaught_exception() throw(); | 
|---|
| 160 | extern _LIBCXXABI_FUNC_VIS unsigned int __cxa_uncaught_exceptions() throw(); | 
|---|
| 161 |  | 
|---|
| 162 | #if defined(__linux__) || defined(__Fuchsia__) | 
|---|
| 163 | // Linux and Fuchsia TLS support. Not yet an official part of the Itanium ABI. | 
|---|
| 164 | // https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables | 
|---|
| 165 | extern _LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(void (*)(void *), void *, | 
|---|
| 166 | void *) throw(); | 
|---|
| 167 | #endif | 
|---|
| 168 |  | 
|---|
| 169 | } // extern "C" | 
|---|
| 170 | } // namespace __cxxabiv1 | 
|---|
| 171 |  | 
|---|
| 172 | namespace abi = __cxxabiv1; | 
|---|
| 173 |  | 
|---|
| 174 | #endif // __cplusplus | 
|---|
| 175 |  | 
|---|
| 176 | #endif // __CXXABI_H | 
|---|
| 177 |  | 
|---|