From 6a863ef65cbdd3bb12404e9871b391a3bcdc0984 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 27 Nov 2021 18:25:33 -0500 Subject: [PATCH] =?UTF-8?q?[kservice]=20=E4=BC=98=E5=8C=96RT=5FPRINTF=5FLO?= =?UTF-8?q?NGLONG=EF=BC=8C=E5=87=8F=E5=B0=91=E9=87=8D=E5=A4=8D=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Kconfig | 10 +++++----- src/kservice.c | 29 +++++++++++------------------ 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/Kconfig b/src/Kconfig index 427a65eb74..a11cb856cf 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -144,7 +144,11 @@ config RT_USING_ASM_MEMSET default n config RT_USING_TINY_FFS - bool "Enable kservice to use tiny ffs" + bool "Enable kservice to use tiny finding first bit set method" + default n + +config RT_PRINTF_LONGLONG + bool "Enable rt_xprintf functions to support long long format" default n endmenu @@ -375,10 +379,6 @@ menu "Kernel Device Object" config RT_CONSOLE_DEVICE_NAME string "the device name for console" default "uart" - - config RT_PRINTF_LONGLONG - bool "rt_kprintf support long long" - default n endif endmenu diff --git a/src/kservice.c b/src/kservice.c index aa5b39075c..5e877e5d2a 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -593,7 +593,6 @@ RTM_EXPORT(rt_show_version); /* private function */ #define _ISDIGIT(c) ((unsigned)((c) - '0') < 10) -#ifdef RT_PRINTF_LONGLONG /** * This function will duplicate a string. * @@ -603,44 +602,38 @@ RTM_EXPORT(rt_show_version); * * @return the duplicated string pointer. */ +#ifdef RT_PRINTF_LONGLONG rt_inline int divide(long long *n, int base) +#else +rt_inline int divide(long *n, int base) +#endif /* RT_PRINTF_LONGLONG */ { int res; /* optimized for processor which does not support divide instructions. */ if (base == 10) { +#ifdef RT_PRINTF_LONGLONG res = (int)(((unsigned long long)*n) % 10U); *n = (long long)(((unsigned long long)*n) / 10U); - } - else - { - res = (int)(((unsigned long long)*n) % 16U); - *n = (long long)(((unsigned long long)*n) / 16U); - } - - return res; -} #else -rt_inline int divide(long *n, int base) -{ - int res; - - /* optimized for processor which does not support divide instructions. */ - if (base == 10) - { res = (int)(((unsigned long)*n) % 10U); *n = (long)(((unsigned long)*n) / 10U); +#endif } else { +#ifdef RT_PRINTF_LONGLONG + res = (int)(((unsigned long long)*n) % 16U); + *n = (long long)(((unsigned long long)*n) / 16U); +#else res = (int)(((unsigned long)*n) % 16U); *n = (long)(((unsigned long)*n) / 16U); +#endif } return res; } -#endif /* RT_PRINTF_LONGLONG */ rt_inline int skip_atoi(const char **s) { -- GitLab