1//===--------------------------- cxxabi.h ---------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef __CXXABI_H
10#define __CXXABI_H
11
12/*
13 * This header provides the interface to the C++ ABI as defined at:
14 * https://itanium-cxx-abi.github.io/cxx-abi/
15 */
16
17#include <stddef.h>
18#include <stdint.h>
19
20#include <__cxxabi_config.h>
21
22#define _LIBCPPABI_VERSION 1002
23#define _LIBCXXABI_NORETURN __attribute__((noreturn))
24
25#ifdef __cplusplus
26
27namespace std {
28#if defined(_WIN32)
29class _LIBCXXABI_TYPE_VIS type_info; // forward declaration
30#else
31class type_info; // forward declaration
32#endif
33}
34
35
36// runtime routines use C calling conventions, but are in __cxxabiv1 namespace
37namespace __cxxabiv1 {
38extern "C" {
39
40// 2.4.2 Allocating the Exception Object
41extern _LIBCXXABI_FUNC_VIS void *
42__cxa_allocate_exception(size_t thrown_size) throw();
43extern _LIBCXXABI_FUNC_VIS void
44__cxa_free_exception(void *thrown_exception) throw();
45
46// 2.4.3 Throwing the Exception Object
47extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
48__cxa_throw(void *thrown_exception, std::type_info *tinfo,
49 void (*dest)(void *));
50
51// 2.5.3 Exception Handlers
52extern _LIBCXXABI_FUNC_VIS void *
53__cxa_get_exception_ptr(void *exceptionObject) throw();
54extern _LIBCXXABI_FUNC_VIS void *
55__cxa_begin_catch(void *exceptionObject) throw();
56extern _LIBCXXABI_FUNC_VIS void __cxa_end_catch();
57#if defined(_LIBCXXABI_ARM_EHABI)
58extern _LIBCXXABI_FUNC_VIS bool
59__cxa_begin_cleanup(void *exceptionObject) throw();
60extern _LIBCXXABI_FUNC_VIS void __cxa_end_cleanup();
61#endif
62extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type();
63
64// 2.5.4 Rethrowing Exceptions
65extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_rethrow();
66
67// 2.6 Auxiliary Runtime APIs
68extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_cast(void);
69extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
70extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
71__cxa_throw_bad_array_new_length(void);
72
73// 3.2.6 Pure Virtual Function API
74extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
75
76// 3.2.7 Deleted Virtual Function API
77extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_deleted_virtual(void);
78
79// 3.3.2 One-time Construction API
80#if defined(_LIBCXXABI_GUARD_ABI_ARM)
81extern _LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(uint32_t *);
82extern _LIBCXXABI_FUNC_VIS void __cxa_guard_release(uint32_t *);
83extern _LIBCXXABI_FUNC_VIS void __cxa_guard_abort(uint32_t *);
84#else
85extern _LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(uint64_t *);
86extern _LIBCXXABI_FUNC_VIS void __cxa_guard_release(uint64_t *);
87extern _LIBCXXABI_FUNC_VIS void __cxa_guard_abort(uint64_t *);
88#endif
89
90// 3.3.3 Array Construction and Destruction API
91extern _LIBCXXABI_FUNC_VIS void *
92__cxa_vec_new(size_t element_count, size_t element_size, size_t padding_size,
93 void (*constructor)(void *), void (*destructor)(void *));
94
95extern _LIBCXXABI_FUNC_VIS void *
96__cxa_vec_new2(size_t element_count, size_t element_size, size_t padding_size,
97 void (*constructor)(void *), void (*destructor)(void *),
98 void *(*alloc)(size_t), void (*dealloc)(void *));
99
100extern _LIBCXXABI_FUNC_VIS void *
101__cxa_vec_new3(size_t element_count, size_t element_size, size_t padding_size,
102 void (*constructor)(void *), void (*destructor)(void *),
103 void *(*alloc)(size_t), void (*dealloc)(void *, size_t));
104
105extern _LIBCXXABI_FUNC_VIS void
106__cxa_vec_ctor(void *array_address, size_t element_count, size_t element_size,
107 void (*constructor)(void *), void (*destructor)(void *));
108
109extern _LIBCXXABI_FUNC_VIS void __cxa_vec_dtor(void *array_address,
110 size_t element_count,
111 size_t element_size,
112 void (*destructor)(void *));
113
114extern _LIBCXXABI_FUNC_VIS void __cxa_vec_cleanup(void *array_address,
115 size_t element_count,
116 size_t element_size,
117 void (*destructor)(void *));
118
119extern _LIBCXXABI_FUNC_VIS void __cxa_vec_delete(void *array_address,
120 size_t element_size,
121 size_t padding_size,
122 void (*destructor)(void *));
123
124extern _LIBCXXABI_FUNC_VIS void
125__cxa_vec_delete2(void *array_address, size_t element_size, size_t padding_size,
126 void (*destructor)(void *), void (*dealloc)(void *));
127
128extern _LIBCXXABI_FUNC_VIS void
129__cxa_vec_delete3(void *__array_address, size_t element_size,
130 size_t padding_size, void (*destructor)(void *),
131 void (*dealloc)(void *, size_t));
132
133extern _LIBCXXABI_FUNC_VIS void
134__cxa_vec_cctor(void *dest_array, void *src_array, size_t element_count,
135 size_t element_size, void (*constructor)(void *, void *),
136 void (*destructor)(void *));
137
138// 3.3.5.3 Runtime API
139extern _LIBCXXABI_FUNC_VIS int __cxa_atexit(void (*f)(void *), void *p,
140 void *d);
141extern _LIBCXXABI_FUNC_VIS int __cxa_finalize(void *);
142
143// 3.4 Demangler API
144extern _LIBCXXABI_FUNC_VIS char *__cxa_demangle(const char *mangled_name,
145 char *output_buffer,
146 size_t *length, int *status);
147
148// Apple additions to support C++ 0x exception_ptr class
149// These are primitives to wrap a smart pointer around an exception object
150extern _LIBCXXABI_FUNC_VIS void *__cxa_current_primary_exception() throw();
151extern _LIBCXXABI_FUNC_VIS void
152__cxa_rethrow_primary_exception(void *primary_exception);
153extern _LIBCXXABI_FUNC_VIS void
154__cxa_increment_exception_refcount(void *primary_exception) throw();
155extern _LIBCXXABI_FUNC_VIS void
156__cxa_decrement_exception_refcount(void *primary_exception) throw();
157
158// Apple extension to support std::uncaught_exception()
159extern _LIBCXXABI_FUNC_VIS bool __cxa_uncaught_exception() throw();
160extern _LIBCXXABI_FUNC_VIS unsigned int __cxa_uncaught_exceptions() throw();
161
162#if defined(__linux__) || defined(__Fuchsia__)
163// Linux and Fuchsia TLS support. Not yet an official part of the Itanium ABI.
164// https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables
165extern _LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(void (*)(void *), void *,
166 void *) throw();
167#endif
168
169} // extern "C"
170} // namespace __cxxabiv1
171
172namespace abi = __cxxabiv1;
173
174#endif // __cplusplus
175
176#endif // __CXXABI_H
177