From 9d8afc8ede235f95faa5c710181cc4fedf444554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=BE=84?= <36236188+Eureka1024@users.noreply.github.com> Date: Wed, 15 Sep 2021 00:07:24 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E7=A7=8D?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E6=9F=A5=E6=89=BE=E5=AD=97=E8=8A=82=E6=9C=80?= =?UTF-8?q?=E4=BD=8E=E9=9D=9E0=E4=BD=8D=E7=9A=84=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/kservice.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/kservice.c b/src/kservice.c index 25d34dfc473..7c62901e365 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -1353,6 +1353,32 @@ RTM_EXPORT(rt_free_align); #endif /* RT_USING_HEAP */ #ifndef RT_USING_CPU_FFS +#ifdef RT_KSERVICE_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) +{ + rt_uint32_t result = (rt_uint32_t)value; + return __lowest_bit_bitmap[ (result & (result - 1) ^ result) % 37]; +} +#else const rt_uint8_t __lowest_bit_bitmap[] = { /* 00 */ 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, @@ -1398,6 +1424,7 @@ int __rt_ffs(int value) return __lowest_bit_bitmap[(value & 0xff000000) >> 24] + 25; } +#endif /* RT_KSERVICE_USING_TINY_FFS */ #endif /* RT_USING_CPU_FFS */ #ifdef RT_DEBUG From 1ef31445fd731c81c403eda47c13f2c027dd26b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=BE=84?= <36236188+Eureka1024@users.noreply.github.com> Date: Wed, 15 Sep 2021 00:10:35 +0800 Subject: [PATCH 2/6] =?UTF-8?q?[src][Kconfig]=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=9A=90=E6=80=A7RT=5FKSERVICE=5FUSING=5FTINY=5FFFS=E5=AE=9A?= =?UTF-8?q?=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Kconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Kconfig b/src/Kconfig index 71abd9cf4f5..1de4bc52c74 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -135,6 +135,10 @@ config RT_USING_ASM_MEMCPY bool default n +config RT_KSERVICE_USING_TINY_FFS + bool "Enable kservice to use tiny ffs" + default n + endmenu menuconfig RT_DEBUG From e6e90629773897394e99a156cf76756b883ff86d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=BE=84?= <36236188+Eureka1024@users.noreply.github.com> Date: Sun, 7 Nov 2021 14:57:02 +0800 Subject: [PATCH 3/6] Update kservice.c --- src/kservice.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/kservice.c b/src/kservice.c index 7c62901e365..dd95fe029a3 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -1375,8 +1375,7 @@ const rt_uint8_t __lowest_bit_bitmap[] = */ int __rt_ffs(int value) { - rt_uint32_t result = (rt_uint32_t)value; - return __lowest_bit_bitmap[ (result & (result - 1) ^ result) % 37]; + return __lowest_bit_bitmap_new[(rt_uint32_t)(value & (value - 1) ^ value) % 37]; } #else const rt_uint8_t __lowest_bit_bitmap[] = From 46fe85e2c2aaa1bca76c53c046fe2bb48f5acee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=BE=84?= <36236188+Eureka1024@users.noreply.github.com> Date: Sun, 7 Nov 2021 15:51:24 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E7=B2=BE=E7=AE=80=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E7=89=88=E7=9A=84=5F=5Frt=5Fffs()=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/kservice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kservice.c b/src/kservice.c index dd95fe029a3..6c54766728a 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -1375,7 +1375,7 @@ const rt_uint8_t __lowest_bit_bitmap[] = */ int __rt_ffs(int value) { - return __lowest_bit_bitmap_new[(rt_uint32_t)(value & (value - 1) ^ value) % 37]; + return __lowest_bit_bitmap[(rt_uint32_t)(value & (value - 1) ^ value) % 37]; } #else const rt_uint8_t __lowest_bit_bitmap[] = From e509b9fe32dd34cd1fdec951b7c233e11a3d0d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=BE=84?= <36236188+Eureka1024@users.noreply.github.com> Date: Tue, 9 Nov 2021 23:30:18 +0800 Subject: [PATCH 5/6] Update Kconfig --- src/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kconfig b/src/Kconfig index 1de4bc52c74..f2481c46515 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -135,7 +135,7 @@ config RT_USING_ASM_MEMCPY bool default n -config RT_KSERVICE_USING_TINY_FFS +config RT_USING_TINY_FFS bool "Enable kservice to use tiny ffs" default n From 216cd309eae96ae3b06e3657fd0f9978569561e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=BE=84?= <36236188+Eureka1024@users.noreply.github.com> Date: Tue, 9 Nov 2021 23:32:51 +0800 Subject: [PATCH 6/6] Update kservice.c --- src/kservice.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kservice.c b/src/kservice.c index 6c54766728a..b526291da2f 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -1353,7 +1353,7 @@ RTM_EXPORT(rt_free_align); #endif /* RT_USING_HEAP */ #ifndef RT_USING_CPU_FFS -#ifdef RT_KSERVICE_USING_TINY_FFS +#ifdef RT_USING_TINY_FFS const rt_uint8_t __lowest_bit_bitmap[] = { /* 0 - 7 */ 0, 1, 2, 27, 3, 24, 28, 32, @@ -1423,7 +1423,7 @@ int __rt_ffs(int value) return __lowest_bit_bitmap[(value & 0xff000000) >> 24] + 25; } -#endif /* RT_KSERVICE_USING_TINY_FFS */ +#endif /* RT_USING_TINY_FFS */ #endif /* RT_USING_CPU_FFS */ #ifdef RT_DEBUG