Merge pull request #14455 from benpicco/fe310-heap_markers

cpu/fe310: use common names for heap markers
This commit is contained in:
Alexandre Abadie 2020-07-08 14:14:38 +02:00 committed by GitHub
commit d02d54b76a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View File

@ -166,11 +166,11 @@ SECTIONS
. = ALIGN(8);
PROVIDE( _end = . );
PROVIDE( end = . );
PROVIDE( _heap_start = . );
PROVIDE( _sheap = . );
.stack ORIGIN(ram) + LENGTH(ram) - __stack_size :
{
PROVIDE( _heap_end = . );
PROVIDE( _eheap = . );
. = __stack_size;
PROVIDE( _sp = . );
} >ram AT>ram :ram

View File

@ -29,9 +29,9 @@
#include "cpu.h"
#include "stdio_uart.h"
extern char _heap_start; /* Heap markers from fe310.ld file */
extern char _heap_end;
char *heap_top = &_heap_start + 4;
extern char _sheap; /* Heap markers from fe310.ld file */
extern char _eheap;
char *heap_top = &_sheap + 4;
/**
* @brief Initialize the Newlib-nano functions (also forces inclusion of stubs for linking)
@ -59,7 +59,7 @@ void *_sbrk(ptrdiff_t incr)
void *res = heap_top;
/* Allocate memory from heap */
if ((heap_top + incr > &_heap_end) || (heap_top + incr < &_heap_start)) {
if ((heap_top + incr > &_eheap) || (heap_top + incr < &_sheap)) {
errno = ENOMEM;
res = (void *) -1;
}

View File

@ -187,10 +187,10 @@ void thread_yield_higher(void)
*/
void heap_stats(void)
{
extern char _heap_start; /* defined in linker script */
extern char _heap_end; /* defined in linker script */
extern char _sheap; /* defined in linker script */
extern char _eheap; /* defined in linker script */
long int heap_size = &_heap_end - &_heap_start;
long int heap_size = &_eheap - &_sheap;
struct mallinfo minfo = mallinfo();
printf("heap: %ld (used %u, free %ld) [bytes]\n",
heap_size, minfo.uordblks, heap_size - minfo.uordblks);