blob: 867ba72940fa17778f761fbf8fcb8b62be7d0594 [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 Hinnant53cf7642012-02-02 20:47:05 +000021#define _LIBCPPABI_VERSION 1001
Nick Kledzikf72cdd52011-08-02 05:01:17 +000022#define LIBCXXABI_NORETURN __attribute__((noreturn))
Marshall Clow4c2acbc2011-06-03 02:04:41 +000023
Nico Weber55d99b72014-06-25 22:49:13 +000024// FIXME: This is also in unwind.h and libunwind.h, can we consolidate?
25#if !defined(__USING_SJLJ_EXCEPTIONS__) && defined(__arm__) && \
26 !defined(__ARM_DWARF_EH__) && !defined(__APPLE__)
27#define LIBCXXABI_ARM_EHABI 1
28#else
29#define LIBCXXABI_ARM_EHABI 0
30#endif
31
Nick Kledzik15a69282011-08-02 05:15:26 +000032#ifdef __cplusplus
33
Howard Hinnantd213ffd2011-05-05 15:27:28 +000034namespace std {
Howard Hinnant25f18072011-06-07 19:56:49 +000035 class type_info; // forward declaration
Howard Hinnantd213ffd2011-05-05 15:27:28 +000036}
37
38
39// runtime routines use C calling conventions, but are in __cxxabiv1 namespace
40namespace __cxxabiv1 {
41 extern "C" {
42
43// 2.4.2 Allocating the Exception Object
Howard Hinnantca00a4e2012-01-30 16:02:11 +000044extern void * __cxa_allocate_exception(size_t thrown_size) throw();
45extern void __cxa_free_exception(void * thrown_exception) throw();
Howard Hinnantd213ffd2011-05-05 15:27:28 +000046
47// 2.4.3 Throwing the Exception Object
Marshall Clow703d1482011-07-20 14:27:46 +000048extern LIBCXXABI_NORETURN void __cxa_throw(void * thrown_exception,
49 std::type_info * tinfo, void (*dest)(void *));
Howard Hinnantd213ffd2011-05-05 15:27:28 +000050
51// 2.5.3 Exception Handlers
Howard Hinnantca00a4e2012-01-30 16:02:11 +000052extern void * __cxa_get_exception_ptr(void * exceptionObject) throw();
53extern void * __cxa_begin_catch(void * exceptionObject) throw();
Howard Hinnantd213ffd2011-05-05 15:27:28 +000054extern void __cxa_end_catch();
Nico Weber55d99b72014-06-25 22:49:13 +000055#if LIBCXXABI_ARM_EHABI
Logan Chien05d51bc2014-05-10 00:42:10 +000056extern bool __cxa_begin_cleanup(void * exceptionObject) throw();
57extern void __cxa_end_cleanup();
58#endif
Howard Hinnantd213ffd2011-05-05 15:27:28 +000059extern std::type_info * __cxa_current_exception_type();
60
61// 2.5.4 Rethrowing Exceptions
Marshall Clow703d1482011-07-20 14:27:46 +000062extern LIBCXXABI_NORETURN void __cxa_rethrow();
Howard Hinnantd213ffd2011-05-05 15:27:28 +000063
64
65
66// 2.6 Auxiliary Runtime APIs
Marshall Clow4c2acbc2011-06-03 02:04:41 +000067extern LIBCXXABI_NORETURN void __cxa_bad_cast(void);
68extern LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
Howard Hinnantd213ffd2011-05-05 15:27:28 +000069
70
71
72// 3.2.6 Pure Virtual Function API
Marshall Clow4c2acbc2011-06-03 02:04:41 +000073extern LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
Howard Hinnantd213ffd2011-05-05 15:27:28 +000074
Howard Hinnant92827182011-05-24 22:01:16 +000075// 3.2.7 Deleted Virtual Function API
Marshall Clow4c2acbc2011-06-03 02:04:41 +000076extern LIBCXXABI_NORETURN void __cxa_deleted_virtual(void);
Howard Hinnant92827182011-05-24 22:01:16 +000077
Howard Hinnantd213ffd2011-05-05 15:27:28 +000078// 3.3.2 One-time Construction API
Howard Hinnantfcd21a12012-03-14 19:30:00 +000079#if __arm__
Nick Lewyckyd8cfd652011-06-07 18:46:10 +000080extern int __cxa_guard_acquire(uint32_t*);
81extern void __cxa_guard_release(uint32_t*);
82extern void __cxa_guard_abort(uint32_t*);
83#else
Howard Hinnantd213ffd2011-05-05 15:27:28 +000084extern int __cxa_guard_acquire(uint64_t*);
85extern void __cxa_guard_release(uint64_t*);
86extern void __cxa_guard_abort(uint64_t*);
Nick Lewyckyd8cfd652011-06-07 18:46:10 +000087#endif
Howard Hinnantd213ffd2011-05-05 15:27:28 +000088
89// 3.3.3 Array Construction and Destruction API
90extern void* __cxa_vec_new(size_t element_count,
Howard Hinnant25f18072011-06-07 19:56:49 +000091 size_t element_size,
Howard Hinnantd213ffd2011-05-05 15:27:28 +000092 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +000093 void (*constructor)(void*),
94 void (*destructor)(void*) );
Howard Hinnantd213ffd2011-05-05 15:27:28 +000095
96extern void* __cxa_vec_new2(size_t element_count,
Howard Hinnant25f18072011-06-07 19:56:49 +000097 size_t element_size,
Howard Hinnantd213ffd2011-05-05 15:27:28 +000098 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +000099 void (*constructor)(void*),
100 void (*destructor)(void*),
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000101 void* (*alloc)(size_t),
102 void (*dealloc)(void*) );
103
104extern void* __cxa_vec_new3(size_t element_count,
Howard Hinnant25f18072011-06-07 19:56:49 +0000105 size_t element_size,
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000106 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +0000107 void (*constructor)(void*),
108 void (*destructor)(void*),
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000109 void* (*alloc)(size_t),
110 void (*dealloc)(void*, size_t) );
111
112extern void __cxa_vec_ctor(void* array_address,
113 size_t element_count,
114 size_t element_size,
Howard Hinnant25f18072011-06-07 19:56:49 +0000115 void (*constructor)(void*),
116 void (*destructor)(void*) );
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000117
118
119extern void __cxa_vec_dtor(void* array_address,
120 size_t element_count,
Howard Hinnant25f18072011-06-07 19:56:49 +0000121 size_t element_size,
122 void (*destructor)(void*) );
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000123
124
125extern void __cxa_vec_cleanup(void* array_address,
126 size_t element_count,
127 size_t element_size,
Howard Hinnant25f18072011-06-07 19:56:49 +0000128 void (*destructor)(void*) );
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000129
130
131extern void __cxa_vec_delete(void* array_address,
132 size_t element_size,
133 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +0000134 void (*destructor)(void*) );
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000135
136
137extern void __cxa_vec_delete2(void* array_address,
138 size_t element_size,
139 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +0000140 void (*destructor)(void*),
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000141 void (*dealloc)(void*) );
142
143
144extern void __cxa_vec_delete3(void* __array_address,
145 size_t element_size,
146 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +0000147 void (*destructor)(void*),
148 void (*dealloc) (void*, size_t));
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000149
150
151extern void __cxa_vec_cctor(void* dest_array,
Howard Hinnant25f18072011-06-07 19:56:49 +0000152 void* src_array,
153 size_t element_count,
154 size_t element_size,
155 void (*constructor) (void*, void*),
156 void (*destructor)(void*) );
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000157
158
159// 3.3.5.3 Runtime API
160extern int __cxa_atexit(void (*f)(void*), void* p, void* d);
161extern int __cxa_finalize(void*);
162
163
164// 3.4 Demangler API
165extern char* __cxa_demangle(const char* mangled_name,
Howard Hinnant25f18072011-06-07 19:56:49 +0000166 char* output_buffer,
167 size_t* length,
168 int* status);
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000169
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000170// Apple additions to support C++ 0x exception_ptr class
171// These are primitives to wrap a smart pointer around an exception object
Howard Hinnantca00a4e2012-01-30 16:02:11 +0000172extern void * __cxa_current_primary_exception() throw();
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000173extern void __cxa_rethrow_primary_exception(void* primary_exception);
Howard Hinnantca00a4e2012-01-30 16:02:11 +0000174extern void __cxa_increment_exception_refcount(void* primary_exception) throw();
175extern void __cxa_decrement_exception_refcount(void* primary_exception) throw();
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000176
177// Apple addition to support std::uncaught_exception()
Howard Hinnantca00a4e2012-01-30 16:02:11 +0000178extern bool __cxa_uncaught_exception() throw();
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000179
180 } // extern "C"
181} // namespace __cxxabiv1
182
Howard Hinnant3759e452012-02-17 18:45:44 +0000183namespace abi = __cxxabiv1;
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000184
Nico Weber55d99b72014-06-25 22:49:13 +0000185#endif // __cplusplus
186
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000187#endif // __CXXABI_H