From 5eb976a088130e253f82f243116dded5495222b2 Mon Sep 17 00:00:00 2001 From: Adam Green Date: Tue, 17 Sep 2013 04:29:35 -0700 Subject: [PATCH] Fix _sbrk() implementation for Cortex-M parts. A recent commit, 43acaa4166, to get _sbrk() to build successfully for LPC2368 broke the Cortex-M implementation. __get_MSP() isn't ever defined as a macro, it is an inline function. This means that the code would always be compiled to use SP instead of MSP on Cortex-M parts. I switched the code to instead use the TARGET_ARM7 define to choose which stack pointer to utilize. I tested this fix by making sure that the LPC2368 version of the mbed SDK would still build successfully with the Python scripts and that the NET1 test still built and ran successfully on my mbed-LPC1768 device. --- libraries/mbed/common/retarget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/mbed/common/retarget.cpp b/libraries/mbed/common/retarget.cpp index 062602c511..742aec0ad5 100644 --- a/libraries/mbed/common/retarget.cpp +++ b/libraries/mbed/common/retarget.cpp @@ -448,10 +448,10 @@ extern "C" caddr_t _sbrk(int incr) { unsigned char* prev_heap = heap; unsigned char* new_heap = heap + incr; -#ifdef __get_MSP - if (new_heap >= (unsigned char*)__get_MSP()) { -#else +#if defined(TARGET_ARM7) if (new_heap >= stack_ptr) { +#else + if (new_heap >= (unsigned char*)__get_MSP()) { #endif errno = ENOMEM; return (caddr_t)-1;