Merge changes from topics "musl_execinfo", "musl_mallinfo", "musl_sysroot"
* changes:
Disable fortify tests for musl
Export kernel uapi, execinfo and b64 headers to musl sysroot
Export bionic's resolv base64 functions to musl
Export bionic's execinfo functions to musl
Enable mallinfo tests for musl
Fix bionic benchmarks and header tests for musl
diff --git a/libc/arch-arm/bionic/kuser_helper_on.S b/libc/arch-arm/bionic/kuser_helper_on.S
index 2a1d86d..08291f7 100644
--- a/libc/arch-arm/bionic/kuser_helper_on.S
+++ b/libc/arch-arm/bionic/kuser_helper_on.S
@@ -32,10 +32,10 @@
.balign 4
.type kuser_helper_on, %object
kuser_helper_on:
- .long 2f-1f // int32_t namesz
- .long 3f-2f // int32_t descsz
- .long NT_TYPE_KUSER // int32_t type
-1:.ascii "Android\0" // char name[]
-2:.long 1 // int32_t on
+ .long 2f-1f // int32_t namesz
+ .long 3f-2f // int32_t descsz
+ .long NT_ANDROID_TYPE_KUSER // int32_t type
+1:.ascii "Android\0" // char name[]
+2:.long 1 // int32_t on
3:
.size kuser_helper_on, .-kuser_helper_on
diff --git a/libc/arch-arm64/bionic/note_memtag_heap_async.S b/libc/arch-arm64/bionic/note_memtag_heap_async.S
index 208115c..931f40b 100644
--- a/libc/arch-arm64/bionic/note_memtag_heap_async.S
+++ b/libc/arch-arm64/bionic/note_memtag_heap_async.S
@@ -33,11 +33,11 @@
.section ".note.android.memtag", "a", %note
.p2align 2
- .long 1f - 0f // int32_t namesz
- .long 3f - 2f // int32_t descsz
- .long NT_TYPE_MEMTAG // int32_t type
+ .long 1f - 0f // int32_t namesz
+ .long 3f - 2f // int32_t descsz
+ .long NT_ANDROID_TYPE_MEMTAG // int32_t type
0:
- .asciz "Android" // char name[]
+ .asciz "Android" // char name[]
1:
.p2align 2
2:
diff --git a/libc/arch-arm64/bionic/note_memtag_heap_sync.S b/libc/arch-arm64/bionic/note_memtag_heap_sync.S
index d71ad02..77ab03a 100644
--- a/libc/arch-arm64/bionic/note_memtag_heap_sync.S
+++ b/libc/arch-arm64/bionic/note_memtag_heap_sync.S
@@ -33,11 +33,11 @@
.section ".note.android.memtag", "a", %note
.p2align 2
- .long 1f - 0f // int32_t namesz
- .long 3f - 2f // int32_t descsz
- .long NT_TYPE_MEMTAG // int32_t type
+ .long 1f - 0f // int32_t namesz
+ .long 3f - 2f // int32_t descsz
+ .long NT_ANDROID_TYPE_MEMTAG // int32_t type
0:
- .asciz "Android" // char name[]
+ .asciz "Android" // char name[]
1:
.p2align 2
2:
diff --git a/libc/arch-common/bionic/crtbrand.S b/libc/arch-common/bionic/crtbrand.S
index 307ef2e..b7540e9 100644
--- a/libc/arch-common/bionic/crtbrand.S
+++ b/libc/arch-common/bionic/crtbrand.S
@@ -40,7 +40,7 @@
abitag:
.long 2f-1f // int32_t namesz
.long 3f-2f // int32_t descsz
- .long NT_TYPE_IDENT // int32_t type
+ .long NT_ANDROID_TYPE_IDENT // int32_t type
#ifdef __ANDROID__
1:.ascii "Android\0" // char name[]
2:.long PLATFORM_SDK_VERSION // int32_t android_api
diff --git a/libc/bionic/libc_init_static.cpp b/libc/bionic/libc_init_static.cpp
index 67e692c..ef2e56a 100644
--- a/libc/bionic/libc_init_static.cpp
+++ b/libc/bionic/libc_init_static.cpp
@@ -194,7 +194,7 @@
if (note->n_namesz != 8 || strncmp(name, "Android", 8) != 0) {
return false;
}
- if (note->n_type != NT_TYPE_MEMTAG) {
+ if (note->n_type != NT_ANDROID_TYPE_MEMTAG) {
return false;
}
if (note->n_descsz != 4) {
diff --git a/libc/include/bits/fortify/stdio.h b/libc/include/bits/fortify/stdio.h
index 42698dd..77bdbb4 100644
--- a/libc/include/bits/fortify/stdio.h
+++ b/libc/include/bits/fortify/stdio.h
@@ -40,6 +40,7 @@
/* No diag -- clang diagnoses misuses of this on its own. */
__BIONIC_FORTIFY_INLINE __printflike(3, 0)
int vsnprintf(char* const __pass_object_size dest, size_t size, const char* format, va_list ap)
+ __diagnose_as_builtin(__builtin_vsnprintf, 1, 2, 3, 4)
__overloadable {
return __builtin___vsnprintf_chk(dest, size, 0, __bos(dest), format, ap);
}
@@ -70,6 +71,7 @@
/* No diag -- clang diagnoses misuses of this on its own. */
__BIONIC_FORTIFY_VARIADIC __printflike(3, 4)
int snprintf(char* const __pass_object_size dest, size_t size, const char* format, ...)
+ __diagnose_as_builtin(__builtin_snprintf, 1, 2, 3)
__overloadable {
va_list va;
va_start(va, format);
diff --git a/libc/include/bits/fortify/string.h b/libc/include/bits/fortify/string.h
index beb5ff5..08bce2d 100644
--- a/libc/include/bits/fortify/string.h
+++ b/libc/include/bits/fortify/string.h
@@ -44,13 +44,16 @@
/* No diag -- clang diagnoses misuses of this on its own. */
__BIONIC_FORTIFY_INLINE
void* memcpy(void* const dst __pass_object_size0, const void* src, size_t copy_amount)
+ __diagnose_as_builtin(__builtin_memcpy, 1, 2, 3)
__overloadable {
return __builtin___memcpy_chk(dst, src, copy_amount, __bos0(dst));
}
/* No diag -- clang diagnoses misuses of this on its own. */
__BIONIC_FORTIFY_INLINE
-void* memmove(void* const dst __pass_object_size0, const void* src, size_t len) __overloadable {
+void* memmove(void* const dst __pass_object_size0, const void* src, size_t len)
+ __diagnose_as_builtin(__builtin_memmove, 1, 2, 3)
+ __overloadable {
return __builtin___memmove_chk(dst, src, len, __bos0(dst));
}
#endif
@@ -59,6 +62,7 @@
#if __ANDROID_API__ >= 30
__BIONIC_FORTIFY_INLINE
void* mempcpy(void* const dst __pass_object_size0, const void* src, size_t copy_amount)
+ __diagnose_as_builtin(__builtin_mempcpy, 1, 2, 3)
__overloadable
__clang_error_if(__bos_unevaluated_lt(__bos0(dst), copy_amount),
"'mempcpy' called with size bigger than buffer") {
@@ -87,6 +91,7 @@
__BIONIC_FORTIFY_INLINE
char* strcpy(char* const dst __pass_object_size, const char* src)
+ __diagnose_as_builtin(__builtin_strcpy, 1, 2)
__overloadable
__clang_error_if(__bos_unevaluated_le(__bos(dst), __builtin_strlen(src)),
"'strcpy' called with string bigger than buffer") {
@@ -112,7 +117,9 @@
#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
/* No diag -- clang diagnoses misuses of this on its own. */
__BIONIC_FORTIFY_INLINE
-char* strncat(char* const dst __pass_object_size, const char* src, size_t n) __overloadable {
+char* strncat(char* const dst __pass_object_size, const char* src, size_t n)
+ __diagnose_as_builtin(__builtin_strncat, 1, 2, 3)
+ __overloadable {
return __builtin___strncat_chk(dst, src, n, __bos(dst));
}
#endif
@@ -120,6 +127,7 @@
/* No diag -- clang diagnoses misuses of this on its own. */
__BIONIC_FORTIFY_INLINE
void* memset(void* const s __pass_object_size0, int c, size_t n) __overloadable
+ __diagnose_as_builtin(__builtin_memset, 1, 2, 3)
/* If you're a user who wants this warning to go away: use `(&memset)(foo, bar, baz)`. */
__clang_warning_if(c && !n, "'memset' will set 0 bytes; maybe the arguments got flipped?") {
#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
@@ -157,6 +165,7 @@
/* No diag -- clang diagnoses misuses of this on its own. */
__BIONIC_FORTIFY_INLINE
char* stpncpy(char* const dst __pass_object_size, const char* const src __pass_object_size, size_t n)
+ __diagnose_as_builtin(__builtin_stpncpy, 1, 2, 3)
__overloadable {
size_t bos_dst = __bos(dst);
size_t bos_src = __bos(src);
@@ -172,6 +181,7 @@
/* No diag -- clang diagnoses misuses of this on its own. */
__BIONIC_FORTIFY_INLINE
char* strncpy(char* const dst __pass_object_size, const char* const src __pass_object_size, size_t n)
+ __diagnose_as_builtin(__builtin_strncpy, 1, 2, 3)
__overloadable {
size_t bos_dst = __bos(dst);
size_t bos_src = __bos(src);
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index 2556d11..99a200a 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -327,6 +327,13 @@
#define __overloadable __attribute__((overloadable))
+// TODO(pirama) Remove this version check after switching to clang-r445002
+#if __clang_major__ == 14 && __clang_patchlevel__ >= 2
+#define __diagnose_as_builtin(...) __attribute__((diagnose_as_builtin(__VA_ARGS__)))
+#else
+#define __diagnose_as_builtin(...)
+#endif
+
/* Used to tag non-static symbols that are private and never exposed by the shared library. */
#define __LIBC_HIDDEN__ __attribute__((visibility("hidden")))
diff --git a/libc/malloc_debug/UnwindBacktrace.cpp b/libc/malloc_debug/UnwindBacktrace.cpp
index dbaebb3..a7036d9 100644
--- a/libc/malloc_debug/UnwindBacktrace.cpp
+++ b/libc/malloc_debug/UnwindBacktrace.cpp
@@ -90,11 +90,13 @@
std::shared_ptr<unwindstack::MapInfo> map_info = info->map_info;
std::string line = android::base::StringPrintf(" #%0zd pc %" PAD_PTR " ", i, info->rel_pc);
- if (map_info->offset() != 0) {
+ if (map_info != nullptr && map_info->offset() != 0) {
line += android::base::StringPrintf("(offset 0x%" PRIx64 ") ", map_info->offset());
}
- if (map_info->name().empty()) {
+ if (map_info == nullptr) {
+ line += "<unknown>";
+ } else if (map_info->name().empty()) {
line += android::base::StringPrintf("<anonymous:%" PRIx64 ">", map_info->start());
} else {
line += map_info->name();
diff --git a/libc/private/bionic_asm_note.h b/libc/private/bionic_asm_note.h
index 80b8f01..d8559ff 100644
--- a/libc/private/bionic_asm_note.h
+++ b/libc/private/bionic_asm_note.h
@@ -28,6 +28,6 @@
#pragma once
-#define NT_TYPE_IDENT 1
-#define NT_TYPE_KUSER 3
-#define NT_TYPE_MEMTAG 4
+#define NT_ANDROID_TYPE_IDENT 1
+#define NT_ANDROID_TYPE_KUSER 3
+#define NT_ANDROID_TYPE_MEMTAG 4
diff --git a/linker/linked_list.h b/linker/linked_list.h
index b8a8f0e..2741008 100644
--- a/linker/linked_list.h
+++ b/linker/linked_list.h
@@ -79,76 +79,89 @@
typedef LinkedListIterator<T> iterator;
typedef T* value_type;
- LinkedList() : head_(nullptr), tail_(nullptr) {}
+ // Allocating the head/tail fields separately from the LinkedList struct saves memory in the
+ // Zygote (e.g. because adding an soinfo to a namespace doesn't dirty the page containing the
+ // soinfo).
+ struct LinkedListHeader {
+ LinkedListEntry<T>* head;
+ LinkedListEntry<T>* tail;
+ };
+
+ // The allocator returns a LinkedListEntry<T>* but we want to treat it as a LinkedListHeader
+ // struct instead.
+ static_assert(sizeof(LinkedListHeader) == sizeof(LinkedListEntry<T>));
+ static_assert(alignof(LinkedListHeader) == alignof(LinkedListEntry<T>));
+
+ constexpr LinkedList() : header_(nullptr) {}
~LinkedList() {
clear();
+ if (header_ != nullptr) {
+ Allocator::free(reinterpret_cast<LinkedListEntry<T>*>(header_));
+ }
}
LinkedList(LinkedList&& that) noexcept {
- this->head_ = that.head_;
- this->tail_ = that.tail_;
- that.head_ = that.tail_ = nullptr;
+ this->header_ = that.header_;
+ that.header_ = nullptr;
+ }
+
+ bool empty() const {
+ return header_ == nullptr || header_->head == nullptr;
}
void push_front(T* const element) {
+ alloc_header();
LinkedListEntry<T>* new_entry = Allocator::alloc();
- new_entry->next = head_;
+ new_entry->next = header_->head;
new_entry->element = element;
- head_ = new_entry;
- if (tail_ == nullptr) {
- tail_ = new_entry;
+ header_->head = new_entry;
+ if (header_->tail == nullptr) {
+ header_->tail = new_entry;
}
}
void push_back(T* const element) {
+ alloc_header();
LinkedListEntry<T>* new_entry = Allocator::alloc();
new_entry->next = nullptr;
new_entry->element = element;
- if (tail_ == nullptr) {
- tail_ = head_ = new_entry;
+ if (header_->tail == nullptr) {
+ header_->tail = header_->head = new_entry;
} else {
- tail_->next = new_entry;
- tail_ = new_entry;
+ header_->tail->next = new_entry;
+ header_->tail = new_entry;
}
}
T* pop_front() {
- if (head_ == nullptr) {
- return nullptr;
- }
+ if (empty()) return nullptr;
- LinkedListEntry<T>* entry = head_;
+ LinkedListEntry<T>* entry = header_->head;
T* element = entry->element;
- head_ = entry->next;
+ header_->head = entry->next;
Allocator::free(entry);
- if (head_ == nullptr) {
- tail_ = nullptr;
+ if (header_->head == nullptr) {
+ header_->tail = nullptr;
}
return element;
}
T* front() const {
- if (head_ == nullptr) {
- return nullptr;
- }
-
- return head_->element;
+ return empty() ? nullptr : header_->head->element;
}
void clear() {
- while (head_ != nullptr) {
- LinkedListEntry<T>* p = head_;
- head_ = head_->next;
+ if (empty()) return;
+
+ while (header_->head != nullptr) {
+ LinkedListEntry<T>* p = header_->head;
+ header_->head = header_->head->next;
Allocator::free(p);
}
- tail_ = nullptr;
- }
-
- bool empty() {
- return (head_ == nullptr);
+ header_->tail = nullptr;
}
template<typename F>
@@ -161,7 +174,7 @@
template<typename F>
bool visit(F action) const {
- for (LinkedListEntry<T>* e = head_; e != nullptr; e = e->next) {
+ for (LinkedListEntry<T>* e = head(); e != nullptr; e = e->next) {
if (!action(e->element)) {
return false;
}
@@ -171,17 +184,18 @@
template<typename F>
void remove_if(F predicate) {
- for (LinkedListEntry<T>* e = head_, *p = nullptr; e != nullptr;) {
+ if (empty()) return;
+ for (LinkedListEntry<T>* e = header_->head, *p = nullptr; e != nullptr;) {
if (predicate(e->element)) {
LinkedListEntry<T>* next = e->next;
if (p == nullptr) {
- head_ = next;
+ header_->head = next;
} else {
p->next = next;
}
- if (tail_ == e) {
- tail_ = p;
+ if (header_->tail == e) {
+ header_->tail = p;
}
Allocator::free(e);
@@ -202,7 +216,7 @@
template<typename F>
T* find_if(F predicate) const {
- for (LinkedListEntry<T>* e = head_; e != nullptr; e = e->next) {
+ for (LinkedListEntry<T>* e = head(); e != nullptr; e = e->next) {
if (predicate(e->element)) {
return e->element;
}
@@ -212,7 +226,7 @@
}
iterator begin() const {
- return iterator(head_);
+ return iterator(head());
}
iterator end() const {
@@ -220,7 +234,7 @@
}
iterator find(T* value) const {
- for (LinkedListEntry<T>* e = head_; e != nullptr; e = e->next) {
+ for (LinkedListEntry<T>* e = head(); e != nullptr; e = e->next) {
if (e->element == value) {
return iterator(e);
}
@@ -231,7 +245,7 @@
size_t copy_to_array(T* array[], size_t array_length) const {
size_t sz = 0;
- for (LinkedListEntry<T>* e = head_; sz < array_length && e != nullptr; e = e->next) {
+ for (LinkedListEntry<T>* e = head(); sz < array_length && e != nullptr; e = e->next) {
array[sz++] = e->element;
}
@@ -239,7 +253,7 @@
}
bool contains(const T* el) const {
- for (LinkedListEntry<T>* e = head_; e != nullptr; e = e->next) {
+ for (LinkedListEntry<T>* e = head(); e != nullptr; e = e->next) {
if (e->element == el) {
return true;
}
@@ -260,7 +274,17 @@
}
private:
- LinkedListEntry<T>* head_;
- LinkedListEntry<T>* tail_;
+ void alloc_header() {
+ if (header_ == nullptr) {
+ header_ = reinterpret_cast<LinkedListHeader*>(Allocator::alloc());
+ header_->head = header_->tail = nullptr;
+ }
+ }
+
+ LinkedListEntry<T>* head() const {
+ return header_ != nullptr ? header_->head : nullptr;
+ }
+
+ LinkedListHeader* header_;
DISALLOW_COPY_AND_ASSIGN(LinkedList);
};
diff --git a/linker/linker_block_allocator.cpp b/linker/linker_block_allocator.cpp
index 5b68b1d..60e5e1c 100644
--- a/linker/linker_block_allocator.cpp
+++ b/linker/linker_block_allocator.cpp
@@ -31,6 +31,7 @@
#include <inttypes.h>
#include <string.h>
#include <sys/mman.h>
+#include <sys/param.h>
#include <sys/prctl.h>
#include <unistd.h>
@@ -39,11 +40,6 @@
static constexpr size_t kAllocateSize = PAGE_SIZE * 100;
static_assert(kAllocateSize % PAGE_SIZE == 0, "Invalid kAllocateSize.");
-// the multiplier should be power of 2
-static constexpr size_t round_up(size_t size, size_t multiplier) {
- return (size + (multiplier - 1)) & ~(multiplier-1);
-}
-
struct LinkerBlockAllocatorPage {
LinkerBlockAllocatorPage* next;
uint8_t bytes[kAllocateSize - 16] __attribute__((aligned(16)));
@@ -54,13 +50,14 @@
size_t num_free_blocks;
};
+static_assert(kBlockSizeAlign >= alignof(FreeBlockInfo));
+static_assert(kBlockSizeMin == sizeof(FreeBlockInfo));
+
LinkerBlockAllocator::LinkerBlockAllocator(size_t block_size)
- : block_size_(
- round_up(block_size < sizeof(FreeBlockInfo) ? sizeof(FreeBlockInfo) : block_size, 16)),
- page_list_(nullptr),
- free_block_list_(nullptr),
- allocated_(0)
-{}
+ : block_size_(__BIONIC_ALIGN(MAX(block_size, kBlockSizeMin), kBlockSizeAlign)),
+ page_list_(nullptr),
+ free_block_list_(nullptr),
+ allocated_(0) {}
void* LinkerBlockAllocator::alloc() {
if (free_block_list_ == nullptr) {
diff --git a/linker/linker_block_allocator.h b/linker/linker_block_allocator.h
index 8ae4094..32656c7 100644
--- a/linker/linker_block_allocator.h
+++ b/linker/linker_block_allocator.h
@@ -33,6 +33,9 @@
#include <android-base/macros.h>
+static constexpr size_t kBlockSizeAlign = sizeof(void*);
+static constexpr size_t kBlockSizeMin = sizeof(void*) * 2;
+
struct LinkerBlockAllocatorPage;
/*
diff --git a/linker/linker_block_allocator_test.cpp b/linker/linker_block_allocator_test.cpp
index 6fb2b26..56fbee8 100644
--- a/linker/linker_block_allocator_test.cpp
+++ b/linker/linker_block_allocator_test.cpp
@@ -29,6 +29,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
+#include <sys/param.h>
#include <gtest/gtest.h>
@@ -44,12 +45,16 @@
};
/*
- * this one has size below allocator cap which is 2*sizeof(void*)
+ * this one has size below kBlockSizeAlign
*/
struct test_struct_small {
- char str[5];
+ char str[3];
};
+struct test_struct_max_align {
+ char str[16];
+} __attribute__((aligned(16)));
+
/*
* 1009 byte struct (1009 is prime)
*/
@@ -58,54 +63,49 @@
};
static size_t kPageSize = sysconf(_SC_PAGE_SIZE);
-};
-TEST(linker_allocator, test_nominal) {
- LinkerTypeAllocator<test_struct_nominal> allocator;
+template <typename Element>
+void linker_allocator_test_helper() {
+ LinkerTypeAllocator<Element> allocator;
- test_struct_nominal* ptr1 = allocator.alloc();
+ Element* ptr1 = allocator.alloc();
ASSERT_TRUE(ptr1 != nullptr);
- ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(ptr1) % 16);
- test_struct_nominal* ptr2 = allocator.alloc();
- ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(ptr2) % 16);
+ ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(ptr1) % kBlockSizeAlign);
+ ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(ptr1) % alignof(Element));
+ Element* ptr2 = allocator.alloc();
+ ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(ptr2) % kBlockSizeAlign);
+ ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(ptr2) % alignof(Element));
ASSERT_TRUE(ptr2 != nullptr);
- // they should be next to each other.
- ASSERT_EQ(reinterpret_cast<uint8_t*>(ptr1)+16, reinterpret_cast<uint8_t*>(ptr2));
- ptr1->value = 42;
+ // they should be next to each other.
+ size_t dist = __BIONIC_ALIGN(MAX(sizeof(Element), kBlockSizeMin), kBlockSizeAlign);
+ ASSERT_EQ(reinterpret_cast<uint8_t*>(ptr1) + dist, reinterpret_cast<uint8_t*>(ptr2));
allocator.free(ptr1);
allocator.free(ptr2);
}
+}; // anonymous namespace
+
+TEST(linker_allocator, test_nominal) {
+ linker_allocator_test_helper<test_struct_nominal>();
+}
+
TEST(linker_allocator, test_small) {
- LinkerTypeAllocator<test_struct_small> allocator;
+ linker_allocator_test_helper<test_struct_small>();
+}
- char* ptr1 = reinterpret_cast<char*>(allocator.alloc());
- char* ptr2 = reinterpret_cast<char*>(allocator.alloc());
-
- ASSERT_TRUE(ptr1 != nullptr);
- ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(ptr1) % 16);
- ASSERT_TRUE(ptr2 != nullptr);
- ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(ptr2) % 16);
- ASSERT_EQ(ptr1+16, ptr2); // aligned to 16
+TEST(linker_allocator, test_max_align) {
+ linker_allocator_test_helper<test_struct_max_align>();
}
TEST(linker_allocator, test_larger) {
+ linker_allocator_test_helper<test_struct_larger>();
+
LinkerTypeAllocator<test_struct_larger> allocator;
- test_struct_larger* ptr1 = allocator.alloc();
- test_struct_larger* ptr2 = allocator.alloc();
-
- ASSERT_TRUE(ptr1 != nullptr);
- ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(ptr1) % 16);
- ASSERT_TRUE(ptr2 != nullptr);
- ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(ptr2) % 16);
-
- ASSERT_EQ(reinterpret_cast<uint8_t*>(ptr1) + 1024, reinterpret_cast<uint8_t*>(ptr2));
-
// lets allocate until we reach next page.
- size_t n = kPageSize/sizeof(test_struct_larger) + 1 - 2;
+ size_t n = kPageSize / sizeof(test_struct_larger) + 1;
for (size_t i=0; i<n; ++i) {
ASSERT_TRUE(allocator.alloc() != nullptr);
@@ -113,7 +113,6 @@
test_struct_larger* ptr_to_free = allocator.alloc();
ASSERT_TRUE(ptr_to_free != nullptr);
- allocator.free(ptr1);
}
static void protect_all() {