File tree 2 files changed +31
-5
lines changed
2 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -199,17 +199,17 @@ config RT_USING_CPU_USAGE_TRACER
199
199
200
200
choice
201
201
prompt "Choose finding first bit set method"
202
- default RT_USING_TINY_FFS
202
+ default RT_USING_BUILTIN_FFS
203
203
204
204
config RT_USING_TINY_FFS
205
205
bool "Tiny: 37 bytes"
206
206
help
207
207
Select this if you want tiny method.
208
208
209
- config RT_USING_PUNY_FFS
210
- bool "Puny : 0 bytes"
209
+ config RT_USING_BUILTIN_FFS
210
+ bool "Builtin : 0 bytes"
211
211
help
212
- Select this if you want puny method.
212
+ Select this if you want builtin method.
213
213
214
214
endchoice
215
215
menuconfig RT_USING_DEBUG
Original file line number Diff line number Diff line change @@ -1026,7 +1026,32 @@ RTM_EXPORT(rt_free_align);
1026
1026
#endif /* RT_USING_HEAP */
1027
1027
1028
1028
#ifndef RT_USING_CPU_FFS
1029
- #ifdef RT_USING_PUNY_FFS
1029
+ #ifdef RT_USING_BUILTIN_FFS
1030
+
1031
+ #if defined(__GNUC__ ) || defined(__clang__ )
1032
+ #define __HAS_BUILTIN_CTZ__
1033
+ #define CTZ (x ) ((x) ? 1 + __builtin_ctz(x) : 0)
1034
+
1035
+ #elif defined(__ARMCC_VERSION ) // Keil ARM Compiler
1036
+ #include "arm_math.h"
1037
+ #define __HAS_BUILTIN_CTZ__
1038
+ #define CTZ (x ) ((x) ? 1 + __CLZ(__RBIT(x)) : 0)
1039
+
1040
+ #elif defined(__ICCARM__ ) // IAR ARM Compiler
1041
+ #include <intrinsics.h>
1042
+ #define __HAS_BUILTIN_CTZ__
1043
+ #define CTZ (x ) ((x) ? 1 + __CLZ(__RBIT(x)) : 0)
1044
+
1045
+ #else
1046
+ #message "Don't know if compiler has builtin ctz"
1047
+ #endif
1048
+
1049
+ #ifdef __HAS_BUILTIN_CTZ__
1050
+ int __rt_ffs (rt_int32_t value )
1051
+ {
1052
+ return CTZ (value );
1053
+ }
1054
+ #else
1030
1055
int __rt_ffs (rt_int32_t value ) {
1031
1056
int position = 1 ; // position start from 1
1032
1057
@@ -1068,6 +1093,7 @@ int __rt_ffs(rt_int32_t value) {
1068
1093
1069
1094
return position ;
1070
1095
}
1096
+ #endif
1071
1097
#elif defined(RT_USING_TINY_FFS )
1072
1098
const rt_uint8_t __lowest_bit_bitmap [] =
1073
1099
{
You can’t perform that action at this time.
0 commit comments