From 8a1e6c01ac11a6af31d6b124fdd52c576120dd82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E5=BF=97=E8=BF=9C?= <1468728718@qq.com> Date: Mon, 23 Aug 2021 18:37:58 +0800 Subject: [PATCH] Disable FINSH_FUNCTION_EXPORT --- .../libraries/m031/rtt_port/drv_common.c | 2 +- .../libraries/m2354/rtt_port/drv_common.c | 2 +- bsp/stm32/libraries/HAL_Drivers/drv_common.c | 2 +- bsp/w60x/drivers/board.c | 2 +- components/finsh/finsh.h | 22 +++++++++---------- components/finsh/msh.c | 11 ++++------ 6 files changed, 18 insertions(+), 23 deletions(-) diff --git a/bsp/nuvoton/libraries/m031/rtt_port/drv_common.c b/bsp/nuvoton/libraries/m031/rtt_port/drv_common.c index 65b100bbe9..35a97b5433 100644 --- a/bsp/nuvoton/libraries/m031/rtt_port/drv_common.c +++ b/bsp/nuvoton/libraries/m031/rtt_port/drv_common.c @@ -138,5 +138,5 @@ static void reboot(uint8_t argc, char **argv) { rt_hw_cpu_reset(); } -FINSH_FUNCTION_EXPORT_ALIAS(reboot, __cmd_reboot, Reboot System); +MSH_CMD_EXPORT(reboot, Reboot System); #endif /* RT_USING_FINSH */ diff --git a/bsp/nuvoton/libraries/m2354/rtt_port/drv_common.c b/bsp/nuvoton/libraries/m2354/rtt_port/drv_common.c index 1dbd98f187..2209fbaba8 100644 --- a/bsp/nuvoton/libraries/m2354/rtt_port/drv_common.c +++ b/bsp/nuvoton/libraries/m2354/rtt_port/drv_common.c @@ -138,6 +138,6 @@ static void reboot(uint8_t argc, char **argv) { rt_hw_cpu_reset(); } -FINSH_FUNCTION_EXPORT_ALIAS(reboot, __cmd_reboot, Reboot System); +MSH_CMD_EXPORT(reboot, Reboot System); #endif /* RT_USING_FINSH */ diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_common.c b/bsp/stm32/libraries/HAL_Drivers/drv_common.c index 678e4ebadb..6cd9130a4a 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_common.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_common.c @@ -25,7 +25,7 @@ static void reboot(uint8_t argc, char **argv) { rt_hw_cpu_reset(); } -FINSH_FUNCTION_EXPORT_ALIAS(reboot, __cmd_reboot, Reboot System); +MSH_CMD_EXPORT(reboot, Reboot System); #endif /* RT_USING_FINSH */ /* SysTick configuration */ diff --git a/bsp/w60x/drivers/board.c b/bsp/w60x/drivers/board.c index 188c698ba9..6997392e66 100644 --- a/bsp/w60x/drivers/board.c +++ b/bsp/w60x/drivers/board.c @@ -255,7 +255,7 @@ static void reboot(uint8_t argc, char **argv) { rt_hw_cpu_reset(); } -FINSH_FUNCTION_EXPORT_ALIAS(reboot, __cmd_reboot, Reboot System); +MSH_CMD_EXPORT(reboot, Reboot System); #endif /* RT_USING_FINSH */ /*@}*/ diff --git a/components/finsh/finsh.h b/components/finsh/finsh.h index 74fef60fc0..380cade403 100644 --- a/components/finsh/finsh.h +++ b/components/finsh/finsh.h @@ -23,7 +23,7 @@ typedef long (*syscall_func)(void); #endif #ifdef FINSH_USING_DESCRIPTION #ifdef _MSC_VER -#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \ +#define MSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \ const char __fsym_##cmd##_name[] = #cmd; \ const char __fsym_##cmd##_desc[] = #desc; \ __declspec(allocate("FSymTab$f")) \ @@ -36,7 +36,7 @@ typedef long (*syscall_func)(void); #pragma comment(linker, "/merge:FSymTab=mytext") #elif defined(__TI_COMPILER_VERSION__) -#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \ +#define MSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \ __TI_FINSH_EXPORT_FUNCTION(__fsym_##cmd); \ const char __fsym_##cmd##_name[] = #cmd; \ const char __fsym_##cmd##_desc[] = #desc; \ @@ -48,7 +48,7 @@ typedef long (*syscall_func)(void); }; #else -#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \ +#define MSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \ const char __fsym_##cmd##_name[] RT_SECTION(".rodata.name") = #cmd; \ const char __fsym_##cmd##_desc[] RT_SECTION(".rodata.name") = #desc; \ RT_USED const struct finsh_syscall __fsym_##cmd RT_SECTION("FSymTab")= \ @@ -61,7 +61,7 @@ typedef long (*syscall_func)(void); #endif #else #ifdef _MSC_VER -#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \ +#define MSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \ const char __fsym_##cmd##_name[] = #cmd; \ __declspec(allocate("FSymTab$f")) \ const struct finsh_syscall __fsym_##cmd = \ @@ -72,7 +72,7 @@ typedef long (*syscall_func)(void); #pragma comment(linker, "/merge:FSymTab=mytext") #elif defined(__TI_COMPILER_VERSION__) -#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \ +#define MSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \ __TI_FINSH_EXPORT_FUNCTION(__fsym_##cmd); \ const char __fsym_##cmd##_name[] = #cmd; \ const struct finsh_syscall __fsym_##cmd = \ @@ -82,7 +82,7 @@ typedef long (*syscall_func)(void); }; #else -#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \ +#define MSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \ const char __fsym_##cmd##_name[] = #cmd; \ RT_USED const struct finsh_syscall __fsym_##cmd RT_SECTION("FSymTab")= \ { \ @@ -102,8 +102,7 @@ typedef long (*syscall_func)(void); * @param name the name of function. * @param desc the description of function, which will show in help. */ -#define FINSH_FUNCTION_EXPORT(name, desc) \ - FINSH_FUNCTION_EXPORT_CMD(name, name, desc) +#define FINSH_FUNCTION_EXPORT(name, desc) /** * @ingroup finsh @@ -114,8 +113,7 @@ typedef long (*syscall_func)(void); * @param alias the alias name of function. * @param desc the description of function, which will show in help. */ -#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \ - FINSH_FUNCTION_EXPORT_CMD(name, alias, desc) +#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) /** * @ingroup finsh @@ -126,9 +124,9 @@ typedef long (*syscall_func)(void); * @param desc the description of command, which will show in help. */ #define MSH_CMD_EXPORT(command, desc) \ - FINSH_FUNCTION_EXPORT_CMD(command, __cmd_##command, desc) + MSH_FUNCTION_EXPORT_CMD(command, command, desc) #define MSH_CMD_EXPORT_ALIAS(command, alias, desc) \ - FINSH_FUNCTION_EXPORT_ALIAS(command, __cmd_##alias, desc) + MSH_FUNCTION_EXPORT_CMD(command, alias, desc) /* system call table */ struct finsh_syscall diff --git a/components/finsh/msh.c b/components/finsh/msh.c index 648b4bbd69..446b25851e 100644 --- a/components/finsh/msh.c +++ b/components/finsh/msh.c @@ -41,11 +41,10 @@ int msh_help(int argc, char **argv) index < _syscall_table_end; FINSH_NEXT_SYSCALL(index)) { - if (strncmp(index->name, "__cmd_", 6) != 0) continue; #if defined(FINSH_USING_DESCRIPTION) && defined(FINSH_USING_SYMTAB) - rt_kprintf("%-16s - %s\n", &index->name[6], index->desc); + rt_kprintf("%-16s - %s\n", index->name, index->desc); #else - rt_kprintf("%s ", &index->name[6]); + rt_kprintf("%s ", index->name); #endif } } @@ -174,10 +173,8 @@ static cmd_function_t msh_get_cmd(char *cmd, int size) index < _syscall_table_end; FINSH_NEXT_SYSCALL(index)) { - if (strncmp(index->name, "__cmd_", 6) != 0) continue; - - if (strncmp(&index->name[6], cmd, size) == 0 && - index->name[6 + size] == '\0') + if (strncmp(index->name, cmd, size) == 0 && + index->name[size] == '\0') { cmd_func = (cmd_function_t)index->func; break;