blob: 253a3df77f9c6db6b173a542dea1aac5206e2742 [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
Dan Albert3cbecdf2015-02-04 21:23:20 +000011#define __CXXABI_H
Howard Hinnantd213ffd2011-05-05 15:27:28 +000012
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
Dan Albert8414c5a2015-02-05 23:55:15 +000021#include <__cxxabi_config.h>
22
Marshall Clow5013d7c2015-06-02 13:03:17 +000023#define _LIBCPPABI_VERSION 1002
Nick Kledzikf72cdd52011-08-02 05:01:17 +000024#define LIBCXXABI_NORETURN __attribute__((noreturn))
Marshall Clow4c2acbc2011-06-03 02:04:41 +000025
Nick Kledzik15a69282011-08-02 05:15:26 +000026#ifdef __cplusplus
27
Howard Hinnantd213ffd2011-05-05 15:27:28 +000028namespace std {
Dan Albert3cbecdf2015-02-04 21:23:20 +000029class type_info; // forward declaration
Howard Hinnantd213ffd2011-05-05 15:27:28 +000030}
31
32
33// runtime routines use C calling conventions, but are in __cxxabiv1 namespace
Dan Albert3cbecdf2015-02-04 21:23:20 +000034namespace __cxxabiv1 {
35extern "C" {
Howard Hinnantd213ffd2011-05-05 15:27:28 +000036
37// 2.4.2 Allocating the Exception Object
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +000038extern void *__cxa_allocate_exception(size_t thrown_size) throw();
39extern void __cxa_free_exception(void *thrown_exception) throw();
Howard Hinnantd213ffd2011-05-05 15:27:28 +000040
41// 2.4.3 Throwing the Exception Object
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +000042extern LIBCXXABI_NORETURN void __cxa_throw(void *thrown_exception,
43 std::type_info *tinfo,
44 void (*dest)(void *));
Howard Hinnantd213ffd2011-05-05 15:27:28 +000045
46// 2.5.3 Exception Handlers
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +000047extern void *__cxa_get_exception_ptr(void *exceptionObject) throw();
48extern void *__cxa_begin_catch(void *exceptionObject) throw();
Howard Hinnantd213ffd2011-05-05 15:27:28 +000049extern void __cxa_end_catch();
Nico Weber55d99b72014-06-25 22:49:13 +000050#if LIBCXXABI_ARM_EHABI
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +000051extern bool __cxa_begin_cleanup(void *exceptionObject) throw();
Logan Chien05d51bc2014-05-10 00:42:10 +000052extern void __cxa_end_cleanup();
53#endif
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +000054extern std::type_info *__cxa_current_exception_type();
Howard Hinnantd213ffd2011-05-05 15:27:28 +000055
56// 2.5.4 Rethrowing Exceptions
Marshall Clow703d1482011-07-20 14:27:46 +000057extern LIBCXXABI_NORETURN void __cxa_rethrow();
Howard Hinnantd213ffd2011-05-05 15:27:28 +000058
Howard Hinnantd213ffd2011-05-05 15:27:28 +000059// 2.6 Auxiliary Runtime APIs
Marshall Clow4c2acbc2011-06-03 02:04:41 +000060extern LIBCXXABI_NORETURN void __cxa_bad_cast(void);
61extern LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
Aaron Ballman68fcfa12014-09-11 17:26:43 +000062extern LIBCXXABI_NORETURN void __cxa_throw_bad_array_new_length(void);
Howard Hinnantd213ffd2011-05-05 15:27:28 +000063
Howard Hinnantd213ffd2011-05-05 15:27:28 +000064// 3.2.6 Pure Virtual Function API
Marshall Clow4c2acbc2011-06-03 02:04:41 +000065extern LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
Howard Hinnantd213ffd2011-05-05 15:27:28 +000066
Howard Hinnant92827182011-05-24 22:01:16 +000067// 3.2.7 Deleted Virtual Function API
Marshall Clow4c2acbc2011-06-03 02:04:41 +000068extern LIBCXXABI_NORETURN void __cxa_deleted_virtual(void);
Howard Hinnant92827182011-05-24 22:01:16 +000069
Howard Hinnantd213ffd2011-05-05 15:27:28 +000070// 3.3.2 One-time Construction API
Dan Alberta1fce462015-02-05 01:33:15 +000071#ifdef __arm__
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +000072extern int __cxa_guard_acquire(uint32_t *);
73extern void __cxa_guard_release(uint32_t *);
74extern void __cxa_guard_abort(uint32_t *);
Nick Lewyckyd8cfd652011-06-07 18:46:10 +000075#else
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +000076extern int __cxa_guard_acquire(uint64_t *);
77extern void __cxa_guard_release(uint64_t *);
78extern void __cxa_guard_abort(uint64_t *);
Nick Lewyckyd8cfd652011-06-07 18:46:10 +000079#endif
Howard Hinnantd213ffd2011-05-05 15:27:28 +000080
81// 3.3.3 Array Construction and Destruction API
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +000082extern void *__cxa_vec_new(size_t element_count, size_t element_size,
83 size_t padding_size, void (*constructor)(void *),
84 void (*destructor)(void *));
Howard Hinnantd213ffd2011-05-05 15:27:28 +000085
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +000086extern void *__cxa_vec_new2(size_t element_count, size_t element_size,
87 size_t padding_size, void (*constructor)(void *),
88 void (*destructor)(void *), void *(*alloc)(size_t),
89 void (*dealloc)(void *));
Howard Hinnantd213ffd2011-05-05 15:27:28 +000090
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +000091extern void *__cxa_vec_new3(size_t element_count, size_t element_size,
92 size_t padding_size, void (*constructor)(void *),
93 void (*destructor)(void *), void *(*alloc)(size_t),
94 void (*dealloc)(void *, size_t));
Dan Albert3cbecdf2015-02-04 21:23:20 +000095
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +000096extern void __cxa_vec_ctor(void *array_address, size_t element_count,
97 size_t element_size, void (*constructor)(void *),
98 void (*destructor)(void *));
Howard Hinnantd213ffd2011-05-05 15:27:28 +000099
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +0000100extern void __cxa_vec_dtor(void *array_address, size_t element_count,
101 size_t element_size, void (*destructor)(void *));
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000102
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +0000103extern void __cxa_vec_cleanup(void *array_address, size_t element_count,
104 size_t element_size, void (*destructor)(void *));
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000105
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +0000106extern void __cxa_vec_delete(void *array_address, size_t element_size,
107 size_t padding_size, void (*destructor)(void *));
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000108
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +0000109extern void __cxa_vec_delete2(void *array_address, size_t element_size,
110 size_t padding_size, void (*destructor)(void *),
111 void (*dealloc)(void *));
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000112
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +0000113extern void __cxa_vec_delete3(void *__array_address, size_t element_size,
114 size_t padding_size, void (*destructor)(void *),
115 void (*dealloc)(void *, size_t));
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000116
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +0000117extern void __cxa_vec_cctor(void *dest_array, void *src_array,
118 size_t element_count, size_t element_size,
119 void (*constructor)(void *, void *),
120 void (*destructor)(void *));
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000121
122// 3.3.5.3 Runtime API
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +0000123extern int __cxa_atexit(void (*f)(void *), void *p, void *d);
124extern int __cxa_finalize(void *);
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000125
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000126// 3.4 Demangler API
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +0000127extern char *__cxa_demangle(const char *mangled_name, char *output_buffer,
128 size_t *length, int *status);
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000129
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000130// Apple additions to support C++ 0x exception_ptr class
131// These are primitives to wrap a smart pointer around an exception object
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +0000132extern void *__cxa_current_primary_exception() throw();
133extern void __cxa_rethrow_primary_exception(void *primary_exception);
134extern void __cxa_increment_exception_refcount(void *primary_exception) throw();
135extern void __cxa_decrement_exception_refcount(void *primary_exception) throw();
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000136
Marshall Clow5013d7c2015-06-02 13:03:17 +0000137// Apple extension to support std::uncaught_exception()
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +0000138extern bool __cxa_uncaught_exception() throw();
139extern unsigned int __cxa_uncaught_exceptions() throw();
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000140
Dan Albertefa37d12014-12-18 00:03:57 +0000141#ifdef __linux__
142// Linux TLS support. Not yet an official part of the Itanium ABI.
143// https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables
144extern int __cxa_thread_atexit(void (*)(void *), void *, void *) throw();
145#endif
146
Saleem Abdulrasool77a304b2015-12-04 02:14:41 +0000147} // extern "C"
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000148} // namespace __cxxabiv1
149
Howard Hinnant3759e452012-02-17 18:45:44 +0000150namespace abi = __cxxabiv1;
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000151
Nico Weber55d99b72014-06-25 22:49:13 +0000152#endif // __cplusplus
153
Dan Albert3cbecdf2015-02-04 21:23:20 +0000154#endif // __CXXABI_H