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 1001
24#define LIBCXXABI_NORETURN  __attribute__((noreturn))
25
26#ifdef __cplusplus
27
28namespace std {
29class type_info; // forward declaration
30}
31
32
33// runtime routines use C calling conventions, but are in __cxxabiv1 namespace
34namespace __cxxabiv1 {
35extern "C"  {
36
37// 2.4.2 Allocating the Exception Object
38extern void * __cxa_allocate_exception(size_t thrown_size) throw();
39extern void __cxa_free_exception(void * thrown_exception) throw();
40
41// 2.4.3 Throwing the Exception Object
42extern LIBCXXABI_NORETURN void __cxa_throw(void * thrown_exception,
43        std::type_info * tinfo, void (*dest)(void *));
44
45// 2.5.3 Exception Handlers
46extern void * __cxa_get_exception_ptr(void * exceptionObject) throw();
47extern void * __cxa_begin_catch(void * exceptionObject) throw();
48extern void __cxa_end_catch();
49#if LIBCXXABI_ARM_EHABI
50extern bool __cxa_begin_cleanup(void * exceptionObject) throw();
51extern void __cxa_end_cleanup();
52#endif
53extern std::type_info * __cxa_current_exception_type();
54
55// 2.5.4 Rethrowing Exceptions
56extern LIBCXXABI_NORETURN void __cxa_rethrow();
57
58
59
60// 2.6 Auxiliary Runtime APIs
61extern LIBCXXABI_NORETURN void __cxa_bad_cast(void);
62extern LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
63extern LIBCXXABI_NORETURN void __cxa_throw_bad_array_new_length(void);
64
65
66
67// 3.2.6 Pure Virtual Function API
68extern LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
69
70// 3.2.7 Deleted Virtual Function API
71extern LIBCXXABI_NORETURN void __cxa_deleted_virtual(void);
72
73// 3.3.2 One-time Construction API
74#ifdef __arm__
75extern int  __cxa_guard_acquire(uint32_t*);
76extern void __cxa_guard_release(uint32_t*);
77extern void __cxa_guard_abort(uint32_t*);
78#else
79extern int  __cxa_guard_acquire(uint64_t*);
80extern void __cxa_guard_release(uint64_t*);
81extern void __cxa_guard_abort(uint64_t*);
82#endif
83
84// 3.3.3 Array Construction and Destruction API
85extern 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
91extern 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
99extern 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
107extern 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
113extern void __cxa_vec_dtor(void*  array_address,
114                           size_t element_count,
115                           size_t element_size,
116                           void (*destructor)(void*));
117
118extern void __cxa_vec_cleanup(void* array_address,
119                             size_t element_count,
120                             size_t element_size,
121                             void  (*destructor)(void*));
122
123extern void __cxa_vec_delete(void*  array_address,
124                             size_t element_size,
125                             size_t padding_size,
126                             void  (*destructor)(void*));
127
128extern 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
134extern 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
140extern 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
148extern int __cxa_atexit(void (*f)(void*), void* p, void* d);
149extern int __cxa_finalize(void*);
150
151// 3.4 Demangler API
152extern 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
159extern void * __cxa_current_primary_exception() throw();
160extern void __cxa_rethrow_primary_exception(void* primary_exception);
161extern void __cxa_increment_exception_refcount(void* primary_exception) throw();
162extern void __cxa_decrement_exception_refcount(void* primary_exception) throw();
163
164// Apple addition to support std::uncaught_exception()
165extern bool __cxa_uncaught_exception() throw();
166
167#ifdef __linux__
168// Linux TLS support. Not yet an official part of the Itanium ABI.
169// https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables
170extern int __cxa_thread_atexit(void (*)(void *), void *, void *) throw();
171#endif
172
173  } // extern "C"
174} // namespace __cxxabiv1
175
176namespace abi = __cxxabiv1;
177
178#endif // __cplusplus
179
180#endif // __CXXABI_H
181