2013-08-23 07:32:25 +00:00
|
|
|
// Copyright 2013 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2013-08-23 07:32:25 +00:00
|
|
|
|
|
|
|
#ifndef V8CONFIG_H_
|
|
|
|
#define V8CONFIG_H_
|
|
|
|
|
2015-06-29 11:47:50 +00:00
|
|
|
// clang-format off
|
|
|
|
|
2013-08-30 12:09:50 +00:00
|
|
|
// Platform headers for feature detection below.
|
|
|
|
#if defined(__ANDROID__)
|
|
|
|
# include <sys/cdefs.h>
|
|
|
|
#elif defined(__APPLE__)
|
2013-08-30 12:30:09 +00:00
|
|
|
# include <TargetConditionals.h>
|
2013-08-30 12:09:50 +00:00
|
|
|
#elif defined(__linux__)
|
|
|
|
# include <features.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// This macro allows to test for the version of the GNU C library (or
|
|
|
|
// a compatible C library that masquerades as glibc). It evaluates to
|
|
|
|
// 0 if libc is not GNU libc or compatible.
|
|
|
|
// Use like:
|
|
|
|
// #if V8_GLIBC_PREREQ(2, 3)
|
|
|
|
// ...
|
|
|
|
// #endif
|
|
|
|
#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
|
|
|
|
# define V8_GLIBC_PREREQ(major, minor) \
|
|
|
|
((__GLIBC__ * 100 + __GLIBC_MINOR__) >= ((major) * 100 + (minor)))
|
|
|
|
#else
|
|
|
|
# define V8_GLIBC_PREREQ(major, minor) 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// This macro allows to test for the version of the GNU C++ compiler.
|
|
|
|
// Note that this also applies to compilers that masquerade as GCC,
|
|
|
|
// for example clang and the Intel C++ compiler for Linux.
|
|
|
|
// Use like:
|
|
|
|
// #if V8_GNUC_PREREQ(4, 3, 1)
|
|
|
|
// ...
|
|
|
|
// #endif
|
|
|
|
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
|
|
|
|
# define V8_GNUC_PREREQ(major, minor, patchlevel) \
|
|
|
|
((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \
|
|
|
|
((major) * 10000 + (minor) * 100 + (patchlevel)))
|
|
|
|
#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
|
2015-03-25 14:22:27 +00:00
|
|
|
# define V8_GNUC_PREREQ(major, minor, patchlevel) \
|
|
|
|
((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= \
|
2013-08-30 12:09:50 +00:00
|
|
|
((major) * 10000 + (minor) * 100 + (patchlevel)))
|
|
|
|
#else
|
|
|
|
# define V8_GNUC_PREREQ(major, minor, patchlevel) 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Operating system detection
|
|
|
|
//
|
|
|
|
// V8_OS_ANDROID - Android
|
|
|
|
// V8_OS_BSD - BSDish (Mac OS X, Net/Free/Open/DragonFlyBSD)
|
|
|
|
// V8_OS_CYGWIN - Cygwin
|
|
|
|
// V8_OS_DRAGONFLYBSD - DragonFlyBSD
|
|
|
|
// V8_OS_FREEBSD - FreeBSD
|
2017-06-11 06:31:33 +00:00
|
|
|
// V8_OS_FUCHSIA - Fuchsia
|
2013-08-23 07:32:25 +00:00
|
|
|
// V8_OS_LINUX - Linux
|
|
|
|
// V8_OS_MACOSX - Mac OS X
|
|
|
|
// V8_OS_NETBSD - NetBSD
|
|
|
|
// V8_OS_OPENBSD - OpenBSD
|
|
|
|
// V8_OS_POSIX - POSIX compatible (mostly everything except Windows)
|
2014-01-02 07:04:05 +00:00
|
|
|
// V8_OS_QNX - QNX Neutrino
|
2013-08-23 07:32:25 +00:00
|
|
|
// V8_OS_SOLARIS - Sun Solaris and OpenSolaris
|
2015-01-30 08:01:53 +00:00
|
|
|
// V8_OS_AIX - AIX
|
2013-08-23 07:32:25 +00:00
|
|
|
// V8_OS_WIN - Microsoft Windows
|
|
|
|
|
|
|
|
#if defined(__ANDROID__)
|
|
|
|
# define V8_OS_ANDROID 1
|
|
|
|
# define V8_OS_LINUX 1
|
|
|
|
# define V8_OS_POSIX 1
|
|
|
|
#elif defined(__APPLE__)
|
|
|
|
# define V8_OS_BSD 1
|
|
|
|
# define V8_OS_MACOSX 1
|
|
|
|
# define V8_OS_POSIX 1
|
|
|
|
#elif defined(__CYGWIN__)
|
|
|
|
# define V8_OS_CYGWIN 1
|
|
|
|
# define V8_OS_POSIX 1
|
|
|
|
#elif defined(__linux__)
|
|
|
|
# define V8_OS_LINUX 1
|
|
|
|
# define V8_OS_POSIX 1
|
|
|
|
#elif defined(__sun)
|
|
|
|
# define V8_OS_POSIX 1
|
|
|
|
# define V8_OS_SOLARIS 1
|
2015-01-30 08:01:53 +00:00
|
|
|
#elif defined(_AIX)
|
|
|
|
#define V8_OS_POSIX 1
|
|
|
|
#define V8_OS_AIX 1
|
2013-08-23 07:32:25 +00:00
|
|
|
#elif defined(__FreeBSD__)
|
|
|
|
# define V8_OS_BSD 1
|
|
|
|
# define V8_OS_FREEBSD 1
|
|
|
|
# define V8_OS_POSIX 1
|
2017-06-11 06:31:33 +00:00
|
|
|
#elif defined(__Fuchsia__)
|
|
|
|
# define V8_OS_FUCHSIA 1
|
|
|
|
# define V8_OS_POSIX 1
|
2013-08-23 07:32:25 +00:00
|
|
|
#elif defined(__DragonFly__)
|
|
|
|
# define V8_OS_BSD 1
|
|
|
|
# define V8_OS_DRAGONFLYBSD 1
|
|
|
|
# define V8_OS_POSIX 1
|
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
# define V8_OS_BSD 1
|
|
|
|
# define V8_OS_NETBSD 1
|
|
|
|
# define V8_OS_POSIX 1
|
|
|
|
#elif defined(__OpenBSD__)
|
|
|
|
# define V8_OS_BSD 1
|
|
|
|
# define V8_OS_OPENBSD 1
|
|
|
|
# define V8_OS_POSIX 1
|
2014-01-02 07:04:05 +00:00
|
|
|
#elif defined(__QNXNTO__)
|
|
|
|
# define V8_OS_POSIX 1
|
|
|
|
# define V8_OS_QNX 1
|
2013-08-23 07:32:25 +00:00
|
|
|
#elif defined(_WIN32)
|
|
|
|
# define V8_OS_WIN 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2013-08-30 12:09:50 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// C library detection
|
|
|
|
//
|
2014-01-28 19:11:13 +00:00
|
|
|
// V8_LIBC_MSVCRT - MSVC libc
|
2013-08-30 12:09:50 +00:00
|
|
|
// V8_LIBC_BIONIC - Bionic libc
|
|
|
|
// V8_LIBC_BSD - BSD libc derivate
|
|
|
|
// V8_LIBC_GLIBC - GNU C library
|
2015-04-14 07:54:30 +00:00
|
|
|
// V8_LIBC_UCLIBC - uClibc
|
2013-08-30 12:09:50 +00:00
|
|
|
//
|
|
|
|
// Note that testing for libc must be done using #if not #ifdef. For example,
|
|
|
|
// to test for the GNU C library, use:
|
|
|
|
// #if V8_LIBC_GLIBC
|
|
|
|
// ...
|
|
|
|
// #endif
|
|
|
|
|
2014-01-28 19:11:13 +00:00
|
|
|
#if defined (_MSC_VER)
|
|
|
|
# define V8_LIBC_MSVCRT 1
|
|
|
|
#elif defined(__BIONIC__)
|
2013-08-30 12:09:50 +00:00
|
|
|
# define V8_LIBC_BIONIC 1
|
|
|
|
# define V8_LIBC_BSD 1
|
2015-04-14 07:54:30 +00:00
|
|
|
#elif defined(__UCLIBC__)
|
|
|
|
// Must test for UCLIBC before GLIBC, as UCLIBC pretends to be GLIBC.
|
|
|
|
# define V8_LIBC_UCLIBC 1
|
2013-08-30 12:09:50 +00:00
|
|
|
#elif defined(__GLIBC__) || defined(__GNU_LIBRARY__)
|
|
|
|
# define V8_LIBC_GLIBC 1
|
|
|
|
#else
|
|
|
|
# define V8_LIBC_BSD V8_OS_BSD
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Compiler detection
|
|
|
|
//
|
2014-12-02 05:23:09 +00:00
|
|
|
// V8_CC_GNU - GCC, or clang in gcc mode
|
2013-08-27 08:27:42 +00:00
|
|
|
// V8_CC_INTEL - Intel C++
|
2013-08-23 07:32:25 +00:00
|
|
|
// V8_CC_MINGW - Minimalist GNU for Windows
|
2013-08-27 14:16:34 +00:00
|
|
|
// V8_CC_MINGW32 - Minimalist GNU for Windows (mingw32)
|
|
|
|
// V8_CC_MINGW64 - Minimalist GNU for Windows (mingw-w64)
|
2014-12-02 05:23:09 +00:00
|
|
|
// V8_CC_MSVC - Microsoft Visual C/C++, or clang in cl.exe mode
|
2013-08-23 07:32:25 +00:00
|
|
|
//
|
|
|
|
// C++11 feature detection
|
|
|
|
//
|
|
|
|
// V8_HAS_CXX11_ALIGNAS - alignas specifier supported
|
2013-08-26 11:18:28 +00:00
|
|
|
// V8_HAS_CXX11_ALIGNOF - alignof(type) operator supported
|
2013-08-23 07:32:25 +00:00
|
|
|
//
|
|
|
|
// Compiler-specific feature detection
|
|
|
|
//
|
2013-08-27 08:27:42 +00:00
|
|
|
// V8_HAS___ALIGNOF - __alignof(type) operator supported
|
|
|
|
// V8_HAS___ALIGNOF__ - __alignof__(type) operator supported
|
|
|
|
// V8_HAS_ATTRIBUTE_ALIGNED - __attribute__((aligned(n))) supported
|
|
|
|
// V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline))
|
|
|
|
// supported
|
|
|
|
// V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported
|
2013-08-27 09:21:16 +00:00
|
|
|
// V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported
|
2013-11-12 12:09:38 +00:00
|
|
|
// V8_HAS_ATTRIBUTE_UNUSED - __attribute__((unused)) supported
|
2013-08-27 08:27:42 +00:00
|
|
|
// V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported
|
|
|
|
// V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result))
|
|
|
|
// supported
|
2014-08-20 12:10:41 +00:00
|
|
|
// V8_HAS_BUILTIN_CLZ - __builtin_clz() supported
|
|
|
|
// V8_HAS_BUILTIN_CTZ - __builtin_ctz() supported
|
2013-08-27 08:27:42 +00:00
|
|
|
// V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported
|
2014-10-20 12:04:22 +00:00
|
|
|
// V8_HAS_BUILTIN_FRAME_ADDRESS - __builtin_frame_address() supported
|
2014-08-20 12:10:41 +00:00
|
|
|
// V8_HAS_BUILTIN_POPCOUNT - __builtin_popcount() supported
|
2014-09-09 14:18:17 +00:00
|
|
|
// V8_HAS_BUILTIN_SADD_OVERFLOW - __builtin_sadd_overflow() supported
|
|
|
|
// V8_HAS_BUILTIN_SSUB_OVERFLOW - __builtin_ssub_overflow() supported
|
2015-06-12 12:03:03 +00:00
|
|
|
// V8_HAS_BUILTIN_UADD_OVERFLOW - __builtin_uadd_overflow() supported
|
2013-08-27 08:27:42 +00:00
|
|
|
// V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported
|
|
|
|
// V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported
|
2013-08-27 09:21:16 +00:00
|
|
|
// V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported
|
2015-01-30 09:29:25 +00:00
|
|
|
// V8_HAS_DECLSPEC_SELECTANY - __declspec(selectany) supported
|
2015-10-08 19:02:29 +00:00
|
|
|
// V8_HAS_DECLSPEC_NORETURN - __declspec(noreturn) supported
|
2013-08-27 08:27:42 +00:00
|
|
|
// V8_HAS___FORCEINLINE - __forceinline supported
|
|
|
|
//
|
|
|
|
// Note that testing for compilers and/or features must be done using #if
|
|
|
|
// not #ifdef. For example, to test for Intel C++ Compiler, use:
|
|
|
|
// #if V8_CC_INTEL
|
|
|
|
// ...
|
|
|
|
// #endif
|
2013-08-23 07:32:25 +00:00
|
|
|
|
|
|
|
#if defined(__clang__)
|
|
|
|
|
2014-12-02 05:23:09 +00:00
|
|
|
#if defined(__GNUC__) // Clang in gcc mode.
|
|
|
|
# define V8_CC_GNU 1
|
|
|
|
#endif
|
2013-08-26 08:06:15 +00:00
|
|
|
|
2013-08-26 11:18:28 +00:00
|
|
|
// Clang defines __alignof__ as alias for __alignof
|
|
|
|
# define V8_HAS___ALIGNOF 1
|
|
|
|
# define V8_HAS___ALIGNOF__ V8_HAS___ALIGNOF
|
|
|
|
|
|
|
|
# define V8_HAS_ATTRIBUTE_ALIGNED (__has_attribute(aligned))
|
2013-08-23 07:32:25 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline))
|
|
|
|
# define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated))
|
2013-08-27 09:21:16 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline))
|
2013-11-12 12:09:38 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused))
|
2013-08-23 07:32:25 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility))
|
2013-08-27 08:27:42 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \
|
|
|
|
(__has_attribute(warn_unused_result))
|
2013-08-23 07:32:25 +00:00
|
|
|
|
2014-08-20 12:10:41 +00:00
|
|
|
# define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz))
|
|
|
|
# define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz))
|
2013-08-23 07:32:25 +00:00
|
|
|
# define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect))
|
2014-10-20 12:04:22 +00:00
|
|
|
# define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address))
|
2014-08-20 12:10:41 +00:00
|
|
|
# define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount))
|
2014-09-09 14:18:17 +00:00
|
|
|
# define V8_HAS_BUILTIN_SADD_OVERFLOW (__has_builtin(__builtin_sadd_overflow))
|
|
|
|
# define V8_HAS_BUILTIN_SSUB_OVERFLOW (__has_builtin(__builtin_ssub_overflow))
|
2015-06-12 12:03:03 +00:00
|
|
|
# define V8_HAS_BUILTIN_UADD_OVERFLOW (__has_builtin(__builtin_uadd_overflow))
|
2013-08-23 07:32:25 +00:00
|
|
|
|
|
|
|
# define V8_HAS_CXX11_ALIGNAS (__has_feature(cxx_alignas))
|
|
|
|
|
|
|
|
#elif defined(__GNUC__)
|
|
|
|
|
|
|
|
# define V8_CC_GNU 1
|
2015-06-29 11:47:50 +00:00
|
|
|
# if defined(__INTEL_COMPILER) // Intel C++ also masquerades as GCC 3.2.0
|
|
|
|
# define V8_CC_INTEL 1
|
|
|
|
# endif
|
|
|
|
# if defined(__MINGW32__)
|
|
|
|
# define V8_CC_MINGW32 1
|
|
|
|
# endif
|
|
|
|
# if defined(__MINGW64__)
|
|
|
|
# define V8_CC_MINGW64 1
|
|
|
|
# endif
|
2013-08-27 14:16:34 +00:00
|
|
|
# define V8_CC_MINGW (V8_CC_MINGW32 || V8_CC_MINGW64)
|
2013-08-23 07:32:25 +00:00
|
|
|
|
2013-08-26 11:18:28 +00:00
|
|
|
# define V8_HAS___ALIGNOF__ (V8_GNUC_PREREQ(4, 3, 0))
|
|
|
|
|
|
|
|
# define V8_HAS_ATTRIBUTE_ALIGNED (V8_GNUC_PREREQ(2, 95, 0))
|
2013-08-24 16:58:32 +00:00
|
|
|
// always_inline is available in gcc 4.0 but not very reliable until 4.4.
|
|
|
|
// Works around "sorry, unimplemented: inlining failed" build errors with
|
|
|
|
// older compilers.
|
|
|
|
# define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0))
|
2013-08-23 07:32:25 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0))
|
2013-09-30 13:28:23 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE (V8_GNUC_PREREQ(4, 5, 0))
|
2013-08-27 09:21:16 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0))
|
2013-11-12 12:09:38 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_UNUSED (V8_GNUC_PREREQ(2, 95, 0))
|
2013-08-23 07:32:25 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0))
|
2013-08-27 08:27:42 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \
|
|
|
|
(!V8_CC_INTEL && V8_GNUC_PREREQ(4, 1, 0))
|
2013-08-23 07:32:25 +00:00
|
|
|
|
2014-08-20 12:10:41 +00:00
|
|
|
# define V8_HAS_BUILTIN_CLZ (V8_GNUC_PREREQ(3, 4, 0))
|
|
|
|
# define V8_HAS_BUILTIN_CTZ (V8_GNUC_PREREQ(3, 4, 0))
|
2013-08-23 07:32:25 +00:00
|
|
|
# define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0))
|
2014-10-20 12:04:22 +00:00
|
|
|
# define V8_HAS_BUILTIN_FRAME_ADDRESS (V8_GNUC_PREREQ(2, 96, 0))
|
2014-08-20 12:10:41 +00:00
|
|
|
# define V8_HAS_BUILTIN_POPCOUNT (V8_GNUC_PREREQ(3, 4, 0))
|
2013-08-23 07:32:25 +00:00
|
|
|
|
2016-03-22 15:24:01 +00:00
|
|
|
# if __cplusplus >= 201103L
|
2013-08-23 07:32:25 +00:00
|
|
|
# define V8_HAS_CXX11_ALIGNAS (V8_GNUC_PREREQ(4, 8, 0))
|
2013-08-26 11:18:28 +00:00
|
|
|
# define V8_HAS_CXX11_ALIGNOF (V8_GNUC_PREREQ(4, 8, 0))
|
2013-08-23 07:32:25 +00:00
|
|
|
# endif
|
2015-05-21 16:21:24 +00:00
|
|
|
#endif
|
2013-08-23 07:32:25 +00:00
|
|
|
|
2015-05-21 16:21:24 +00:00
|
|
|
#if defined(_MSC_VER)
|
2013-08-23 07:32:25 +00:00
|
|
|
# define V8_CC_MSVC 1
|
2013-08-26 11:18:28 +00:00
|
|
|
# define V8_HAS___ALIGNOF 1
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
# define V8_HAS_DECLSPEC_ALIGN 1
|
2014-10-20 12:04:22 +00:00
|
|
|
# define V8_HAS_DECLSPEC_DEPRECATED 1
|
2013-08-27 09:21:16 +00:00
|
|
|
# define V8_HAS_DECLSPEC_NOINLINE 1
|
2015-01-30 09:29:25 +00:00
|
|
|
# define V8_HAS_DECLSPEC_SELECTANY 1
|
2015-10-08 19:02:29 +00:00
|
|
|
# define V8_HAS_DECLSPEC_NORETURN 1
|
2013-08-23 07:32:25 +00:00
|
|
|
|
|
|
|
# define V8_HAS___FORCEINLINE 1
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Helper macros
|
|
|
|
|
|
|
|
// A macro used to make better inlining. Don't bother for debug builds.
|
2013-09-12 08:57:10 +00:00
|
|
|
// Use like:
|
|
|
|
// V8_INLINE int GetZero() { return 0; }
|
2013-08-23 07:32:25 +00:00
|
|
|
#if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE
|
2013-09-12 08:57:10 +00:00
|
|
|
# define V8_INLINE inline __attribute__((always_inline))
|
2013-08-23 07:32:25 +00:00
|
|
|
#elif !defined(DEBUG) && V8_HAS___FORCEINLINE
|
2013-09-12 08:57:10 +00:00
|
|
|
# define V8_INLINE __forceinline
|
2013-08-23 07:32:25 +00:00
|
|
|
#else
|
2013-09-12 08:57:10 +00:00
|
|
|
# define V8_INLINE inline
|
2013-08-23 07:32:25 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2013-08-27 09:21:16 +00:00
|
|
|
// A macro used to tell the compiler to never inline a particular function.
|
|
|
|
// Don't bother for debug builds.
|
2013-09-12 08:57:10 +00:00
|
|
|
// Use like:
|
|
|
|
// V8_NOINLINE int GetMinusOne() { return -1; }
|
2013-08-27 09:21:16 +00:00
|
|
|
#if !defined(DEBUG) && V8_HAS_ATTRIBUTE_NOINLINE
|
2013-09-12 08:57:10 +00:00
|
|
|
# define V8_NOINLINE __attribute__((noinline))
|
2013-08-27 09:21:16 +00:00
|
|
|
#elif !defined(DEBUG) && V8_HAS_DECLSPEC_NOINLINE
|
2013-09-12 08:57:10 +00:00
|
|
|
# define V8_NOINLINE __declspec(noinline)
|
2013-08-27 09:21:16 +00:00
|
|
|
#else
|
2013-09-12 08:57:10 +00:00
|
|
|
# define V8_NOINLINE /* NOT SUPPORTED */
|
2013-08-27 09:21:16 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2015-10-08 19:02:29 +00:00
|
|
|
// A macro used to tell the compiler that a particular function never returns.
|
|
|
|
// Use like:
|
|
|
|
// V8_NORETURN void MyAbort() { abort(); }
|
2017-06-09 15:24:13 +00:00
|
|
|
// TODO(v8): Replace all uses by [[noreturn]] and remove this macro.
|
|
|
|
#define V8_NORETURN [[noreturn]] // NOLINT(whitespace/braces)
|
2015-10-08 19:02:29 +00:00
|
|
|
|
|
|
|
|
2015-05-21 10:34:42 +00:00
|
|
|
// A macro (V8_DEPRECATED) to mark classes or functions as deprecated.
|
2013-09-30 13:28:23 +00:00
|
|
|
#if defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE
|
2015-05-21 10:34:42 +00:00
|
|
|
#define V8_DEPRECATED(message, declarator) \
|
|
|
|
declarator __attribute__((deprecated(message)))
|
2013-09-30 13:28:23 +00:00
|
|
|
#elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED
|
2015-05-21 10:34:42 +00:00
|
|
|
#define V8_DEPRECATED(message, declarator) \
|
|
|
|
declarator __attribute__((deprecated))
|
2013-09-30 13:28:23 +00:00
|
|
|
#elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED
|
2015-05-21 10:34:42 +00:00
|
|
|
#define V8_DEPRECATED(message, declarator) __declspec(deprecated) declarator
|
2013-08-23 07:32:25 +00:00
|
|
|
#else
|
2015-05-21 10:34:42 +00:00
|
|
|
#define V8_DEPRECATED(message, declarator) declarator
|
2013-08-23 07:32:25 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2015-05-21 10:34:42 +00:00
|
|
|
// A macro (V8_DEPRECATE_SOON) to make it easier to see what will be deprecated.
|
|
|
|
#if defined(V8_IMMINENT_DEPRECATION_WARNINGS) && \
|
|
|
|
V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE
|
|
|
|
#define V8_DEPRECATE_SOON(message, declarator) \
|
|
|
|
declarator __attribute__((deprecated(message)))
|
|
|
|
#elif defined(V8_IMMINENT_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED
|
|
|
|
#define V8_DEPRECATE_SOON(message, declarator) \
|
|
|
|
declarator __attribute__((deprecated))
|
|
|
|
#elif defined(V8_IMMINENT_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED
|
|
|
|
#define V8_DEPRECATE_SOON(message, declarator) __declspec(deprecated) declarator
|
|
|
|
#else
|
2015-03-09 09:49:09 +00:00
|
|
|
#define V8_DEPRECATE_SOON(message, declarator) declarator
|
2015-05-21 10:34:42 +00:00
|
|
|
#endif
|
2015-03-09 09:49:09 +00:00
|
|
|
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
// A macro to provide the compiler with branch prediction information.
|
|
|
|
#if V8_HAS_BUILTIN_EXPECT
|
|
|
|
# define V8_UNLIKELY(condition) (__builtin_expect(!!(condition), 0))
|
|
|
|
# define V8_LIKELY(condition) (__builtin_expect(!!(condition), 1))
|
|
|
|
#else
|
|
|
|
# define V8_UNLIKELY(condition) (condition)
|
|
|
|
# define V8_LIKELY(condition) (condition)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// This macro allows to specify memory alignment for structs, classes, etc.
|
|
|
|
// Use like:
|
2013-08-26 11:18:28 +00:00
|
|
|
// class V8_ALIGNED(16) MyClass { ... };
|
|
|
|
// V8_ALIGNED(32) int array[42];
|
2013-08-23 07:32:25 +00:00
|
|
|
#if V8_HAS_CXX11_ALIGNAS
|
2013-08-26 11:18:28 +00:00
|
|
|
# define V8_ALIGNED(n) alignas(n)
|
|
|
|
#elif V8_HAS_ATTRIBUTE_ALIGNED
|
|
|
|
# define V8_ALIGNED(n) __attribute__((aligned(n)))
|
2013-08-23 07:32:25 +00:00
|
|
|
#elif V8_HAS_DECLSPEC_ALIGN
|
2013-08-26 11:18:28 +00:00
|
|
|
# define V8_ALIGNED(n) __declspec(align(n))
|
|
|
|
#else
|
|
|
|
# define V8_ALIGNED(n) /* NOT SUPPORTED */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// This macro is similar to V8_ALIGNED(), but takes a type instead of size
|
|
|
|
// in bytes. If the compiler does not supports using the alignment of the
|
|
|
|
// |type|, it will align according to the |alignment| instead. For example,
|
|
|
|
// Visual Studio C++ cannot combine __declspec(align) and __alignof. The
|
|
|
|
// |alignment| must be a literal that is used as a kind of worst-case fallback
|
|
|
|
// alignment.
|
|
|
|
// Use like:
|
|
|
|
// struct V8_ALIGNAS(AnotherClass, 16) NewClass { ... };
|
|
|
|
// V8_ALIGNAS(double, 8) int array[100];
|
|
|
|
#if V8_HAS_CXX11_ALIGNAS
|
|
|
|
# define V8_ALIGNAS(type, alignment) alignas(type)
|
|
|
|
#elif V8_HAS___ALIGNOF__ && V8_HAS_ATTRIBUTE_ALIGNED
|
|
|
|
# define V8_ALIGNAS(type, alignment) __attribute__((aligned(__alignof__(type))))
|
|
|
|
#else
|
|
|
|
# define V8_ALIGNAS(type, alignment) V8_ALIGNED(alignment)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// This macro returns alignment in bytes (an integer power of two) required for
|
|
|
|
// any instance of the given type, which is either complete type, an array type,
|
|
|
|
// or a reference type.
|
|
|
|
// Use like:
|
|
|
|
// size_t alignment = V8_ALIGNOF(double);
|
|
|
|
#if V8_HAS_CXX11_ALIGNOF
|
|
|
|
# define V8_ALIGNOF(type) alignof(type)
|
|
|
|
#elif V8_HAS___ALIGNOF
|
|
|
|
# define V8_ALIGNOF(type) __alignof(type)
|
|
|
|
#elif V8_HAS___ALIGNOF__
|
|
|
|
# define V8_ALIGNOF(type) __alignof__(type)
|
2013-08-23 07:32:25 +00:00
|
|
|
#else
|
2013-08-26 11:18:28 +00:00
|
|
|
// Note that alignment of a type within a struct can be less than the
|
|
|
|
// alignment of the type stand-alone (because of ancient ABIs), so this
|
|
|
|
// should only be used as a last resort.
|
|
|
|
namespace v8 { template <typename T> class AlignOfHelper { char c; T t; }; }
|
|
|
|
# define V8_ALIGNOF(type) (sizeof(::v8::AlignOfHelper<type>) - sizeof(type))
|
2013-08-23 07:32:25 +00:00
|
|
|
#endif
|
|
|
|
|
2015-02-27 10:39:25 +00:00
|
|
|
// Annotate a function indicating the caller must examine the return value.
|
|
|
|
// Use like:
|
|
|
|
// int foo() WARN_UNUSED_RESULT;
|
|
|
|
#if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT
|
|
|
|
#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
|
|
|
#else
|
|
|
|
#define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */
|
|
|
|
#endif
|
|
|
|
|
2015-06-29 11:47:50 +00:00
|
|
|
// clang-format on
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
#endif // V8CONFIG_H_
|