Warning: This file is not a C or C++ file. It does not have highlighting.

1//===----------------------------------------------------------------------===//
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 15000
23#define _LIBCXXABI_NORETURN __attribute__((noreturn))
24#define _LIBCXXABI_ALWAYS_COLD __attribute__((cold))
25
26#ifdef __cplusplus
27
28namespace std {
29#if defined(_WIN32)
30class _LIBCXXABI_TYPE_VIS type_info; // forward declaration
31#else
32class type_info; // forward declaration
33#endif
34}
35
36
37// runtime routines use C calling conventions, but are in __cxxabiv1 namespace
38namespace __cxxabiv1 {
39
40struct __cxa_exception;
41
42extern "C" {
43
44// 2.4.2 Allocating the Exception Object
45extern _LIBCXXABI_FUNC_VIS void *
46__cxa_allocate_exception(size_t thrown_size) throw();
47extern _LIBCXXABI_FUNC_VIS void
48__cxa_free_exception(void *thrown_exception) throw();
49// This function is an LLVM extension, which mirrors the same extension in libsupc++ and libcxxrt
50extern _LIBCXXABI_FUNC_VIS __cxa_exception*
51__cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw();
52
53// 2.4.3 Throwing the Exception Object
54extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
55__cxa_throw(void *thrown_exception, std::type_info *tinfo,
56#ifdef __USING_WASM_EXCEPTIONS__
57 // In Wasm, a destructor returns its argument
58 void *(_LIBCXXABI_DTOR_FUNC *dest)(void *));
59#else
60 void (_LIBCXXABI_DTOR_FUNC *dest)(void *));
61#endif
62
63// 2.5.3 Exception Handlers
64extern _LIBCXXABI_FUNC_VIS void *
65__cxa_get_exception_ptr(void *exceptionObject) throw();
66extern _LIBCXXABI_FUNC_VIS void *
67__cxa_begin_catch(void *exceptionObject) throw();
68extern _LIBCXXABI_FUNC_VIS void __cxa_end_catch();
69#if defined(_LIBCXXABI_ARM_EHABI)
70extern _LIBCXXABI_FUNC_VIS bool
71__cxa_begin_cleanup(void *exceptionObject) throw();
72extern _LIBCXXABI_FUNC_VIS void __cxa_end_cleanup();
73#endif
74extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type();
75
76// 2.5.4 Rethrowing Exceptions
77extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_rethrow();
78
79// 2.6 Auxiliary Runtime APIs
80extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_cast(void);
81extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
82extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
83__cxa_throw_bad_array_new_length(void);
84
85// 3.2.6 Pure Virtual Function API
86extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
87
88// 3.2.7 Deleted Virtual Function API
89extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_deleted_virtual(void);
90
91// 3.3.2 One-time Construction API
92#if defined(_LIBCXXABI_GUARD_ABI_ARM)
93extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD int __cxa_guard_acquire(uint32_t *);
94extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_release(uint32_t *);
95extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_abort(uint32_t *);
96#else
97extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD int __cxa_guard_acquire(uint64_t *);
98extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_release(uint64_t *);
99extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_abort(uint64_t *);
100#endif
101
102// 3.3.3 Array Construction and Destruction API
103extern _LIBCXXABI_FUNC_VIS void *
104__cxa_vec_new(size_t element_count, size_t element_size, size_t padding_size,
105 void (*constructor)(void *), void (*destructor)(void *));
106
107extern _LIBCXXABI_FUNC_VIS void *
108__cxa_vec_new2(size_t element_count, size_t element_size, size_t padding_size,
109 void (*constructor)(void *), void (*destructor)(void *),
110 void *(*alloc)(size_t), void (*dealloc)(void *));
111
112extern _LIBCXXABI_FUNC_VIS void *
113__cxa_vec_new3(size_t element_count, size_t element_size, size_t padding_size,
114 void (*constructor)(void *), void (*destructor)(void *),
115 void *(*alloc)(size_t), void (*dealloc)(void *, size_t));
116
117extern _LIBCXXABI_FUNC_VIS void
118__cxa_vec_ctor(void *array_address, size_t element_count, size_t element_size,
119 void (*constructor)(void *), void (*destructor)(void *));
120
121extern _LIBCXXABI_FUNC_VIS void __cxa_vec_dtor(void *array_address,
122 size_t element_count,
123 size_t element_size,
124 void (*destructor)(void *));
125
126extern _LIBCXXABI_FUNC_VIS void __cxa_vec_cleanup(void *array_address,
127 size_t element_count,
128 size_t element_size,
129 void (*destructor)(void *));
130
131extern _LIBCXXABI_FUNC_VIS void __cxa_vec_delete(void *array_address,
132 size_t element_size,
133 size_t padding_size,
134 void (*destructor)(void *));
135
136extern _LIBCXXABI_FUNC_VIS void
137__cxa_vec_delete2(void *array_address, size_t element_size, size_t padding_size,
138 void (*destructor)(void *), void (*dealloc)(void *));
139
140extern _LIBCXXABI_FUNC_VIS void
141__cxa_vec_delete3(void *__array_address, size_t element_size,
142 size_t padding_size, void (*destructor)(void *),
143 void (*dealloc)(void *, size_t));
144
145extern _LIBCXXABI_FUNC_VIS void
146__cxa_vec_cctor(void *dest_array, void *src_array, size_t element_count,
147 size_t element_size, void (*constructor)(void *, void *),
148 void (*destructor)(void *));
149
150// 3.3.5.3 Runtime API
151// These functions are part of the C++ ABI, but they are not defined in libc++abi:
152// int __cxa_atexit(void (*)(void *), void *, void *);
153// void __cxa_finalize(void *);
154
155// 3.4 Demangler API
156extern _LIBCXXABI_FUNC_VIS char *__cxa_demangle(const char *mangled_name,
157 char *output_buffer,
158 size_t *length, int *status);
159
160// Apple additions to support C++ 0x exception_ptr class
161// These are primitives to wrap a smart pointer around an exception object
162extern _LIBCXXABI_FUNC_VIS void *__cxa_current_primary_exception() throw();
163extern _LIBCXXABI_FUNC_VIS void
164__cxa_rethrow_primary_exception(void *primary_exception);
165extern _LIBCXXABI_FUNC_VIS void
166__cxa_increment_exception_refcount(void *primary_exception) throw();
167extern _LIBCXXABI_FUNC_VIS void
168__cxa_decrement_exception_refcount(void *primary_exception) throw();
169
170// Apple extension to support std::uncaught_exception()
171extern _LIBCXXABI_FUNC_VIS bool __cxa_uncaught_exception() throw();
172extern _LIBCXXABI_FUNC_VIS unsigned int __cxa_uncaught_exceptions() throw();
173
174#if defined(__linux__) || defined(__Fuchsia__)
175// Linux and Fuchsia TLS support. Not yet an official part of the Itanium ABI.
176// https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables
177extern _LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(void (*)(void *), void *,
178 void *) throw();
179#endif
180
181} // extern "C"
182} // namespace __cxxabiv1
183
184namespace abi = __cxxabiv1;
185
186#endif // __cplusplus
187
188#endif // __CXXABI_H
189

Warning: This file is not a C or C++ file. It does not have highlighting.

source code of libcxxabi/include/cxxabi.h