blob: af0e0003636d00746de0fd95a6a814ae329ba2d7 [file] [log] [blame]
Howard Hinnantd213ffd2011-05-05 15:27:28 +00001//===--------------------------- 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
Howard Hinnant25f18072011-06-07 19:56:49 +000021#define LIBCXXABI_NORETURN
Marshall Clow4c2acbc2011-06-03 02:04:41 +000022
Howard Hinnantd213ffd2011-05-05 15:27:28 +000023namespace std {
Howard Hinnant25f18072011-06-07 19:56:49 +000024 class type_info; // forward declaration
Howard Hinnantd213ffd2011-05-05 15:27:28 +000025}
26
27
28// runtime routines use C calling conventions, but are in __cxxabiv1 namespace
29namespace __cxxabiv1 {
30 extern "C" {
31
32// 2.4.2 Allocating the Exception Object
33extern void * __cxa_allocate_exception(size_t thrown_size) throw();
34extern void __cxa_free_exception(void * thrown_exception) throw();
35
36// 2.4.3 Throwing the Exception Object
37extern void __cxa_throw(void * thrown_exception, struct std::type_info * tinfo,
38 void (*dest)(void *));
39
40// 2.5.3 Exception Handlers
41extern void * __cxa_get_exception_ptr(void * exceptionObject) throw();
42extern void * __cxa_begin_catch(void * exceptionObject) throw();
43extern void __cxa_end_catch();
44extern std::type_info * __cxa_current_exception_type();
45
46// 2.5.4 Rethrowing Exceptions
47extern void __cxa_rethrow();
48
49
50
51// 2.6 Auxiliary Runtime APIs
Marshall Clow4c2acbc2011-06-03 02:04:41 +000052extern LIBCXXABI_NORETURN void __cxa_bad_cast(void);
53extern LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
Howard Hinnantd213ffd2011-05-05 15:27:28 +000054
55
56
57// 3.2.6 Pure Virtual Function API
Marshall Clow4c2acbc2011-06-03 02:04:41 +000058extern LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
Howard Hinnantd213ffd2011-05-05 15:27:28 +000059
Howard Hinnant92827182011-05-24 22:01:16 +000060// 3.2.7 Deleted Virtual Function API
Marshall Clow4c2acbc2011-06-03 02:04:41 +000061extern LIBCXXABI_NORETURN void __cxa_deleted_virtual(void);
Howard Hinnant92827182011-05-24 22:01:16 +000062
Howard Hinnantd213ffd2011-05-05 15:27:28 +000063// 3.3.2 One-time Construction API
Nick Lewyckyd8cfd652011-06-07 18:46:10 +000064#ifdef LIBCXXABI_ARMEABI
65extern int __cxa_guard_acquire(uint32_t*);
66extern void __cxa_guard_release(uint32_t*);
67extern void __cxa_guard_abort(uint32_t*);
68#else
Howard Hinnantd213ffd2011-05-05 15:27:28 +000069extern int __cxa_guard_acquire(uint64_t*);
70extern void __cxa_guard_release(uint64_t*);
71extern void __cxa_guard_abort(uint64_t*);
Nick Lewyckyd8cfd652011-06-07 18:46:10 +000072#endif
Howard Hinnantd213ffd2011-05-05 15:27:28 +000073
74// 3.3.3 Array Construction and Destruction API
75extern void* __cxa_vec_new(size_t element_count,
Howard Hinnant25f18072011-06-07 19:56:49 +000076 size_t element_size,
Howard Hinnantd213ffd2011-05-05 15:27:28 +000077 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +000078 void (*constructor)(void*),
79 void (*destructor)(void*) );
Howard Hinnantd213ffd2011-05-05 15:27:28 +000080
81extern void* __cxa_vec_new2(size_t element_count,
Howard Hinnant25f18072011-06-07 19:56:49 +000082 size_t element_size,
Howard Hinnantd213ffd2011-05-05 15:27:28 +000083 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +000084 void (*constructor)(void*),
85 void (*destructor)(void*),
Howard Hinnantd213ffd2011-05-05 15:27:28 +000086 void* (*alloc)(size_t),
87 void (*dealloc)(void*) );
88
89extern void* __cxa_vec_new3(size_t element_count,
Howard Hinnant25f18072011-06-07 19:56:49 +000090 size_t element_size,
Howard Hinnantd213ffd2011-05-05 15:27:28 +000091 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +000092 void (*constructor)(void*),
93 void (*destructor)(void*),
Howard Hinnantd213ffd2011-05-05 15:27:28 +000094 void* (*alloc)(size_t),
95 void (*dealloc)(void*, size_t) );
96
97extern void __cxa_vec_ctor(void* array_address,
98 size_t element_count,
99 size_t element_size,
Howard Hinnant25f18072011-06-07 19:56:49 +0000100 void (*constructor)(void*),
101 void (*destructor)(void*) );
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000102
103
104extern void __cxa_vec_dtor(void* array_address,
105 size_t element_count,
Howard Hinnant25f18072011-06-07 19:56:49 +0000106 size_t element_size,
107 void (*destructor)(void*) );
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000108
109
110extern void __cxa_vec_cleanup(void* array_address,
111 size_t element_count,
112 size_t element_size,
Howard Hinnant25f18072011-06-07 19:56:49 +0000113 void (*destructor)(void*) );
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000114
115
116extern void __cxa_vec_delete(void* array_address,
117 size_t element_size,
118 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +0000119 void (*destructor)(void*) );
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000120
121
122extern void __cxa_vec_delete2(void* array_address,
123 size_t element_size,
124 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +0000125 void (*destructor)(void*),
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000126 void (*dealloc)(void*) );
127
128
129extern void __cxa_vec_delete3(void* __array_address,
130 size_t element_size,
131 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +0000132 void (*destructor)(void*),
133 void (*dealloc) (void*, size_t));
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000134
135
136extern void __cxa_vec_cctor(void* dest_array,
Howard Hinnant25f18072011-06-07 19:56:49 +0000137 void* src_array,
138 size_t element_count,
139 size_t element_size,
140 void (*constructor) (void*, void*),
141 void (*destructor)(void*) );
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000142
143
144// 3.3.5.3 Runtime API
145extern int __cxa_atexit(void (*f)(void*), void* p, void* d);
146extern int __cxa_finalize(void*);
147
148
149// 3.4 Demangler API
150extern char* __cxa_demangle(const char* mangled_name,
Howard Hinnant25f18072011-06-07 19:56:49 +0000151 char* output_buffer,
152 size_t* length,
153 int* status);
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000154
155 } // extern "C"
156} // namespace __cxxabiv1
157namespace abi = __cxxabiv1;
158
159
160
161
162
163// Below are Apple extensions to support implementing C++ ABI in a seperate dylib
164namespace __cxxabiapple {
165 extern "C" {
166
167// Apple additions to support multiple STL stacks that share common
168// terminate, unexpected, and new handlers
169extern void (*__cxa_terminate_handler)();
170extern void (*__cxa_unexpected_handler)();
171extern void (*__cxa_new_handler)();
172
173// Apple additions to support C++ 0x exception_ptr class
174// These are primitives to wrap a smart pointer around an exception object
175extern void * __cxa_current_primary_exception() throw();
176extern void __cxa_rethrow_primary_exception(void* primary_exception);
177extern void __cxa_increment_exception_refcount(void* primary_exception) throw();
178extern void __cxa_decrement_exception_refcount(void* primary_exception) throw();
179
180// Apple addition to support std::uncaught_exception()
181extern bool __cxa_uncaught_exception() throw();
182
183 } // extern "C"
184} // namespace __cxxabiv1
185
186
187
188#endif // __CXXABI_H