diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-03-19 13:54:41 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-03-19 13:54:41 +0000 |
commit | 83cb7877f608eb9b3d65981095216842f686c527 (patch) | |
tree | b77d0d40fdcb999068c2aae99b94f0aa1e42f2d9 | |
parent | e75628e9e9bba6c65b067372d381d9e03560923a (diff) | |
download | compiler-rt-83cb7877f608eb9b3d65981095216842f686c527.tar.gz compiler-rt-83cb7877f608eb9b3d65981095216842f686c527.tar.bz2 compiler-rt-83cb7877f608eb9b3d65981095216842f686c527.tar.xz |
[sanitizer] Move ASan platform macros to sanitizer_common and rename them appropriately.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177397 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/asan/asan_internal.h | 35 | ||||
-rw-r--r-- | lib/asan/asan_linux.cc | 6 | ||||
-rw-r--r-- | lib/asan/asan_mac.h | 6 | ||||
-rw-r--r-- | lib/asan/asan_malloc_linux.cc | 2 | ||||
-rw-r--r-- | lib/asan/asan_mapping.h | 4 | ||||
-rw-r--r-- | lib/asan/asan_new_delete.cc | 2 | ||||
-rw-r--r-- | lib/asan/asan_rtl.cc | 4 | ||||
-rw-r--r-- | lib/asan/asan_thread_registry.cc | 2 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_internal_defs.h | 31 |
9 files changed, 46 insertions, 46 deletions
diff --git a/lib/asan/asan_internal.h b/lib/asan/asan_internal.h index 1edd8a78..ab128318 100644 --- a/lib/asan/asan_internal.h +++ b/lib/asan/asan_internal.h @@ -21,39 +21,8 @@ #include "sanitizer_common/sanitizer_stacktrace.h" #include "sanitizer_common/sanitizer_libc.h" -#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) -# error "This operating system is not supported by AddressSanitizer" -#endif - #define ASAN_DEFAULT_FAILURE_EXITCODE 1 -#if defined(__linux__) -# define ASAN_LINUX 1 -#else -# define ASAN_LINUX 0 -#endif - -#if defined(__APPLE__) -# define ASAN_MAC 1 -#else -# define ASAN_MAC 0 -#endif - -#if defined(_WIN32) -# define ASAN_WINDOWS 1 -#else -# define ASAN_WINDOWS 0 -#endif - -#if defined(__ANDROID__) || defined(ANDROID) -# define ASAN_ANDROID 1 -#else -# define ASAN_ANDROID 0 -#endif - - -#define ASAN_POSIX (ASAN_LINUX || ASAN_MAC) - #if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) # error "The AddressSanitizer run-time should not be" " instrumented by AddressSanitizer" @@ -63,7 +32,7 @@ // If set, asan will install its own SEGV signal handler. #ifndef ASAN_NEEDS_SEGV -# if ASAN_ANDROID == 1 +# if SANITIZER_ANDROID == 1 # define ASAN_NEEDS_SEGV 0 # else # define ASAN_NEEDS_SEGV 1 @@ -92,7 +61,7 @@ #endif #ifndef ASAN_USE_PREINIT_ARRAY -# define ASAN_USE_PREINIT_ARRAY (ASAN_LINUX && !ASAN_ANDROID) +# define ASAN_USE_PREINIT_ARRAY (SANITIZER_LINUX && !SANITIZER_ANDROID) #endif // All internal functions in asan reside inside the __asan namespace diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc index 845493de..9b2ed170 100644 --- a/lib/asan/asan_linux.cc +++ b/lib/asan/asan_linux.cc @@ -31,7 +31,7 @@ #include <unistd.h> #include <unwind.h> -#if !ASAN_ANDROID +#if !SANITIZER_ANDROID // FIXME: where to get ucontext on Android? #include <sys/ucontext.h> #endif @@ -50,7 +50,7 @@ void *AsanDoesNotSupportStaticLinkage() { } void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) { -#if ASAN_ANDROID +#if SANITIZER_ANDROID *pc = *sp = *bp = 0; #elif defined(__arm__) ucontext_t *ucontext = (ucontext_t*)context; @@ -119,7 +119,7 @@ void GetStackTrace(StackTrace *stack, uptr max_s, uptr pc, uptr bp, bool fast) { } } -#if !ASAN_ANDROID +#if !SANITIZER_ANDROID void ReadContextStack(void *context, uptr *stack, uptr *ssize) { ucontext_t *ucp = (ucontext_t*)context; *stack = (uptr)ucp->uc_stack.ss_sp; diff --git a/lib/asan/asan_mac.h b/lib/asan/asan_mac.h index be913865..ce411122 100644 --- a/lib/asan/asan_mac.h +++ b/lib/asan/asan_mac.h @@ -11,8 +11,8 @@ // // Mac-specific ASan definitions. //===----------------------------------------------------------------------===// -#ifndef ASAN_MAC_H -#define ASAN_MAC_H +#ifndef SANITIZER_MAC_H +#define SANITIZER_MAC_H // CF_RC_BITS, the layout of CFRuntimeBase and __CFStrIsConstant are internal // and subject to change in further CoreFoundation versions. Apple does not @@ -54,4 +54,4 @@ void MaybeReplaceCFAllocator(); } // namespace __asan -#endif // ASAN_MAC_H +#endif // SANITIZER_MAC_H diff --git a/lib/asan/asan_malloc_linux.cc b/lib/asan/asan_malloc_linux.cc index c30c5db5..864ff4ad 100644 --- a/lib/asan/asan_malloc_linux.cc +++ b/lib/asan/asan_malloc_linux.cc @@ -21,7 +21,7 @@ #include "asan_stack.h" #include "asan_thread_registry.h" -#if ASAN_ANDROID +#if SANITIZER_ANDROID DECLARE_REAL_AND_INTERCEPTOR(void*, malloc, uptr size) DECLARE_REAL_AND_INTERCEPTOR(void, free, void *ptr) DECLARE_REAL_AND_INTERCEPTOR(void*, calloc, uptr nmemb, uptr size) diff --git a/lib/asan/asan_mapping.h b/lib/asan/asan_mapping.h index 161ab653..f0462922 100644 --- a/lib/asan/asan_mapping.h +++ b/lib/asan/asan_mapping.h @@ -56,7 +56,7 @@ extern SANITIZER_INTERFACE_ATTRIBUTE uptr __asan_mapping_offset; # define SHADOW_SCALE (__asan_mapping_scale) # define SHADOW_OFFSET (__asan_mapping_offset) #else -# if ASAN_ANDROID +# if SANITIZER_ANDROID # define SHADOW_SCALE (3) # define SHADOW_OFFSET (0) # else @@ -67,7 +67,7 @@ extern SANITIZER_INTERFACE_ATTRIBUTE uptr __asan_mapping_offset; # if defined(__powerpc64__) # define SHADOW_OFFSET (1ULL << 41) # else -# if ASAN_MAC +# if SANITIZER_MAC # define SHADOW_OFFSET (1ULL << 44) # else # define SHADOW_OFFSET 0x7fff8000ULL diff --git a/lib/asan/asan_new_delete.cc b/lib/asan/asan_new_delete.cc index 40aa31c2..7b0617a1 100644 --- a/lib/asan/asan_new_delete.cc +++ b/lib/asan/asan_new_delete.cc @@ -29,7 +29,7 @@ using namespace __asan; // NOLINT // On Android new() goes through malloc interceptors. // See also https://code.google.com/p/address-sanitizer/issues/detail?id=131. -#if !ASAN_ANDROID +#if !SANITIZER_ANDROID // Fake std::nothrow_t to avoid including <new>. namespace std { diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc index 29023390..1d6a0244 100644 --- a/lib/asan/asan_rtl.cc +++ b/lib/asan/asan_rtl.cc @@ -169,7 +169,7 @@ void InitializeFlags(Flags *f, const char *env) { f->poison_heap = true; // Turn off alloc/dealloc mismatch checker on Mac for now. // TODO(glider): Fix known issues and enable this back. - f->alloc_dealloc_mismatch = (ASAN_MAC == 0);; + f->alloc_dealloc_mismatch = (SANITIZER_MAC == 0);; f->use_stack_depot = true; // Only affects allocator2. f->strict_memcmp = true; @@ -462,7 +462,7 @@ void __asan_init() { bool full_shadow_is_available = MemoryRangeIsAvailable(shadow_start, shadow_end); -#if ASAN_LINUX && defined(__x86_64__) && !ASAN_FIXED_MAPPING +#if SANITIZER_LINUX && defined(__x86_64__) && !ASAN_FIXED_MAPPING if (!full_shadow_is_available) { kMidMemBeg = kLowMemEnd < 0x3000000000ULL ? 0x3000000000ULL : 0; kMidMemEnd = kLowMemEnd < 0x3000000000ULL ? 0x4fffffffffULL : 0; diff --git a/lib/asan/asan_thread_registry.cc b/lib/asan/asan_thread_registry.cc index 80675405..2fd1746e 100644 --- a/lib/asan/asan_thread_registry.cc +++ b/lib/asan/asan_thread_registry.cc @@ -70,7 +70,7 @@ AsanThread *AsanThreadRegistry::GetMain() { AsanThread *AsanThreadRegistry::GetCurrent() { AsanThreadSummary *summary = (AsanThreadSummary *)AsanTSDGet(); if (!summary) { -#if ASAN_ANDROID +#if SANITIZER_ANDROID // On Android, libc constructor is called _after_ asan_init, and cleans up // TSD. Try to figure out if this is still the main thread by the stack // address. We are not entirely sure that we have correct main thread diff --git a/lib/sanitizer_common/sanitizer_internal_defs.h b/lib/sanitizer_common/sanitizer_internal_defs.h index e052cbdc..12f01e31 100644 --- a/lib/sanitizer_common/sanitizer_internal_defs.h +++ b/lib/sanitizer_common/sanitizer_internal_defs.h @@ -13,6 +13,37 @@ #ifndef SANITIZER_DEFS_H #define SANITIZER_DEFS_H +#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) +# error "This operating system is not supported" +#endif + +#if defined(__linux__) +# define SANITIZER_LINUX 1 +#else +# define SANITIZER_LINUX 0 +#endif + +#if defined(__APPLE__) +# define SANITIZER_MAC 1 +#else +# define SANITIZER_MAC 0 +#endif + +#if defined(_WIN32) +# define SANITIZER_WINDOWS 1 +#else +# define SANITIZER_WINDOWS 0 +#endif + +#if defined(__ANDROID__) || defined(ANDROID) +# define SANITIZER_ANDROID 1 +#else +# define SANITIZER_ANDROID 0 +#endif + +#define SANITIZER_POSIX (SANITIZER_LINUX || SANITIZER_MAC) + + #if defined(_WIN32) // FIXME find out what we need on Windows. __declspec(dllexport) ? # define SANITIZER_INTERFACE_ATTRIBUTE |