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