2011-05-05 23:27:28 +08:00
|
|
|
//===--------------------------- cxxabi.h ---------------------------------===//
|
|
|
|
//
|
2019-01-19 18:56:40 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2011-05-05 23:27:28 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef __CXXABI_H
|
2015-02-05 05:23:20 +08:00
|
|
|
#define __CXXABI_H
|
2011-05-05 23:27:28 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This header provides the interface to the C++ ABI as defined at:
|
2019-10-02 02:14:27 +08:00
|
|
|
* https://itanium-cxx-abi.github.io/cxx-abi/
|
2011-05-05 23:27:28 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2015-02-06 07:55:15 +08:00
|
|
|
#include <__cxxabi_config.h>
|
|
|
|
|
2015-06-02 21:03:17 +08:00
|
|
|
#define _LIBCPPABI_VERSION 1002
|
2017-03-01 10:23:54 +08:00
|
|
|
#define _LIBCXXABI_NORETURN __attribute__((noreturn))
|
2020-08-13 13:11:50 +08:00
|
|
|
#define _LIBCXXABI_ALWAYS_COLD __attribute__((cold))
|
2011-06-03 10:04:41 +08:00
|
|
|
|
2011-08-02 13:15:26 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2011-05-05 23:27:28 +08:00
|
|
|
namespace std {
|
2015-12-04 10:14:58 +08:00
|
|
|
#if defined(_WIN32)
|
|
|
|
class _LIBCXXABI_TYPE_VIS type_info; // forward declaration
|
|
|
|
#else
|
2015-02-05 05:23:20 +08:00
|
|
|
class type_info; // forward declaration
|
2015-12-04 10:14:58 +08:00
|
|
|
#endif
|
2011-05-05 23:27:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// runtime routines use C calling conventions, but are in __cxxabiv1 namespace
|
2015-02-05 05:23:20 +08:00
|
|
|
namespace __cxxabiv1 {
|
|
|
|
extern "C" {
|
2011-05-05 23:27:28 +08:00
|
|
|
|
|
|
|
// 2.4.2 Allocating the Exception Object
|
2015-12-04 10:14:58 +08:00
|
|
|
extern _LIBCXXABI_FUNC_VIS void *
|
|
|
|
__cxa_allocate_exception(size_t thrown_size) throw();
|
|
|
|
extern _LIBCXXABI_FUNC_VIS void
|
|
|
|
__cxa_free_exception(void *thrown_exception) throw();
|
2011-05-05 23:27:28 +08:00
|
|
|
|
|
|
|
// 2.4.3 Throwing the Exception Object
|
2017-03-01 10:23:54 +08:00
|
|
|
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
|
2015-12-04 10:14:58 +08:00
|
|
|
__cxa_throw(void *thrown_exception, std::type_info *tinfo,
|
|
|
|
void (*dest)(void *));
|
2011-05-05 23:27:28 +08:00
|
|
|
|
|
|
|
// 2.5.3 Exception Handlers
|
2015-12-04 10:14:58 +08:00
|
|
|
extern _LIBCXXABI_FUNC_VIS void *
|
|
|
|
__cxa_get_exception_ptr(void *exceptionObject) throw();
|
|
|
|
extern _LIBCXXABI_FUNC_VIS void *
|
|
|
|
__cxa_begin_catch(void *exceptionObject) throw();
|
|
|
|
extern _LIBCXXABI_FUNC_VIS void __cxa_end_catch();
|
2017-03-01 19:42:01 +08:00
|
|
|
#if defined(_LIBCXXABI_ARM_EHABI)
|
2015-12-04 10:14:58 +08:00
|
|
|
extern _LIBCXXABI_FUNC_VIS bool
|
|
|
|
__cxa_begin_cleanup(void *exceptionObject) throw();
|
|
|
|
extern _LIBCXXABI_FUNC_VIS void __cxa_end_cleanup();
|
2014-05-10 08:42:10 +08:00
|
|
|
#endif
|
2015-12-04 10:14:58 +08:00
|
|
|
extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type();
|
2011-05-05 23:27:28 +08:00
|
|
|
|
|
|
|
// 2.5.4 Rethrowing Exceptions
|
2017-03-01 10:23:54 +08:00
|
|
|
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_rethrow();
|
2011-05-05 23:27:28 +08:00
|
|
|
|
|
|
|
// 2.6 Auxiliary Runtime APIs
|
2017-03-01 10:23:54 +08:00
|
|
|
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_cast(void);
|
|
|
|
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
|
|
|
|
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
|
2015-12-04 10:14:58 +08:00
|
|
|
__cxa_throw_bad_array_new_length(void);
|
2011-05-05 23:27:28 +08:00
|
|
|
|
|
|
|
// 3.2.6 Pure Virtual Function API
|
2017-03-01 10:23:54 +08:00
|
|
|
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
|
2011-05-05 23:27:28 +08:00
|
|
|
|
2011-05-25 06:01:16 +08:00
|
|
|
// 3.2.7 Deleted Virtual Function API
|
2017-03-01 10:23:54 +08:00
|
|
|
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_deleted_virtual(void);
|
2011-05-25 06:01:16 +08:00
|
|
|
|
2011-05-05 23:27:28 +08:00
|
|
|
// 3.3.2 One-time Construction API
|
2019-04-11 01:12:06 +08:00
|
|
|
#if defined(_LIBCXXABI_GUARD_ABI_ARM)
|
2020-08-13 13:11:50 +08:00
|
|
|
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD int __cxa_guard_acquire(uint32_t *);
|
|
|
|
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_release(uint32_t *);
|
|
|
|
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_abort(uint32_t *);
|
2011-06-08 02:46:10 +08:00
|
|
|
#else
|
2020-08-13 13:11:50 +08:00
|
|
|
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD int __cxa_guard_acquire(uint64_t *);
|
|
|
|
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_release(uint64_t *);
|
|
|
|
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_abort(uint64_t *);
|
2011-06-08 02:46:10 +08:00
|
|
|
#endif
|
2011-05-05 23:27:28 +08:00
|
|
|
|
|
|
|
// 3.3.3 Array Construction and Destruction API
|
2015-12-04 10:14:58 +08:00
|
|
|
extern _LIBCXXABI_FUNC_VIS void *
|
|
|
|
__cxa_vec_new(size_t element_count, size_t element_size, size_t padding_size,
|
|
|
|
void (*constructor)(void *), void (*destructor)(void *));
|
|
|
|
|
|
|
|
extern _LIBCXXABI_FUNC_VIS void *
|
|
|
|
__cxa_vec_new2(size_t element_count, size_t element_size, size_t padding_size,
|
|
|
|
void (*constructor)(void *), void (*destructor)(void *),
|
|
|
|
void *(*alloc)(size_t), void (*dealloc)(void *));
|
|
|
|
|
|
|
|
extern _LIBCXXABI_FUNC_VIS void *
|
|
|
|
__cxa_vec_new3(size_t element_count, size_t element_size, size_t padding_size,
|
|
|
|
void (*constructor)(void *), void (*destructor)(void *),
|
|
|
|
void *(*alloc)(size_t), void (*dealloc)(void *, size_t));
|
|
|
|
|
|
|
|
extern _LIBCXXABI_FUNC_VIS void
|
|
|
|
__cxa_vec_ctor(void *array_address, size_t element_count, size_t element_size,
|
|
|
|
void (*constructor)(void *), void (*destructor)(void *));
|
|
|
|
|
|
|
|
extern _LIBCXXABI_FUNC_VIS void __cxa_vec_dtor(void *array_address,
|
|
|
|
size_t element_count,
|
|
|
|
size_t element_size,
|
|
|
|
void (*destructor)(void *));
|
|
|
|
|
|
|
|
extern _LIBCXXABI_FUNC_VIS void __cxa_vec_cleanup(void *array_address,
|
|
|
|
size_t element_count,
|
|
|
|
size_t element_size,
|
|
|
|
void (*destructor)(void *));
|
|
|
|
|
|
|
|
extern _LIBCXXABI_FUNC_VIS void __cxa_vec_delete(void *array_address,
|
|
|
|
size_t element_size,
|
|
|
|
size_t padding_size,
|
|
|
|
void (*destructor)(void *));
|
|
|
|
|
|
|
|
extern _LIBCXXABI_FUNC_VIS void
|
|
|
|
__cxa_vec_delete2(void *array_address, size_t element_size, size_t padding_size,
|
|
|
|
void (*destructor)(void *), void (*dealloc)(void *));
|
|
|
|
|
|
|
|
extern _LIBCXXABI_FUNC_VIS void
|
|
|
|
__cxa_vec_delete3(void *__array_address, size_t element_size,
|
|
|
|
size_t padding_size, void (*destructor)(void *),
|
|
|
|
void (*dealloc)(void *, size_t));
|
|
|
|
|
|
|
|
extern _LIBCXXABI_FUNC_VIS void
|
|
|
|
__cxa_vec_cctor(void *dest_array, void *src_array, size_t element_count,
|
|
|
|
size_t element_size, void (*constructor)(void *, void *),
|
|
|
|
void (*destructor)(void *));
|
2011-05-05 23:27:28 +08:00
|
|
|
|
|
|
|
// 3.3.5.3 Runtime API
|
2020-09-15 05:16:46 +08:00
|
|
|
// These functions are part of the C++ ABI, but they are not defined in libc++abi:
|
|
|
|
// int __cxa_atexit(void (*)(void *), void *, void *);
|
|
|
|
// void __cxa_finalize(void *);
|
2011-05-05 23:27:28 +08:00
|
|
|
|
|
|
|
// 3.4 Demangler API
|
2015-12-04 10:14:58 +08:00
|
|
|
extern _LIBCXXABI_FUNC_VIS char *__cxa_demangle(const char *mangled_name,
|
|
|
|
char *output_buffer,
|
|
|
|
size_t *length, int *status);
|
2011-05-05 23:27:28 +08:00
|
|
|
|
|
|
|
// Apple additions to support C++ 0x exception_ptr class
|
|
|
|
// These are primitives to wrap a smart pointer around an exception object
|
2015-12-04 10:14:58 +08:00
|
|
|
extern _LIBCXXABI_FUNC_VIS void *__cxa_current_primary_exception() throw();
|
|
|
|
extern _LIBCXXABI_FUNC_VIS void
|
|
|
|
__cxa_rethrow_primary_exception(void *primary_exception);
|
|
|
|
extern _LIBCXXABI_FUNC_VIS void
|
|
|
|
__cxa_increment_exception_refcount(void *primary_exception) throw();
|
|
|
|
extern _LIBCXXABI_FUNC_VIS void
|
|
|
|
__cxa_decrement_exception_refcount(void *primary_exception) throw();
|
2011-05-05 23:27:28 +08:00
|
|
|
|
2015-06-02 21:03:17 +08:00
|
|
|
// Apple extension to support std::uncaught_exception()
|
2015-12-04 10:14:58 +08:00
|
|
|
extern _LIBCXXABI_FUNC_VIS bool __cxa_uncaught_exception() throw();
|
|
|
|
extern _LIBCXXABI_FUNC_VIS unsigned int __cxa_uncaught_exceptions() throw();
|
2011-05-05 23:27:28 +08:00
|
|
|
|
2018-10-30 04:20:26 +08:00
|
|
|
#if defined(__linux__) || defined(__Fuchsia__)
|
|
|
|
// Linux and Fuchsia TLS support. Not yet an official part of the Itanium ABI.
|
2014-12-18 08:03:57 +08:00
|
|
|
// https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables
|
2015-12-04 10:14:58 +08:00
|
|
|
extern _LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(void (*)(void *), void *,
|
|
|
|
void *) throw();
|
2014-12-18 08:03:57 +08:00
|
|
|
#endif
|
|
|
|
|
2015-12-04 10:14:41 +08:00
|
|
|
} // extern "C"
|
2011-05-05 23:27:28 +08:00
|
|
|
} // namespace __cxxabiv1
|
|
|
|
|
2012-02-18 02:45:44 +08:00
|
|
|
namespace abi = __cxxabiv1;
|
2011-05-05 23:27:28 +08:00
|
|
|
|
2014-06-26 06:49:13 +08:00
|
|
|
#endif // __cplusplus
|
|
|
|
|
2015-02-05 05:23:20 +08:00
|
|
|
#endif // __CXXABI_H
|