11cb0ef41Sopenharmony_ci// Copyright 2013 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#ifndef V8CONFIG_H_ 61cb0ef41Sopenharmony_ci#define V8CONFIG_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#ifdef V8_GN_HEADER 91cb0ef41Sopenharmony_ci#if __cplusplus >= 201703L && !__has_include("v8-gn.h") 101cb0ef41Sopenharmony_ci#error Missing v8-gn.h. The configuration for v8 is missing from the include \ 111cb0ef41Sopenharmony_cipath. Add it with -I<path> to the command line 121cb0ef41Sopenharmony_ci#endif 131cb0ef41Sopenharmony_ci#include "v8-gn.h" // NOLINT(build/include_directory) 141cb0ef41Sopenharmony_ci#endif 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci// clang-format off 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci// Platform headers for feature detection below. 191cb0ef41Sopenharmony_ci#if defined(__ANDROID__) 201cb0ef41Sopenharmony_ci# include <sys/cdefs.h> 211cb0ef41Sopenharmony_ci#elif defined(__APPLE__) 221cb0ef41Sopenharmony_ci# include <TargetConditionals.h> 231cb0ef41Sopenharmony_ci#elif defined(__linux__) 241cb0ef41Sopenharmony_ci# include <features.h> 251cb0ef41Sopenharmony_ci#endif 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci// This macro allows to test for the version of the GNU C library (or 291cb0ef41Sopenharmony_ci// a compatible C library that masquerades as glibc). It evaluates to 301cb0ef41Sopenharmony_ci// 0 if libc is not GNU libc or compatible. 311cb0ef41Sopenharmony_ci// Use like: 321cb0ef41Sopenharmony_ci// #if V8_GLIBC_PREREQ(2, 3) 331cb0ef41Sopenharmony_ci// ... 341cb0ef41Sopenharmony_ci// #endif 351cb0ef41Sopenharmony_ci#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) 361cb0ef41Sopenharmony_ci# define V8_GLIBC_PREREQ(major, minor) \ 371cb0ef41Sopenharmony_ci ((__GLIBC__ * 100 + __GLIBC_MINOR__) >= ((major) * 100 + (minor))) 381cb0ef41Sopenharmony_ci#else 391cb0ef41Sopenharmony_ci# define V8_GLIBC_PREREQ(major, minor) 0 401cb0ef41Sopenharmony_ci#endif 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci// This macro allows to test for the version of the GNU C++ compiler. 441cb0ef41Sopenharmony_ci// Note that this also applies to compilers that masquerade as GCC, 451cb0ef41Sopenharmony_ci// for example clang and the Intel C++ compiler for Linux. 461cb0ef41Sopenharmony_ci// Use like: 471cb0ef41Sopenharmony_ci// #if V8_GNUC_PREREQ(4, 3, 1) 481cb0ef41Sopenharmony_ci// ... 491cb0ef41Sopenharmony_ci// #endif 501cb0ef41Sopenharmony_ci#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) 511cb0ef41Sopenharmony_ci# define V8_GNUC_PREREQ(major, minor, patchlevel) \ 521cb0ef41Sopenharmony_ci ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \ 531cb0ef41Sopenharmony_ci ((major) * 10000 + (minor) * 100 + (patchlevel))) 541cb0ef41Sopenharmony_ci#elif defined(__GNUC__) && defined(__GNUC_MINOR__) 551cb0ef41Sopenharmony_ci# define V8_GNUC_PREREQ(major, minor, patchlevel) \ 561cb0ef41Sopenharmony_ci ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= \ 571cb0ef41Sopenharmony_ci ((major) * 10000 + (minor) * 100 + (patchlevel))) 581cb0ef41Sopenharmony_ci#else 591cb0ef41Sopenharmony_ci# define V8_GNUC_PREREQ(major, minor, patchlevel) 0 601cb0ef41Sopenharmony_ci#endif 611cb0ef41Sopenharmony_ci 621cb0ef41Sopenharmony_ci 631cb0ef41Sopenharmony_ci 641cb0ef41Sopenharmony_ci// ----------------------------------------------------------------------------- 651cb0ef41Sopenharmony_ci// Operating system detection (host) 661cb0ef41Sopenharmony_ci// 671cb0ef41Sopenharmony_ci// V8_OS_ANDROID - Android 681cb0ef41Sopenharmony_ci// V8_OS_BSD - BSDish (macOS, Net/Free/Open/DragonFlyBSD) 691cb0ef41Sopenharmony_ci// V8_OS_CYGWIN - Cygwin 701cb0ef41Sopenharmony_ci// V8_OS_DRAGONFLYBSD - DragonFlyBSD 711cb0ef41Sopenharmony_ci// V8_OS_FREEBSD - FreeBSD 721cb0ef41Sopenharmony_ci// V8_OS_FUCHSIA - Fuchsia 731cb0ef41Sopenharmony_ci// V8_OS_LINUX - Linux (Android, ChromeOS, Linux, ...) 741cb0ef41Sopenharmony_ci// V8_OS_DARWIN - Darwin (macOS, iOS) 751cb0ef41Sopenharmony_ci// V8_OS_MACOS - macOS 761cb0ef41Sopenharmony_ci// V8_OS_IOS - iOS 771cb0ef41Sopenharmony_ci// V8_OS_NETBSD - NetBSD 781cb0ef41Sopenharmony_ci// V8_OS_OPENBSD - OpenBSD 791cb0ef41Sopenharmony_ci// V8_OS_POSIX - POSIX compatible (mostly everything except Windows) 801cb0ef41Sopenharmony_ci// V8_OS_QNX - QNX Neutrino 811cb0ef41Sopenharmony_ci// V8_OS_SOLARIS - Sun Solaris and OpenSolaris 821cb0ef41Sopenharmony_ci// V8_OS_STARBOARD - Starboard (platform abstraction for Cobalt) 831cb0ef41Sopenharmony_ci// V8_OS_AIX - AIX 841cb0ef41Sopenharmony_ci// V8_OS_WIN - Microsoft Windows 851cb0ef41Sopenharmony_ci 861cb0ef41Sopenharmony_ci#if defined(__ANDROID__) 871cb0ef41Sopenharmony_ci# define V8_OS_ANDROID 1 881cb0ef41Sopenharmony_ci# define V8_OS_LINUX 1 891cb0ef41Sopenharmony_ci# define V8_OS_POSIX 1 901cb0ef41Sopenharmony_ci# define V8_OS_STRING "android" 911cb0ef41Sopenharmony_ci 921cb0ef41Sopenharmony_ci#elif defined(__APPLE__) 931cb0ef41Sopenharmony_ci# define V8_OS_POSIX 1 941cb0ef41Sopenharmony_ci# define V8_OS_BSD 1 951cb0ef41Sopenharmony_ci# define V8_OS_DARWIN 1 961cb0ef41Sopenharmony_ci# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE 971cb0ef41Sopenharmony_ci# define V8_OS_IOS 1 981cb0ef41Sopenharmony_ci# define V8_OS_STRING "ios" 991cb0ef41Sopenharmony_ci# else 1001cb0ef41Sopenharmony_ci# define V8_OS_MACOS 1 1011cb0ef41Sopenharmony_ci# define V8_OS_STRING "macos" 1021cb0ef41Sopenharmony_ci# endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE 1031cb0ef41Sopenharmony_ci 1041cb0ef41Sopenharmony_ci#elif defined(__CYGWIN__) 1051cb0ef41Sopenharmony_ci# define V8_OS_CYGWIN 1 1061cb0ef41Sopenharmony_ci# define V8_OS_POSIX 1 1071cb0ef41Sopenharmony_ci# define V8_OS_STRING "cygwin" 1081cb0ef41Sopenharmony_ci 1091cb0ef41Sopenharmony_ci#elif defined(__linux__) 1101cb0ef41Sopenharmony_ci# define V8_OS_LINUX 1 1111cb0ef41Sopenharmony_ci# define V8_OS_POSIX 1 1121cb0ef41Sopenharmony_ci# define V8_OS_STRING "linux" 1131cb0ef41Sopenharmony_ci 1141cb0ef41Sopenharmony_ci#elif defined(__sun) 1151cb0ef41Sopenharmony_ci# define V8_OS_POSIX 1 1161cb0ef41Sopenharmony_ci# define V8_OS_SOLARIS 1 1171cb0ef41Sopenharmony_ci# define V8_OS_STRING "sun" 1181cb0ef41Sopenharmony_ci 1191cb0ef41Sopenharmony_ci#elif defined(STARBOARD) 1201cb0ef41Sopenharmony_ci# define V8_OS_STARBOARD 1 1211cb0ef41Sopenharmony_ci# define V8_OS_STRING "starboard" 1221cb0ef41Sopenharmony_ci 1231cb0ef41Sopenharmony_ci#elif defined(_AIX) 1241cb0ef41Sopenharmony_ci# define V8_OS_POSIX 1 1251cb0ef41Sopenharmony_ci# define V8_OS_AIX 1 1261cb0ef41Sopenharmony_ci# define V8_OS_STRING "aix" 1271cb0ef41Sopenharmony_ci 1281cb0ef41Sopenharmony_ci#elif defined(__FreeBSD__) 1291cb0ef41Sopenharmony_ci# define V8_OS_BSD 1 1301cb0ef41Sopenharmony_ci# define V8_OS_FREEBSD 1 1311cb0ef41Sopenharmony_ci# define V8_OS_POSIX 1 1321cb0ef41Sopenharmony_ci# define V8_OS_STRING "freebsd" 1331cb0ef41Sopenharmony_ci 1341cb0ef41Sopenharmony_ci#elif defined(__Fuchsia__) 1351cb0ef41Sopenharmony_ci# define V8_OS_FUCHSIA 1 1361cb0ef41Sopenharmony_ci# define V8_OS_POSIX 1 1371cb0ef41Sopenharmony_ci# define V8_OS_STRING "fuchsia" 1381cb0ef41Sopenharmony_ci 1391cb0ef41Sopenharmony_ci#elif defined(__DragonFly__) 1401cb0ef41Sopenharmony_ci# define V8_OS_BSD 1 1411cb0ef41Sopenharmony_ci# define V8_OS_DRAGONFLYBSD 1 1421cb0ef41Sopenharmony_ci# define V8_OS_POSIX 1 1431cb0ef41Sopenharmony_ci# define V8_OS_STRING "dragonflybsd" 1441cb0ef41Sopenharmony_ci 1451cb0ef41Sopenharmony_ci#elif defined(__NetBSD__) 1461cb0ef41Sopenharmony_ci# define V8_OS_BSD 1 1471cb0ef41Sopenharmony_ci# define V8_OS_NETBSD 1 1481cb0ef41Sopenharmony_ci# define V8_OS_POSIX 1 1491cb0ef41Sopenharmony_ci# define V8_OS_STRING "netbsd" 1501cb0ef41Sopenharmony_ci 1511cb0ef41Sopenharmony_ci#elif defined(__OpenBSD__) 1521cb0ef41Sopenharmony_ci# define V8_OS_BSD 1 1531cb0ef41Sopenharmony_ci# define V8_OS_OPENBSD 1 1541cb0ef41Sopenharmony_ci# define V8_OS_POSIX 1 1551cb0ef41Sopenharmony_ci# define V8_OS_STRING "openbsd" 1561cb0ef41Sopenharmony_ci 1571cb0ef41Sopenharmony_ci#elif defined(__QNXNTO__) 1581cb0ef41Sopenharmony_ci# define V8_OS_POSIX 1 1591cb0ef41Sopenharmony_ci# define V8_OS_QNX 1 1601cb0ef41Sopenharmony_ci# define V8_OS_STRING "qnx" 1611cb0ef41Sopenharmony_ci 1621cb0ef41Sopenharmony_ci#elif defined(_WIN32) 1631cb0ef41Sopenharmony_ci# define V8_OS_WIN 1 1641cb0ef41Sopenharmony_ci# define V8_OS_STRING "windows" 1651cb0ef41Sopenharmony_ci#endif 1661cb0ef41Sopenharmony_ci 1671cb0ef41Sopenharmony_ci// ----------------------------------------------------------------------------- 1681cb0ef41Sopenharmony_ci// Operating system detection (target) 1691cb0ef41Sopenharmony_ci// 1701cb0ef41Sopenharmony_ci// V8_TARGET_OS_ANDROID 1711cb0ef41Sopenharmony_ci// V8_TARGET_OS_FUCHSIA 1721cb0ef41Sopenharmony_ci// V8_TARGET_OS_IOS 1731cb0ef41Sopenharmony_ci// V8_TARGET_OS_LINUX 1741cb0ef41Sopenharmony_ci// V8_TARGET_OS_MACOS 1751cb0ef41Sopenharmony_ci// V8_TARGET_OS_WIN 1761cb0ef41Sopenharmony_ci// V8_TARGET_OS_CHROMEOS 1771cb0ef41Sopenharmony_ci// 1781cb0ef41Sopenharmony_ci// If not set explicitly, these fall back to corresponding V8_OS_ values. 1791cb0ef41Sopenharmony_ci 1801cb0ef41Sopenharmony_ci#ifdef V8_HAVE_TARGET_OS 1811cb0ef41Sopenharmony_ci 1821cb0ef41Sopenharmony_ci// The target OS is provided, just check that at least one known value is set. 1831cb0ef41Sopenharmony_ci# if !defined(V8_TARGET_OS_ANDROID) \ 1841cb0ef41Sopenharmony_ci && !defined(V8_TARGET_OS_FUCHSIA) \ 1851cb0ef41Sopenharmony_ci && !defined(V8_TARGET_OS_IOS) \ 1861cb0ef41Sopenharmony_ci && !defined(V8_TARGET_OS_LINUX) \ 1871cb0ef41Sopenharmony_ci && !defined(V8_TARGET_OS_MACOS) \ 1881cb0ef41Sopenharmony_ci && !defined(V8_TARGET_OS_WIN) \ 1891cb0ef41Sopenharmony_ci && !defined(V8_TARGET_OS_CHROMEOS) 1901cb0ef41Sopenharmony_ci# error No known target OS defined. 1911cb0ef41Sopenharmony_ci# endif 1921cb0ef41Sopenharmony_ci 1931cb0ef41Sopenharmony_ci#else // V8_HAVE_TARGET_OS 1941cb0ef41Sopenharmony_ci 1951cb0ef41Sopenharmony_ci# if defined(V8_TARGET_OS_ANDROID) \ 1961cb0ef41Sopenharmony_ci || defined(V8_TARGET_OS_FUCHSIA) \ 1971cb0ef41Sopenharmony_ci || defined(V8_TARGET_OS_IOS) \ 1981cb0ef41Sopenharmony_ci || defined(V8_TARGET_OS_LINUX) \ 1991cb0ef41Sopenharmony_ci || defined(V8_TARGET_OS_MACOS) \ 2001cb0ef41Sopenharmony_ci || defined(V8_TARGET_OS_WIN) \ 2011cb0ef41Sopenharmony_ci || defined(V8_TARGET_OS_CHROMEOS) 2021cb0ef41Sopenharmony_ci# error A target OS is defined but V8_HAVE_TARGET_OS is unset. 2031cb0ef41Sopenharmony_ci# endif 2041cb0ef41Sopenharmony_ci 2051cb0ef41Sopenharmony_ci// Fall back to the detected host OS. 2061cb0ef41Sopenharmony_ci#ifdef V8_OS_ANDROID 2071cb0ef41Sopenharmony_ci# define V8_TARGET_OS_ANDROID 2081cb0ef41Sopenharmony_ci#endif 2091cb0ef41Sopenharmony_ci 2101cb0ef41Sopenharmony_ci#ifdef V8_OS_FUCHSIA 2111cb0ef41Sopenharmony_ci# define V8_TARGET_OS_FUCHSIA 2121cb0ef41Sopenharmony_ci#endif 2131cb0ef41Sopenharmony_ci 2141cb0ef41Sopenharmony_ci#ifdef V8_OS_IOS 2151cb0ef41Sopenharmony_ci# define V8_TARGET_OS_IOS 2161cb0ef41Sopenharmony_ci#endif 2171cb0ef41Sopenharmony_ci 2181cb0ef41Sopenharmony_ci#ifdef V8_OS_LINUX 2191cb0ef41Sopenharmony_ci# define V8_TARGET_OS_LINUX 2201cb0ef41Sopenharmony_ci#endif 2211cb0ef41Sopenharmony_ci 2221cb0ef41Sopenharmony_ci#ifdef V8_OS_MACOS 2231cb0ef41Sopenharmony_ci# define V8_TARGET_OS_MACOS 2241cb0ef41Sopenharmony_ci#endif 2251cb0ef41Sopenharmony_ci 2261cb0ef41Sopenharmony_ci#ifdef V8_OS_WIN 2271cb0ef41Sopenharmony_ci# define V8_TARGET_OS_WIN 2281cb0ef41Sopenharmony_ci#endif 2291cb0ef41Sopenharmony_ci 2301cb0ef41Sopenharmony_ci#endif // V8_HAVE_TARGET_OS 2311cb0ef41Sopenharmony_ci 2321cb0ef41Sopenharmony_ci#if defined(V8_TARGET_OS_ANDROID) 2331cb0ef41Sopenharmony_ci# define V8_TARGET_OS_STRING "android" 2341cb0ef41Sopenharmony_ci#elif defined(V8_TARGET_OS_FUCHSIA) 2351cb0ef41Sopenharmony_ci# define V8_TARGET_OS_STRING "fuchsia" 2361cb0ef41Sopenharmony_ci#elif defined(V8_TARGET_OS_IOS) 2371cb0ef41Sopenharmony_ci# define V8_TARGET_OS_STRING "ios" 2381cb0ef41Sopenharmony_ci#elif defined(V8_TARGET_OS_LINUX) 2391cb0ef41Sopenharmony_ci# define V8_TARGET_OS_STRING "linux" 2401cb0ef41Sopenharmony_ci#elif defined(V8_TARGET_OS_MACOS) 2411cb0ef41Sopenharmony_ci# define V8_TARGET_OS_STRING "macos" 2421cb0ef41Sopenharmony_ci#elif defined(V8_TARGET_OS_WINDOWS) 2431cb0ef41Sopenharmony_ci# define V8_TARGET_OS_STRING "windows" 2441cb0ef41Sopenharmony_ci#else 2451cb0ef41Sopenharmony_ci# define V8_TARGET_OS_STRING "unknown" 2461cb0ef41Sopenharmony_ci#endif 2471cb0ef41Sopenharmony_ci 2481cb0ef41Sopenharmony_ci// ----------------------------------------------------------------------------- 2491cb0ef41Sopenharmony_ci// C library detection 2501cb0ef41Sopenharmony_ci// 2511cb0ef41Sopenharmony_ci// V8_LIBC_MSVCRT - MSVC libc 2521cb0ef41Sopenharmony_ci// V8_LIBC_BIONIC - Bionic libc 2531cb0ef41Sopenharmony_ci// V8_LIBC_BSD - BSD libc derivate 2541cb0ef41Sopenharmony_ci// V8_LIBC_GLIBC - GNU C library 2551cb0ef41Sopenharmony_ci// V8_LIBC_UCLIBC - uClibc 2561cb0ef41Sopenharmony_ci// 2571cb0ef41Sopenharmony_ci// Note that testing for libc must be done using #if not #ifdef. For example, 2581cb0ef41Sopenharmony_ci// to test for the GNU C library, use: 2591cb0ef41Sopenharmony_ci// #if V8_LIBC_GLIBC 2601cb0ef41Sopenharmony_ci// ... 2611cb0ef41Sopenharmony_ci// #endif 2621cb0ef41Sopenharmony_ci 2631cb0ef41Sopenharmony_ci#if defined (_MSC_VER) 2641cb0ef41Sopenharmony_ci# define V8_LIBC_MSVCRT 1 2651cb0ef41Sopenharmony_ci#elif defined(__BIONIC__) 2661cb0ef41Sopenharmony_ci# define V8_LIBC_BIONIC 1 2671cb0ef41Sopenharmony_ci# define V8_LIBC_BSD 1 2681cb0ef41Sopenharmony_ci#elif defined(__UCLIBC__) 2691cb0ef41Sopenharmony_ci// Must test for UCLIBC before GLIBC, as UCLIBC pretends to be GLIBC. 2701cb0ef41Sopenharmony_ci# define V8_LIBC_UCLIBC 1 2711cb0ef41Sopenharmony_ci#elif defined(__GLIBC__) || defined(__GNU_LIBRARY__) 2721cb0ef41Sopenharmony_ci# define V8_LIBC_GLIBC 1 2731cb0ef41Sopenharmony_ci#else 2741cb0ef41Sopenharmony_ci# define V8_LIBC_BSD V8_OS_BSD 2751cb0ef41Sopenharmony_ci#endif 2761cb0ef41Sopenharmony_ci 2771cb0ef41Sopenharmony_ci 2781cb0ef41Sopenharmony_ci// ----------------------------------------------------------------------------- 2791cb0ef41Sopenharmony_ci// Compiler detection 2801cb0ef41Sopenharmony_ci// 2811cb0ef41Sopenharmony_ci// V8_CC_GNU - GCC, or clang in gcc mode 2821cb0ef41Sopenharmony_ci// V8_CC_INTEL - Intel C++ 2831cb0ef41Sopenharmony_ci// V8_CC_MINGW - Minimalist GNU for Windows 2841cb0ef41Sopenharmony_ci// V8_CC_MINGW32 - Minimalist GNU for Windows (mingw32) 2851cb0ef41Sopenharmony_ci// V8_CC_MINGW64 - Minimalist GNU for Windows (mingw-w64) 2861cb0ef41Sopenharmony_ci// V8_CC_MSVC - Microsoft Visual C/C++, or clang in cl.exe mode 2871cb0ef41Sopenharmony_ci// 2881cb0ef41Sopenharmony_ci// C++11 feature detection 2891cb0ef41Sopenharmony_ci// 2901cb0ef41Sopenharmony_ci// Compiler-specific feature detection 2911cb0ef41Sopenharmony_ci// 2921cb0ef41Sopenharmony_ci// V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline)) 2931cb0ef41Sopenharmony_ci// supported 2941cb0ef41Sopenharmony_ci// V8_HAS_ATTRIBUTE_CONSTINIT - __attribute__((require_constant_ 2951cb0ef41Sopenharmony_ci// initialization)) 2961cb0ef41Sopenharmony_ci// supported 2971cb0ef41Sopenharmony_ci// V8_HAS_ATTRIBUTE_NONNULL - __attribute__((nonnull)) supported 2981cb0ef41Sopenharmony_ci// V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported 2991cb0ef41Sopenharmony_ci// V8_HAS_ATTRIBUTE_UNUSED - __attribute__((unused)) supported 3001cb0ef41Sopenharmony_ci// V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported 3011cb0ef41Sopenharmony_ci// V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result)) 3021cb0ef41Sopenharmony_ci// supported 3031cb0ef41Sopenharmony_ci// V8_HAS_CPP_ATTRIBUTE_NODISCARD - [[nodiscard]] supported 3041cb0ef41Sopenharmony_ci// V8_HAS_CPP_ATTRIBUTE_NO_UNIQUE_ADDRESS 3051cb0ef41Sopenharmony_ci// - [[no_unique_address]] supported 3061cb0ef41Sopenharmony_ci// V8_HAS_BUILTIN_BSWAP16 - __builtin_bswap16() supported 3071cb0ef41Sopenharmony_ci// V8_HAS_BUILTIN_BSWAP32 - __builtin_bswap32() supported 3081cb0ef41Sopenharmony_ci// V8_HAS_BUILTIN_BSWAP64 - __builtin_bswap64() supported 3091cb0ef41Sopenharmony_ci// V8_HAS_BUILTIN_CLZ - __builtin_clz() supported 3101cb0ef41Sopenharmony_ci// V8_HAS_BUILTIN_CTZ - __builtin_ctz() supported 3111cb0ef41Sopenharmony_ci// V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported 3121cb0ef41Sopenharmony_ci// V8_HAS_BUILTIN_FRAME_ADDRESS - __builtin_frame_address() supported 3131cb0ef41Sopenharmony_ci// V8_HAS_BUILTIN_POPCOUNT - __builtin_popcount() supported 3141cb0ef41Sopenharmony_ci// V8_HAS_BUILTIN_ADD_OVERFLOW - __builtin_add_overflow() supported 3151cb0ef41Sopenharmony_ci// V8_HAS_BUILTIN_SUB_OVERFLOW - __builtin_sub_overflow() supported 3161cb0ef41Sopenharmony_ci// V8_HAS_BUILTIN_MUL_OVERFLOW - __builtin_mul_overflow() supported 3171cb0ef41Sopenharmony_ci// V8_HAS_BUILTIN_SADD_OVERFLOW - __builtin_sadd_overflow() supported 3181cb0ef41Sopenharmony_ci// V8_HAS_BUILTIN_SSUB_OVERFLOW - __builtin_ssub_overflow() supported 3191cb0ef41Sopenharmony_ci// V8_HAS_BUILTIN_UADD_OVERFLOW - __builtin_uadd_overflow() supported 3201cb0ef41Sopenharmony_ci// V8_HAS_BUILTIN_SMUL_OVERFLOW - __builtin_smul_overflow() supported 3211cb0ef41Sopenharmony_ci// V8_HAS_COMPUTED_GOTO - computed goto/labels as values 3221cb0ef41Sopenharmony_ci// supported 3231cb0ef41Sopenharmony_ci// V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported 3241cb0ef41Sopenharmony_ci// V8_HAS_DECLSPEC_SELECTANY - __declspec(selectany) supported 3251cb0ef41Sopenharmony_ci// V8_HAS___FORCEINLINE - __forceinline supported 3261cb0ef41Sopenharmony_ci// 3271cb0ef41Sopenharmony_ci// Note that testing for compilers and/or features must be done using #if 3281cb0ef41Sopenharmony_ci// not #ifdef. For example, to test for Intel C++ Compiler, use: 3291cb0ef41Sopenharmony_ci// #if V8_CC_INTEL 3301cb0ef41Sopenharmony_ci// ... 3311cb0ef41Sopenharmony_ci// #endif 3321cb0ef41Sopenharmony_ci 3331cb0ef41Sopenharmony_ci#if defined(__has_cpp_attribute) 3341cb0ef41Sopenharmony_ci#define V8_HAS_CPP_ATTRIBUTE(FEATURE) __has_cpp_attribute(FEATURE) 3351cb0ef41Sopenharmony_ci#else 3361cb0ef41Sopenharmony_ci#define V8_HAS_CPP_ATTRIBUTE(FEATURE) 0 3371cb0ef41Sopenharmony_ci#endif 3381cb0ef41Sopenharmony_ci 3391cb0ef41Sopenharmony_ci#if defined(__clang__) 3401cb0ef41Sopenharmony_ci 3411cb0ef41Sopenharmony_ci#if defined(__GNUC__) // Clang in gcc mode. 3421cb0ef41Sopenharmony_ci# define V8_CC_GNU 1 3431cb0ef41Sopenharmony_ci#endif 3441cb0ef41Sopenharmony_ci 3451cb0ef41Sopenharmony_ci# define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) 3461cb0ef41Sopenharmony_ci# define V8_HAS_ATTRIBUTE_CONSTINIT \ 3471cb0ef41Sopenharmony_ci (__has_attribute(require_constant_initialization)) 3481cb0ef41Sopenharmony_ci# define V8_HAS_ATTRIBUTE_CONST (__has_attribute(const)) 3491cb0ef41Sopenharmony_ci# define V8_HAS_ATTRIBUTE_NONNULL (__has_attribute(nonnull)) 3501cb0ef41Sopenharmony_ci# define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline)) 3511cb0ef41Sopenharmony_ci# define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused)) 3521cb0ef41Sopenharmony_ci// Support for the "preserve_most" attribute is limited: 3531cb0ef41Sopenharmony_ci// - 32-bit platforms do not implement it, 3541cb0ef41Sopenharmony_ci// - component builds fail because _dl_runtime_resolve clobbers registers, 3551cb0ef41Sopenharmony_ci// - we see crashes on arm64 on Windows (https://crbug.com/1409934), which can 3561cb0ef41Sopenharmony_ci// hopefully be fixed in the future. 3571cb0ef41Sopenharmony_ci// Additionally, the initial implementation in clang <= 16 overwrote the return 3581cb0ef41Sopenharmony_ci// register(s) in the epilogue of a preserve_most function, so we only use 3591cb0ef41Sopenharmony_ci// preserve_most in clang >= 17 (see https://reviews.llvm.org/D143425). 3601cb0ef41Sopenharmony_ci#if (defined(_M_X64) || defined(__x86_64__) /* x64 (everywhere) */ \ 3611cb0ef41Sopenharmony_ci || ((defined(__AARCH64EL__) || defined(_M_ARM64)) /* arm64, but ... */ \ 3621cb0ef41Sopenharmony_ci && !defined(_WIN32))) /* not on windows */ \ 3631cb0ef41Sopenharmony_ci && !defined(COMPONENT_BUILD) /* no component build */\ 3641cb0ef41Sopenharmony_ci && __clang_major__ >= 17 /* clang >= 17 */ 3651cb0ef41Sopenharmony_ci# define V8_HAS_ATTRIBUTE_PRESERVE_MOST (__has_attribute(preserve_most)) 3661cb0ef41Sopenharmony_ci#endif 3671cb0ef41Sopenharmony_ci# define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility)) 3681cb0ef41Sopenharmony_ci# define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ 3691cb0ef41Sopenharmony_ci (__has_attribute(warn_unused_result)) 3701cb0ef41Sopenharmony_ci 3711cb0ef41Sopenharmony_ci# define V8_HAS_CPP_ATTRIBUTE_NODISCARD (V8_HAS_CPP_ATTRIBUTE(nodiscard)) 3721cb0ef41Sopenharmony_ci# define V8_HAS_CPP_ATTRIBUTE_NO_UNIQUE_ADDRESS \ 3731cb0ef41Sopenharmony_ci (V8_HAS_CPP_ATTRIBUTE(no_unique_address)) 3741cb0ef41Sopenharmony_ci 3751cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_ASSUME (__has_builtin(__builtin_assume)) 3761cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_ASSUME_ALIGNED (__has_builtin(__builtin_assume_aligned)) 3771cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_BSWAP16 (__has_builtin(__builtin_bswap16)) 3781cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_BSWAP32 (__has_builtin(__builtin_bswap32)) 3791cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_BSWAP64 (__has_builtin(__builtin_bswap64)) 3801cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz)) 3811cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz)) 3821cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) 3831cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address)) 3841cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount)) 3851cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_ADD_OVERFLOW (__has_builtin(__builtin_add_overflow)) 3861cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_SUB_OVERFLOW (__has_builtin(__builtin_sub_overflow)) 3871cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_MUL_OVERFLOW (__has_builtin(__builtin_mul_overflow)) 3881cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_SADD_OVERFLOW (__has_builtin(__builtin_sadd_overflow)) 3891cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_SSUB_OVERFLOW (__has_builtin(__builtin_ssub_overflow)) 3901cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_UADD_OVERFLOW (__has_builtin(__builtin_uadd_overflow)) 3911cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_SMUL_OVERFLOW (__has_builtin(__builtin_smul_overflow)) 3921cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_UNREACHABLE (__has_builtin(__builtin_unreachable)) 3931cb0ef41Sopenharmony_ci 3941cb0ef41Sopenharmony_ci// Clang has no __has_feature for computed gotos. 3951cb0ef41Sopenharmony_ci// GCC doc: https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html 3961cb0ef41Sopenharmony_ci# define V8_HAS_COMPUTED_GOTO 1 3971cb0ef41Sopenharmony_ci 3981cb0ef41Sopenharmony_ci#elif defined(__GNUC__) 3991cb0ef41Sopenharmony_ci 4001cb0ef41Sopenharmony_ci# define V8_CC_GNU 1 4011cb0ef41Sopenharmony_ci# if defined(__INTEL_COMPILER) // Intel C++ also masquerades as GCC 3.2.0 4021cb0ef41Sopenharmony_ci# define V8_CC_INTEL 1 4031cb0ef41Sopenharmony_ci# endif 4041cb0ef41Sopenharmony_ci# if defined(__MINGW32__) 4051cb0ef41Sopenharmony_ci# define V8_CC_MINGW32 1 4061cb0ef41Sopenharmony_ci# endif 4071cb0ef41Sopenharmony_ci# if defined(__MINGW64__) 4081cb0ef41Sopenharmony_ci# define V8_CC_MINGW64 1 4091cb0ef41Sopenharmony_ci# endif 4101cb0ef41Sopenharmony_ci# define V8_CC_MINGW (V8_CC_MINGW32 || V8_CC_MINGW64) 4111cb0ef41Sopenharmony_ci 4121cb0ef41Sopenharmony_ci// always_inline is available in gcc 4.0 but not very reliable until 4.4. 4131cb0ef41Sopenharmony_ci// Works around "sorry, unimplemented: inlining failed" build errors with 4141cb0ef41Sopenharmony_ci// older compilers. 4151cb0ef41Sopenharmony_ci# define V8_HAS_ATTRIBUTE_ALWAYS_INLINE 1 4161cb0ef41Sopenharmony_ci# define V8_HAS_ATTRIBUTE_NOINLINE 1 4171cb0ef41Sopenharmony_ci# define V8_HAS_ATTRIBUTE_UNUSED 1 4181cb0ef41Sopenharmony_ci# define V8_HAS_ATTRIBUTE_VISIBILITY 1 4191cb0ef41Sopenharmony_ci# define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT (!V8_CC_INTEL) 4201cb0ef41Sopenharmony_ci 4211cb0ef41Sopenharmony_ci// [[nodiscard]] does not work together with with 4221cb0ef41Sopenharmony_ci// __attribute__((visibility(""))) on GCC 7.4 which is why there is no define 4231cb0ef41Sopenharmony_ci// for V8_HAS_CPP_ATTRIBUTE_NODISCARD. See https://crbug.com/v8/11707. 4241cb0ef41Sopenharmony_ci 4251cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_ASSUME_ALIGNED 1 4261cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_CLZ 1 4271cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_CTZ 1 4281cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_EXPECT 1 4291cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_FRAME_ADDRESS 1 4301cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_POPCOUNT 1 4311cb0ef41Sopenharmony_ci# define V8_HAS_BUILTIN_UNREACHABLE 1 4321cb0ef41Sopenharmony_ci 4331cb0ef41Sopenharmony_ci// GCC doc: https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html 4341cb0ef41Sopenharmony_ci#define V8_HAS_COMPUTED_GOTO 1 4351cb0ef41Sopenharmony_ci 4361cb0ef41Sopenharmony_ci#endif 4371cb0ef41Sopenharmony_ci 4381cb0ef41Sopenharmony_ci#if defined(_MSC_VER) 4391cb0ef41Sopenharmony_ci# define V8_CC_MSVC 1 4401cb0ef41Sopenharmony_ci 4411cb0ef41Sopenharmony_ci# define V8_HAS_DECLSPEC_NOINLINE 1 4421cb0ef41Sopenharmony_ci# define V8_HAS_DECLSPEC_SELECTANY 1 4431cb0ef41Sopenharmony_ci 4441cb0ef41Sopenharmony_ci# define V8_HAS___FORCEINLINE 1 4451cb0ef41Sopenharmony_ci 4461cb0ef41Sopenharmony_ci#endif 4471cb0ef41Sopenharmony_ci 4481cb0ef41Sopenharmony_ci 4491cb0ef41Sopenharmony_ci// ----------------------------------------------------------------------------- 4501cb0ef41Sopenharmony_ci// Helper macros 4511cb0ef41Sopenharmony_ci 4521cb0ef41Sopenharmony_ci// A macro used to make better inlining. Don't bother for debug builds. 4531cb0ef41Sopenharmony_ci// Use like: 4541cb0ef41Sopenharmony_ci// V8_INLINE int GetZero() { return 0; } 4551cb0ef41Sopenharmony_ci#if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE 4561cb0ef41Sopenharmony_ci# define V8_INLINE inline __attribute__((always_inline)) 4571cb0ef41Sopenharmony_ci#elif !defined(DEBUG) && V8_HAS___FORCEINLINE 4581cb0ef41Sopenharmony_ci# define V8_INLINE __forceinline 4591cb0ef41Sopenharmony_ci#else 4601cb0ef41Sopenharmony_ci# define V8_INLINE inline 4611cb0ef41Sopenharmony_ci#endif 4621cb0ef41Sopenharmony_ci 4631cb0ef41Sopenharmony_ci#ifdef DEBUG 4641cb0ef41Sopenharmony_ci// In debug mode, check assumptions instead of actually adding annotations. 4651cb0ef41Sopenharmony_ci# define V8_ASSUME(condition) DCHECK(condition) 4661cb0ef41Sopenharmony_ci#elif V8_HAS_BUILTIN_ASSUME 4671cb0ef41Sopenharmony_ci# define V8_ASSUME(condition) __builtin_assume(condition) 4681cb0ef41Sopenharmony_ci#elif V8_HAS_BUILTIN_UNREACHABLE 4691cb0ef41Sopenharmony_ci# define V8_ASSUME(condition) \ 4701cb0ef41Sopenharmony_ci do { if (!(condition)) __builtin_unreachable(); } while (false) 4711cb0ef41Sopenharmony_ci#else 4721cb0ef41Sopenharmony_ci# define V8_ASSUME(condition) 4731cb0ef41Sopenharmony_ci#endif 4741cb0ef41Sopenharmony_ci 4751cb0ef41Sopenharmony_ci#if V8_HAS_BUILTIN_ASSUME_ALIGNED 4761cb0ef41Sopenharmony_ci# define V8_ASSUME_ALIGNED(ptr, alignment) \ 4771cb0ef41Sopenharmony_ci __builtin_assume_aligned((ptr), (alignment)) 4781cb0ef41Sopenharmony_ci#else 4791cb0ef41Sopenharmony_ci# define V8_ASSUME_ALIGNED(ptr, alignment) (ptr) 4801cb0ef41Sopenharmony_ci#endif 4811cb0ef41Sopenharmony_ci 4821cb0ef41Sopenharmony_ci 4831cb0ef41Sopenharmony_ci// A macro to mark functions whose values don't change (e.g. across calls) 4841cb0ef41Sopenharmony_ci// and thereby compiler is free to hoist and fold multiple calls together. 4851cb0ef41Sopenharmony_ci// Use like: 4861cb0ef41Sopenharmony_ci// V8_CONST int foo() { ... } 4871cb0ef41Sopenharmony_ci#if V8_HAS_ATTRIBUTE_CONST 4881cb0ef41Sopenharmony_ci# define V8_CONST __attribute__((const)) 4891cb0ef41Sopenharmony_ci#else 4901cb0ef41Sopenharmony_ci# define V8_CONST 4911cb0ef41Sopenharmony_ci#endif 4921cb0ef41Sopenharmony_ci 4931cb0ef41Sopenharmony_ci// A macro to mark a declaration as requiring constant initialization. 4941cb0ef41Sopenharmony_ci// Use like: 4951cb0ef41Sopenharmony_ci// int* foo V8_CONSTINIT; 4961cb0ef41Sopenharmony_ci#if V8_HAS_ATTRIBUTE_CONSTINIT 4971cb0ef41Sopenharmony_ci# define V8_CONSTINIT __attribute__((require_constant_initialization)) 4981cb0ef41Sopenharmony_ci#else 4991cb0ef41Sopenharmony_ci# define V8_CONSTINIT 5001cb0ef41Sopenharmony_ci#endif 5011cb0ef41Sopenharmony_ci 5021cb0ef41Sopenharmony_ci 5031cb0ef41Sopenharmony_ci// A macro to mark specific arguments as non-null. 5041cb0ef41Sopenharmony_ci// Use like: 5051cb0ef41Sopenharmony_ci// int add(int* x, int y, int* z) V8_NONNULL(1, 3) { return *x + y + *z; } 5061cb0ef41Sopenharmony_ci#if V8_HAS_ATTRIBUTE_NONNULL 5071cb0ef41Sopenharmony_ci# define V8_NONNULL(...) __attribute__((nonnull(__VA_ARGS__))) 5081cb0ef41Sopenharmony_ci#else 5091cb0ef41Sopenharmony_ci# define V8_NONNULL(...) /* NOT SUPPORTED */ 5101cb0ef41Sopenharmony_ci#endif 5111cb0ef41Sopenharmony_ci 5121cb0ef41Sopenharmony_ci 5131cb0ef41Sopenharmony_ci// A macro used to tell the compiler to never inline a particular function. 5141cb0ef41Sopenharmony_ci// Use like: 5151cb0ef41Sopenharmony_ci// V8_NOINLINE int GetMinusOne() { return -1; } 5161cb0ef41Sopenharmony_ci#if V8_HAS_ATTRIBUTE_NOINLINE 5171cb0ef41Sopenharmony_ci# define V8_NOINLINE __attribute__((noinline)) 5181cb0ef41Sopenharmony_ci#elif V8_HAS_DECLSPEC_NOINLINE 5191cb0ef41Sopenharmony_ci# define V8_NOINLINE __declspec(noinline) 5201cb0ef41Sopenharmony_ci#else 5211cb0ef41Sopenharmony_ci# define V8_NOINLINE /* NOT SUPPORTED */ 5221cb0ef41Sopenharmony_ci#endif 5231cb0ef41Sopenharmony_ci 5241cb0ef41Sopenharmony_ci 5251cb0ef41Sopenharmony_ci// A macro used to change the calling conventions to preserve all registers (no 5261cb0ef41Sopenharmony_ci// caller-saved registers). Use this for cold functions called from hot 5271cb0ef41Sopenharmony_ci// functions. 5281cb0ef41Sopenharmony_ci// Note: The attribute is considered experimental, so apply with care. Also, 5291cb0ef41Sopenharmony_ci// "preserve_most" is currently not handling the return value correctly, so only 5301cb0ef41Sopenharmony_ci// use it for functions returning void (see https://reviews.llvm.org/D141020). 5311cb0ef41Sopenharmony_ci// Use like: 5321cb0ef41Sopenharmony_ci// V8_NOINLINE V8_PRESERVE_MOST void UnlikelyMethod(); 5331cb0ef41Sopenharmony_ci#if V8_HAS_ATTRIBUTE_PRESERVE_MOST 5341cb0ef41Sopenharmony_ci# define V8_PRESERVE_MOST __attribute__((preserve_most)) 5351cb0ef41Sopenharmony_ci#else 5361cb0ef41Sopenharmony_ci# define V8_PRESERVE_MOST /* NOT SUPPORTED */ 5371cb0ef41Sopenharmony_ci#endif 5381cb0ef41Sopenharmony_ci 5391cb0ef41Sopenharmony_ci 5401cb0ef41Sopenharmony_ci// A macro (V8_DEPRECATED) to mark classes or functions as deprecated. 5411cb0ef41Sopenharmony_ci#if defined(V8_DEPRECATION_WARNINGS) 5421cb0ef41Sopenharmony_ci# define V8_DEPRECATED(message) [[deprecated(message)]] 5431cb0ef41Sopenharmony_ci#else 5441cb0ef41Sopenharmony_ci# define V8_DEPRECATED(message) 5451cb0ef41Sopenharmony_ci#endif 5461cb0ef41Sopenharmony_ci 5471cb0ef41Sopenharmony_ci 5481cb0ef41Sopenharmony_ci// A macro (V8_DEPRECATE_SOON) to make it easier to see what will be deprecated. 5491cb0ef41Sopenharmony_ci#if defined(V8_IMMINENT_DEPRECATION_WARNINGS) 5501cb0ef41Sopenharmony_ci# define V8_DEPRECATE_SOON(message) [[deprecated(message)]] 5511cb0ef41Sopenharmony_ci#else 5521cb0ef41Sopenharmony_ci# define V8_DEPRECATE_SOON(message) 5531cb0ef41Sopenharmony_ci#endif 5541cb0ef41Sopenharmony_ci 5551cb0ef41Sopenharmony_ci 5561cb0ef41Sopenharmony_ci#if defined(V8_IMMINENT_DEPRECATION_WARNINGS) || \ 5571cb0ef41Sopenharmony_ci defined(V8_DEPRECATION_WARNINGS) 5581cb0ef41Sopenharmony_ci#if defined(V8_CC_MSVC) 5591cb0ef41Sopenharmony_ci# define START_ALLOW_USE_DEPRECATED() \ 5601cb0ef41Sopenharmony_ci __pragma(warning(push)) \ 5611cb0ef41Sopenharmony_ci __pragma(warning(disable : 4996)) 5621cb0ef41Sopenharmony_ci# define END_ALLOW_USE_DEPRECATED() __pragma(warning(pop)) 5631cb0ef41Sopenharmony_ci#else // !defined(V8_CC_MSVC) 5641cb0ef41Sopenharmony_ci# define START_ALLOW_USE_DEPRECATED() \ 5651cb0ef41Sopenharmony_ci _Pragma("GCC diagnostic push") \ 5661cb0ef41Sopenharmony_ci _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") 5671cb0ef41Sopenharmony_ci#define END_ALLOW_USE_DEPRECATED() _Pragma("GCC diagnostic pop") 5681cb0ef41Sopenharmony_ci#endif // !defined(V8_CC_MSVC) 5691cb0ef41Sopenharmony_ci#else // !(defined(V8_IMMINENT_DEPRECATION_WARNINGS) || 5701cb0ef41Sopenharmony_ci // defined(V8_DEPRECATION_WARNINGS)) 5711cb0ef41Sopenharmony_ci#define START_ALLOW_USE_DEPRECATED() 5721cb0ef41Sopenharmony_ci#define END_ALLOW_USE_DEPRECATED() 5731cb0ef41Sopenharmony_ci#endif // !(defined(V8_IMMINENT_DEPRECATION_WARNINGS) || 5741cb0ef41Sopenharmony_ci // defined(V8_DEPRECATION_WARNINGS)) 5751cb0ef41Sopenharmony_ci#define ALLOW_COPY_AND_MOVE_WITH_DEPRECATED_FIELDS(ClassName) \ 5761cb0ef41Sopenharmony_ci START_ALLOW_USE_DEPRECATED() \ 5771cb0ef41Sopenharmony_ci ClassName(const ClassName&) = default; \ 5781cb0ef41Sopenharmony_ci ClassName(ClassName&&) = default; \ 5791cb0ef41Sopenharmony_ci ClassName& operator=(const ClassName&) = default; \ 5801cb0ef41Sopenharmony_ci ClassName& operator=(ClassName&&) = default; \ 5811cb0ef41Sopenharmony_ci END_ALLOW_USE_DEPRECATED() 5821cb0ef41Sopenharmony_ci 5831cb0ef41Sopenharmony_ci 5841cb0ef41Sopenharmony_ci#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ < 6) 5851cb0ef41Sopenharmony_ci# define V8_ENUM_DEPRECATED(message) 5861cb0ef41Sopenharmony_ci# define V8_ENUM_DEPRECATE_SOON(message) 5871cb0ef41Sopenharmony_ci#else 5881cb0ef41Sopenharmony_ci# define V8_ENUM_DEPRECATED(message) V8_DEPRECATED(message) 5891cb0ef41Sopenharmony_ci# define V8_ENUM_DEPRECATE_SOON(message) V8_DEPRECATE_SOON(message) 5901cb0ef41Sopenharmony_ci#endif 5911cb0ef41Sopenharmony_ci 5921cb0ef41Sopenharmony_ci 5931cb0ef41Sopenharmony_ci// A macro to provide the compiler with branch prediction information. 5941cb0ef41Sopenharmony_ci#if V8_HAS_BUILTIN_EXPECT 5951cb0ef41Sopenharmony_ci# define V8_UNLIKELY(condition) (__builtin_expect(!!(condition), 0)) 5961cb0ef41Sopenharmony_ci# define V8_LIKELY(condition) (__builtin_expect(!!(condition), 1)) 5971cb0ef41Sopenharmony_ci#else 5981cb0ef41Sopenharmony_ci# define V8_UNLIKELY(condition) (condition) 5991cb0ef41Sopenharmony_ci# define V8_LIKELY(condition) (condition) 6001cb0ef41Sopenharmony_ci#endif 6011cb0ef41Sopenharmony_ci 6021cb0ef41Sopenharmony_ci 6031cb0ef41Sopenharmony_ci// Annotate a function indicating the caller must examine the return value. 6041cb0ef41Sopenharmony_ci// Use like: 6051cb0ef41Sopenharmony_ci// int foo() V8_WARN_UNUSED_RESULT; 6061cb0ef41Sopenharmony_ci#if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT 6071cb0ef41Sopenharmony_ci#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) 6081cb0ef41Sopenharmony_ci#else 6091cb0ef41Sopenharmony_ci#define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */ 6101cb0ef41Sopenharmony_ci#endif 6111cb0ef41Sopenharmony_ci 6121cb0ef41Sopenharmony_ci 6131cb0ef41Sopenharmony_ci// Annotate a class or constructor indicating the caller must assign the 6141cb0ef41Sopenharmony_ci// constructed instances. 6151cb0ef41Sopenharmony_ci// Apply to the whole class like: 6161cb0ef41Sopenharmony_ci// class V8_NODISCARD Foo() { ... }; 6171cb0ef41Sopenharmony_ci// or apply to just one constructor like: 6181cb0ef41Sopenharmony_ci// V8_NODISCARD Foo() { ... }; 6191cb0ef41Sopenharmony_ci// [[nodiscard]] comes in C++17 but supported in clang with -std >= c++11. 6201cb0ef41Sopenharmony_ci#if V8_HAS_CPP_ATTRIBUTE_NODISCARD 6211cb0ef41Sopenharmony_ci#define V8_NODISCARD [[nodiscard]] 6221cb0ef41Sopenharmony_ci#else 6231cb0ef41Sopenharmony_ci#define V8_NODISCARD /* NOT SUPPORTED */ 6241cb0ef41Sopenharmony_ci#endif 6251cb0ef41Sopenharmony_ci 6261cb0ef41Sopenharmony_ci// The no_unique_address attribute allows tail padding in a non-static data 6271cb0ef41Sopenharmony_ci// member to overlap other members of the enclosing class (and in the special 6281cb0ef41Sopenharmony_ci// case when the type is empty, permits it to fully overlap other members). The 6291cb0ef41Sopenharmony_ci// field is laid out as if a base class were encountered at the corresponding 6301cb0ef41Sopenharmony_ci// point within the class (except that it does not share a vptr with the 6311cb0ef41Sopenharmony_ci// enclosing object). 6321cb0ef41Sopenharmony_ci// 6331cb0ef41Sopenharmony_ci// Apply to a data member like: 6341cb0ef41Sopenharmony_ci// 6351cb0ef41Sopenharmony_ci// class Foo { 6361cb0ef41Sopenharmony_ci// V8_NO_UNIQUE_ADDRESS Bar bar_; 6371cb0ef41Sopenharmony_ci// }; 6381cb0ef41Sopenharmony_ci// 6391cb0ef41Sopenharmony_ci// [[no_unique_address]] comes in C++20 but supported in clang with 6401cb0ef41Sopenharmony_ci// -std >= c++11. 6411cb0ef41Sopenharmony_ci#if V8_HAS_CPP_ATTRIBUTE_NO_UNIQUE_ADDRESS 6421cb0ef41Sopenharmony_ci#define V8_NO_UNIQUE_ADDRESS [[no_unique_address]] 6431cb0ef41Sopenharmony_ci#else 6441cb0ef41Sopenharmony_ci#define V8_NO_UNIQUE_ADDRESS /* NOT SUPPORTED */ 6451cb0ef41Sopenharmony_ci#endif 6461cb0ef41Sopenharmony_ci 6471cb0ef41Sopenharmony_ci// Marks a type as being eligible for the "trivial" ABI despite having a 6481cb0ef41Sopenharmony_ci// non-trivial destructor or copy/move constructor. Such types can be relocated 6491cb0ef41Sopenharmony_ci// after construction by simply copying their memory, which makes them eligible 6501cb0ef41Sopenharmony_ci// to be passed in registers. The canonical example is std::unique_ptr. 6511cb0ef41Sopenharmony_ci// 6521cb0ef41Sopenharmony_ci// Use with caution; this has some subtle effects on constructor/destructor 6531cb0ef41Sopenharmony_ci// ordering and will be very incorrect if the type relies on its address 6541cb0ef41Sopenharmony_ci// remaining constant. When used as a function argument (by value), the value 6551cb0ef41Sopenharmony_ci// may be constructed in the caller's stack frame, passed in a register, and 6561cb0ef41Sopenharmony_ci// then used and destructed in the callee's stack frame. A similar thing can 6571cb0ef41Sopenharmony_ci// occur when values are returned. 6581cb0ef41Sopenharmony_ci// 6591cb0ef41Sopenharmony_ci// TRIVIAL_ABI is not needed for types which have a trivial destructor and 6601cb0ef41Sopenharmony_ci// copy/move constructors, since those are automatically trivial by the ABI 6611cb0ef41Sopenharmony_ci// spec. 6621cb0ef41Sopenharmony_ci// 6631cb0ef41Sopenharmony_ci// It is also not likely to be effective on types too large to be passed in one 6641cb0ef41Sopenharmony_ci// or two registers on typical target ABIs. 6651cb0ef41Sopenharmony_ci// 6661cb0ef41Sopenharmony_ci// See also: 6671cb0ef41Sopenharmony_ci// https://clang.llvm.org/docs/AttributeReference.html#trivial-abi 6681cb0ef41Sopenharmony_ci// https://libcxx.llvm.org/docs/DesignDocs/UniquePtrTrivialAbi.html 6691cb0ef41Sopenharmony_ci#if defined(__clang__) && defined(__has_attribute) 6701cb0ef41Sopenharmony_ci#if __has_attribute(trivial_abi) 6711cb0ef41Sopenharmony_ci#define V8_TRIVIAL_ABI [[clang::trivial_abi]] 6721cb0ef41Sopenharmony_ci#endif // __has_attribute(trivial_abi) 6731cb0ef41Sopenharmony_ci#endif // defined(__clang__) && defined(__has_attribute) 6741cb0ef41Sopenharmony_ci#if !defined(V8_TRIVIAL_ABI) 6751cb0ef41Sopenharmony_ci#define V8_TRIVIAL_ABI 6761cb0ef41Sopenharmony_ci#endif //!defined(V8_TRIVIAL_ABI) 6771cb0ef41Sopenharmony_ci 6781cb0ef41Sopenharmony_ci// Helper macro to define no_sanitize attributes only with clang. 6791cb0ef41Sopenharmony_ci#if defined(__clang__) && defined(__has_attribute) 6801cb0ef41Sopenharmony_ci#if __has_attribute(no_sanitize) 6811cb0ef41Sopenharmony_ci#define V8_CLANG_NO_SANITIZE(what) __attribute__((no_sanitize(what))) 6821cb0ef41Sopenharmony_ci#endif 6831cb0ef41Sopenharmony_ci#endif 6841cb0ef41Sopenharmony_ci#if !defined(V8_CLANG_NO_SANITIZE) 6851cb0ef41Sopenharmony_ci#define V8_CLANG_NO_SANITIZE(what) 6861cb0ef41Sopenharmony_ci#endif 6871cb0ef41Sopenharmony_ci 6881cb0ef41Sopenharmony_ci#if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED) 6891cb0ef41Sopenharmony_ci#error Inconsistent build configuration: To build the V8 shared library \ 6901cb0ef41Sopenharmony_ciset BUILDING_V8_SHARED, to include its headers for linking against the \ 6911cb0ef41Sopenharmony_ciV8 shared library set USING_V8_SHARED. 6921cb0ef41Sopenharmony_ci#endif 6931cb0ef41Sopenharmony_ci 6941cb0ef41Sopenharmony_ci#ifdef V8_OS_WIN 6951cb0ef41Sopenharmony_ci 6961cb0ef41Sopenharmony_ci// Setup for Windows DLL export/import. When building the V8 DLL the 6971cb0ef41Sopenharmony_ci// BUILDING_V8_SHARED needs to be defined. When building a program which uses 6981cb0ef41Sopenharmony_ci// the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 6991cb0ef41Sopenharmony_ci// static library or building a program which uses the V8 static library neither 7001cb0ef41Sopenharmony_ci// BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. 7011cb0ef41Sopenharmony_ci#ifdef BUILDING_V8_SHARED 7021cb0ef41Sopenharmony_ci# define V8_EXPORT __declspec(dllexport) 7031cb0ef41Sopenharmony_ci#elif USING_V8_SHARED 7041cb0ef41Sopenharmony_ci# define V8_EXPORT __declspec(dllimport) 7051cb0ef41Sopenharmony_ci#else 7061cb0ef41Sopenharmony_ci# define V8_EXPORT 7071cb0ef41Sopenharmony_ci#endif // BUILDING_V8_SHARED 7081cb0ef41Sopenharmony_ci 7091cb0ef41Sopenharmony_ci#else // V8_OS_WIN 7101cb0ef41Sopenharmony_ci 7111cb0ef41Sopenharmony_ci// Setup for Linux shared library export. 7121cb0ef41Sopenharmony_ci#if V8_HAS_ATTRIBUTE_VISIBILITY 7131cb0ef41Sopenharmony_ci# ifdef BUILDING_V8_SHARED 7141cb0ef41Sopenharmony_ci# define V8_EXPORT __attribute__ ((visibility("default"))) 7151cb0ef41Sopenharmony_ci# else 7161cb0ef41Sopenharmony_ci# define V8_EXPORT 7171cb0ef41Sopenharmony_ci# endif 7181cb0ef41Sopenharmony_ci#else 7191cb0ef41Sopenharmony_ci# define V8_EXPORT 7201cb0ef41Sopenharmony_ci#endif 7211cb0ef41Sopenharmony_ci 7221cb0ef41Sopenharmony_ci#endif // V8_OS_WIN 7231cb0ef41Sopenharmony_ci 7241cb0ef41Sopenharmony_ci// clang-format on 7251cb0ef41Sopenharmony_ci 7261cb0ef41Sopenharmony_ci// Processor architecture detection. For more info on what's defined, see: 7271cb0ef41Sopenharmony_ci// http://msdn.microsoft.com/en-us/library/b0084kay.aspx 7281cb0ef41Sopenharmony_ci// http://www.agner.org/optimize/calling_conventions.pdf 7291cb0ef41Sopenharmony_ci// or with gcc, run: "echo | gcc -E -dM -" 7301cb0ef41Sopenharmony_ci// The V8_HOST_ARCH_* macros correspond to the architecture on which V8, as a 7311cb0ef41Sopenharmony_ci// virtual machine and compiler, runs. Don't confuse this with the architecture 7321cb0ef41Sopenharmony_ci// on which V8 is built. 7331cb0ef41Sopenharmony_ci#if defined(_M_X64) || defined(__x86_64__) 7341cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_X64 1 7351cb0ef41Sopenharmony_ci#if defined(__x86_64__) && __SIZEOF_POINTER__ == 4 // Check for x32. 7361cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_32_BIT 1 7371cb0ef41Sopenharmony_ci#else 7381cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_64_BIT 1 7391cb0ef41Sopenharmony_ci#endif 7401cb0ef41Sopenharmony_ci#elif defined(_M_IX86) || defined(__i386__) 7411cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_IA32 1 7421cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_32_BIT 1 7431cb0ef41Sopenharmony_ci#elif defined(__AARCH64EL__) || defined(_M_ARM64) 7441cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_ARM64 1 7451cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_64_BIT 1 7461cb0ef41Sopenharmony_ci#elif defined(__ARMEL__) 7471cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_ARM 1 7481cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_32_BIT 1 7491cb0ef41Sopenharmony_ci#elif defined(__mips64) 7501cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_MIPS64 1 7511cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_64_BIT 1 7521cb0ef41Sopenharmony_ci#elif defined(__loongarch64) 7531cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_LOONG64 1 7541cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_64_BIT 1 7551cb0ef41Sopenharmony_ci#elif defined(__PPC64__) || defined(_ARCH_PPC64) 7561cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_PPC64 1 7571cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_64_BIT 1 7581cb0ef41Sopenharmony_ci#elif defined(__PPC__) || defined(_ARCH_PPC) 7591cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_PPC 1 7601cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_32_BIT 1 7611cb0ef41Sopenharmony_ci#elif defined(__s390__) || defined(__s390x__) 7621cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_S390 1 7631cb0ef41Sopenharmony_ci#if defined(__s390x__) 7641cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_64_BIT 1 7651cb0ef41Sopenharmony_ci#else 7661cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_32_BIT 1 7671cb0ef41Sopenharmony_ci#endif 7681cb0ef41Sopenharmony_ci#elif defined(__riscv) || defined(__riscv__) 7691cb0ef41Sopenharmony_ci#if __riscv_xlen == 64 7701cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_RISCV64 1 7711cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_64_BIT 1 7721cb0ef41Sopenharmony_ci#elif __riscv_xlen == 32 7731cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_RISCV32 1 7741cb0ef41Sopenharmony_ci#define V8_HOST_ARCH_32_BIT 1 7751cb0ef41Sopenharmony_ci#else 7761cb0ef41Sopenharmony_ci#error "Cannot detect Riscv's bitwidth" 7771cb0ef41Sopenharmony_ci#endif 7781cb0ef41Sopenharmony_ci#else 7791cb0ef41Sopenharmony_ci#error "Host architecture was not detected as supported by v8" 7801cb0ef41Sopenharmony_ci#endif 7811cb0ef41Sopenharmony_ci 7821cb0ef41Sopenharmony_ci// Target architecture detection. This corresponds to the architecture for which 7831cb0ef41Sopenharmony_ci// V8's JIT will generate code (the last stage of the canadian cross-compiler). 7841cb0ef41Sopenharmony_ci// The macros may be set externally. If not, detect in the same way as the host 7851cb0ef41Sopenharmony_ci// architecture, that is, target the native environment as presented by the 7861cb0ef41Sopenharmony_ci// compiler. 7871cb0ef41Sopenharmony_ci#if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM && \ 7881cb0ef41Sopenharmony_ci !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_PPC && \ 7891cb0ef41Sopenharmony_ci !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_S390 && \ 7901cb0ef41Sopenharmony_ci !V8_TARGET_ARCH_RISCV64 && !V8_TARGET_ARCH_LOONG64 && \ 7911cb0ef41Sopenharmony_ci !V8_TARGET_ARCH_RISCV32 7921cb0ef41Sopenharmony_ci#if defined(_M_X64) || defined(__x86_64__) 7931cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_X64 1 7941cb0ef41Sopenharmony_ci#elif defined(_M_IX86) || defined(__i386__) 7951cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_IA32 1 7961cb0ef41Sopenharmony_ci#elif defined(__AARCH64EL__) || defined(_M_ARM64) 7971cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_ARM64 1 7981cb0ef41Sopenharmony_ci#elif defined(__ARMEL__) 7991cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_ARM 1 8001cb0ef41Sopenharmony_ci#elif defined(__mips64) 8011cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_MIPS64 1 8021cb0ef41Sopenharmony_ci#elif defined(__loongarch64) 8031cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_LOONG64 1 8041cb0ef41Sopenharmony_ci#elif defined(_ARCH_PPC64) 8051cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_PPC64 1 8061cb0ef41Sopenharmony_ci#elif defined(_ARCH_PPC) 8071cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_PPC 1 8081cb0ef41Sopenharmony_ci#elif defined(__s390__) 8091cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_S390 1 8101cb0ef41Sopenharmony_ci#if defined(__s390x__) 8111cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_S390X 1 8121cb0ef41Sopenharmony_ci#endif 8131cb0ef41Sopenharmony_ci#elif defined(__riscv) || defined(__riscv__) 8141cb0ef41Sopenharmony_ci#if __riscv_xlen == 64 8151cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_RISCV64 1 8161cb0ef41Sopenharmony_ci#elif __riscv_xlen == 32 8171cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_RISCV32 1 8181cb0ef41Sopenharmony_ci#endif 8191cb0ef41Sopenharmony_ci#else 8201cb0ef41Sopenharmony_ci#error Target architecture was not detected as supported by v8 8211cb0ef41Sopenharmony_ci#endif 8221cb0ef41Sopenharmony_ci#endif 8231cb0ef41Sopenharmony_ci 8241cb0ef41Sopenharmony_ci// Determine architecture pointer size. 8251cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_IA32 8261cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_32_BIT 1 8271cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_X64 8281cb0ef41Sopenharmony_ci#if !V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_64_BIT 8291cb0ef41Sopenharmony_ci#if defined(__x86_64__) && __SIZEOF_POINTER__ == 4 // Check for x32. 8301cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_32_BIT 1 8311cb0ef41Sopenharmony_ci#else 8321cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_64_BIT 1 8331cb0ef41Sopenharmony_ci#endif 8341cb0ef41Sopenharmony_ci#endif 8351cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_ARM 8361cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_32_BIT 1 8371cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_ARM64 8381cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_64_BIT 1 8391cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_MIPS 8401cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_32_BIT 1 8411cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_MIPS64 8421cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_64_BIT 1 8431cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_LOONG64 8441cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_64_BIT 1 8451cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_PPC 8461cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_32_BIT 1 8471cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_PPC64 8481cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_64_BIT 1 8491cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_S390 8501cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 8511cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_64_BIT 1 8521cb0ef41Sopenharmony_ci#else 8531cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_32_BIT 1 8541cb0ef41Sopenharmony_ci#endif 8551cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_RISCV64 8561cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_64_BIT 1 8571cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_RISCV32 8581cb0ef41Sopenharmony_ci#define V8_TARGET_ARCH_32_BIT 1 8591cb0ef41Sopenharmony_ci#else 8601cb0ef41Sopenharmony_ci#error Unknown target architecture pointer size 8611cb0ef41Sopenharmony_ci#endif 8621cb0ef41Sopenharmony_ci 8631cb0ef41Sopenharmony_ci// Check for supported combinations of host and target architectures. 8641cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_IA32 && !V8_HOST_ARCH_IA32 8651cb0ef41Sopenharmony_ci#error Target architecture ia32 is only supported on ia32 host 8661cb0ef41Sopenharmony_ci#endif 8671cb0ef41Sopenharmony_ci#if (V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_64_BIT && \ 8681cb0ef41Sopenharmony_ci !((V8_HOST_ARCH_X64 || V8_HOST_ARCH_ARM64) && V8_HOST_ARCH_64_BIT)) 8691cb0ef41Sopenharmony_ci#error Target architecture x64 is only supported on x64 and arm64 host 8701cb0ef41Sopenharmony_ci#endif 8711cb0ef41Sopenharmony_ci#if (V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT && \ 8721cb0ef41Sopenharmony_ci !(V8_HOST_ARCH_X64 && V8_HOST_ARCH_32_BIT)) 8731cb0ef41Sopenharmony_ci#error Target architecture x32 is only supported on x64 host with x32 support 8741cb0ef41Sopenharmony_ci#endif 8751cb0ef41Sopenharmony_ci#if (V8_TARGET_ARCH_ARM && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_ARM)) 8761cb0ef41Sopenharmony_ci#error Target architecture arm is only supported on arm and ia32 host 8771cb0ef41Sopenharmony_ci#endif 8781cb0ef41Sopenharmony_ci#if (V8_TARGET_ARCH_ARM64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_ARM64)) 8791cb0ef41Sopenharmony_ci#error Target architecture arm64 is only supported on arm64 and x64 host 8801cb0ef41Sopenharmony_ci#endif 8811cb0ef41Sopenharmony_ci#if (V8_TARGET_ARCH_MIPS64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_MIPS64)) 8821cb0ef41Sopenharmony_ci#error Target architecture mips64 is only supported on mips64 and x64 host 8831cb0ef41Sopenharmony_ci#endif 8841cb0ef41Sopenharmony_ci#if (V8_TARGET_ARCH_RISCV64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_RISCV64)) 8851cb0ef41Sopenharmony_ci#error Target architecture riscv64 is only supported on riscv64 and x64 host 8861cb0ef41Sopenharmony_ci#endif 8871cb0ef41Sopenharmony_ci#if (V8_TARGET_ARCH_RISCV32 && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_RISCV32)) 8881cb0ef41Sopenharmony_ci#error Target architecture riscv32 is only supported on riscv32 and ia32 host 8891cb0ef41Sopenharmony_ci#endif 8901cb0ef41Sopenharmony_ci#if (V8_TARGET_ARCH_LOONG64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_LOONG64)) 8911cb0ef41Sopenharmony_ci#error Target architecture loong64 is only supported on loong64 and x64 host 8921cb0ef41Sopenharmony_ci#endif 8931cb0ef41Sopenharmony_ci 8941cb0ef41Sopenharmony_ci// Determine architecture endianness. 8951cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_IA32 8961cb0ef41Sopenharmony_ci#define V8_TARGET_LITTLE_ENDIAN 1 8971cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_X64 8981cb0ef41Sopenharmony_ci#define V8_TARGET_LITTLE_ENDIAN 1 8991cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_ARM 9001cb0ef41Sopenharmony_ci#define V8_TARGET_LITTLE_ENDIAN 1 9011cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_ARM64 9021cb0ef41Sopenharmony_ci#define V8_TARGET_LITTLE_ENDIAN 1 9031cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_LOONG64 9041cb0ef41Sopenharmony_ci#define V8_TARGET_LITTLE_ENDIAN 1 9051cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_MIPS64 9061cb0ef41Sopenharmony_ci#if defined(__MIPSEB__) || defined(V8_TARGET_ARCH_MIPS64_BE) 9071cb0ef41Sopenharmony_ci#define V8_TARGET_BIG_ENDIAN 1 9081cb0ef41Sopenharmony_ci#else 9091cb0ef41Sopenharmony_ci#define V8_TARGET_LITTLE_ENDIAN 1 9101cb0ef41Sopenharmony_ci#endif 9111cb0ef41Sopenharmony_ci#elif defined(__BIG_ENDIAN__) // FOR PPCGR on AIX 9121cb0ef41Sopenharmony_ci#define V8_TARGET_BIG_ENDIAN 1 9131cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_PPC_LE 9141cb0ef41Sopenharmony_ci#define V8_TARGET_LITTLE_ENDIAN 1 9151cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_PPC_BE 9161cb0ef41Sopenharmony_ci#define V8_TARGET_BIG_ENDIAN 1 9171cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_S390 9181cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390_LE_SIM 9191cb0ef41Sopenharmony_ci#define V8_TARGET_LITTLE_ENDIAN 1 9201cb0ef41Sopenharmony_ci#else 9211cb0ef41Sopenharmony_ci#define V8_TARGET_BIG_ENDIAN 1 9221cb0ef41Sopenharmony_ci#endif 9231cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_RISCV32 || V8_TARGET_ARCH_RISCV64 9241cb0ef41Sopenharmony_ci#define V8_TARGET_LITTLE_ENDIAN 1 9251cb0ef41Sopenharmony_ci#elif defined(__BYTE_ORDER__) 9261cb0ef41Sopenharmony_ci#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 9271cb0ef41Sopenharmony_ci#define V8_TARGET_BIG_ENDIAN 1 9281cb0ef41Sopenharmony_ci#else 9291cb0ef41Sopenharmony_ci#define V8_TARGET_LITTLE_ENDIAN 1 9301cb0ef41Sopenharmony_ci#endif 9311cb0ef41Sopenharmony_ci#else 9321cb0ef41Sopenharmony_ci#error Unknown target architecture endianness 9331cb0ef41Sopenharmony_ci#endif 9341cb0ef41Sopenharmony_ci 9351cb0ef41Sopenharmony_ci#undef V8_HAS_CPP_ATTRIBUTE 9361cb0ef41Sopenharmony_ci 9371cb0ef41Sopenharmony_ci#if !defined(V8_STATIC_ROOTS) 9381cb0ef41Sopenharmony_ci#define V8_STATIC_ROOTS_BOOL false 9391cb0ef41Sopenharmony_ci#else 9401cb0ef41Sopenharmony_ci#define V8_STATIC_ROOTS_BOOL true 9411cb0ef41Sopenharmony_ci#endif 9421cb0ef41Sopenharmony_ci 9431cb0ef41Sopenharmony_ci#endif // V8CONFIG_H_ 944