summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2016-07-20 11:43:52 +0000
committerDmitry Vyukov <dvyukov@google.com>2016-07-20 11:43:52 +0000
commitbbed03ee9bd169a8f69986830deebe0fda8a35af (patch)
tree7f769e671e8f831555535d10723ac43a39d1a4f6
parentb4d64cf27d1dc9431bd75d69631850ef79531166 (diff)
downloadbcm5719-llvm-bbed03ee9bd169a8f69986830deebe0fda8a35af.tar.gz
bcm5719-llvm-bbed03ee9bd169a8f69986830deebe0fda8a35af.zip
tsan: fix windows build
Currently fails as: gotsan.cc: In function 'void* __sanitizer::__libc_memalign(__sanitizer::uptr, __sanitizer::uptr)': gotsan.cc:6194:50: error: 'posix_memalign' was not declared in this scope uptr error = posix_memalign(&p, alignment, size); Windows does not provide posix_memalign. llvm-svn: 276107
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc
index df298c62271..2b5d192502f 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc
@@ -22,18 +22,22 @@ namespace __sanitizer {
#if defined(SANITIZER_GO) || defined(SANITIZER_USE_MALLOC)
# if SANITIZER_LINUX && !SANITIZER_ANDROID
extern "C" void *__libc_malloc(uptr size);
+# ifndef SANITIZER_GO
extern "C" void *__libc_memalign(uptr alignment, uptr size);
+# endif
extern "C" void *__libc_realloc(void *ptr, uptr size);
extern "C" void __libc_free(void *ptr);
# else
# include <stdlib.h>
# define __libc_malloc malloc
+# ifndef SANITIZER_GO
static void *__libc_memalign(uptr alignment, uptr size) {
void *p;
uptr error = posix_memalign(&p, alignment, size);
if (error) return nullptr;
return p;
}
+# endif
# define __libc_realloc realloc
# define __libc_free free
# endif
@@ -41,10 +45,20 @@ static void *__libc_memalign(uptr alignment, uptr size) {
static void *RawInternalAlloc(uptr size, InternalAllocatorCache *cache,
uptr alignment) {
(void)cache;
+#ifndef SANITIZER_GO
if (alignment == 0)
return __libc_malloc(size);
else
return __libc_memalign(alignment, size);
+#else
+ // Windows does not provide __libc_memalign/posix_memalign. It provides
+ // __aligned_malloc, but the allocated blocks can't be passed to free,
+ // they need to be passed to __aligned_free. InternalAlloc interface does
+ // not account for such requirement. Alignemnt does not seem to be used
+ // anywhere in runtime, so just call __libc_malloc for now.
+ DCHECK_EQ(alignment, 0);
+ return __libc_malloc(size);
+#endif
}
static void *RawInternalRealloc(void *ptr, uptr size,
OpenPOWER on IntegriCloud