From 8dfab786e153cbc0bc08fcb837a1d70ab00d1eff Mon Sep 17 00:00:00 2001 From: "bernard.xiong@gmail.com" Date: Mon, 29 Nov 2010 13:29:51 +0000 Subject: [PATCH] add FINSH_FUNCTION_EXPORT_ALIAS preprocessor in finsh shell. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1142 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- components/finsh/finsh.h | 28 ++++++++++++++++++++++++++++ src/module.c | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/components/finsh/finsh.h b/components/finsh/finsh.h index 87f8d72780..fd51b72a64 100644 --- a/components/finsh/finsh.h +++ b/components/finsh/finsh.h @@ -173,6 +173,25 @@ struct finsh_sysvar* finsh_sysvar_lookup(const char* name); (syscall_func)&name \ }; + /** + * @ingroup finsh + * + * This macro exports a system function with an alias name to finsh shell. + * + * @param name the name of function. + * @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) \ + const char __fsym_##name##_name[] = #alias; \ + const char __fsym_##name##_desc[] = #desc; \ + const struct finsh_syscall __fsym_##name SECTION("FSymTab")= \ + { \ + __fsym_##name##_name, \ + __fsym_##name##_desc, \ + (syscall_func)&name \ + }; + /** * @ingroup finsh * @@ -201,6 +220,14 @@ struct finsh_sysvar* finsh_sysvar_lookup(const char* name); (syscall_func)&name \ }; + #define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \ + const char __fsym_##name##_name[] = #alias; \ + const struct finsh_syscall __fsym_##name SECTION("FSymTab")= \ + { \ + __fsym_##name##_name, \ + (syscall_func)&name \ + }; + #define FINSH_VAR_EXPORT(name, type, desc) \ const char __vsym_##name##_name[] = #name; \ const struct finsh_sysvar __vsym_##name SECTION("VSymTab")= \ @@ -212,6 +239,7 @@ struct finsh_sysvar* finsh_sysvar_lookup(const char* name); #endif #else #define FINSH_FUNCTION_EXPORT(name, desc) + #define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) #define FINSH_VAR_EXPORT(name, type, desc) #endif diff --git a/src/module.c b/src/module.c index 5bab451ac3..a8875126ca 100644 --- a/src/module.c +++ b/src/module.c @@ -478,7 +478,7 @@ rt_module_t rt_module_open(const char* filename) #if defined(RT_USING_FINSH) #include -FINSH_FUNCTION_EXPORT(rt_module_open, load module from file); +FINSH_FUNCTION_EXPORT_ALIAS(rt_module_open, exec, exec module from file); #endif #endif