mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 04:02:27 +00:00
feat(heap): Update component to latest TLSF
The new TLSF architecture has changed. tlsf.h public API header is now moved into an include folder. tlsf_common.h is removed from the repo. This commit updates the heap component and respective esp_rom patches to take into account this new architecture.
This commit is contained in:
@@ -13,7 +13,7 @@ SOURCE_FILES = $(abspath \
|
||||
main.cpp \
|
||||
)
|
||||
|
||||
INCLUDE_FLAGS = -I../include -I../../../tools/catch -I../tlsf
|
||||
INCLUDE_FLAGS = -I../include -I../../../tools/catch -I../tlsf -I../tlsf/include
|
||||
|
||||
GCOV ?= gcov
|
||||
|
||||
|
@@ -8,9 +8,9 @@
|
||||
#include "multi_heap.h"
|
||||
|
||||
#include "../multi_heap_config.h"
|
||||
#include "../tlsf/tlsf.h"
|
||||
#include "../tlsf/tlsf_common.h"
|
||||
#include "../tlsf/include/tlsf.h"
|
||||
#include "../tlsf/tlsf_block_functions.h"
|
||||
#include "../tlsf/tlsf_control_functions.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
@@ -19,7 +19,7 @@
|
||||
* malloc and free and allocate memory from the host heap. Since the test
|
||||
* `TEST_CASE("multi_heap many random allocations", "[multi_heap]")`
|
||||
* calls multi_heap_allocation_impl() with sizes that can go up to 8MB,
|
||||
* an allocatation on the heap will be prefered rather than the stack which
|
||||
* an allocatation on the heap will be preferred rather than the stack which
|
||||
* might not have the necessary memory.
|
||||
*/
|
||||
static void *__malloc__(size_t bytes)
|
||||
@@ -62,7 +62,7 @@ TEST_CASE("multi_heap simple allocations", "[multi_heap]")
|
||||
REQUIRE( (intptr_t)buf < (intptr_t)(small_heap + sizeof(small_heap)));
|
||||
|
||||
REQUIRE( multi_heap_get_allocated_size(heap, buf) >= test_alloc_size );
|
||||
REQUIRE( multi_heap_get_allocated_size(heap, buf) < test_alloc_size + 16);
|
||||
printf("test alloc size %d\n", test_alloc_size);
|
||||
|
||||
memset(buf, 0xEE, test_alloc_size);
|
||||
|
||||
@@ -482,7 +482,7 @@ TEST_CASE("multi_heap aligned allocations", "[multi_heap]")
|
||||
{
|
||||
uint8_t test_heap[4 * 1024];
|
||||
multi_heap_handle_t heap = multi_heap_register(test_heap, sizeof(test_heap));
|
||||
uint32_t aligments = 0; // starts from alignment by 4-byte boundary
|
||||
uint32_t alignments = 0; // starts from alignment by 4-byte boundary
|
||||
size_t old_size = multi_heap_free_size(heap);
|
||||
size_t leakage = 1024;
|
||||
printf("[ALIGNED_ALLOC] heap_size before: %d \n", old_size);
|
||||
@@ -491,26 +491,26 @@ TEST_CASE("multi_heap aligned allocations", "[multi_heap]")
|
||||
multi_heap_dump(heap);
|
||||
printf("*********************\n");
|
||||
|
||||
for(;aligments <= 256; aligments++) {
|
||||
for(;alignments <= 256; alignments++) {
|
||||
|
||||
//Use some stupid size value to test correct alignment even in strange
|
||||
//memory layout objects:
|
||||
uint8_t *buf = (uint8_t *)multi_heap_aligned_alloc(heap, (aligments + 137), aligments );
|
||||
if(((aligments & (aligments - 1)) != 0) || (!aligments)) {
|
||||
uint8_t *buf = (uint8_t *)multi_heap_aligned_alloc(heap, (alignments + 137), alignments );
|
||||
if(((alignments & (alignments - 1)) != 0) || (!alignments)) {
|
||||
REQUIRE( buf == NULL );
|
||||
} else {
|
||||
REQUIRE( buf != NULL );
|
||||
REQUIRE((intptr_t)buf >= (intptr_t)test_heap);
|
||||
REQUIRE((intptr_t)buf < (intptr_t)(test_heap + sizeof(test_heap)));
|
||||
|
||||
printf("[ALIGNED_ALLOC] alignment required: %u \n", aligments);
|
||||
printf("[ALIGNED_ALLOC] alignment required: %u \n", alignments);
|
||||
printf("[ALIGNED_ALLOC] address of allocated memory: %p \n\n", (void *)buf);
|
||||
//Address of obtained block must be aligned with selected value
|
||||
REQUIRE(((intptr_t)buf & (aligments - 1)) == 0);
|
||||
REQUIRE(((intptr_t)buf & (alignments - 1)) == 0);
|
||||
|
||||
//Write some data, if it corrupts memory probably the heap
|
||||
//canary verification will fail:
|
||||
memset(buf, 0xA5, (aligments + 137));
|
||||
memset(buf, 0xA5, (alignments + 137));
|
||||
|
||||
multi_heap_free(heap, buf);
|
||||
}
|
||||
@@ -519,7 +519,7 @@ TEST_CASE("multi_heap aligned allocations", "[multi_heap]")
|
||||
/* Check that TLSF doesn't allocate a memory space smaller than required.
|
||||
* In any case, TLSF will write data in the previous block than the one
|
||||
* allocated. Thus, we should try to get/allocate this previous block. If
|
||||
* the poisoned filled pattern has beeen overwritten by TLSF, then this
|
||||
* the poisoned filled pattern has been overwritten by TLSF, then this
|
||||
* previous block will trigger an exception.
|
||||
* More info on this bug in !16296. */
|
||||
const size_t size = 50; /* TLSF will round the size up */
|
||||
|
Reference in New Issue
Block a user