diff options
author | Christopher Ferris <cferris@google.com> | 2016-02-11 15:51:31 -0800 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2016-02-12 17:30:30 -0800 |
commit | 72df6708c829a4c6494936fdfbda6dc7e68e647b (patch) | |
tree | 17ede0d54b6f50c3598a3fcec56f50754067690d /libc/malloc_debug/tests/malloc_debug_unit_tests.cpp | |
parent | 72bca4b4105e24058f3f2eca024382bedb122a30 (diff) |
Fix the default alignment of the allocations.
In order to enforce this constraint:
The pointer returned if the allocation succeeds shall be suitably
aligned so that it may be assigned to a pointer to any type of object
and then used to access such an object in the space allocated.
Force all allocations on 32 bit systems to have 8 byte alignment,
and all allocations on 64 bit systems to have 16 byte alignment.
Add a test to verify that the allocator returns the correct alignments.
Bug: 26739265
Change-Id: I9af53279617408676b94e4ec6481b3ed7ffafc6a
Diffstat (limited to 'libc/malloc_debug/tests/malloc_debug_unit_tests.cpp')
-rw-r--r-- | libc/malloc_debug/tests/malloc_debug_unit_tests.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp index 9fc8a5788..b316e8a40 100644 --- a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp +++ b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp @@ -34,6 +34,7 @@ #include <private/bionic_macros.h> #include <private/bionic_malloc_dispatch.h> +#include "Config.h" #include "malloc_debug.h" #include "log_fake.h" @@ -70,9 +71,9 @@ constexpr char DIVIDER[] = constexpr uint32_t BACKTRACE_HEADER = 0x1; static size_t get_tag_offset(uint32_t flags = 0, size_t backtrace_frames = 0) { - size_t offset = BIONIC_ALIGN(sizeof(Header), sizeof(uintptr_t)); + size_t offset = BIONIC_ALIGN(sizeof(Header), MINIMUM_ALIGNMENT_BYTES); if (flags & BACKTRACE_HEADER) { - offset += BIONIC_ALIGN(sizeof(BacktraceHeader) + sizeof(uintptr_t) * backtrace_frames, sizeof(uintptr_t)); + offset += BIONIC_ALIGN(sizeof(BacktraceHeader) + sizeof(uintptr_t) * backtrace_frames, MINIMUM_ALIGNMENT_BYTES); } return offset; } |