Path: blob/main/system/lib/libcxxabi/include/cxxabi.h
6182 views
//===----------------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef __CXXABI_H9#define __CXXABI_H1011/*12* This header provides the interface to the C++ ABI as defined at:13* https://itanium-cxx-abi.github.io/cxx-abi/14*/1516#include <stddef.h>17#include <stdint.h>1819#include <__cxxabi_config.h>2021#define _LIBCPPABI_VERSION 1500022#define _LIBCXXABI_NORETURN __attribute__((noreturn))23#define _LIBCXXABI_ALWAYS_COLD __attribute__((cold))2425#ifdef __cplusplus2627namespace std {28#if defined(_WIN32)29class _LIBCXXABI_TYPE_VIS type_info; // forward declaration30#else31class type_info; // forward declaration32#endif33}343536// runtime routines use C calling conventions, but are in __cxxabiv1 namespace37namespace __cxxabiv1 {3839struct __cxa_exception;4041extern "C" {4243// 2.4.2 Allocating the Exception Object44extern _LIBCXXABI_FUNC_VIS void *45__cxa_allocate_exception(size_t thrown_size) _LIBCXXABI_NOEXCEPT;46extern _LIBCXXABI_FUNC_VIS void47__cxa_free_exception(void *thrown_exception) _LIBCXXABI_NOEXCEPT;48// This function is an LLVM extension, which mirrors the same extension in libsupc++ and libcxxrt49extern _LIBCXXABI_FUNC_VIS __cxa_exception*50#ifdef __wasm__51// In Wasm, a destructor returns its argument52__cxa_init_primary_exception(void* object, std::type_info* tinfo, void*(_LIBCXXABI_DTOR_FUNC* dest)(void*)) _LIBCXXABI_NOEXCEPT;53#else54__cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) _LIBCXXABI_NOEXCEPT;55#endif5657// 2.4.3 Throwing the Exception Object58extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void59__cxa_throw(void *thrown_exception, std::type_info *tinfo,60#ifdef __wasm__61void *(_LIBCXXABI_DTOR_FUNC *dest)(void *));62#else63void (_LIBCXXABI_DTOR_FUNC *dest)(void *));64#endif6566// 2.5.3 Exception Handlers67extern _LIBCXXABI_FUNC_VIS void *68__cxa_get_exception_ptr(void *exceptionObject) _LIBCXXABI_NOEXCEPT;69extern _LIBCXXABI_FUNC_VIS void *70__cxa_begin_catch(void *exceptionObject) _LIBCXXABI_NOEXCEPT;71extern _LIBCXXABI_FUNC_VIS void __cxa_end_catch();72#if defined(_LIBCXXABI_ARM_EHABI)73extern _LIBCXXABI_FUNC_VIS bool74__cxa_begin_cleanup(void *exceptionObject) _LIBCXXABI_NOEXCEPT;75extern _LIBCXXABI_FUNC_VIS void __cxa_end_cleanup();76#endif77extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type();7879// GNU extension80// Calls `terminate` with the current exception being caught. This function is used by GCC when a `noexcept` function81// throws an exception inside a try/catch block and doesn't catch it.82extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_call_terminate(void*) _LIBCXXABI_NOEXCEPT;8384// 2.5.4 Rethrowing Exceptions85extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_rethrow();8687// 2.6 Auxiliary Runtime APIs88extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_cast(void);89extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_typeid(void);90extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void91__cxa_throw_bad_array_new_length(void);9293// 3.2.6 Pure Virtual Function API94extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_pure_virtual(void);9596// 3.2.7 Deleted Virtual Function API97extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_deleted_virtual(void);9899// 3.3.2 One-time Construction API100#if defined(_LIBCXXABI_GUARD_ABI_ARM)101extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD int __cxa_guard_acquire(uint32_t *);102extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_release(uint32_t *);103extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_abort(uint32_t *);104#else105extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD int __cxa_guard_acquire(uint64_t *);106extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_release(uint64_t *);107extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_abort(uint64_t *);108#endif109110// 3.3.3 Array Construction and Destruction API111extern _LIBCXXABI_FUNC_VIS void *112__cxa_vec_new(size_t element_count, size_t element_size, size_t padding_size,113void (*constructor)(void *), void (*destructor)(void *));114115extern _LIBCXXABI_FUNC_VIS void *116__cxa_vec_new2(size_t element_count, size_t element_size, size_t padding_size,117void (*constructor)(void *), void (*destructor)(void *),118void *(*alloc)(size_t), void (*dealloc)(void *));119120extern _LIBCXXABI_FUNC_VIS void *121__cxa_vec_new3(size_t element_count, size_t element_size, size_t padding_size,122void (*constructor)(void *), void (*destructor)(void *),123void *(*alloc)(size_t), void (*dealloc)(void *, size_t));124125extern _LIBCXXABI_FUNC_VIS void126__cxa_vec_ctor(void *array_address, size_t element_count, size_t element_size,127void (*constructor)(void *), void (*destructor)(void *));128129extern _LIBCXXABI_FUNC_VIS void __cxa_vec_dtor(void *array_address,130size_t element_count,131size_t element_size,132void (*destructor)(void *));133134extern _LIBCXXABI_FUNC_VIS void __cxa_vec_cleanup(void *array_address,135size_t element_count,136size_t element_size,137void (*destructor)(void *));138139extern _LIBCXXABI_FUNC_VIS void __cxa_vec_delete(void *array_address,140size_t element_size,141size_t padding_size,142void (*destructor)(void *));143144extern _LIBCXXABI_FUNC_VIS void145__cxa_vec_delete2(void *array_address, size_t element_size, size_t padding_size,146void (*destructor)(void *), void (*dealloc)(void *));147148extern _LIBCXXABI_FUNC_VIS void149__cxa_vec_delete3(void *__array_address, size_t element_size,150size_t padding_size, void (*destructor)(void *),151void (*dealloc)(void *, size_t));152153extern _LIBCXXABI_FUNC_VIS void154__cxa_vec_cctor(void *dest_array, void *src_array, size_t element_count,155size_t element_size, void (*constructor)(void *, void *),156void (*destructor)(void *));157158// 3.3.5.3 Runtime API159// These functions are part of the C++ ABI, but they are not defined in libc++abi:160// int __cxa_atexit(void (*)(void *), void *, void *);161// void __cxa_finalize(void *);162163// 3.4 Demangler API164extern _LIBCXXABI_FUNC_VIS char *__cxa_demangle(const char *mangled_name,165char *output_buffer,166size_t *length, int *status);167168// Apple additions to support C++ 0x exception_ptr class169// These are primitives to wrap a smart pointer around an exception object170extern _LIBCXXABI_FUNC_VIS void *__cxa_current_primary_exception() _LIBCXXABI_NOEXCEPT;171extern _LIBCXXABI_FUNC_VIS void172__cxa_rethrow_primary_exception(void *primary_exception);173extern _LIBCXXABI_FUNC_VIS void174__cxa_increment_exception_refcount(void *primary_exception) _LIBCXXABI_NOEXCEPT;175extern _LIBCXXABI_FUNC_VIS void176__cxa_decrement_exception_refcount(void *primary_exception) _LIBCXXABI_NOEXCEPT;177178// Apple extension to support std::uncaught_exception()179extern _LIBCXXABI_FUNC_VIS bool __cxa_uncaught_exception() _LIBCXXABI_NOEXCEPT;180extern _LIBCXXABI_FUNC_VIS unsigned int __cxa_uncaught_exceptions() _LIBCXXABI_NOEXCEPT;181182#if defined(__linux__) || defined(__Fuchsia__)183// Linux and Fuchsia TLS support. Not yet an official part of the Itanium ABI.184// https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables185extern _LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(void (*)(void *), void *,186void *) _LIBCXXABI_NOEXCEPT;187#endif188189} // extern "C"190} // namespace __cxxabiv1191192namespace abi = __cxxabiv1;193194#endif // __cplusplus195196#endif // __CXXABI_H197198199