mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-16 10:03:50 +01:00
191 lines
8.0 KiB
Diff
191 lines
8.0 KiB
Diff
From 6a80d252810469dd3c6e0bbd4f27de02c90cb12e Mon Sep 17 00:00:00 2001
|
|
From: Gunar Schorcht <gunar@schorcht.net>
|
|
Date: Tue, 11 Mar 2025 02:01:29 +0100
|
|
Subject: [PATCH 28/28] heap: add prefix esp_ to tlsf to avoid conflicts with
|
|
tlsf package
|
|
|
|
---
|
|
components/heap/multi_heap.c | 58 ++++++++++++++++++------------------
|
|
1 file changed, 29 insertions(+), 29 deletions(-)
|
|
|
|
diff --git a/components/heap/multi_heap.c b/components/heap/multi_heap.c
|
|
index d47a6c0a3a..78fc411b74 100644
|
|
--- a/components/heap/multi_heap.c
|
|
+++ b/components/heap/multi_heap.c
|
|
@@ -15,8 +15,8 @@
|
|
#include "multi_heap.h"
|
|
#include "multi_heap_internal.h"
|
|
|
|
-#include "tlsf.h"
|
|
-#include "tlsf_block_functions.h"
|
|
+#include "esp_tlsf.h"
|
|
+#include "esp_tlsf_block_functions.h"
|
|
|
|
/* Note: Keep platform-specific parts in this header, this source
|
|
file should depend on libc only */
|
|
@@ -110,7 +110,7 @@ void multi_heap_in_rom_init(void)
|
|
/* Check a block is valid for this heap. Used to verify parameters. */
|
|
__attribute__((noinline)) NOCLONE_ATTR static void assert_valid_block(const heap_t *heap, const multi_heap_block_handle_t block)
|
|
{
|
|
- pool_t pool = tlsf_get_pool(heap->heap_data);
|
|
+ pool_t pool = esp_tlsf_get_pool(heap->heap_data);
|
|
void *ptr = block_to_ptr(block);
|
|
|
|
MULTI_HEAP_ASSERT((ptr >= pool) &&
|
|
@@ -125,7 +125,7 @@ void *multi_heap_get_block_address_impl(multi_heap_block_handle_t block)
|
|
|
|
size_t multi_heap_get_allocated_size_impl(multi_heap_handle_t heap, void *p)
|
|
{
|
|
- return tlsf_block_size(p);
|
|
+ return esp_tlsf_block_size(p);
|
|
}
|
|
|
|
multi_heap_handle_t multi_heap_register_impl(void *start_ptr, size_t size)
|
|
@@ -142,13 +142,13 @@ multi_heap_handle_t multi_heap_register_impl(void *start_ptr, size_t size)
|
|
/* Do not specify any maximum size for the allocations so that the default configuration is used */
|
|
const size_t max_bytes = 0;
|
|
|
|
- result->heap_data = tlsf_create_with_pool(start_ptr + sizeof(heap_t), size, max_bytes);
|
|
+ result->heap_data = esp_tlsf_create_with_pool(start_ptr + sizeof(heap_t), size, max_bytes);
|
|
if(!result->heap_data) {
|
|
return NULL;
|
|
}
|
|
|
|
result->lock = NULL;
|
|
- result->free_bytes = size - tlsf_size(result->heap_data);
|
|
+ result->free_bytes = size - esp_tlsf_size(result->heap_data);
|
|
result->pool_size = size;
|
|
result->minimum_free_bytes = result->free_bytes;
|
|
return result;
|
|
@@ -172,7 +172,7 @@ void multi_heap_internal_unlock(multi_heap_handle_t heap)
|
|
multi_heap_block_handle_t multi_heap_get_first_block(multi_heap_handle_t heap)
|
|
{
|
|
assert(heap != NULL);
|
|
- pool_t pool = tlsf_get_pool(heap->heap_data);
|
|
+ pool_t pool = esp_tlsf_get_pool(heap->heap_data);
|
|
multi_heap_block_handle_t block = offset_to_block(pool, -(int)block_header_overhead);
|
|
|
|
return block;
|
|
@@ -206,10 +206,10 @@ void *multi_heap_malloc_impl(multi_heap_handle_t heap, size_t size)
|
|
|
|
|
|
multi_heap_internal_lock(heap);
|
|
- void *result = tlsf_malloc(heap->heap_data, size);
|
|
+ void *result = esp_tlsf_malloc(heap->heap_data, size);
|
|
if(result) {
|
|
- heap->free_bytes -= tlsf_block_size(result);
|
|
- heap->free_bytes -= tlsf_alloc_overhead();
|
|
+ heap->free_bytes -= esp_tlsf_block_size(result);
|
|
+ heap->free_bytes -= esp_tlsf_alloc_overhead();
|
|
if (heap->free_bytes < heap->minimum_free_bytes) {
|
|
heap->minimum_free_bytes = heap->free_bytes;
|
|
}
|
|
@@ -228,9 +228,9 @@ void multi_heap_free_impl(multi_heap_handle_t heap, void *p)
|
|
assert_valid_block(heap, block_from_ptr(p));
|
|
|
|
multi_heap_internal_lock(heap);
|
|
- heap->free_bytes += tlsf_block_size(p);
|
|
- heap->free_bytes += tlsf_alloc_overhead();
|
|
- tlsf_free(heap->heap_data, p);
|
|
+ heap->free_bytes += esp_tlsf_block_size(p);
|
|
+ heap->free_bytes += esp_tlsf_alloc_overhead();
|
|
+ esp_tlsf_free(heap->heap_data, p);
|
|
multi_heap_internal_unlock(heap);
|
|
}
|
|
|
|
@@ -249,13 +249,13 @@ void *multi_heap_realloc_impl(multi_heap_handle_t heap, void *p, size_t size)
|
|
}
|
|
|
|
multi_heap_internal_lock(heap);
|
|
- size_t previous_block_size = tlsf_block_size(p);
|
|
- void *result = tlsf_realloc(heap->heap_data, p, size);
|
|
+ size_t previous_block_size = esp_tlsf_block_size(p);
|
|
+ void *result = esp_tlsf_realloc(heap->heap_data, p, size);
|
|
if(result) {
|
|
- /* No need to subtract the tlsf_alloc_overhead() as it has already
|
|
+ /* No need to subtract the esp_tlsf_alloc_overhead() as it has already
|
|
* been subtracted when allocating the block at first with malloc */
|
|
heap->free_bytes += previous_block_size;
|
|
- heap->free_bytes -= tlsf_block_size(result);
|
|
+ heap->free_bytes -= esp_tlsf_block_size(result);
|
|
if (heap->free_bytes < heap->minimum_free_bytes) {
|
|
heap->minimum_free_bytes = heap->free_bytes;
|
|
}
|
|
@@ -282,10 +282,10 @@ void *multi_heap_aligned_alloc_impl_offs(multi_heap_handle_t heap, size_t size,
|
|
}
|
|
|
|
multi_heap_internal_lock(heap);
|
|
- void *result = tlsf_memalign_offs(heap->heap_data, alignment, size, offset);
|
|
+ void *result = esp_tlsf_memalign_offs(heap->heap_data, alignment, size, offset);
|
|
if(result) {
|
|
- heap->free_bytes -= tlsf_block_size(result);
|
|
- heap->free_bytes -= tlsf_alloc_overhead();
|
|
+ heap->free_bytes -= esp_tlsf_block_size(result);
|
|
+ heap->free_bytes -= esp_tlsf_alloc_overhead();
|
|
if(heap->free_bytes < heap->minimum_free_bytes) {
|
|
heap->minimum_free_bytes = heap->free_bytes;
|
|
}
|
|
@@ -322,7 +322,7 @@ static bool g_print_errors = false;
|
|
*
|
|
* @return bool: true if the the memory is not corrupted, false if the memory if corrupted.
|
|
*/
|
|
-bool tlsf_check_hook(void *start, size_t size, bool is_free)
|
|
+bool esp_tlsf_check_hook(void *start, size_t size, bool is_free)
|
|
{
|
|
return multi_heap_internal_check_block_poisoning(start, size, is_free, g_print_errors);
|
|
}
|
|
@@ -341,11 +341,11 @@ bool multi_heap_check(multi_heap_handle_t heap, bool print_errors)
|
|
(void) print_errors;
|
|
#endif
|
|
|
|
- if(tlsf_check(heap->heap_data)) {
|
|
+ if(esp_tlsf_check(heap->heap_data)) {
|
|
valid = false;
|
|
}
|
|
|
|
- if(tlsf_check_pool(tlsf_get_pool(heap->heap_data))) {
|
|
+ if(esp_tlsf_check_pool(esp_tlsf_get_pool(heap->heap_data))) {
|
|
valid = false;
|
|
}
|
|
|
|
@@ -366,7 +366,7 @@ void multi_heap_dump(multi_heap_handle_t heap)
|
|
|
|
multi_heap_internal_lock(heap);
|
|
MULTI_HEAP_STDERR_PRINTF("Showing data for heap: %p \n", (void *)heap);
|
|
- tlsf_walk_pool(tlsf_get_pool(heap->heap_data), multi_heap_dump_tlsf, NULL);
|
|
+ esp_tlsf_walk_pool(esp_tlsf_get_pool(heap->heap_data), multi_heap_dump_tlsf, NULL);
|
|
multi_heap_internal_unlock(heap);
|
|
}
|
|
|
|
@@ -417,14 +417,14 @@ void multi_heap_get_info_impl(multi_heap_handle_t heap, multi_heap_info_t *info)
|
|
}
|
|
|
|
multi_heap_internal_lock(heap);
|
|
- tlsf_walk_pool(tlsf_get_pool(heap->heap_data), multi_heap_get_info_tlsf, info);
|
|
+ esp_tlsf_walk_pool(esp_tlsf_get_pool(heap->heap_data), multi_heap_get_info_tlsf, info);
|
|
/* TLSF has an overhead per block. Calculate the total amount of overhead, it shall not be
|
|
* part of the allocated bytes */
|
|
- overhead = info->allocated_blocks * tlsf_alloc_overhead();
|
|
- info->total_allocated_bytes = (heap->pool_size - tlsf_size(heap->heap_data)) - heap->free_bytes - overhead;
|
|
+ overhead = info->allocated_blocks * esp_tlsf_alloc_overhead();
|
|
+ info->total_allocated_bytes = (heap->pool_size - esp_tlsf_size(heap->heap_data)) - heap->free_bytes - overhead;
|
|
info->minimum_free_bytes = heap->minimum_free_bytes;
|
|
info->total_free_bytes = heap->free_bytes;
|
|
- info->largest_free_block = tlsf_fit_size(heap->heap_data, info->largest_free_block);
|
|
+ info->largest_free_block = esp_tlsf_fit_size(heap->heap_data, info->largest_free_block);
|
|
multi_heap_internal_unlock(heap);
|
|
}
|
|
|
|
@@ -433,7 +433,7 @@ void multi_heap_walk(multi_heap_handle_t heap, multi_heap_walker_cb_t walker_fun
|
|
assert(heap != NULL);
|
|
|
|
multi_heap_internal_lock(heap);
|
|
- tlsf_walk_pool(tlsf_get_pool(heap->heap_data), walker_func, user_data);
|
|
+ esp_tlsf_walk_pool(esp_tlsf_get_pool(heap->heap_data), walker_func, user_data);
|
|
multi_heap_internal_unlock(heap);
|
|
}
|
|
|
|
--
|
|
2.34.1
|
|
|