diff options
| author | yangjie <[email protected]> | 2019-07-03 18:47:11 +0800 |
|---|---|---|
| committer | yangjie <[email protected]> | 2019-07-03 18:47:11 +0800 |
| commit | 31ffc4582c04b4ff5e59404b06d1e52d4b5cff63 (patch) | |
| tree | 18d158df862c4784aea2b79a840260f1ed12493b /libcpu/arm/cortex-m3 | |
| parent | c578016f92848398bc433196befbbe0d2ec24078 (diff) | |
[libcpu/arm]add __rt_ffs() for armclang in CORTEX M3/4/7
Diffstat (limited to 'libcpu/arm/cortex-m3')
| -rw-r--r-- | libcpu/arm/cortex-m3/cpuport.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libcpu/arm/cortex-m3/cpuport.c b/libcpu/arm/cortex-m3/cpuport.c index a386747750..0a948c528b 100644 --- a/libcpu/arm/cortex-m3/cpuport.c +++ b/libcpu/arm/cortex-m3/cpuport.c @@ -11,6 +11,7 @@ * 2012-12-23 aozima stack addr align to 8byte. * 2012-12-29 Bernard Add exception hook. * 2013-07-09 aozima enhancement hard fault exception handler. + * 2019-07-03 yangjie add __rt_ffs() for armclang. */ #include <rtthread.h> @@ -382,6 +383,25 @@ __asm int __rt_ffs(int value) exit BX lr } +#elif defined(__CLANG_ARM) +int __rt_ffs(int value) +{ + __asm volatile( + "CMP r0, #0x00 \n" + "BEQ exit \n" + + "RBIT r0, r0 \n" + "CLZ r0, r0 \n" + "ADDS r0, r0, #0x01 \n" + + "exit: \n" + "BX lr \n" + + : "=r"(value) + : "r"(value) + ); + return value; +} #elif defined(__IAR_SYSTEMS_ICC__) int __rt_ffs(int value) { |
