From 9bbc4e5e6b6d5c6efe24484d9032a8b8da2f1920 Mon Sep 17 00:00:00 2001 From: aozima Date: Wed, 23 Aug 2017 16:13:51 +0800 Subject: [PATCH] update cortex-m libcpu: fixed compile error. --- libcpu/arm/cortex-m3/cpuport.c | 11 +++++++---- libcpu/arm/cortex-m4/cpuport.c | 9 ++++++--- libcpu/arm/cortex-m7/cpuport.c | 9 ++++++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/libcpu/arm/cortex-m3/cpuport.c b/libcpu/arm/cortex-m3/cpuport.c index f938bab800..10989ffc5b 100644 --- a/libcpu/arm/cortex-m3/cpuport.c +++ b/libcpu/arm/cortex-m3/cpuport.c @@ -368,11 +368,12 @@ __asm int __rt_ffs(int value) { CMP r0, #0x00 BEQ exit + RBIT r0, r0 CLZ r0, r0 ADDS r0, r0, #0x01 - exit +exit BX lr } #elif defined(__IAR_SYSTEMS_ICC__) @@ -380,9 +381,11 @@ int __rt_ffs(int value) { if (value == 0) return value; - __ASM("RBIT r0, r0"); - __ASM("CLZ r0, r0"); - __ASM("ADDS r0, r0, #0x01"); + asm("RBIT %0, %1" : "=r"(value) : "r"(value)); + asm("CLZ %0, %1" : "=r"(value) : "r"(value)); + asm("ADDS %0, %1, #0x01" : "=r"(value) : "r"(value)); + + return value; } #elif defined(__GNUC__) int __rt_ffs(int value) diff --git a/libcpu/arm/cortex-m4/cpuport.c b/libcpu/arm/cortex-m4/cpuport.c index 47d8473997..e74c337c60 100644 --- a/libcpu/arm/cortex-m4/cpuport.c +++ b/libcpu/arm/cortex-m4/cpuport.c @@ -238,6 +238,7 @@ __asm int __rt_ffs(int value) { CMP r0, #0x00 BEQ exit + RBIT r0, r0 CLZ r0, r0 ADDS r0, r0, #0x01 @@ -250,9 +251,11 @@ int __rt_ffs(int value) { if (value == 0) return value; - __ASM("RBIT r0, r0"); - __ASM("CLZ r0, r0"); - __ASM("ADDS r0, r0, #0x01"); + asm("RBIT %0, %1" : "=r"(value) : "r"(value)); + asm("CLZ %0, %1" : "=r"(value) : "r"(value)); + asm("ADDS %0, %1, #0x01" : "=r"(value) : "r"(value)); + + return value; } #elif defined(__GNUC__) int __rt_ffs(int value) diff --git a/libcpu/arm/cortex-m7/cpuport.c b/libcpu/arm/cortex-m7/cpuport.c index 47d8473997..e74c337c60 100644 --- a/libcpu/arm/cortex-m7/cpuport.c +++ b/libcpu/arm/cortex-m7/cpuport.c @@ -238,6 +238,7 @@ __asm int __rt_ffs(int value) { CMP r0, #0x00 BEQ exit + RBIT r0, r0 CLZ r0, r0 ADDS r0, r0, #0x01 @@ -250,9 +251,11 @@ int __rt_ffs(int value) { if (value == 0) return value; - __ASM("RBIT r0, r0"); - __ASM("CLZ r0, r0"); - __ASM("ADDS r0, r0, #0x01"); + asm("RBIT %0, %1" : "=r"(value) : "r"(value)); + asm("CLZ %0, %1" : "=r"(value) : "r"(value)); + asm("ADDS %0, %1, #0x01" : "=r"(value) : "r"(value)); + + return value; } #elif defined(__GNUC__) int __rt_ffs(int value)