• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
11 #define __CXXABI_H
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 
21 #include <__cxxabi_config.h>
22 
23 #define _LIBCPPABI_VERSION 1002
24 #define LIBCXXABI_NORETURN  __attribute__((noreturn))
25 
26 #ifdef __cplusplus
27 
28 namespace std {
29 class type_info; // forward declaration
30 }
31 
32 
33 // runtime routines use C calling conventions, but are in __cxxabiv1 namespace
34 namespace __cxxabiv1 {
35 extern "C"  {
36 
37 // 2.4.2 Allocating the Exception Object
38 extern void * __cxa_allocate_exception(size_t thrown_size) throw();
39 extern void __cxa_free_exception(void * thrown_exception) throw();
40 
41 // 2.4.3 Throwing the Exception Object
42 extern LIBCXXABI_NORETURN void __cxa_throw(void * thrown_exception,
43         std::type_info * tinfo, void (*dest)(void *));
44 
45 // 2.5.3 Exception Handlers
46 extern void * __cxa_get_exception_ptr(void * exceptionObject) throw();
47 extern void * __cxa_begin_catch(void * exceptionObject) throw();
48 extern void __cxa_end_catch();
49 #if LIBCXXABI_ARM_EHABI
50 extern bool __cxa_begin_cleanup(void * exceptionObject) throw();
51 extern void __cxa_end_cleanup();
52 #endif
53 extern std::type_info * __cxa_current_exception_type();
54 
55 // 2.5.4 Rethrowing Exceptions
56 extern LIBCXXABI_NORETURN void __cxa_rethrow();
57 
58 
59 
60 // 2.6 Auxiliary Runtime APIs
61 extern LIBCXXABI_NORETURN void __cxa_bad_cast(void);
62 extern LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
63 extern LIBCXXABI_NORETURN void __cxa_throw_bad_array_new_length(void);
64 
65 
66 
67 // 3.2.6 Pure Virtual Function API
68 extern LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
69 
70 // 3.2.7 Deleted Virtual Function API
71 extern LIBCXXABI_NORETURN void __cxa_deleted_virtual(void);
72 
73 // 3.3.2 One-time Construction API
74 #ifdef __arm__
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
79 extern int  __cxa_guard_acquire(uint64_t*);
80 extern void __cxa_guard_release(uint64_t*);
81 extern void __cxa_guard_abort(uint64_t*);
82 #endif
83 
84 // 3.3.3 Array Construction and Destruction API
85 extern void* __cxa_vec_new(size_t element_count,
86                            size_t element_size,
87                            size_t padding_size,
88                            void (*constructor)(void*),
89                            void (*destructor)(void*));
90 
91 extern void* __cxa_vec_new2(size_t element_count,
92                             size_t element_size,
93                             size_t padding_size,
94                             void  (*constructor)(void*),
95                             void  (*destructor)(void*),
96                             void* (*alloc)(size_t),
97                             void  (*dealloc)(void*));
98 
99 extern void* __cxa_vec_new3(size_t element_count,
100                             size_t element_size,
101                             size_t padding_size,
102                             void  (*constructor)(void*),
103                             void  (*destructor)(void*),
104                             void* (*alloc)(size_t),
105                             void  (*dealloc)(void*, size_t));
106 
107 extern void __cxa_vec_ctor(void*  array_address,
108                            size_t element_count,
109                            size_t element_size,
110                            void (*constructor)(void*),
111                            void (*destructor)(void*));
112 
113 extern void __cxa_vec_dtor(void*  array_address,
114                            size_t element_count,
115                            size_t element_size,
116                            void (*destructor)(void*));
117 
118 extern void __cxa_vec_cleanup(void* array_address,
119                              size_t element_count,
120                              size_t element_size,
121                              void  (*destructor)(void*));
122 
123 extern void __cxa_vec_delete(void*  array_address,
124                              size_t element_size,
125                              size_t padding_size,
126                              void  (*destructor)(void*));
127 
128 extern void __cxa_vec_delete2(void* array_address,
129                              size_t element_size,
130                              size_t padding_size,
131                              void  (*destructor)(void*),
132                              void  (*dealloc)(void*));
133 
134 extern void __cxa_vec_delete3(void* __array_address,
135                              size_t element_size,
136                              size_t padding_size,
137                              void  (*destructor)(void*),
138                              void  (*dealloc)(void*, size_t));
139 
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*));
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 
151 // 3.4 Demangler API
152 extern char* __cxa_demangle(const char* mangled_name,
153                             char*       output_buffer,
154                             size_t*     length,
155                             int*        status);
156 
157 // Apple additions to support C++ 0x exception_ptr class
158 // These are primitives to wrap a smart pointer around an exception object
159 extern void * __cxa_current_primary_exception() throw();
160 extern void __cxa_rethrow_primary_exception(void* primary_exception);
161 extern void __cxa_increment_exception_refcount(void* primary_exception) throw();
162 extern void __cxa_decrement_exception_refcount(void* primary_exception) throw();
163 
164 // Apple extension to support std::uncaught_exception()
165 extern bool          __cxa_uncaught_exception () throw();
166 extern unsigned int  __cxa_uncaught_exceptions() throw();
167 
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 
174   } // extern "C"
175 } // namespace __cxxabiv1
176 
177 namespace abi = __cxxabiv1;
178 
179 #endif // __cplusplus
180 
181 #endif // __CXXABI_H
182