132 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef ____CXXABI_CONFIG_H10#define ____CXXABI_CONFIG_H11 12#if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \13 !defined(__ARM_DWARF_EH__) && !defined(__SEH__)14#define _LIBCXXABI_ARM_EHABI15#endif16 17#if defined(__clang__)18# define _LIBCXXABI_COMPILER_CLANG19# ifndef __apple_build_version__20# define _LIBCXXABI_CLANG_VER (__clang_major__ * 100 + __clang_minor__)21# endif22#elif defined(__GNUC__)23# define _LIBCXXABI_COMPILER_GCC24#endif25 26#if defined(_WIN32)27 #if defined(_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCXXABI_BUILDING_LIBRARY))28 #define _LIBCXXABI_HIDDEN29 #define _LIBCXXABI_DATA_VIS30 #define _LIBCXXABI_FUNC_VIS31 #define _LIBCXXABI_TYPE_VIS32 #elif defined(_LIBCXXABI_BUILDING_LIBRARY)33 #define _LIBCXXABI_HIDDEN34 #define _LIBCXXABI_DATA_VIS __declspec(dllexport)35 #define _LIBCXXABI_FUNC_VIS __declspec(dllexport)36 #define _LIBCXXABI_TYPE_VIS __declspec(dllexport)37 #else38 #define _LIBCXXABI_HIDDEN39 #define _LIBCXXABI_DATA_VIS __declspec(dllimport)40 #define _LIBCXXABI_FUNC_VIS __declspec(dllimport)41 #define _LIBCXXABI_TYPE_VIS __declspec(dllimport)42 #endif43#else44 #if !defined(_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS)45 #define _LIBCXXABI_HIDDEN __attribute__((__visibility__("hidden")))46 #define _LIBCXXABI_DATA_VIS __attribute__((__visibility__("default")))47 #define _LIBCXXABI_FUNC_VIS __attribute__((__visibility__("default")))48 #if __has_attribute(__type_visibility__)49 #define _LIBCXXABI_TYPE_VIS __attribute__((__type_visibility__("default")))50 #else51 #define _LIBCXXABI_TYPE_VIS __attribute__((__visibility__("default")))52 #endif53 #else54 #define _LIBCXXABI_HIDDEN55 #define _LIBCXXABI_DATA_VIS56 #define _LIBCXXABI_FUNC_VIS57 #define _LIBCXXABI_TYPE_VIS58 #endif59#endif60 61#define _LIBCXXABI_WEAK __attribute__((__weak__))62 63#if __has_attribute(__no_sanitize__) && defined(_LIBCXXABI_COMPILER_CLANG)64#define _LIBCXXABI_NO_CFI __attribute__((__no_sanitize__("cfi")))65#else66#define _LIBCXXABI_NO_CFI67#endif68 69// wasm32 follows the arm32 ABI convention of using 32-bit guard.70#if defined(__arm__) || defined(__wasm32__) || defined(__ARM64_ARCH_8_32__)71# define _LIBCXXABI_GUARD_ABI_ARM72#endif73 74#if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L75# define _LIBCXXABI_NO_EXCEPTIONS76#endif77 78#if defined(_WIN32)79#define _LIBCXXABI_DTOR_FUNC __thiscall80#else81#define _LIBCXXABI_DTOR_FUNC82#endif83 84#if __has_include(<ptrauth.h>)85# include <ptrauth.h>86#endif87 88#if __has_feature(ptrauth_calls)89 90// ptrauth_string_discriminator("__cxa_exception::actionRecord") == 0xFC9191# define __ptrauth_cxxabi_action_record __ptrauth(ptrauth_key_process_dependent_data, 1, 0xFC91)92 93// ptrauth_string_discriminator("__cxa_exception::languageSpecificData") == 0xE8EE94# define __ptrauth_cxxabi_lsd __ptrauth(ptrauth_key_process_dependent_data, 1, 0xE8EE)95 96// ptrauth_string_discriminator("__cxa_exception::catchTemp") == 0xFA5897# define __ptrauth_cxxabi_catch_temp_disc 0xFA5898# define __ptrauth_cxxabi_catch_temp_key ptrauth_key_process_dependent_data99# define __ptrauth_cxxabi_catch_temp __ptrauth(__ptrauth_cxxabi_catch_temp_key, 1, __ptrauth_cxxabi_catch_temp_disc)100 101// ptrauth_string_discriminator("__cxa_exception::adjustedPtr") == 0x99E4102# define __ptrauth_cxxabi_adjusted_ptr __ptrauth(ptrauth_key_process_dependent_data, 1, 0x99E4)103 104// ptrauth_string_discriminator("__cxa_exception::unexpectedHandler") == 0x99A9105# define __ptrauth_cxxabi_unexpected_handler __ptrauth(ptrauth_key_function_pointer, 1, 0x99A9)106 107// ptrauth_string_discriminator("__cxa_exception::terminateHandler") == 0x0886)108# define __ptrauth_cxxabi_terminate_handler __ptrauth(ptrauth_key_function_pointer, 1, 0x886)109 110// ptrauth_string_discriminator("__cxa_exception::exceptionDestructor") == 0xC088111# define __ptrauth_cxxabi_exception_destructor __ptrauth(ptrauth_key_function_pointer, 1, 0xC088)112 113#else114 115# define __ptrauth_cxxabi_action_record116# define __ptrauth_cxxabi_lsd117# define __ptrauth_cxxabi_catch_temp118# define __ptrauth_cxxabi_adjusted_ptr119# define __ptrauth_cxxabi_unexpected_handler120# define __ptrauth_cxxabi_terminate_handler121# define __ptrauth_cxxabi_exception_destructor122 123#endif124 125#if __cplusplus < 201103L126# define _LIBCXXABI_NOEXCEPT throw()127#else128# define _LIBCXXABI_NOEXCEPT noexcept129#endif130 131#endif // ____CXXABI_CONFIG_H132