mirror of https://github.com/ARMmbed/mbed-os.git
Fix heap allocation when used with RTOS
Remove the code which checks the heap against the stack to determine if there is space left. Using the stack pointer as a limit causes problems when used with an RTOS since the stack pointer depends on the current thread which can use a user-allocated stack residing anywhere in memory.
parent
98a8c49f00
commit
6b4dfeb1ab
|
@ -461,9 +461,7 @@ extern "C" void __iar_argc_argv() {
|
|||
// Linker defined symbol used by _sbrk to indicate where heap should start.
|
||||
extern "C" int __end__;
|
||||
|
||||
#if defined(TARGET_CORTEX_A)
|
||||
extern "C" uint32_t __HeapLimit;
|
||||
#endif
|
||||
|
||||
// Turn off the errno macro and use actual global variable instead.
|
||||
#undef errno
|
||||
|
@ -486,11 +484,7 @@ extern "C" caddr_t _sbrk(int incr) {
|
|||
unsigned char* prev_heap = heap;
|
||||
unsigned char* new_heap = heap + incr;
|
||||
|
||||
#if defined(TARGET_CORTEX_A)
|
||||
if (new_heap >= (unsigned char*)&__HeapLimit) { /* __HeapLimit is end of heap section */
|
||||
#else
|
||||
if (new_heap >= (unsigned char*)__current_sp()) {
|
||||
#endif
|
||||
errno = ENOMEM;
|
||||
return (caddr_t)-1;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ __StackTop:
|
|||
#ifdef __HEAP_SIZE
|
||||
.equ Heap_Size, __HEAP_SIZE
|
||||
#else
|
||||
.equ Heap_Size, 0x400
|
||||
.equ Heap_Size, 0x20000
|
||||
#endif
|
||||
.globl __HeapBase
|
||||
.globl __HeapLimit
|
||||
|
|
Loading…
Reference in New Issue