123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- #ifndef BASE_COMPILER_SPECIFIC_H_
- #define BASE_COMPILER_SPECIFIC_H_
- #include "build/build_config.h"
- #if defined(COMPILER_MSVC) && !defined(__clang__)
- #error "Only clang-cl is supported on Windows, see https://crbug.com/988071"
- #endif
- #define ALLOW_UNUSED_LOCAL(x) (void)x
- #if defined(COMPILER_GCC) || defined(__clang__)
- #define ALLOW_UNUSED_TYPE __attribute__((unused))
- #else
- #define ALLOW_UNUSED_TYPE
- #endif
- #if defined(COMPILER_GCC)
- #define NOINLINE __attribute__((noinline))
- #elif defined(COMPILER_MSVC)
- #define NOINLINE __declspec(noinline)
- #else
- #define NOINLINE
- #endif
- #if defined(COMPILER_GCC) && defined(NDEBUG)
- #define ALWAYS_INLINE inline __attribute__((__always_inline__))
- #elif defined(COMPILER_MSVC) && defined(NDEBUG)
- #define ALWAYS_INLINE __forceinline
- #else
- #define ALWAYS_INLINE inline
- #endif
- #if defined(__clang__) && __has_attribute(not_tail_called)
- #define NOT_TAIL_CALLED __attribute__((not_tail_called))
- #else
- #define NOT_TAIL_CALLED
- #endif
- #if defined(COMPILER_MSVC)
- #define ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
- #elif defined(COMPILER_GCC)
- #define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
- #endif
- #undef WARN_UNUSED_RESULT
- #if defined(COMPILER_GCC) || defined(__clang__)
- #define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
- #else
- #define WARN_UNUSED_RESULT
- #endif
- #if defined(COMPILER_GCC) || defined(__clang__)
- #define PRINTF_FORMAT(format_param, dots_param) \
- __attribute__((format(printf, format_param, dots_param)))
- #else
- #define PRINTF_FORMAT(format_param, dots_param)
- #endif
- #define WPRINTF_FORMAT(format_param, dots_param)
- #if defined(__has_attribute)
- #if __has_attribute(no_sanitize)
- #define NO_SANITIZE(what) __attribute__((no_sanitize(what)))
- #endif
- #endif
- #if !defined(NO_SANITIZE)
- #define NO_SANITIZE(what)
- #endif
- #if defined(MEMORY_SANITIZER) && !defined(OS_NACL)
- #include <sanitizer/msan_interface.h>
- #define MSAN_UNPOISON(p, size) __msan_unpoison(p, size)
- #define MSAN_CHECK_MEM_IS_INITIALIZED(p, size) \
- __msan_check_mem_is_initialized(p, size)
- #else // MEMORY_SANITIZER
- #define MSAN_UNPOISON(p, size)
- #define MSAN_CHECK_MEM_IS_INITIALIZED(p, size)
- #endif // MEMORY_SANITIZER
- #if !defined(DISABLE_CFI_PERF)
- #if defined(__clang__) && defined(OFFICIAL_BUILD)
- #define DISABLE_CFI_PERF __attribute__((no_sanitize("cfi")))
- #else
- #define DISABLE_CFI_PERF
- #endif
- #endif
- #if !defined(DISABLE_CFI_ICALL)
- #if defined(OS_WIN)
- #define DISABLE_CFI_ICALL NO_SANITIZE("cfi-icall") __declspec(guard(nocf))
- #else
- #define DISABLE_CFI_ICALL NO_SANITIZE("cfi-icall")
- #endif
- #endif
- #if !defined(DISABLE_CFI_ICALL)
- #define DISABLE_CFI_ICALL
- #endif
- #if !defined(CDECL)
- #if defined(OS_WIN)
- #define CDECL __cdecl
- #else // defined(OS_WIN)
- #define CDECL
- #endif // defined(OS_WIN)
- #endif // !defined(CDECL)
- #if !defined(UNLIKELY)
- #if defined(COMPILER_GCC) || defined(__clang__)
- #define UNLIKELY(x) __builtin_expect(!!(x), 0)
- #else
- #define UNLIKELY(x) (x)
- #endif // defined(COMPILER_GCC)
- #endif // !defined(UNLIKELY)
- #if !defined(LIKELY)
- #if defined(COMPILER_GCC) || defined(__clang__)
- #define LIKELY(x) __builtin_expect(!!(x), 1)
- #else
- #define LIKELY(x) (x)
- #endif // defined(COMPILER_GCC)
- #endif // !defined(LIKELY)
- #if defined(__has_feature)
- #define HAS_FEATURE(FEATURE) __has_feature(FEATURE)
- #else
- #define HAS_FEATURE(FEATURE) 0
- #endif
- #if defined(__clang__)
- #define FALLTHROUGH [[clang::fallthrough]]
- #else
- #define FALLTHROUGH
- #endif
- #if defined(COMPILER_GCC)
- #define PRETTY_FUNCTION __PRETTY_FUNCTION__
- #elif defined(COMPILER_MSVC)
- #define PRETTY_FUNCTION __FUNCSIG__
- #else
- #define PRETTY_FUNCTION __func__
- #endif
- #if !defined(CPU_ARM_NEON)
- #if defined(__arm__)
- #if !defined(__ARMEB__) && !defined(__ARM_EABI__) && !defined(__EABI__) && \
- !defined(__VFP_FP__) && !defined(_WIN32_WCE) && !defined(ANDROID)
- #error Chromium does not support middle endian architecture
- #endif
- #if defined(__ARM_NEON__)
- #define CPU_ARM_NEON 1
- #endif
- #endif // defined(__arm__)
- #endif // !defined(CPU_ARM_NEON)
- #if !defined(HAVE_MIPS_MSA_INTRINSICS)
- #if defined(__mips_msa) && defined(__mips_isa_rev) && (__mips_isa_rev >= 5)
- #define HAVE_MIPS_MSA_INTRINSICS 1
- #endif
- #endif
- #if defined(__clang__) && __has_attribute(uninitialized)
- #define STACK_UNINITIALIZED __attribute__((uninitialized))
- #else
- #define STACK_UNINITIALIZED
- #endif
- #if defined(__clang_analyzer__)
- inline constexpr bool AnalyzerNoReturn() __attribute__((analyzer_noreturn)) {
- return false;
- }
- inline constexpr bool AnalyzerAssumeTrue(bool arg) {
-
-
- return arg || AnalyzerNoReturn();
- }
- #define ANALYZER_ASSUME_TRUE(arg) ::AnalyzerAssumeTrue(!!(arg))
- #define ANALYZER_SKIP_THIS_PATH() static_cast<void>(::AnalyzerNoReturn())
- #define ANALYZER_ALLOW_UNUSED(var) static_cast<void>(var);
- #else // !defined(__clang_analyzer__)
- #define ANALYZER_ASSUME_TRUE(arg) (arg)
- #define ANALYZER_SKIP_THIS_PATH()
- #define ANALYZER_ALLOW_UNUSED(var) static_cast<void>(var);
- #endif // defined(__clang_analyzer__)
- #endif // BASE_COMPILER_SPECIFIC_H_
|