Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: target-freescale
Fork of mbed-hal by
Revision 4:473d4af53300, committed 2016-04-04
- Comitter:
- Alessandro Angelino
- Date:
- Mon Apr 04 14:24:07 2016 +0100
- Parent:
- 3:e4b241e107f9
- Commit message:
- Fix function to get sp when in unprivileged mode
Changed in this revision
common/retarget.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/common/retarget.cpp Fri Apr 01 15:04:27 2016 +0000 +++ b/common/retarget.cpp Mon Apr 04 14:24:07 2016 +0100 @@ -469,8 +469,16 @@ #undef errno extern "C" int errno; -// For ARM7 only -register unsigned char * stack_ptr __asm ("sp"); +// Stack pointer handling +#ifdef __ICCARM__ +#define __current_sp() __get_SP() +#else +static inline unsigned int __current_sp(void) +{ + register unsigned sp asm("sp"); + return sp; +} +#endif /* __ICCARM__ */ // Dynamic memory allocation related syscall. extern "C" caddr_t _sbrk(int incr) { @@ -478,12 +486,10 @@ unsigned char* prev_heap = heap; unsigned char* new_heap = heap + incr; -#if defined(TARGET_ARM7) - if (new_heap >= stack_ptr) { -#elif defined(TARGET_CORTEX_A) +#if defined(TARGET_CORTEX_A) if (new_heap >= (unsigned char*)&__HeapLimit) { /* __HeapLimit is end of heap section */ #else - if (new_heap >= (unsigned char*)__get_MSP()) { + if (new_heap >= (unsigned char*)__current_sp()) { #endif errno = ENOMEM; return (caddr_t)-1; @@ -566,4 +572,3 @@ } } // namespace mbed -