|
@@ -1360,6 +1360,31 @@ RTM_EXPORT(rt_free_align);
|
|
#endif /* RT_USING_HEAP */
|
|
#endif /* RT_USING_HEAP */
|
|
|
|
|
|
#ifndef RT_USING_CPU_FFS
|
|
#ifndef RT_USING_CPU_FFS
|
|
|
|
+#ifdef RT_USING_TINY_FFS
|
|
|
|
+const rt_uint8_t __lowest_bit_bitmap[] =
|
|
|
|
+{
|
|
|
|
+ /* 0 - 7 */ 0, 1, 2, 27, 3, 24, 28, 32,
|
|
|
|
+ /* 8 - 15 */ 4, 17, 25, 31, 29, 12, 32, 14,
|
|
|
|
+ /* 16 - 23 */ 5, 8, 18, 32, 26, 23, 32, 16,
|
|
|
|
+ /* 24 - 31 */ 30, 11, 13, 7, 32, 22, 15, 10,
|
|
|
|
+ /* 32 - 36 */ 6, 21, 9, 20, 19
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * This function finds the first bit set (beginning with the least significant bit)
|
|
|
|
+ * in value and return the index of that bit.
|
|
|
|
+ *
|
|
|
|
+ * Bits are numbered starting at 1 (the least significant bit). A return value of
|
|
|
|
+ * zero from any of these functions means that the argument was zero.
|
|
|
|
+ *
|
|
|
|
+ * @return return the index of the first bit set. If value is 0, then this function
|
|
|
|
+ * shall return 0.
|
|
|
|
+ */
|
|
|
|
+int __rt_ffs(int value)
|
|
|
|
+{
|
|
|
|
+ return __lowest_bit_bitmap[(rt_uint32_t)(value & (value - 1) ^ value) % 37];
|
|
|
|
+}
|
|
|
|
+#else
|
|
const rt_uint8_t __lowest_bit_bitmap[] =
|
|
const rt_uint8_t __lowest_bit_bitmap[] =
|
|
{
|
|
{
|
|
/* 00 */ 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
/* 00 */ 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
@@ -1405,6 +1430,7 @@ int __rt_ffs(int value)
|
|
|
|
|
|
return __lowest_bit_bitmap[(value & 0xff000000) >> 24] + 25;
|
|
return __lowest_bit_bitmap[(value & 0xff000000) >> 24] + 25;
|
|
}
|
|
}
|
|
|
|
+#endif /* RT_USING_TINY_FFS */
|
|
#endif /* RT_USING_CPU_FFS */
|
|
#endif /* RT_USING_CPU_FFS */
|
|
|
|
|
|
#ifdef RT_DEBUG
|
|
#ifdef RT_DEBUG
|