Replace some #ifdef(s) with plain if(s).

llvm-svn: 151526
This commit is contained in:
Evgeniy Stepanov 2012-02-27 13:07:29 +00:00
parent 93887631d9
commit d84e16e6a3
4 changed files with 20 additions and 31 deletions

View File

@ -46,24 +46,17 @@ static const size_t kMinAllocSize = REDZONE * 2;
static const uint64_t kMaxAvailableRam = 128ULL << 30; // 128G
static const size_t kMaxThreadLocalQuarantine = 1 << 20; // 1M
#if ASAN_LOW_MEMORY == 1
static const size_t kMinMmapSize = 4UL << 17; // 128K
static const size_t kMaxSizeForThreadLocalFreeList = 1 << 15; // 32K
#else
static const size_t kMinMmapSize = 4UL << 20; // 4M
static const size_t kMaxSizeForThreadLocalFreeList = 1 << 17; // 128K
#endif
static const size_t kMinMmapSize = (ASAN_LOW_MEMORY) ? 4UL << 17 : 4UL << 20;
static const size_t kMaxSizeForThreadLocalFreeList =
(ASAN_LOW_MEMORY) ? 1 << 15 : 1 << 17;
// Size classes less than kMallocSizeClassStep are powers of two.
// All other size classes are multiples of kMallocSizeClassStep.
static const size_t kMallocSizeClassStepLog = 26;
static const size_t kMallocSizeClassStep = 1UL << kMallocSizeClassStepLog;
#if __WORDSIZE == 32
static const size_t kMaxAllowedMallocSize = 3UL << 30; // 3G
#else
static const size_t kMaxAllowedMallocSize = 8UL << 30; // 8G
#endif
static const size_t kMaxAllowedMallocSize =
(__WORDSIZE == 32) ? 3UL << 30 : 8UL << 30;
static inline bool IsAligned(uintptr_t a, uintptr_t alignment) {
return (a & (alignment - 1)) == 0;

View File

@ -129,6 +129,12 @@ extern "C" void* _ReturnAddress(void);
# define ASAN_FLEXIBLE_MAPPING_AND_OFFSET 0
#endif
// If set, values like allocator chunk size, as well as defaults for some flags
// will be changed towards less memory overhead.
#ifndef ASAN_LOW_MEMORY
# define ASAN_LOW_MEMORY 0
#endif
// All internal functions in asan reside inside the __asan namespace
// to avoid namespace collisions with the user programs.
// Seperate namespace also makes it simpler to distinguish the asan run-time

View File

@ -410,15 +410,8 @@ void __asan_init() {
FLAG_v = IntFlagValue(options, "verbosity=", 0);
#if ASAN_LOW_MEMORY == 1
FLAG_quarantine_size =
IntFlagValue(options, "quarantine_size=", 1UL << 24); // 16M
FLAG_redzone = IntFlagValue(options, "redzone=", 64);
#else
FLAG_quarantine_size =
IntFlagValue(options, "quarantine_size=", 1UL << 28); // 256M
FLAG_redzone = IntFlagValue(options, "redzone=", 128);
#endif
FLAG_redzone = IntFlagValue(options, "redzone=",
(ASAN_LOW_MEMORY) ? 64 : 128);
CHECK(FLAG_redzone >= 32);
CHECK((FLAG_redzone & (FLAG_redzone - 1)) == 0);
@ -443,6 +436,9 @@ void __asan_init() {
Atexit(asan_atexit);
}
FLAG_quarantine_size = IntFlagValue(options, "quarantine_size=",
(ASAN_LOW_MEMORY) ? 1UL << 24 : 1UL << 28);
// interceptors
InitializeAsanInterceptors();

View File

@ -453,11 +453,7 @@ static void MallocStress(size_t n) {
}
TEST(AddressSanitizer, MallocStressTest) {
#if ASAN_LOW_MEMORY == 1
MallocStress(20000);
#else
MallocStress(200000);
#endif
MallocStress((ASAN_LOW_MEMORY) ? 20000 : 200000);
}
static void TestLargeMalloc(size_t size) {
@ -489,13 +485,11 @@ TEST(AddressSanitizer, HugeMallocTest) {
TEST(AddressSanitizer, ThreadedMallocStressTest) {
const int kNumThreads = 4;
const int kNumIterations = (ASAN_LOW_MEMORY) ? 10000 : 100000;
pthread_t t[kNumThreads];
for (int i = 0; i < kNumThreads; i++) {
#if ASAN_LOW_MEMORY == 1
pthread_create(&t[i], 0, (void* (*)(void *x))MallocStress, (void*)10000);
#else
pthread_create(&t[i], 0, (void* (*)(void *x))MallocStress, (void*)100000);
#endif
pthread_create(&t[i], 0, (void* (*)(void *x))MallocStress,
(void*)kNumIterations);
}
for (int i = 0; i < kNumThreads; i++) {
pthread_join(t[i], 0);