[llvm-commits] [compiler-rt] r157747 - in /compiler-rt/trunk/lib: asan/asan_allocator.cc asan/asan_allocator.h asan/asan_globals.cc asan/asan_interceptors.cc asan/asan_interceptors.h asan/asan_internal.h asan/asan_linux.cc asan/asan_mac.cc asan/asan_mapping.h asan/asan_poisoning.cc asan/asan_posix.cc asan/asan_printf.cc asan/asan_procmaps.h asan/asan_rtl.cc asan/asan_stack.cc asan/asan_stack.h asan/asan_thread.cc asan/asan_win.cc asan/tests/asan_noinst_test.cc sanitizer_common/sanitizer_defs.h
Kostya Serebryany
kcc at google.com
Thu May 31 08:02:08 PDT 2012
Author: kcc
Date: Thu May 31 10:02:07 2012
New Revision: 157747
URL: http://llvm.org/viewvc/llvm-project?rev=157747&view=rev
Log:
[asan] more renaming
Modified:
compiler-rt/trunk/lib/asan/asan_allocator.cc
compiler-rt/trunk/lib/asan/asan_allocator.h
compiler-rt/trunk/lib/asan/asan_globals.cc
compiler-rt/trunk/lib/asan/asan_interceptors.cc
compiler-rt/trunk/lib/asan/asan_interceptors.h
compiler-rt/trunk/lib/asan/asan_internal.h
compiler-rt/trunk/lib/asan/asan_linux.cc
compiler-rt/trunk/lib/asan/asan_mac.cc
compiler-rt/trunk/lib/asan/asan_mapping.h
compiler-rt/trunk/lib/asan/asan_poisoning.cc
compiler-rt/trunk/lib/asan/asan_posix.cc
compiler-rt/trunk/lib/asan/asan_printf.cc
compiler-rt/trunk/lib/asan/asan_procmaps.h
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/asan/asan_stack.cc
compiler-rt/trunk/lib/asan/asan_stack.h
compiler-rt/trunk/lib/asan/asan_thread.cc
compiler-rt/trunk/lib/asan/asan_win.cc
compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_defs.h
Modified: compiler-rt/trunk/lib/asan/asan_allocator.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.cc?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator.cc Thu May 31 10:02:07 2012
@@ -43,7 +43,7 @@
#define REDZONE FLAG_redzone
static const uptr kMinAllocSize = REDZONE * 2;
-static const uint64_t kMaxAvailableRam = 128ULL << 30; // 128G
+static const u64 kMaxAvailableRam = 128ULL << 30; // 128G
static const uptr kMaxThreadLocalQuarantine = 1 << 20; // 1M
static const uptr kMinMmapSize = (ASAN_LOW_MEMORY) ? 4UL << 17 : 4UL << 20;
@@ -94,7 +94,7 @@
return 1UL << (up + 1);
}
-static inline uptr SizeClassToSize(uint8_t size_class) {
+static inline uptr SizeClassToSize(u8 size_class) {
CHECK(size_class < kNumberOfSizeClasses);
if (size_class <= kMallocSizeClassStepLog) {
return 1UL << size_class;
@@ -103,8 +103,8 @@
}
}
-static inline uint8_t SizeToSizeClass(uptr size) {
- uint8_t res = 0;
+static inline u8 SizeToSizeClass(uptr size) {
+ u8 res = 0;
if (size <= kMallocSizeClassStep) {
uptr rounded = RoundUpToPowerOfTwo(size);
res = Log2(rounded);
@@ -129,9 +129,9 @@
kAsanHeapRightRedzoneMagic);
}
-static uint8_t *MmapNewPagesAndPoisonShadow(uptr size) {
+static u8 *MmapNewPagesAndPoisonShadow(uptr size) {
CHECK(IsAligned(size, kPageSize));
- uint8_t *res = (uint8_t*)AsanMmapSomewhereOrDie(size, __FUNCTION__);
+ u8 *res = (u8*)AsanMmapSomewhereOrDie(size, __FUNCTION__);
PoisonShadow((uptr)res, size, kAsanHeapLeftRedzoneMagic);
if (FLAG_debug) {
Printf("ASAN_MMAP: [%p, %p)\n", res, res + size);
@@ -157,35 +157,35 @@
};
struct ChunkBase {
- uint16_t chunk_state;
- uint8_t size_class;
- uint32_t offset; // User-visible memory starts at this+offset (beg()).
- int32_t alloc_tid;
- int32_t free_tid;
+ u16 chunk_state;
+ u8 size_class;
+ u32 offset; // User-visible memory starts at this+offset (beg()).
+ s32 alloc_tid;
+ s32 free_tid;
uptr used_size; // Size requested by the user.
AsanChunk *next;
uptr beg() { return (uptr)this + offset; }
uptr Size() { return SizeClassToSize(size_class); }
- uint8_t SizeClass() { return size_class; }
+ u8 SizeClass() { return size_class; }
};
struct AsanChunk: public ChunkBase {
- uint32_t *compressed_alloc_stack() {
+ u32 *compressed_alloc_stack() {
CHECK(REDZONE >= sizeof(ChunkBase));
- return (uint32_t*)((uptr)this + sizeof(ChunkBase));
+ return (u32*)((uptr)this + sizeof(ChunkBase));
}
- uint32_t *compressed_free_stack() {
+ u32 *compressed_free_stack() {
CHECK(REDZONE >= sizeof(ChunkBase));
- return (uint32_t*)((uptr)this + REDZONE);
+ return (u32*)((uptr)this + REDZONE);
}
// The left redzone after the ChunkBase is given to the alloc stack trace.
uptr compressed_alloc_stack_size() {
- return (REDZONE - sizeof(ChunkBase)) / sizeof(uint32_t);
+ return (REDZONE - sizeof(ChunkBase)) / sizeof(u32);
}
uptr compressed_free_stack_size() {
- return (REDZONE) / sizeof(uint32_t);
+ return (REDZONE) / sizeof(u32);
}
bool AddrIsInside(uptr addr, uptr access_size, uptr *offset) {
@@ -307,7 +307,7 @@
explicit MallocInfo(LinkerInitialized x) : mu_(x) { }
- AsanChunk *AllocateChunks(uint8_t size_class, uptr n_chunks) {
+ AsanChunk *AllocateChunks(u8 size_class, uptr n_chunks) {
AsanChunk *m = 0;
AsanChunk **fl = &free_lists_[size_class];
{
@@ -515,7 +515,7 @@
}
// Get a list of newly allocated chunks.
- AsanChunk *GetNewChunks(uint8_t size_class) {
+ AsanChunk *GetNewChunks(u8 size_class) {
uptr size = SizeClassToSize(size_class);
CHECK(IsPowerOfTwo(kMinMmapSize));
CHECK(size < kMinMmapSize || (size % kMinMmapSize) == 0);
@@ -530,7 +530,7 @@
mmap_size += kPageSize;
}
CHECK(n_chunks > 0);
- uint8_t *mem = MmapNewPagesAndPoisonShadow(mmap_size);
+ u8 *mem = MmapNewPagesAndPoisonShadow(mmap_size);
// Statistics.
AsanStats &thread_stats = asanThreadRegistry().GetCurrentThreadStats();
@@ -608,7 +608,7 @@
}
}
-static uint8_t *Allocate(uptr alignment, uptr size, AsanStackTrace *stack) {
+static u8 *Allocate(uptr alignment, uptr size, AsanStackTrace *stack) {
__asan_init();
CHECK(stack);
if (size == 0) {
@@ -626,7 +626,7 @@
return 0;
}
- uint8_t size_class = SizeToSizeClass(needed_size);
+ u8 size_class = SizeToSizeClass(needed_size);
uptr size_to_allocate = SizeClassToSize(size_class);
CHECK(size_to_allocate >= kMinAllocSize);
CHECK(size_to_allocate >= needed_size);
@@ -692,10 +692,10 @@
if (size <= FLAG_max_malloc_fill_size) {
REAL(memset)((void*)addr, 0, rounded_size);
}
- return (uint8_t*)addr;
+ return (u8*)addr;
}
-static void Deallocate(uint8_t *ptr, AsanStackTrace *stack) {
+static void Deallocate(u8 *ptr, AsanStackTrace *stack) {
if (!ptr) return;
CHECK(stack);
@@ -707,7 +707,7 @@
AsanChunk *m = PtrToChunk((uptr)ptr);
// Flip the state atomically to avoid race on double-free.
- uint16_t old_chunk_state = AtomicExchange(&m->chunk_state, CHUNK_QUARANTINE);
+ u16 old_chunk_state = AtomicExchange(&m->chunk_state, CHUNK_QUARANTINE);
if (old_chunk_state == CHUNK_QUARANTINE) {
Report("ERROR: AddressSanitizer attempting double-free on %p:\n", ptr);
@@ -751,7 +751,7 @@
}
}
-static uint8_t *Reallocate(uint8_t *old_ptr, uptr new_size,
+static u8 *Reallocate(u8 *old_ptr, uptr new_size,
AsanStackTrace *stack) {
CHECK(old_ptr && new_size);
@@ -764,7 +764,7 @@
CHECK(m->chunk_state == CHUNK_ALLOCATED);
uptr old_size = m->used_size;
uptr memcpy_size = Min(new_size, old_size);
- uint8_t *new_ptr = Allocate(0, new_size, stack);
+ u8 *new_ptr = Allocate(0, new_size, stack);
if (new_ptr) {
CHECK(REAL(memcpy) != 0);
REAL(memcpy)(new_ptr, old_ptr, memcpy_size);
@@ -805,7 +805,7 @@
void asan_free(void *ptr, AsanStackTrace *stack) {
ASAN_DELETE_HOOK(ptr);
- Deallocate((uint8_t*)ptr, stack);
+ Deallocate((u8*)ptr, stack);
}
void *asan_malloc(uptr size, AsanStackTrace *stack) {
@@ -829,10 +829,10 @@
return ptr;
} else if (size == 0) {
ASAN_DELETE_HOOK(p);
- Deallocate((uint8_t*)p, stack);
+ Deallocate((u8*)p, stack);
return 0;
}
- return Reallocate((uint8_t*)p, size, stack);
+ return Reallocate((u8*)p, size, stack);
}
void *asan_valloc(uptr size, AsanStackTrace *stack) {
Modified: compiler-rt/trunk/lib/asan/asan_allocator.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.h?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator.h (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator.h Thu May 31 10:02:07 2012
@@ -60,8 +60,8 @@
uptr magic; // Modified by the instrumented code.
uptr descr; // Modified by the instrumented code.
FakeFrame *next;
- uint64_t real_stack : 48;
- uint64_t size_minus_one : 16;
+ u64 real_stack : 48;
+ u64 size_minus_one : 16;
};
struct FakeFrameFifo {
Modified: compiler-rt/trunk/lib/asan/asan_globals.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_globals.cc?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_globals.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_globals.cc Thu May 31 10:02:07 2012
@@ -45,7 +45,7 @@
kGlobalAndStackRedzone, kAsanGlobalRedzoneMagic);
if ((g.size % kGlobalAndStackRedzone) != 0) {
// partial right redzone
- uint64_t g_aligned_down_size = kGlobalAndStackRedzone *
+ u64 g_aligned_down_size = kGlobalAndStackRedzone *
(g.size / kGlobalAndStackRedzone);
CHECK(g_aligned_down_size == g_aligned_size - kGlobalAndStackRedzone);
PoisonShadowPartialRightRedzone(g.beg + g_aligned_down_size,
Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Thu May 31 10:02:07 2012
@@ -184,11 +184,11 @@
// ---------------------- Internal string functions ---------------- {{{1
-int64_t internal_simple_strtoll(const char *nptr, char **endptr, int base) {
+s64 internal_simple_strtoll(const char *nptr, char **endptr, int base) {
CHECK(base == 10);
while (IsSpace(*nptr)) nptr++;
int sgn = 1;
- uint64_t res = 0;
+ u64 res = 0;
bool have_digits = false;
char *old_nptr = (char*)nptr;
if (*nptr == '+') {
@@ -209,13 +209,13 @@
*endptr = (have_digits) ? (char*)nptr : old_nptr;
}
if (sgn > 0) {
- return (int64_t)(Min((uint64_t)INT64_MAX, res));
+ return (s64)(Min((u64)INT64_MAX, res));
} else {
- return (res > INT64_MAX) ? INT64_MIN : ((int64_t)res * -1);
+ return (res > INT64_MAX) ? INT64_MIN : ((s64)res * -1);
}
}
-int64_t internal_atoll(const char *nptr) {
+s64 internal_atoll(const char *nptr) {
return internal_simple_strtoll(nptr, (char**)0, 10);
}
Modified: compiler-rt/trunk/lib/asan/asan_interceptors.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.h?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.h (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.h Thu May 31 10:02:07 2012
@@ -31,7 +31,7 @@
namespace __asan {
// __asan::internal_X() is the implementation of X() for use in RTL.
-int64_t internal_atoll(const char *nptr);
+s64 internal_atoll(const char *nptr);
uptr internal_strlen(const char *s);
uptr internal_strnlen(const char *s, uptr maxlen);
char* internal_strchr(const char *s, int c);
@@ -43,7 +43,7 @@
int internal_strcmp(const char *s1, const char *s2);
char *internal_strncpy(char *dst, const char *src, uptr n);
// Works only for base=10 and doesn't set errno.
-int64_t internal_simple_strtoll(const char *nptr, char **endptr, int base);
+s64 internal_simple_strtoll(const char *nptr, char **endptr, int base);
void InitializeAsanInterceptors();
Modified: compiler-rt/trunk/lib/asan/asan_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Thu May 31 10:02:07 2012
@@ -23,19 +23,19 @@
#if defined(_WIN32)
# if defined(__clang__)
-typedef int intptr_t;
+typedef int sptr;
typedef unsigned int uptr;
# endif
// There's no <stdint.h> in Visual Studio 9, so we have to define [u]int*_t.
-typedef unsigned __int8 uint8_t;
-typedef unsigned __int16 uint16_t;
-typedef unsigned __int32 uint32_t;
-typedef unsigned __int64 uint64_t;
-typedef __int8 int8_t;
+typedef unsigned __int8 u8;
+typedef unsigned __int16 u16;
+typedef unsigned __int32 u32;
+typedef unsigned __int64 u64;
+typedef __int8 s8;
typedef __int16 int16_t;
-typedef __int32 int32_t;
-typedef __int64 int64_t;
+typedef __int32 s32;
+typedef __int64 s64;
typedef unsigned long DWORD; // NOLINT
extern "C" void* _ReturnAddress(void);
@@ -48,7 +48,7 @@
# define ASAN_INTERFACE_ATTRIBUTE // TODO(timurrrr): do we need this on Win?
#else // defined(_WIN32)
-# include <stdint.h> // for __WORDSIZE
+// #include <stdint.h>
# define ALIAS(x) __attribute__((alias(x)))
# define ALIGNED(x) __attribute__((aligned(x)))
@@ -194,7 +194,7 @@
int GetPid();
uptr GetThreadSelf();
int AtomicInc(int *a);
-uint16_t AtomicExchange(uint16_t *a, uint16_t new_val);
+u16 AtomicExchange(u16 *a, u16 new_val);
// Wrapper for TLS/TSD.
void AsanTSDInit(void (*destructor)(void *tsd));
@@ -223,13 +223,13 @@
// asan_poisoning.cc
// Poisons the shadow memory for "size" bytes starting from "addr".
-void PoisonShadow(uptr addr, uptr size, uint8_t value);
+void PoisonShadow(uptr addr, uptr size, u8 value);
// Poisons the shadow memory for "redzone_size" bytes starting from
// "addr + size".
void PoisonShadowPartialRightRedzone(uptr addr,
uptr size,
uptr redzone_size,
- uint8_t value);
+ u8 value);
// Platfrom-specific options.
#ifdef __APPLE__
@@ -241,13 +241,13 @@
#endif // __APPLE__
extern uptr FLAG_quarantine_size;
-extern int64_t FLAG_demangle;
+extern s64 FLAG_demangle;
extern bool FLAG_symbolize;
-extern int64_t FLAG_v;
+extern s64 FLAG_v;
extern uptr FLAG_redzone;
-extern int64_t FLAG_debug;
+extern s64 FLAG_debug;
extern bool FLAG_poison_shadow;
-extern int64_t FLAG_report_globals;
+extern s64 FLAG_report_globals;
extern uptr FLAG_malloc_context_size;
extern bool FLAG_replace_str;
extern bool FLAG_replace_intrin;
@@ -255,9 +255,9 @@
extern bool FLAG_fast_unwind;
extern bool FLAG_use_fake_stack;
extern uptr FLAG_max_malloc_fill_size;
-extern int64_t FLAG_exitcode;
+extern s64 FLAG_exitcode;
extern bool FLAG_allow_user_poisoning;
-extern int64_t FLAG_sleep_before_dying;
+extern s64 FLAG_sleep_before_dying;
extern bool FLAG_handle_segv;
extern bool FLAG_use_sigaltstack;
extern bool FLAG_check_malloc_usable_size;
Modified: compiler-rt/trunk/lib/asan/asan_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_linux.cc?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_linux.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_linux.cc Thu May 31 10:02:07 2012
@@ -74,7 +74,7 @@
}
static void *asan_mmap(void *addr, uptr length, int prot, int flags,
- int fd, uint64_t offset) {
+ int fd, u64 offset) {
# if __WORDSIZE == 64
return (void *)syscall(__NR_mmap, addr, length, prot, flags, fd, offset);
# else
Modified: compiler-rt/trunk/lib/asan/asan_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_mac.cc?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_mac.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_mac.cc Thu May 31 10:02:07 2012
@@ -98,7 +98,7 @@
}
static void *asan_mmap(void *addr, size_t length, int prot, int flags,
- int fd, uint64_t offset) {
+ int fd, u64 offset) {
return mmap(addr, length, prot, flags, fd, offset);
}
@@ -211,14 +211,14 @@
// and returns the start and end addresses and file offset of the corresponding
// segment.
// Note that the segment addresses are not necessarily sorted.
-template<uint32_t kLCSegment, typename SegmentCommand>
+template<u32 kLCSegment, typename SegmentCommand>
bool AsanProcMaps::NextSegmentLoad(
uptr *start, uptr *end, uptr *offset,
char filename[], size_t filename_size) {
const char* lc = current_load_cmd_addr_;
current_load_cmd_addr_ += ((const load_command *)lc)->cmdsize;
if (((const load_command *)lc)->cmd == kLCSegment) {
- const intptr_t dlloff = _dyld_get_image_vmaddr_slide(current_image_);
+ const sptr dlloff = _dyld_get_image_vmaddr_slide(current_image_);
const SegmentCommand* sc = (const SegmentCommand *)lc;
if (start) *start = sc->vmaddr + dlloff;
if (end) *end = sc->vmaddr + sc->vmsize + dlloff;
@@ -414,7 +414,7 @@
typedef void* dispatch_group_t;
typedef void* dispatch_queue_t;
-typedef uint64_t dispatch_time_t;
+typedef u64 dispatch_time_t;
typedef void (*dispatch_function_t)(void *block);
typedef void* (*worker_t)(void *block);
@@ -604,9 +604,9 @@
// See http://opensource.apple.com/source/CF/CF-635.15/CFRuntime.h
typedef struct __CFRuntimeBase {
uptr _cfisa;
- uint8_t _cfinfo[4];
+ u8 _cfinfo[4];
#if __LP64__
- uint32_t _rc;
+ u32 _rc;
#endif
} CFRuntimeBase;
Modified: compiler-rt/trunk/lib/asan/asan_mapping.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_mapping.h?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_mapping.h (original)
+++ compiler-rt/trunk/lib/asan/asan_mapping.h Thu May 31 10:02:07 2012
@@ -103,10 +103,10 @@
static inline bool AddressIsPoisoned(uptr a) {
const uptr kAccessSize = 1;
- uint8_t *shadow_address = (uint8_t*)MemToShadow(a);
- int8_t shadow_value = *shadow_address;
+ u8 *shadow_address = (u8*)MemToShadow(a);
+ s8 shadow_value = *shadow_address;
if (shadow_value) {
- uint8_t last_accessed_byte = (a & (SHADOW_GRANULARITY - 1))
+ u8 last_accessed_byte = (a & (SHADOW_GRANULARITY - 1))
+ kAccessSize - 1;
return (last_accessed_byte >= shadow_value);
}
Modified: compiler-rt/trunk/lib/asan/asan_poisoning.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_poisoning.cc?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_poisoning.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_poisoning.cc Thu May 31 10:02:07 2012
@@ -19,7 +19,7 @@
namespace __asan {
-void PoisonShadow(uptr addr, uptr size, uint8_t value) {
+void PoisonShadow(uptr addr, uptr size, u8 value) {
CHECK(AddrIsAlignedByGranularity(addr));
CHECK(AddrIsAlignedByGranularity(addr + size));
uptr shadow_beg = MemToShadow(addr);
@@ -31,9 +31,9 @@
void PoisonShadowPartialRightRedzone(uptr addr,
uptr size,
uptr redzone_size,
- uint8_t value) {
+ u8 value) {
CHECK(AddrIsAlignedByGranularity(addr));
- uint8_t *shadow = (uint8_t*)MemToShadow(addr);
+ u8 *shadow = (u8*)MemToShadow(addr);
for (uptr i = 0; i < redzone_size;
i += SHADOW_GRANULARITY, shadow++) {
if (i + SHADOW_GRANULARITY <= size) {
@@ -48,12 +48,12 @@
struct ShadowSegmentEndpoint {
- uint8_t *chunk;
- int8_t offset; // in [0, SHADOW_GRANULARITY)
- int8_t value; // = *chunk;
+ u8 *chunk;
+ s8 offset; // in [0, SHADOW_GRANULARITY)
+ s8 value; // = *chunk;
explicit ShadowSegmentEndpoint(uptr address) {
- chunk = (uint8_t*)MemToShadow(address);
+ chunk = (u8*)MemToShadow(address);
offset = address & (SHADOW_GRANULARITY - 1);
value = *chunk;
}
@@ -85,7 +85,7 @@
ShadowSegmentEndpoint end(end_addr);
if (beg.chunk == end.chunk) {
CHECK(beg.offset < end.offset);
- int8_t value = beg.value;
+ s8 value = beg.value;
CHECK(value == end.value);
// We can only poison memory if the byte in end.offset is unaddressable.
// No need to re-poison memory if it is poisoned already.
@@ -126,7 +126,7 @@
ShadowSegmentEndpoint end(end_addr);
if (beg.chunk == end.chunk) {
CHECK(beg.offset < end.offset);
- int8_t value = beg.value;
+ s8 value = beg.value;
CHECK(value == end.value);
// We unpoison memory bytes up to enbytes up to end.offset if it is not
// unpoisoned already.
Modified: compiler-rt/trunk/lib/asan/asan_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_posix.cc?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_posix.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_posix.cc Thu May 31 10:02:07 2012
@@ -143,7 +143,7 @@
void AsanDumpProcessMap() {
AsanProcMaps proc_maps;
uptr start, end;
- const intptr_t kBufSize = 4095;
+ const sptr kBufSize = 4095;
char filename[kBufSize];
Report("Process memory map follows:\n");
while (proc_maps.Next(&start, &end, /* file_offset */0,
@@ -185,7 +185,7 @@
#endif
}
-uint16_t AtomicExchange(uint16_t *a, uint16_t new_val) {
+u16 AtomicExchange(u16 *a, u16 new_val) {
return __sync_lock_test_and_set(a, new_val);
}
Modified: compiler-rt/trunk/lib/asan/asan_printf.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_printf.cc?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_printf.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_printf.cc Thu May 31 10:02:07 2012
@@ -52,8 +52,8 @@
// Appends number in a given base to buffer. If its length is less than
// "minimal_num_length", it is padded with leading zeroes.
-static int AppendUnsigned(char **buff, const char *buff_end, uint64_t num,
- uint8_t base, uint8_t minimal_num_length) {
+static int AppendUnsigned(char **buff, const char *buff_end, u64 num,
+ u8 base, u8 minimal_num_length) {
uptr const kMaxLen = 30;
RAW_CHECK(base == 10 || base == 16);
RAW_CHECK(minimal_num_length < kMaxLen);
@@ -75,13 +75,13 @@
}
static inline int AppendSignedDecimal(char **buff, const char *buff_end,
- int64_t num) {
+ s64 num) {
int result = 0;
if (num < 0) {
result += AppendChar(buff, buff_end, '-');
num = -num;
}
- result += AppendUnsigned(buff, buff_end, (uint64_t)num, 10, 0);
+ result += AppendUnsigned(buff, buff_end, (u64)num, 10, 0);
return result;
}
@@ -97,7 +97,7 @@
}
static inline int AppendPointer(char **buff, const char *buff_end,
- uint64_t ptr_value) {
+ u64 ptr_value) {
int result = 0;
result += AppendString(buff, buff_end, "0x");
result += AppendUnsigned(buff, buff_end, ptr_value, 16,
@@ -119,10 +119,10 @@
cur++;
bool have_z = (*cur == 'z');
cur += have_z;
- int64_t dval;
- uint64_t uval;
+ s64 dval;
+ u64 uval;
switch (*cur) {
- case 'd': dval = have_z ? va_arg(args, intptr_t)
+ case 'd': dval = have_z ? va_arg(args, sptr)
: va_arg(args, int);
result += AppendSignedDecimal(&buff, buff_end, dval);
break;
Modified: compiler-rt/trunk/lib/asan/asan_procmaps.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_procmaps.h?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_procmaps.h (original)
+++ compiler-rt/trunk/lib/asan/asan_procmaps.h Thu May 31 10:02:07 2012
@@ -56,11 +56,11 @@
uptr proc_self_maps_buff_len_;
char *current_;
#elif defined __APPLE__
- template<uint32_t kLCSegment, typename SegmentCommand>
+ template<u32 kLCSegment, typename SegmentCommand>
bool NextSegmentLoad(uptr *start, uptr *end, uptr *offset,
char filename[], uptr filename_size);
int current_image_;
- uint32_t current_magic_;
+ u32 current_magic_;
int current_load_cmd_count_;
char *current_load_cmd_addr_;
#endif
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Thu May 31 10:02:07 2012
@@ -30,24 +30,24 @@
uptr FLAG_malloc_context_size = kMallocContextSize;
uptr FLAG_max_malloc_fill_size = 0;
-int64_t FLAG_v = 0;
+s64 FLAG_v = 0;
uptr FLAG_redzone = (ASAN_LOW_MEMORY) ? 64 : 128; // power of two, >= 32
uptr FLAG_quarantine_size = (ASAN_LOW_MEMORY) ? 1UL << 24 : 1UL << 28;
-static int64_t FLAG_atexit = 0;
+static s64 FLAG_atexit = 0;
bool FLAG_poison_shadow = 1;
-int64_t FLAG_report_globals = 1;
+s64 FLAG_report_globals = 1;
bool FLAG_handle_segv = ASAN_NEEDS_SEGV;
bool FLAG_use_sigaltstack = 0;
bool FLAG_symbolize = 1;
-int64_t FLAG_demangle = 1;
-int64_t FLAG_debug = 0;
+s64 FLAG_demangle = 1;
+s64 FLAG_debug = 0;
bool FLAG_replace_cfallocator = 1; // Used on Mac only.
bool FLAG_replace_str = 1;
bool FLAG_replace_intrin = 1;
bool FLAG_use_fake_stack = 1;
-int64_t FLAG_exitcode = ASAN_DEFAULT_FAILURE_EXITCODE;
+s64 FLAG_exitcode = ASAN_DEFAULT_FAILURE_EXITCODE;
bool FLAG_allow_user_poisoning = 1;
-int64_t FLAG_sleep_before_dying = 0;
+s64 FLAG_sleep_before_dying = 0;
bool FLAG_abort_on_error = 0;
bool FLAG_unmap_shadow_on_exit = 0;
bool FLAG_disable_core = __WORDSIZE == 64;
@@ -69,7 +69,7 @@
}
static void PrintBytes(const char *before, uptr *a) {
- uint8_t *bytes = (uint8_t*)a;
+ u8 *bytes = (u8*)a;
uptr byte_num = (__WORDSIZE) / 8;
Printf("%s%p:", before, (void*)a);
for (uptr i = 0; i < byte_num; i++) {
@@ -167,7 +167,7 @@
static bool DescribeStackAddress(uptr addr, uptr access_size) {
AsanThread *t = asanThreadRegistry().FindThreadByStackAddress(addr);
if (!t) return false;
- const intptr_t kBufSize = 4095;
+ const sptr kBufSize = 4095;
char buf[kBufSize];
uptr offset = 0;
const char *frame_descr = t->GetFrameNameByAddr(addr, &offset);
@@ -181,7 +181,7 @@
buf[0] = 0;
internal_strncat(buf, frame_descr,
Min(kBufSize,
- static_cast<intptr_t>(name_end - frame_descr)));
+ static_cast<sptr>(name_end - frame_descr)));
Printf("Address %p is located at offset %zu "
"in frame <%s> of T%d's stack:\n",
addr, offset, buf, t->tid());
@@ -193,7 +193,7 @@
// Report all objects in this frame.
for (uptr i = 0; i < n_objects; i++) {
uptr beg, size;
- intptr_t len;
+ sptr len;
beg = internal_simple_strtoll(p, &p, 10);
size = internal_simple_strtoll(p, &p, 10);
len = internal_simple_strtoll(p, &p, 10);
@@ -277,7 +277,7 @@
// -------------------------- Init ------------------- {{{1
static void IntFlagValue(const char *flags, const char *flag,
- int64_t *out_val) {
+ s64 *out_val) {
if (!flags) return;
const char *str = internal_strstr(flags, flag);
if (!str) return;
@@ -368,7 +368,7 @@
Printf("=================================================================\n");
const char *bug_descr = "unknown-crash";
if (AddrIsInMem(addr)) {
- uint8_t *shadow_addr = (uint8_t*)MemToShadow(addr);
+ u8 *shadow_addr = (u8*)MemToShadow(addr);
// If we are accessing 16 bytes, look at the second shadow byte.
if (*shadow_addr == 0 && access_size > SHADOW_GRANULARITY)
shadow_addr++;
@@ -456,18 +456,18 @@
static void ParseAsanOptions(const char *options) {
IntFlagValue(options, "malloc_context_size=",
- (int64_t*)&FLAG_malloc_context_size);
+ (s64*)&FLAG_malloc_context_size);
CHECK(FLAG_malloc_context_size <= kMallocContextSize);
IntFlagValue(options, "max_malloc_fill_size=",
- (int64_t*)&FLAG_max_malloc_fill_size);
+ (s64*)&FLAG_max_malloc_fill_size);
IntFlagValue(options, "verbosity=", &FLAG_v);
- IntFlagValue(options, "redzone=", (int64_t*)&FLAG_redzone);
+ IntFlagValue(options, "redzone=", (s64*)&FLAG_redzone);
CHECK(FLAG_redzone >= 32);
CHECK((FLAG_redzone & (FLAG_redzone - 1)) == 0);
- IntFlagValue(options, "quarantine_size=", (int64_t*)&FLAG_quarantine_size);
+ IntFlagValue(options, "quarantine_size=", (s64*)&FLAG_quarantine_size);
IntFlagValue(options, "atexit=", &FLAG_atexit);
BoolFlagValue(options, "poison_shadow=", &FLAG_poison_shadow);
Modified: compiler-rt/trunk/lib/asan/asan_stack.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_stack.cc?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_stack.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_stack.cc Thu May 31 10:02:07 2012
@@ -85,7 +85,7 @@
// On 64-bits we compress stack traces: if a given pc differes slightly from
// the previous one, we record a 31-bit offset instead of the full pc.
uptr AsanStackTrace::CompressStack(AsanStackTrace *stack,
- uint32_t *compressed, uptr size) {
+ u32 *compressed, uptr size) {
#if __WORDSIZE == 32
// Don't compress, just copy.
uptr res = 0;
@@ -103,10 +103,10 @@
for (uptr i = 0, n = stack->size; i < n; i++) {
uptr pc = stack->trace[i];
if (!pc) break;
- if ((int64_t)pc < 0) break;
+ if ((s64)pc < 0) break;
// Printf("C pc[%zu] %zx\n", i, pc);
if (prev_pc - pc < kMaxOffset || pc - prev_pc < kMaxOffset) {
- uptr offset = (int64_t)(pc - prev_pc);
+ uptr offset = (s64)(pc - prev_pc);
offset |= (1U << 31);
if (c_index >= size) break;
// Printf("C co[%zu] offset %zx\n", i, offset);
@@ -148,7 +148,7 @@
}
void AsanStackTrace::UncompressStack(AsanStackTrace *stack,
- uint32_t *compressed, uptr size) {
+ u32 *compressed, uptr size) {
#if __WORDSIZE == 32
// Don't uncompress, just copy.
stack->size = 0;
@@ -161,12 +161,12 @@
uptr prev_pc = 0;
stack->size = 0;
for (uptr i = 0; i < size && stack->size < kStackTraceMax; i++) {
- uint32_t x = compressed[i];
+ u32 x = compressed[i];
uptr pc = 0;
if (x & (1U << 31)) {
// Printf("U co[%zu] offset: %x\n", i, x);
// this is an offset
- int32_t offset = x;
+ s32 offset = x;
offset = (offset << 1) >> 1; // remove the 31-byte and sign-extend.
pc = prev_pc + offset;
CHECK(pc);
Modified: compiler-rt/trunk/lib/asan/asan_stack.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_stack.h?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_stack.h (original)
+++ compiler-rt/trunk/lib/asan/asan_stack.h Thu May 31 10:02:07 2012
@@ -50,9 +50,9 @@
static uptr GetCurrentPc();
static uptr CompressStack(AsanStackTrace *stack,
- uint32_t *compressed, uptr size);
+ u32 *compressed, uptr size);
static void UncompressStack(AsanStackTrace *stack,
- uint32_t *compressed, uptr size);
+ u32 *compressed, uptr size);
};
} // namespace __asan
Modified: compiler-rt/trunk/lib/asan/asan_thread.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_thread.cc?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_thread.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_thread.cc Thu May 31 10:02:07 2012
@@ -116,8 +116,8 @@
is_fake_stack = true;
}
uptr aligned_addr = addr & ~(__WORDSIZE/8 - 1); // align addr.
- uint8_t *shadow_ptr = (uint8_t*)MemToShadow(aligned_addr);
- uint8_t *shadow_bottom = (uint8_t*)MemToShadow(bottom);
+ u8 *shadow_ptr = (u8*)MemToShadow(aligned_addr);
+ u8 *shadow_bottom = (u8*)MemToShadow(bottom);
while (shadow_ptr >= shadow_bottom &&
*shadow_ptr != kAsanStackLeftRedzoneMagic) {
Modified: compiler-rt/trunk/lib/asan/asan_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_win.cc?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_win.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_win.cc Thu May 31 10:02:07 2012
@@ -234,7 +234,7 @@
return InterlockedExchangeAdd((LONG*)a, 1) + 1;
}
-uint16_t AtomicExchange(uint16_t *a, uint16_t new_val) {
+u16 AtomicExchange(u16 *a, u16 new_val) {
// InterlockedExchange16 seems unavailable on some MSVS installations.
// Everybody stand back, I pretend to know inline assembly!
// FIXME: I assume VC is smart enough to save/restore eax/ecx?
Modified: compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc Thu May 31 10:02:07 2012
@@ -27,11 +27,11 @@
// Simple stand-alone pseudorandom number generator.
// Current algorithm is ANSI C linear congruential PRNG.
-static inline uint32_t my_rand(uint32_t* state) {
+static inline u32 my_rand(u32* state) {
return (*state = *state * 1103515245 + 12345) >> 16;
}
-static uint32_t global_seed = 0;
+static u32 global_seed = 0;
TEST(AddressSanitizer, InternalSimpleDeathTest) {
@@ -39,7 +39,7 @@
}
static void MallocStress(size_t n) {
- uint32_t seed = my_rand(&global_seed);
+ u32 seed = my_rand(&global_seed);
__asan::AsanStackTrace stack1;
stack1.trace[0] = 0xa123;
stack1.trace[1] = 0xa456;
@@ -95,13 +95,13 @@
static void PrintShadow(const char *tag, uptr ptr, size_t size) {
fprintf(stderr, "%s shadow: %lx size % 3ld: ", tag, (long)ptr, (long)size);
uptr prev_shadow = 0;
- for (intptr_t i = -32; i < (intptr_t)size + 32; i++) {
+ for (sptr i = -32; i < (sptr)size + 32; i++) {
uptr shadow = __asan::MemToShadow(ptr + i);
- if (i == 0 || i == (intptr_t)size)
+ if (i == 0 || i == (sptr)size)
fprintf(stderr, ".");
if (shadow != prev_shadow) {
prev_shadow = shadow;
- fprintf(stderr, "%02x", (int)*(uint8_t*)shadow);
+ fprintf(stderr, "%02x", (int)*(u8*)shadow);
}
}
fprintf(stderr, "\n");
@@ -207,9 +207,9 @@
};
void CompressStackTraceTest(size_t n_iter) {
- uint32_t seed = my_rand(&global_seed);
+ u32 seed = my_rand(&global_seed);
const size_t kNumPcs = ASAN_ARRAY_SIZE(pc_array);
- uint32_t compressed[2 * kNumPcs];
+ u32 compressed[2 * kNumPcs];
for (size_t iter = 0; iter < n_iter; iter++) {
std::random_shuffle(pc_array, pc_array + kNumPcs);
@@ -235,7 +235,7 @@
void CompressStackTraceBenchmark(size_t n_iter) {
const size_t kNumPcs = ASAN_ARRAY_SIZE(pc_array);
- uint32_t compressed[2 * kNumPcs];
+ u32 compressed[2 * kNumPcs];
std::random_shuffle(pc_array, pc_array + kNumPcs);
__asan::AsanStackTrace stack0;
@@ -274,7 +274,7 @@
}
void *ThreadedQuarantineTestWorker(void *unused) {
- uint32_t seed = my_rand(&global_seed);
+ u32 seed = my_rand(&global_seed);
__asan::AsanStackTrace stack;
stack.trace[0] = 0x890;
stack.size = 1;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_defs.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_defs.h?rev=157747&r1=157746&r2=157747&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_defs.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_defs.h Thu May 31 10:02:07 2012
@@ -28,7 +28,15 @@
// For portability reasons we do not include stddef.h, stdint.h or any other
// system header, but we do need some basic types that are not defined
// in a portable way by the language itself.
-typedef unsigned long uptr; // Unsigned integer of the same size as a pointer.
-// FIXME: add u64, u32, etc.
+typedef unsigned long uptr;
+typedef signed long sptr;
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned int u32;
+typedef unsigned long long u64;
+typedef signed char s8;
+typedef signed short s16;
+typedef signed int s32;
+typedef signed long long s64;
#endif // SANITIZER_DEFS_H
More information about the llvm-commits
mailing list