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 |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +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 |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 42 | extern LIBCXXABI_NORETURN void __cxa_throw(void *thrown_exception, |
| 43 | std::type_info *tinfo, |
| 44 | void (*dest)(void *)); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 45 | |
| 46 | // 2.5.3 Exception Handlers |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 47 | extern void *__cxa_get_exception_ptr(void *exceptionObject) throw(); |
| 48 | extern void *__cxa_begin_catch(void *exceptionObject) throw(); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 49 | extern void __cxa_end_catch(); |
Nico Weber | 55d99b7 | 2014-06-25 22:49:13 +0000 | [diff] [blame] | 50 | #if LIBCXXABI_ARM_EHABI |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 51 | extern bool __cxa_begin_cleanup(void *exceptionObject) throw(); |
Logan Chien | 05d51bc | 2014-05-10 00:42:10 +0000 | [diff] [blame] | 52 | extern void __cxa_end_cleanup(); |
| 53 | #endif |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 54 | extern std::type_info *__cxa_current_exception_type(); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 55 | |
| 56 | // 2.5.4 Rethrowing Exceptions |
Marshall Clow | 703d148 | 2011-07-20 14:27:46 +0000 | [diff] [blame] | 57 | extern LIBCXXABI_NORETURN void __cxa_rethrow(); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 58 | |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 59 | // 2.6 Auxiliary Runtime APIs |
Marshall Clow | 4c2acbc | 2011-06-03 02:04:41 +0000 | [diff] [blame] | 60 | extern LIBCXXABI_NORETURN void __cxa_bad_cast(void); |
| 61 | extern LIBCXXABI_NORETURN void __cxa_bad_typeid(void); |
Aaron Ballman | 68fcfa1 | 2014-09-11 17:26:43 +0000 | [diff] [blame] | 62 | extern LIBCXXABI_NORETURN void __cxa_throw_bad_array_new_length(void); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 63 | |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 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 |
Dan Albert | a1fce46 | 2015-02-05 01:33:15 +0000 | [diff] [blame] | 71 | #ifdef __arm__ |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +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 *); |
Nick Lewycky | d8cfd65 | 2011-06-07 18:46:10 +0000 | [diff] [blame] | 75 | #else |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +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 |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 82 | extern void *__cxa_vec_new(size_t element_count, size_t element_size, |
| 83 | size_t padding_size, void (*constructor)(void *), |
| 84 | void (*destructor)(void *)); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 85 | |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 86 | extern void *__cxa_vec_new2(size_t element_count, size_t element_size, |
| 87 | size_t padding_size, void (*constructor)(void *), |
| 88 | void (*destructor)(void *), void *(*alloc)(size_t), |
| 89 | void (*dealloc)(void *)); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 90 | |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 91 | extern void *__cxa_vec_new3(size_t element_count, size_t element_size, |
| 92 | size_t padding_size, void (*constructor)(void *), |
| 93 | void (*destructor)(void *), void *(*alloc)(size_t), |
| 94 | void (*dealloc)(void *, size_t)); |
Dan Albert | 3cbecdf | 2015-02-04 21:23:20 +0000 | [diff] [blame] | 95 | |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 96 | extern void __cxa_vec_ctor(void *array_address, size_t element_count, |
| 97 | size_t element_size, void (*constructor)(void *), |
| 98 | void (*destructor)(void *)); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 99 | |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 100 | extern void __cxa_vec_dtor(void *array_address, size_t element_count, |
| 101 | size_t element_size, void (*destructor)(void *)); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 102 | |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 103 | extern void __cxa_vec_cleanup(void *array_address, size_t element_count, |
| 104 | size_t element_size, void (*destructor)(void *)); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 105 | |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 106 | extern void __cxa_vec_delete(void *array_address, size_t element_size, |
| 107 | size_t padding_size, void (*destructor)(void *)); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 108 | |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 109 | extern void __cxa_vec_delete2(void *array_address, size_t element_size, |
| 110 | size_t padding_size, void (*destructor)(void *), |
| 111 | void (*dealloc)(void *)); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 112 | |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 113 | extern void __cxa_vec_delete3(void *__array_address, size_t element_size, |
| 114 | size_t padding_size, void (*destructor)(void *), |
| 115 | void (*dealloc)(void *, size_t)); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 116 | |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 117 | extern void __cxa_vec_cctor(void *dest_array, void *src_array, |
| 118 | size_t element_count, size_t element_size, |
| 119 | void (*constructor)(void *, void *), |
| 120 | void (*destructor)(void *)); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 121 | |
| 122 | // 3.3.5.3 Runtime API |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 123 | extern int __cxa_atexit(void (*f)(void *), void *p, void *d); |
| 124 | extern int __cxa_finalize(void *); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 125 | |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 126 | // 3.4 Demangler API |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 127 | extern char *__cxa_demangle(const char *mangled_name, char *output_buffer, |
| 128 | size_t *length, int *status); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 129 | |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 130 | // Apple additions to support C++ 0x exception_ptr class |
| 131 | // These are primitives to wrap a smart pointer around an exception object |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 132 | extern void *__cxa_current_primary_exception() throw(); |
| 133 | extern void __cxa_rethrow_primary_exception(void *primary_exception); |
| 134 | extern void __cxa_increment_exception_refcount(void *primary_exception) throw(); |
| 135 | extern void __cxa_decrement_exception_refcount(void *primary_exception) throw(); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 136 | |
Marshall Clow | 5013d7c | 2015-06-02 13:03:17 +0000 | [diff] [blame] | 137 | // Apple extension to support std::uncaught_exception() |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 138 | extern bool __cxa_uncaught_exception() throw(); |
| 139 | extern unsigned int __cxa_uncaught_exceptions() throw(); |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 140 | |
Dan Albert | efa37d1 | 2014-12-18 00:03:57 +0000 | [diff] [blame] | 141 | #ifdef __linux__ |
| 142 | // Linux TLS support. Not yet an official part of the Itanium ABI. |
| 143 | // https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables |
| 144 | extern int __cxa_thread_atexit(void (*)(void *), void *, void *) throw(); |
| 145 | #endif |
| 146 | |
Saleem Abdulrasool | 77a304b | 2015-12-04 02:14:41 +0000 | [diff] [blame^] | 147 | } // extern "C" |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 148 | } // namespace __cxxabiv1 |
| 149 | |
Howard Hinnant | 3759e45 | 2012-02-17 18:45:44 +0000 | [diff] [blame] | 150 | namespace abi = __cxxabiv1; |
Howard Hinnant | d213ffd | 2011-05-05 15:27:28 +0000 | [diff] [blame] | 151 | |
Nico Weber | 55d99b7 | 2014-06-25 22:49:13 +0000 | [diff] [blame] | 152 | #endif // __cplusplus |
| 153 | |
Dan Albert | 3cbecdf | 2015-02-04 21:23:20 +0000 | [diff] [blame] | 154 | #endif // __CXXABI_H |