Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:14:08

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef __CXXABI_H
0010 #define __CXXABI_H
0011 
0012 /*
0013  * This header provides the interface to the C++ ABI as defined at:
0014  *       https://itanium-cxx-abi.github.io/cxx-abi/
0015  */
0016 
0017 #include <stddef.h>
0018 #include <stdint.h>
0019 
0020 #include <__cxxabi_config.h>
0021 
0022 #define _LIBCPPABI_VERSION 15000
0023 #define _LIBCXXABI_NORETURN  __attribute__((noreturn))
0024 #define _LIBCXXABI_ALWAYS_COLD __attribute__((cold))
0025 
0026 #ifdef __cplusplus
0027 
0028 namespace std {
0029 #if defined(_WIN32)
0030 class _LIBCXXABI_TYPE_VIS type_info; // forward declaration
0031 #else
0032 class type_info; // forward declaration
0033 #endif
0034 }
0035 
0036 
0037 // runtime routines use C calling conventions, but are in __cxxabiv1 namespace
0038 namespace __cxxabiv1 {
0039 
0040 struct __cxa_exception;
0041 
0042 extern "C"  {
0043 
0044 // 2.4.2 Allocating the Exception Object
0045 extern _LIBCXXABI_FUNC_VIS void *
0046 __cxa_allocate_exception(size_t thrown_size) _LIBCXXABI_NOEXCEPT;
0047 extern _LIBCXXABI_FUNC_VIS void
0048 __cxa_free_exception(void *thrown_exception) _LIBCXXABI_NOEXCEPT;
0049 // This function is an LLVM extension, which mirrors the same extension in libsupc++ and libcxxrt
0050 extern _LIBCXXABI_FUNC_VIS __cxa_exception*
0051 #ifdef __wasm__
0052 // In Wasm, a destructor returns its argument
0053 __cxa_init_primary_exception(void* object, std::type_info* tinfo, void*(_LIBCXXABI_DTOR_FUNC* dest)(void*)) _LIBCXXABI_NOEXCEPT;
0054 #else
0055 __cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) _LIBCXXABI_NOEXCEPT;
0056 #endif
0057 
0058 // 2.4.3 Throwing the Exception Object
0059 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
0060 __cxa_throw(void *thrown_exception, std::type_info *tinfo,
0061 #ifdef __wasm__
0062             void *(_LIBCXXABI_DTOR_FUNC *dest)(void *));
0063 #else
0064             void (_LIBCXXABI_DTOR_FUNC *dest)(void *));
0065 #endif
0066 
0067 // 2.5.3 Exception Handlers
0068 extern _LIBCXXABI_FUNC_VIS void *
0069 __cxa_get_exception_ptr(void *exceptionObject) _LIBCXXABI_NOEXCEPT;
0070 extern _LIBCXXABI_FUNC_VIS void *
0071 __cxa_begin_catch(void *exceptionObject) _LIBCXXABI_NOEXCEPT;
0072 extern _LIBCXXABI_FUNC_VIS void __cxa_end_catch();
0073 #if defined(_LIBCXXABI_ARM_EHABI)
0074 extern _LIBCXXABI_FUNC_VIS bool
0075 __cxa_begin_cleanup(void *exceptionObject) _LIBCXXABI_NOEXCEPT;
0076 extern _LIBCXXABI_FUNC_VIS void __cxa_end_cleanup();
0077 #endif
0078 extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type();
0079 
0080 // GNU extension
0081 // Calls `terminate` with the current exception being caught. This function is used by GCC when a `noexcept` function
0082 // throws an exception inside a try/catch block and doesn't catch it.
0083 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_call_terminate(void*) _LIBCXXABI_NOEXCEPT;
0084 
0085 // 2.5.4 Rethrowing Exceptions
0086 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_rethrow();
0087 
0088 // 2.6 Auxiliary Runtime APIs
0089 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_cast(void);
0090 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
0091 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
0092 __cxa_throw_bad_array_new_length(void);
0093 
0094 // 3.2.6 Pure Virtual Function API
0095 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
0096 
0097 // 3.2.7 Deleted Virtual Function API
0098 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_deleted_virtual(void);
0099 
0100 // 3.3.2 One-time Construction API
0101 #if defined(_LIBCXXABI_GUARD_ABI_ARM)
0102 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD int __cxa_guard_acquire(uint32_t *);
0103 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_release(uint32_t *);
0104 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_abort(uint32_t *);
0105 #else
0106 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD int __cxa_guard_acquire(uint64_t *);
0107 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_release(uint64_t *);
0108 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_abort(uint64_t *);
0109 #endif
0110 
0111 // 3.3.3 Array Construction and Destruction API
0112 extern _LIBCXXABI_FUNC_VIS void *
0113 __cxa_vec_new(size_t element_count, size_t element_size, size_t padding_size,
0114               void (*constructor)(void *), void (*destructor)(void *));
0115 
0116 extern _LIBCXXABI_FUNC_VIS void *
0117 __cxa_vec_new2(size_t element_count, size_t element_size, size_t padding_size,
0118                void (*constructor)(void *), void (*destructor)(void *),
0119                void *(*alloc)(size_t), void (*dealloc)(void *));
0120 
0121 extern _LIBCXXABI_FUNC_VIS void *
0122 __cxa_vec_new3(size_t element_count, size_t element_size, size_t padding_size,
0123                void (*constructor)(void *), void (*destructor)(void *),
0124                void *(*alloc)(size_t), void (*dealloc)(void *, size_t));
0125 
0126 extern _LIBCXXABI_FUNC_VIS void
0127 __cxa_vec_ctor(void *array_address, size_t element_count, size_t element_size,
0128                void (*constructor)(void *), void (*destructor)(void *));
0129 
0130 extern _LIBCXXABI_FUNC_VIS void __cxa_vec_dtor(void *array_address,
0131                                                size_t element_count,
0132                                                size_t element_size,
0133                                                void (*destructor)(void *));
0134 
0135 extern _LIBCXXABI_FUNC_VIS void __cxa_vec_cleanup(void *array_address,
0136                                                   size_t element_count,
0137                                                   size_t element_size,
0138                                                   void (*destructor)(void *));
0139 
0140 extern _LIBCXXABI_FUNC_VIS void __cxa_vec_delete(void *array_address,
0141                                                  size_t element_size,
0142                                                  size_t padding_size,
0143                                                  void (*destructor)(void *));
0144 
0145 extern _LIBCXXABI_FUNC_VIS void
0146 __cxa_vec_delete2(void *array_address, size_t element_size, size_t padding_size,
0147                   void (*destructor)(void *), void (*dealloc)(void *));
0148 
0149 extern _LIBCXXABI_FUNC_VIS void
0150 __cxa_vec_delete3(void *__array_address, size_t element_size,
0151                   size_t padding_size, void (*destructor)(void *),
0152                   void (*dealloc)(void *, size_t));
0153 
0154 extern _LIBCXXABI_FUNC_VIS void
0155 __cxa_vec_cctor(void *dest_array, void *src_array, size_t element_count,
0156                 size_t element_size, void (*constructor)(void *, void *),
0157                 void (*destructor)(void *));
0158 
0159 // 3.3.5.3 Runtime API
0160 // These functions are part of the C++ ABI, but they are not defined in libc++abi:
0161 //    int __cxa_atexit(void (*)(void *), void *, void *);
0162 //    void __cxa_finalize(void *);
0163 
0164 // 3.4 Demangler API
0165 extern _LIBCXXABI_FUNC_VIS char *__cxa_demangle(const char *mangled_name,
0166                                                 char *output_buffer,
0167                                                 size_t *length, int *status);
0168 
0169 // Apple additions to support C++ 0x exception_ptr class
0170 // These are primitives to wrap a smart pointer around an exception object
0171 extern _LIBCXXABI_FUNC_VIS void *__cxa_current_primary_exception() _LIBCXXABI_NOEXCEPT;
0172 extern _LIBCXXABI_FUNC_VIS void
0173 __cxa_rethrow_primary_exception(void *primary_exception);
0174 extern _LIBCXXABI_FUNC_VIS void
0175 __cxa_increment_exception_refcount(void *primary_exception) _LIBCXXABI_NOEXCEPT;
0176 extern _LIBCXXABI_FUNC_VIS void
0177 __cxa_decrement_exception_refcount(void *primary_exception) _LIBCXXABI_NOEXCEPT;
0178 
0179 // Apple extension to support std::uncaught_exception()
0180 extern _LIBCXXABI_FUNC_VIS bool __cxa_uncaught_exception() _LIBCXXABI_NOEXCEPT;
0181 extern _LIBCXXABI_FUNC_VIS unsigned int __cxa_uncaught_exceptions() _LIBCXXABI_NOEXCEPT;
0182 
0183 #if defined(__linux__) || defined(__Fuchsia__)
0184 // Linux and Fuchsia TLS support. Not yet an official part of the Itanium ABI.
0185 // https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables
0186 extern _LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(void (*)(void *), void *,
0187                                                    void *) _LIBCXXABI_NOEXCEPT;
0188 #endif
0189 
0190 } // extern "C"
0191 } // namespace __cxxabiv1
0192 
0193 namespace abi = __cxxabiv1;
0194 
0195 #endif // __cplusplus
0196 
0197 #endif // __CXXABI_H