1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/sys/shell/commands/sc_heap.c
Gunar Schorcht 140987fc3a sys/shell: cleanup the heap command approach
Replaces the special heap command approach of the lpc_common module with a more general heap command approach. Module lpc_common was already removed with PR #2118. PR #2118 integrated cpu/lpc_common code in cpu/lpc2387. With PR #3530 special heap handling for cpu/lpc2387 was replaced by newlib memory management which uses _sbrk_r to allocate chunks from the heap. _sbrk_r uses _sheap and _eheap symbols that are defined in lpc2387.ld and can be used together with mallinfo function for heap statistics.
2019-09-05 09:18:46 +02:00

42 lines
861 B
C

/*
* Copyright (C) 2013 Zakaria Kasmi <zkasmi@inf.fu-berlin.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup sys_shell_commands
* @{
*
* @file
* @brief Print the state of the heap
*
* @author Zakaria Kasmi <zkasmi@inf.fu-berlin.de>
*
* @}
*/
#include "cpu_conf.h"
#if defined(MODULE_NEWLIB_SYSCALLS_DEFAULT) || defined (HAVE_HEAP_STATS)
extern void heap_stats(void);
#else
#include <stdio.h>
#endif
int _heap_handler(int argc, char **argv)
{
(void) argc;
(void) argv;
#if defined(MODULE_NEWLIB_SYSCALLS_DEFAULT) || defined (HAVE_HEAP_STATS)
heap_stats();
return 0;
#else
printf("heap statistics are not supported for %s cpu\n", RIOT_CPU);
return 1;
#endif
}