1d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant//===--------------------------- cxxabi.h ---------------------------------===//
2d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant//
3d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant//                     The LLVM Compiler Infrastructure
4d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant//
5d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// This file is dual licensed under the MIT and the University of Illinois Open
6d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// Source Licenses. See LICENSE.TXT for details.
7d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant//
8d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant//===----------------------------------------------------------------------===//
9d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
10d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant#ifndef __CXXABI_H
113cbecdfb17187900a42286372a094055a3a87d57Dan Albert#define __CXXABI_H
12d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
13d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant/*
14d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant * This header provides the interface to the C++ ABI as defined at:
15d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant *       http://www.codesourcery.com/cxx-abi/
16d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant */
17d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
18d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant#include <stddef.h>
19d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant#include <stdint.h>
20d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
218414c5a5176832964a5c9789344cf39714846841Dan Albert#include <__cxxabi_config.h>
228414c5a5176832964a5c9789344cf39714846841Dan Albert
235013d7c4d0baf9c67939f123fea6f5b3dc31052dMarshall Clow#define _LIBCPPABI_VERSION 1002
24f72cdd5b49372fa50dbc79d712615b4b35b00796Nick Kledzik#define LIBCXXABI_NORETURN  __attribute__((noreturn))
254c2acbcfc928a7d4f18b2c9202288abdf0131219Marshall Clow
2615a6928f197d9bdce3284fb1588820989abdc1e5Nick Kledzik#ifdef __cplusplus
2715a6928f197d9bdce3284fb1588820989abdc1e5Nick Kledzik
28d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantnamespace std {
293cbecdfb17187900a42286372a094055a3a87d57Dan Albertclass type_info; // forward declaration
30d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant}
31d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
32d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
33d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// runtime routines use C calling conventions, but are in __cxxabiv1 namespace
343cbecdfb17187900a42286372a094055a3a87d57Dan Albertnamespace __cxxabiv1 {
353cbecdfb17187900a42286372a094055a3a87d57Dan Albertextern "C"  {
36d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
37d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 2.4.2 Allocating the Exception Object
38ca00a4e83ed1adcdc6f34ae25c5e705315168a26Howard Hinnantextern void * __cxa_allocate_exception(size_t thrown_size) throw();
39ca00a4e83ed1adcdc6f34ae25c5e705315168a26Howard Hinnantextern void __cxa_free_exception(void * thrown_exception) throw();
40d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
41d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 2.4.3 Throwing the Exception Object
423cbecdfb17187900a42286372a094055a3a87d57Dan Albertextern LIBCXXABI_NORETURN void __cxa_throw(void * thrown_exception,
43703d148d5994d7a1cd189dc57acc7704f48fbd13Marshall Clow        std::type_info * tinfo, void (*dest)(void *));
44d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
45d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 2.5.3 Exception Handlers
46ca00a4e83ed1adcdc6f34ae25c5e705315168a26Howard Hinnantextern void * __cxa_get_exception_ptr(void * exceptionObject) throw();
47ca00a4e83ed1adcdc6f34ae25c5e705315168a26Howard Hinnantextern void * __cxa_begin_catch(void * exceptionObject) throw();
48d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void __cxa_end_catch();
4955d99b725810205ee953f134f14de6c5c49dd760Nico Weber#if LIBCXXABI_ARM_EHABI
5005d51bcf07d0ec1c40785b4a860fd917410b4be1Logan Chienextern bool __cxa_begin_cleanup(void * exceptionObject) throw();
5105d51bcf07d0ec1c40785b4a860fd917410b4be1Logan Chienextern void __cxa_end_cleanup();
5205d51bcf07d0ec1c40785b4a860fd917410b4be1Logan Chien#endif
53d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern std::type_info * __cxa_current_exception_type();
54d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
55d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 2.5.4 Rethrowing Exceptions
56703d148d5994d7a1cd189dc57acc7704f48fbd13Marshall Clowextern LIBCXXABI_NORETURN void __cxa_rethrow();
57d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
58d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
59d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
60d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 2.6 Auxiliary Runtime APIs
614c2acbcfc928a7d4f18b2c9202288abdf0131219Marshall Clowextern LIBCXXABI_NORETURN void __cxa_bad_cast(void);
624c2acbcfc928a7d4f18b2c9202288abdf0131219Marshall Clowextern LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
6368fcfa16650b79a767953a9a4b684d228bd5920cAaron Ballmanextern LIBCXXABI_NORETURN void __cxa_throw_bad_array_new_length(void);
64d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
65d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
66d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
67d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 3.2.6 Pure Virtual Function API
684c2acbcfc928a7d4f18b2c9202288abdf0131219Marshall Clowextern LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
69d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
7092827189cbb1e63dfebf0a46aac4372c3089ff11Howard Hinnant// 3.2.7 Deleted Virtual Function API
714c2acbcfc928a7d4f18b2c9202288abdf0131219Marshall Clowextern LIBCXXABI_NORETURN void __cxa_deleted_virtual(void);
7292827189cbb1e63dfebf0a46aac4372c3089ff11Howard Hinnant
73d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 3.3.2 One-time Construction API
74a1fce46063c99e307594236c55004b4e5b62243fDan Albert#ifdef __arm__
75d8cfd659b70bcf65a9c810ebe525632af38726f0Nick Lewyckyextern int  __cxa_guard_acquire(uint32_t*);
76d8cfd659b70bcf65a9c810ebe525632af38726f0Nick Lewyckyextern void __cxa_guard_release(uint32_t*);
77d8cfd659b70bcf65a9c810ebe525632af38726f0Nick Lewyckyextern void __cxa_guard_abort(uint32_t*);
78d8cfd659b70bcf65a9c810ebe525632af38726f0Nick Lewycky#else
79d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern int  __cxa_guard_acquire(uint64_t*);
80d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void __cxa_guard_release(uint64_t*);
81d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void __cxa_guard_abort(uint64_t*);
82d8cfd659b70bcf65a9c810ebe525632af38726f0Nick Lewycky#endif
83d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
84d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 3.3.3 Array Construction and Destruction API
853cbecdfb17187900a42286372a094055a3a87d57Dan Albertextern void* __cxa_vec_new(size_t element_count,
863cbecdfb17187900a42286372a094055a3a87d57Dan Albert                           size_t element_size,
873cbecdfb17187900a42286372a094055a3a87d57Dan Albert                           size_t padding_size,
8825f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant                           void (*constructor)(void*),
893cbecdfb17187900a42286372a094055a3a87d57Dan Albert                           void (*destructor)(void*));
90d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
91d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void* __cxa_vec_new2(size_t element_count,
923cbecdfb17187900a42286372a094055a3a87d57Dan Albert                            size_t element_size,
93d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant                            size_t padding_size,
9425f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant                            void  (*constructor)(void*),
9525f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant                            void  (*destructor)(void*),
963cbecdfb17187900a42286372a094055a3a87d57Dan Albert                            void* (*alloc)(size_t),
973cbecdfb17187900a42286372a094055a3a87d57Dan Albert                            void  (*dealloc)(void*));
98d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
99d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void* __cxa_vec_new3(size_t element_count,
1003cbecdfb17187900a42286372a094055a3a87d57Dan Albert                            size_t element_size,
101d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant                            size_t padding_size,
10225f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant                            void  (*constructor)(void*),
10325f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant                            void  (*destructor)(void*),
1043cbecdfb17187900a42286372a094055a3a87d57Dan Albert                            void* (*alloc)(size_t),
1053cbecdfb17187900a42286372a094055a3a87d57Dan Albert                            void  (*dealloc)(void*, size_t));
1063cbecdfb17187900a42286372a094055a3a87d57Dan Albert
1073cbecdfb17187900a42286372a094055a3a87d57Dan Albertextern void __cxa_vec_ctor(void*  array_address,
108d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant                           size_t element_count,
1093cbecdfb17187900a42286372a094055a3a87d57Dan Albert                           size_t element_size,
11025f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant                           void (*constructor)(void*),
1113cbecdfb17187900a42286372a094055a3a87d57Dan Albert                           void (*destructor)(void*));
112d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
1133cbecdfb17187900a42286372a094055a3a87d57Dan Albertextern void __cxa_vec_dtor(void*  array_address,
114d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant                           size_t element_count,
1153cbecdfb17187900a42286372a094055a3a87d57Dan Albert                           size_t element_size,
1163cbecdfb17187900a42286372a094055a3a87d57Dan Albert                           void (*destructor)(void*));
117d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
1183cbecdfb17187900a42286372a094055a3a87d57Dan Albertextern void __cxa_vec_cleanup(void* array_address,
119d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant                             size_t element_count,
1203cbecdfb17187900a42286372a094055a3a87d57Dan Albert                             size_t element_size,
1213cbecdfb17187900a42286372a094055a3a87d57Dan Albert                             void  (*destructor)(void*));
122d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
1233cbecdfb17187900a42286372a094055a3a87d57Dan Albertextern void __cxa_vec_delete(void*  array_address,
1243cbecdfb17187900a42286372a094055a3a87d57Dan Albert                             size_t element_size,
1253cbecdfb17187900a42286372a094055a3a87d57Dan Albert                             size_t padding_size,
1263cbecdfb17187900a42286372a094055a3a87d57Dan Albert                             void  (*destructor)(void*));
127d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
1283cbecdfb17187900a42286372a094055a3a87d57Dan Albertextern void __cxa_vec_delete2(void* array_address,
1293cbecdfb17187900a42286372a094055a3a87d57Dan Albert                             size_t element_size,
1303cbecdfb17187900a42286372a094055a3a87d57Dan Albert                             size_t padding_size,
13125f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant                             void  (*destructor)(void*),
1323cbecdfb17187900a42286372a094055a3a87d57Dan Albert                             void  (*dealloc)(void*));
133d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
1343cbecdfb17187900a42286372a094055a3a87d57Dan Albertextern void __cxa_vec_delete3(void* __array_address,
1353cbecdfb17187900a42286372a094055a3a87d57Dan Albert                             size_t element_size,
1363cbecdfb17187900a42286372a094055a3a87d57Dan Albert                             size_t padding_size,
13725f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant                             void  (*destructor)(void*),
1383cbecdfb17187900a42286372a094055a3a87d57Dan Albert                             void  (*dealloc)(void*, size_t));
139d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
1403cbecdfb17187900a42286372a094055a3a87d57Dan Albertextern void __cxa_vec_cctor(void*  dest_array,
1413cbecdfb17187900a42286372a094055a3a87d57Dan Albert                            void*  src_array,
1423cbecdfb17187900a42286372a094055a3a87d57Dan Albert                            size_t element_count,
1433cbecdfb17187900a42286372a094055a3a87d57Dan Albert                            size_t element_size,
1443cbecdfb17187900a42286372a094055a3a87d57Dan Albert                            void  (*constructor)(void*, void*),
1453cbecdfb17187900a42286372a094055a3a87d57Dan Albert                            void  (*destructor)(void*));
146d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
147d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 3.3.5.3 Runtime API
148d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern int __cxa_atexit(void (*f)(void*), void* p, void* d);
149d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern int __cxa_finalize(void*);
150d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
151d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// 3.4 Demangler API
1523cbecdfb17187900a42286372a094055a3a87d57Dan Albertextern char* __cxa_demangle(const char* mangled_name,
15325f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant                            char*       output_buffer,
1543cbecdfb17187900a42286372a094055a3a87d57Dan Albert                            size_t*     length,
15525f180797ba296e6cd3aa45e1fef9321b828301aHoward Hinnant                            int*        status);
156d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
157d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// Apple additions to support C++ 0x exception_ptr class
158d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant// These are primitives to wrap a smart pointer around an exception object
159ca00a4e83ed1adcdc6f34ae25c5e705315168a26Howard Hinnantextern void * __cxa_current_primary_exception() throw();
160d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnantextern void __cxa_rethrow_primary_exception(void* primary_exception);
161ca00a4e83ed1adcdc6f34ae25c5e705315168a26Howard Hinnantextern void __cxa_increment_exception_refcount(void* primary_exception) throw();
162ca00a4e83ed1adcdc6f34ae25c5e705315168a26Howard Hinnantextern void __cxa_decrement_exception_refcount(void* primary_exception) throw();
163d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
1645013d7c4d0baf9c67939f123fea6f5b3dc31052dMarshall Clow// Apple extension to support std::uncaught_exception()
1655013d7c4d0baf9c67939f123fea6f5b3dc31052dMarshall Clowextern bool          __cxa_uncaught_exception () throw();
1665013d7c4d0baf9c67939f123fea6f5b3dc31052dMarshall Clowextern unsigned int  __cxa_uncaught_exceptions() throw();
167d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
168efa37d1c95f5500535e12c5f72f4ac9a90687605Dan Albert#ifdef __linux__
169efa37d1c95f5500535e12c5f72f4ac9a90687605Dan Albert// Linux TLS support. Not yet an official part of the Itanium ABI.
170efa37d1c95f5500535e12c5f72f4ac9a90687605Dan Albert// https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables
171efa37d1c95f5500535e12c5f72f4ac9a90687605Dan Albertextern int __cxa_thread_atexit(void (*)(void *), void *, void *) throw();
172efa37d1c95f5500535e12c5f72f4ac9a90687605Dan Albert#endif
173efa37d1c95f5500535e12c5f72f4ac9a90687605Dan Albert
174d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant  } // extern "C"
175d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant} // namespace __cxxabiv1
176d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
1773759e4591ba1e1fe07e097b5e0e031fb0a0de227Howard Hinnantnamespace abi = __cxxabiv1;
178d213ffdf3befead3b8f5a0ba12ce1c2d9949525Howard Hinnant
17955d99b725810205ee953f134f14de6c5c49dd760Nico Weber#endif // __cplusplus
18055d99b725810205ee953f134f14de6c5c49dd760Nico Weber
1813cbecdfb17187900a42286372a094055a3a87d57Dan Albert#endif // __CXXABI_H
182