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