1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-24 22:13:52 +01:00

cpu/atmega_common: changes for common heap command

This commit is contained in:
Gunar Schorcht 2019-02-03 18:59:27 +01:00 committed by Schorcht
parent e9e6b7f31a
commit 4b009649c6
2 changed files with 27 additions and 0 deletions

View File

@ -112,6 +112,28 @@ void cpu_init(void)
periph_init();
}
struct __freelist {
size_t size;
struct __freelist *next;
};
extern struct __freelist *__flp;
extern char *__malloc_heap_start;
extern char *__malloc_heap_end;
extern char *__brkval;
void heap_stats(void)
{
int heap_size = __malloc_heap_end - __malloc_heap_start;
int free = __malloc_heap_end - __brkval;
struct __freelist *fp;
for (fp = __flp; fp; fp = fp->next) {
free += fp->size;
}
printf("heap: %d (used %d, free %d) [bytes]\n",
heap_size, heap_size - free, free);
}
/* This is a vector which is aliased to __vector_default,
* the vector executed when an ISR fires with no accompanying
* ISR handler. This may be used along with the ISR() macro to

View File

@ -56,6 +56,11 @@ extern "C" {
*/
#define PUF_SRAM_ATTRIBUTES __attribute__((used, section(".noinit")))
/**
* @brief Declare the heap_stats function as available
*/
#define HAVE_HEAP_STATS
#ifdef __cplusplus
}
#endif