Changeset View
Changeset View
Standalone View
Standalone View
compiler-rt/lib/sanitizer_common/sanitizer_platform.h
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
#if defined(__sun__) && defined(__svr4__) | #if defined(__sun__) && defined(__svr4__) | ||||
# define SANITIZER_SOLARIS 1 | # define SANITIZER_SOLARIS 1 | ||||
#else | #else | ||||
# define SANITIZER_SOLARIS 0 | # define SANITIZER_SOLARIS 0 | ||||
#endif | #endif | ||||
#if defined(__APPLE__) | #if defined(__APPLE__) | ||||
# define SANITIZER_MAC 1 | # define SANITIZER_APPLE 1 | ||||
// SANITIZER_MAC will be deprecated/removed in the future | |||||
# define SANITIZER_MAC SANITIZER_APPLE | |||||
# include <TargetConditionals.h> | # include <TargetConditionals.h> | ||||
# if TARGET_OS_OSX | # if TARGET_OS_OSX | ||||
# define SANITIZER_OSX 1 | # define SANITIZER_OSX 1 | ||||
# else | # else | ||||
# define SANITIZER_OSX 0 | # define SANITIZER_OSX 0 | ||||
# endif | # endif | ||||
# if TARGET_OS_IPHONE | # if TARGET_OS_IPHONE | ||||
# define SANITIZER_IOS 1 | # define SANITIZER_IOS 1 | ||||
# else | # else | ||||
# define SANITIZER_IOS 0 | # define SANITIZER_IOS 0 | ||||
# endif | # endif | ||||
# if TARGET_OS_WATCH | |||||
# define SANITIZER_WATCHOS 1 | |||||
# else | |||||
# define SANITIZER_WATCHOS 0 | |||||
# endif | |||||
# if TARGET_OS_TV | |||||
yln: Is `TARGET_OS_IPHONE` needed here? | |||||
# define SANITIZER_TVOS 1 | |||||
# else | |||||
# define SANITIZER_TVOS 0 | |||||
# endif | |||||
# if TARGET_OS_SIMULATOR | # if TARGET_OS_SIMULATOR | ||||
# define SANITIZER_IOSSIM 1 | # define SANITIZER_IOSSIM 1 | ||||
# else | # else | ||||
# define SANITIZER_IOSSIM 0 | # define SANITIZER_IOSSIM 0 | ||||
# endif | # endif | ||||
#else | #else | ||||
# define SANITIZER_MAC 0 | # define SANITIZER_APPLE 0 | ||||
# define SANITIZER_MAC SANITIZER_APPLE | |||||
# define SANITIZER_IOS 0 | # define SANITIZER_IOS 0 | ||||
# define SANITIZER_IOSSIM 0 | # define SANITIZER_IOSSIM 0 | ||||
# define SANITIZER_OSX 0 | # define SANITIZER_OSX 0 | ||||
#endif | #endif | ||||
ylnUnsubmitted We are missing SANITIZER_WATCHOS and SANITIZER_TVOS here in the non-Apple case. yln: We are missing `SANITIZER_WATCHOS` and `SANITIZER_TVOS` here in the non-Apple case. | |||||
wrotkiAuthorUnsubmitted The diff looks a bit weird here (reviews.llvm,.org) , but I think it's still correct. I'll retest just in case. wrotki: The diff looks a bit weird here (reviews.llvm,.org) , but I think it's still correct. I'll… | |||||
#if defined(__APPLE__) && TARGET_OS_IPHONE && TARGET_OS_WATCH | |||||
# define SANITIZER_WATCHOS 1 | |||||
#else | |||||
# define SANITIZER_WATCHOS 0 | |||||
#endif | |||||
#if defined(__APPLE__) && TARGET_OS_IPHONE && TARGET_OS_TV | |||||
# define SANITIZER_TVOS 1 | |||||
#else | |||||
# define SANITIZER_TVOS 0 | |||||
#endif | |||||
#if defined(_WIN32) | #if defined(_WIN32) | ||||
# define SANITIZER_WINDOWS 1 | # define SANITIZER_WINDOWS 1 | ||||
#else | #else | ||||
# define SANITIZER_WINDOWS 0 | # define SANITIZER_WINDOWS 0 | ||||
#endif | #endif | ||||
#if defined(_WIN64) | #if defined(_WIN64) | ||||
# define SANITIZER_WINDOWS64 1 | # define SANITIZER_WINDOWS64 1 | ||||
Show All 16 Lines | |||||
// Assume linux that is not glibc or android is musl libc. | // Assume linux that is not glibc or android is musl libc. | ||||
#if SANITIZER_LINUX && !SANITIZER_GLIBC && !SANITIZER_ANDROID | #if SANITIZER_LINUX && !SANITIZER_GLIBC && !SANITIZER_ANDROID | ||||
# define SANITIZER_MUSL 1 | # define SANITIZER_MUSL 1 | ||||
#else | #else | ||||
# define SANITIZER_MUSL 0 | # define SANITIZER_MUSL 0 | ||||
#endif | #endif | ||||
#define SANITIZER_POSIX \ | #define SANITIZER_POSIX \ | ||||
(SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_MAC || \ | (SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_APPLE || \ | ||||
SANITIZER_NETBSD || SANITIZER_SOLARIS) | SANITIZER_NETBSD || SANITIZER_SOLARIS) | ||||
#if __LP64__ || defined(_WIN64) | #if __LP64__ || defined(_WIN64) | ||||
# define SANITIZER_WORDSIZE 64 | # define SANITIZER_WORDSIZE 64 | ||||
#else | #else | ||||
# define SANITIZER_WORDSIZE 32 | # define SANITIZER_WORDSIZE 32 | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | |||||
# if SANITIZER_GO && defined(__mips64) | # if SANITIZER_GO && defined(__mips64) | ||||
# define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 47) | # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 47) | ||||
# else | # else | ||||
# define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 40) | # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 40) | ||||
# endif | # endif | ||||
#elif SANITIZER_RISCV64 | #elif SANITIZER_RISCV64 | ||||
# define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 38) | # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 38) | ||||
#elif defined(__aarch64__) | #elif defined(__aarch64__) | ||||
# if SANITIZER_MAC | # if SANITIZER_APPLE | ||||
# if SANITIZER_OSX || SANITIZER_IOSSIM | # if SANITIZER_OSX || SANITIZER_IOSSIM | ||||
# define SANITIZER_MMAP_RANGE_SIZE \ | # define SANITIZER_MMAP_RANGE_SIZE \ | ||||
FIRST_32_SECOND_64(1ULL << 32, 1ULL << 47) | FIRST_32_SECOND_64(1ULL << 32, 1ULL << 47) | ||||
# else | # else | ||||
// Darwin iOS/ARM64 has a 36-bit VMA, 64GiB VM | // Darwin iOS/ARM64 has a 36-bit VMA, 64GiB VM | ||||
# define SANITIZER_MMAP_RANGE_SIZE \ | # define SANITIZER_MMAP_RANGE_SIZE \ | ||||
FIRST_32_SECOND_64(1ULL << 32, 1ULL << 36) | FIRST_32_SECOND_64(1ULL << 32, 1ULL << 36) | ||||
# endif | # endif | ||||
Show All 40 Lines | |||||
/// * 1800: Microsoft Visual Studio 2013 / 12.0 | /// * 1800: Microsoft Visual Studio 2013 / 12.0 | ||||
/// * 1900: Microsoft Visual Studio 2015 / 14.0 | /// * 1900: Microsoft Visual Studio 2015 / 14.0 | ||||
#ifdef _MSC_VER | #ifdef _MSC_VER | ||||
# define MSC_PREREQ(version) (_MSC_VER >= (version)) | # define MSC_PREREQ(version) (_MSC_VER >= (version)) | ||||
#else | #else | ||||
# define MSC_PREREQ(version) 0 | # define MSC_PREREQ(version) 0 | ||||
#endif | #endif | ||||
#if SANITIZER_MAC && defined(__x86_64__) | #if SANITIZER_APPLE && defined(__x86_64__) | ||||
# define SANITIZER_NON_UNIQUE_TYPEINFO 0 | # define SANITIZER_NON_UNIQUE_TYPEINFO 0 | ||||
#else | #else | ||||
# define SANITIZER_NON_UNIQUE_TYPEINFO 1 | # define SANITIZER_NON_UNIQUE_TYPEINFO 1 | ||||
#endif | #endif | ||||
// On linux, some architectures had an ABI transition from 64-bit long double | // On linux, some architectures had an ABI transition from 64-bit long double | ||||
// (ie. same as double) to 128-bit long double. On those, glibc symbols | // (ie. same as double) to 128-bit long double. On those, glibc symbols | ||||
// involving long doubles come in two versions, and we need to pass the | // involving long doubles come in two versions, and we need to pass the | ||||
Show All 11 Lines | |||||
// dlopen mallocs "libgcc_s.so" string which confuses LSan, it fails to realize | // dlopen mallocs "libgcc_s.so" string which confuses LSan, it fails to realize | ||||
// that this allocation happens in dynamic linker and should be ignored. | // that this allocation happens in dynamic linker and should be ignored. | ||||
#if SANITIZER_PPC || defined(__thumb__) | #if SANITIZER_PPC || defined(__thumb__) | ||||
# define SANITIZER_SUPPRESS_LEAK_ON_PTHREAD_EXIT 1 | # define SANITIZER_SUPPRESS_LEAK_ON_PTHREAD_EXIT 1 | ||||
#else | #else | ||||
# define SANITIZER_SUPPRESS_LEAK_ON_PTHREAD_EXIT 0 | # define SANITIZER_SUPPRESS_LEAK_ON_PTHREAD_EXIT 0 | ||||
#endif | #endif | ||||
#if SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_NETBSD || SANITIZER_SOLARIS | #if SANITIZER_FREEBSD || SANITIZER_APPLE || SANITIZER_NETBSD || SANITIZER_SOLARIS | ||||
# define SANITIZER_MADVISE_DONTNEED MADV_FREE | # define SANITIZER_MADVISE_DONTNEED MADV_FREE | ||||
#else | #else | ||||
# define SANITIZER_MADVISE_DONTNEED MADV_DONTNEED | # define SANITIZER_MADVISE_DONTNEED MADV_DONTNEED | ||||
#endif | #endif | ||||
// Older gcc have issues aligning to a constexpr, and require an integer. | // Older gcc have issues aligning to a constexpr, and require an integer. | ||||
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56859 among others. | // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56859 among others. | ||||
#if defined(__powerpc__) || defined(__powerpc64__) | #if defined(__powerpc__) || defined(__powerpc64__) | ||||
# define SANITIZER_CACHE_LINE_SIZE 128 | # define SANITIZER_CACHE_LINE_SIZE 128 | ||||
#else | #else | ||||
# define SANITIZER_CACHE_LINE_SIZE 64 | # define SANITIZER_CACHE_LINE_SIZE 64 | ||||
#endif | #endif | ||||
// Enable offline markup symbolizer for Fuchsia. | // Enable offline markup symbolizer for Fuchsia. | ||||
#if SANITIZER_FUCHSIA | #if SANITIZER_FUCHSIA | ||||
# define SANITIZER_SYMBOLIZER_MARKUP 1 | # define SANITIZER_SYMBOLIZER_MARKUP 1 | ||||
#else | #else | ||||
# define SANITIZER_SYMBOLIZER_MARKUP 0 | # define SANITIZER_SYMBOLIZER_MARKUP 0 | ||||
#endif | #endif | ||||
// Enable ability to support sanitizer initialization that is | // Enable ability to support sanitizer initialization that is | ||||
// compatible with the sanitizer library being loaded via | // compatible with the sanitizer library being loaded via | ||||
// `dlopen()`. | // `dlopen()`. | ||||
#if SANITIZER_MAC | #if SANITIZER_APPLE | ||||
# define SANITIZER_SUPPORTS_INIT_FOR_DLOPEN 1 | # define SANITIZER_SUPPORTS_INIT_FOR_DLOPEN 1 | ||||
#else | #else | ||||
# define SANITIZER_SUPPORTS_INIT_FOR_DLOPEN 0 | # define SANITIZER_SUPPORTS_INIT_FOR_DLOPEN 0 | ||||
#endif | #endif | ||||
// SANITIZER_SUPPORTS_THREADLOCAL | // SANITIZER_SUPPORTS_THREADLOCAL | ||||
// 1 - THREADLOCAL macro is supported by target | // 1 - THREADLOCAL macro is supported by target | ||||
// 0 - THREADLOCAL macro is not supported by target | // 0 - THREADLOCAL macro is not supported by target | ||||
Show All 23 Lines |
Is TARGET_OS_IPHONE needed here?