tests/malloc: Allow malloc to fail when out of RAM, add heap test

cases.

Fixes #76.
This commit is contained in:
Angus Gratton 2016-02-16 22:00:29 +11:00
parent 80b191af08
commit 8fffd14e50
4 changed files with 41 additions and 14 deletions

View file

@ -81,13 +81,16 @@
unsigned cpu_sr;
char level1_int_disabled;
/* Supervisor stack pointer entry. This is the "high water mark" of how far the
supervisor stack grew down before task started.
/* Supervisor stack pointer entry. On reset, sdk_user_start sets a
* tentative 512 byte supervisor stack size.
After tasks start, task stacks are all allocated from the heap and
FreeRTOS checks for stack overflow.
When the scheduler starts, this changes to the "high water mark" of
how far the supervisor stack grew down before task started.
After tasks start, task stacks are all allocated from the heap and
FreeRTOS checks for stack overflow.
*/
static uint32_t xPortSupervisorStackPointer;
void *xPortSupervisorStackPointer;
/*
* Stack initialization
@ -218,7 +221,7 @@ size_t xPortGetFreeHeapSize( void )
struct mallinfo mi = mallinfo();
uint32_t brk_val = (uint32_t) sbrk(0);
uint32_t sp = xPortSupervisorStackPointer;
intptr_t sp = (intptr_t)xPortSupervisorStackPointer;
if(sp == 0) /* scheduler not started */
__asm__ __volatile__ ("mov %0, a1\n" : "=a"(sp));
return sp - brk_val + mi.fordblks;