[llvm-commits] [compiler-rt] r160503 - in /compiler-rt/trunk/lib/sanitizer_common: sanitizer_allocator64.h tests/sanitizer_allocator64_testlib.cc
Kostya Serebryany
kcc at google.com
Thu Jul 19 05:15:33 PDT 2012
Author: kcc
Date: Thu Jul 19 07:15:33 2012
New Revision: 160503
URL: http://llvm.org/viewvc/llvm-project?rev=160503&view=rev
Log:
[tsan] minor fixes in tsan allocator and its testlib. Now runs fine with chrome
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator64.h
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator64_testlib.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator64.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator64.h?rev=160503&r1=160502&r2=160503&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator64.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator64.h Thu Jul 19 07:15:33 2012
@@ -408,8 +408,8 @@
void *Allocate(AllocatorCache *cache, uptr size, uptr alignment,
bool cleared = false) {
- if (size == 0) return 0;
- CHECK_GT(size, 0);
+ // Returning 0 on malloc(0) may break a lot of code.
+ if (size == 0) size = 1;
if (alignment > 8)
size = RoundUpTo(size, alignment);
void *res;
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator64_testlib.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator64_testlib.cc?rev=160503&r1=160502&r2=160503&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator64_testlib.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator64_testlib.cc Thu Jul 19 07:15:33 2012
@@ -57,6 +57,7 @@
#if 1
extern "C" {
void *malloc(size_t size) {
+ Init();
assert(inited);
return allocator.Allocate(&cache, size, 8);
}
@@ -77,8 +78,23 @@
}
void *memalign() { assert(0); }
-int posix_memalign() { assert(0); }
-void *valloc() { assert(0); }
-void *pvalloc() { assert(0); }
+
+int posix_memalign(void **memptr, size_t alignment, size_t size) {
+ *memptr = allocator.Allocate(&cache, size, alignment);
+ CHECK(((uptr)*memptr & (alignment - 1)) == 0);
+ return 0;
+}
+
+void *valloc(size_t size) {
+ assert(inited);
+ return allocator.Allocate(&cache, size, kPageSize);
+}
+
+void *pvalloc(size_t size) {
+ assert(inited);
+ if (size == 0) size = kPageSize;
+ return allocator.Allocate(&cache, size, kPageSize);
+}
+
}
#endif
More information about the llvm-commits
mailing list