diff --git a/compiler-rt/lib/gwp_asan/definitions.h b/compiler-rt/lib/gwp_asan/definitions.h --- a/compiler-rt/lib/gwp_asan/definitions.h +++ b/compiler-rt/lib/gwp_asan/definitions.h @@ -9,21 +9,9 @@ #ifndef GWP_ASAN_DEFINITIONS_H_ #define GWP_ASAN_DEFINITIONS_H_ -#define TLS_INITIAL_EXEC __thread __attribute__((tls_model("initial-exec"))) +#define GWP_ASAN_TLS_INITIAL_EXEC __thread __attribute__((tls_model("initial-exec"))) -#ifdef LIKELY -# undef LIKELY -#endif // defined(LIKELY) -#define LIKELY(X) __builtin_expect(!!(X), 1) - -#ifdef UNLIKELY -# undef UNLIKELY -#endif // defined(UNLIKELY) -#define UNLIKELY(X) __builtin_expect(!!(X), 0) - -#ifdef ALWAYS_INLINE -# undef ALWAYS_INLINE -#endif // defined(ALWAYS_INLINE) -#define ALWAYS_INLINE inline __attribute__((always_inline)) +#define GWP_ASAN_UNLIKELY(X) __builtin_expect(!!(X), 0) +#define GWP_ASAN_ALWAYS_INLINE inline __attribute__((always_inline)) #endif // GWP_ASAN_DEFINITIONS_H_ diff --git a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h --- a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h +++ b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h @@ -100,19 +100,19 @@ void init(const options::Options &Opts); // Return whether the allocation should be randomly chosen for sampling. - ALWAYS_INLINE bool shouldSample() { + GWP_ASAN_ALWAYS_INLINE bool shouldSample() { // NextSampleCounter == 0 means we "should regenerate the counter". // == 1 means we "should sample this allocation". - if (UNLIKELY(ThreadLocals.NextSampleCounter == 0)) + if (GWP_ASAN_UNLIKELY(ThreadLocals.NextSampleCounter == 0)) ThreadLocals.NextSampleCounter = (getRandomUnsigned32() % AdjustedSampleRate) + 1; - return UNLIKELY(--ThreadLocals.NextSampleCounter == 0); + return GWP_ASAN_UNLIKELY(--ThreadLocals.NextSampleCounter == 0); } // Returns whether the provided pointer is a current sampled allocation that // is owned by this pool. - ALWAYS_INLINE bool pointerIsMine(const void *Ptr) const { + GWP_ASAN_ALWAYS_INLINE bool pointerIsMine(const void *Ptr) const { uintptr_t P = reinterpret_cast(Ptr); return GuardedPagePool <= P && P < GuardedPagePoolEnd; } @@ -267,7 +267,7 @@ // allocation. bool RecursiveGuard = false; }; - static TLS_INITIAL_EXEC ThreadLocalPackedVariables ThreadLocals; + static GWP_ASAN_TLS_INITIAL_EXEC ThreadLocalPackedVariables ThreadLocals; }; } // namespace gwp_asan diff --git a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp --- a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp +++ b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp @@ -527,7 +527,7 @@ printAllocDeallocTraces(AccessPtr, Meta, Printf, PrintBacktrace); } -TLS_INITIAL_EXEC +GWP_ASAN_TLS_INITIAL_EXEC GuardedPoolAllocator::ThreadLocalPackedVariables GuardedPoolAllocator::ThreadLocals; } // namespace gwp_asan