arm/arch: using __builtin_frame_address(0) implement up_getsp().

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
This commit is contained in:
wangbowen6 2022-04-15 17:35:00 +08:00 committed by Xiang Xiao
parent 6af167c086
commit 91d02f5db8

View File

@ -40,6 +40,8 @@
* Pre-processor Prototypes
****************************************************************************/
#define up_getsp() (uintptr_t)__builtin_frame_address(0)
#ifdef CONFIG_PIC
/* This identifies the register the is used by the processor as the PIC base
@ -108,24 +110,6 @@ do { \
* Inline functions
****************************************************************************/
/****************************************************************************
* Name: up_getsp
****************************************************************************/
/* I don't know if the builtin to get SP is enabled */
static inline uint32_t up_getsp(void)
{
uint32_t sp;
__asm__
(
"\tmov %0, sp\n\t"
: "=r"(sp)
);
return sp;
}
/****************************************************************************
* Public Types
****************************************************************************/