summaryrefslogtreecommitdiff
path: root/lib/lsan/lsan_allocator.cc
diff options
context:
space:
mode:
authorAlex Shlyapnikov <alekseys@google.com>2018-03-12 21:59:06 +0000
committerAlex Shlyapnikov <alekseys@google.com>2018-03-12 21:59:06 +0000
commit4c895bfe35adea9996ffe603d7ca215fb7e6d1ef (patch)
tree2e153cf78b4d9f5c59f751d4cb617069cf9ca9be /lib/lsan/lsan_allocator.cc
parent39ded27815df4a8cb76ad0b55461111ab35378e6 (diff)
[Sanitizers] Add more standard compliant posix_memalign implementation for LSan.
Summary: Add more standard compliant posix_memalign implementation for LSan and use corresponding sanitizer's posix_memalign implenetations in allocation wrappers on Mac. Reviewers: eugenis, fjricci Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D44335 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@327338 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/lsan/lsan_allocator.cc')
-rw-r--r--lib/lsan/lsan_allocator.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/lsan/lsan_allocator.cc b/lib/lsan/lsan_allocator.cc
index f5e4b5803..85721c431 100644
--- a/lib/lsan/lsan_allocator.cc
+++ b/lib/lsan/lsan_allocator.cc
@@ -128,6 +128,21 @@ uptr GetMallocUsableSize(const void *p) {
return m->requested_size;
}
+int lsan_posix_memalign(void **memptr, uptr alignment, uptr size,
+ const StackTrace &stack) {
+ if (UNLIKELY(!CheckPosixMemalignAlignment(alignment))) {
+ ReturnNullOrDieOnFailure::OnBadRequest();
+ return errno_EINVAL;
+ }
+ void *ptr = Allocate(stack, size, alignment, kAlwaysClearMemory);
+ if (UNLIKELY(!ptr))
+ // OOM error is already taken care of by Allocate.
+ return errno_ENOMEM;
+ CHECK(IsAligned((uptr)ptr, alignment));
+ *memptr = ptr;
+ return 0;
+}
+
void *lsan_memalign(uptr alignment, uptr size, const StackTrace &stack) {
if (UNLIKELY(!IsPowerOfTwo(alignment))) {
errno = errno_EINVAL;