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
This commit is contained in:
bernard.xiong@gmail.com 2010-11-29 13:29:51 +00:00
parent bd15cf6a7a
commit 8dfab786e1
2 changed files with 29 additions and 1 deletions

View File

@ -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

View File

@ -478,7 +478,7 @@ rt_module_t rt_module_open(const char* filename)
#if defined(RT_USING_FINSH)
#include <finsh.h>
FINSH_FUNCTION_EXPORT(rt_module_open, load module from file);
FINSH_FUNCTION_EXPORT_ALIAS(rt_module_open, exec, exec module from file);
#endif
#endif