mirror of
https://github.com/NevermindZZT/letter-shell.git
synced 2025-01-21 10:02:54 +08:00
防止 编译器优化
This commit is contained in:
parent
672b08efcc
commit
e376b61397
16
README.md
16
README.md
@ -318,8 +318,8 @@ letter shell 3.x对可执行命令,按键,用户以及变量分别提供了
|
||||
#define SHELL_EXPORT_CMD(_attr, _name, _func, _desc) \
|
||||
const char shellCmd##_name[] = #_name; \
|
||||
const char shellDesc##_name[] = #_desc; \
|
||||
const ShellCommand \
|
||||
shellCommand##_name SECTION("shellCommand") = \
|
||||
SHELL_USED const ShellCommand \
|
||||
shellCommand##_name SHELL_SECTION("shellCommand") = \
|
||||
{ \
|
||||
.attr.value = _attr, \
|
||||
.data.cmd.name = shellCmd##_name, \
|
||||
@ -344,8 +344,8 @@ letter shell 3.x对可执行命令,按键,用户以及变量分别提供了
|
||||
#define SHELL_EXPORT_VAR(_attr, _name, _value, _desc) \
|
||||
const char shellCmd##_name[] = #_name; \
|
||||
const char shellDesc##_name[] = #_desc; \
|
||||
const ShellCommand \
|
||||
shellVar##_name SECTION("shellCommand") = \
|
||||
SHELL_USED const ShellCommand \
|
||||
shellVar##_name SHELL_SECTION("shellCommand") = \
|
||||
{ \
|
||||
.attr.value = _attr, \
|
||||
.data.var.name = shellCmd##_name, \
|
||||
@ -373,8 +373,8 @@ letter shell 3.x对可执行命令,按键,用户以及变量分别提供了
|
||||
const char shellCmd##_name[] = #_name; \
|
||||
const char shellPassword##_name[] = #_password; \
|
||||
const char shellDesc##_name[] = #_desc; \
|
||||
const ShellCommand \
|
||||
shellUser##_name SECTION("shellCommand") = \
|
||||
SHELL_USED const ShellCommand \
|
||||
shellUser##_name SHELL_SECTION("shellCommand") = \
|
||||
{ \
|
||||
.attr.value = _attr|SHELL_CMD_TYPE(SHELL_TYPE_USER), \
|
||||
.data.user.name = shellCmd##_name, \
|
||||
@ -398,8 +398,8 @@ letter shell 3.x对可执行命令,按键,用户以及变量分别提供了
|
||||
*/
|
||||
#define SHELL_EXPORT_KEY(_attr, _value, _func, _desc) \
|
||||
const char shellDesc##_value[] = #_desc; \
|
||||
const ShellCommand \
|
||||
shellKey##_value SECTION("shellCommand") = \
|
||||
SHELL_USED const ShellCommand \
|
||||
shellKey##_value SHELL_SECTION("shellCommand") = \
|
||||
{ \
|
||||
.attr.value = _attr|SHELL_CMD_TYPE(SHELL_TYPE_KEY), \
|
||||
.data.key.value = _value, \
|
||||
|
@ -74,8 +74,8 @@ typedef struct shell_command_cpp_key
|
||||
#define SHELL_EXPORT_CMD(_attr, _name, _func, _desc) \
|
||||
const char shellCmd##_name[] = #_name; \
|
||||
const char shellDesc##_name[] = #_desc; \
|
||||
extern "C" const ShellCommandCppCmd \
|
||||
shellCommand##_name SECTION("shellCommand") = \
|
||||
extern "C" SHELL_USED const ShellCommandCppCmd \
|
||||
shellCommand##_name SHELL_SECTION("shellCommand") = \
|
||||
{ \
|
||||
_attr, \
|
||||
shellCmd##_name, \
|
||||
@ -95,8 +95,8 @@ typedef struct shell_command_cpp_key
|
||||
#define SHELL_EXPORT_VAR(_attr, _name, _value, _desc) \
|
||||
const char shellCmd##_name[] = #_name; \
|
||||
const char shellDesc##_name[] = #_desc; \
|
||||
extern "C" const ShellCommandCppVar \
|
||||
shellVar##_name SECTION("shellCommand") = \
|
||||
extern "C" SHELL_USED const ShellCommandCppVar \
|
||||
shellVar##_name SHELL_SECTION("shellCommand") = \
|
||||
{ \
|
||||
_attr, \
|
||||
shellCmd##_name, \
|
||||
@ -117,8 +117,8 @@ typedef struct shell_command_cpp_key
|
||||
const char shellCmd##_name[] = #_name; \
|
||||
const char shellPassword##_name[] = #_password; \
|
||||
const char shellDesc##_name[] = #_desc; \
|
||||
extern "C" const ShellCommandCppUser \
|
||||
shellUser##_name SECTION("shellCommand") = \
|
||||
extern "C" SHELL_USED const ShellCommandCppUser \
|
||||
shellUser##_name SHELL_SECTION("shellCommand") = \
|
||||
{ \
|
||||
_attr|SHELL_CMD_TYPE(SHELL_TYPE_USER), \
|
||||
shellCmd##_name, \
|
||||
@ -137,9 +137,9 @@ typedef struct shell_command_cpp_key
|
||||
*/
|
||||
#define SHELL_EXPORT_KEY(_attr, _value, _func, _desc) \
|
||||
const char shellDesc##_value[] = #_desc; \
|
||||
extern "C" const ShellCommandCppKey \
|
||||
shellKey##_value SECTION("shellCommand") = \
|
||||
{ \
|
||||
extern "C" SHELL_USED const ShellCommandCppKey \
|
||||
shellKey##_value SHELL_SECTION("shellCommand") = \
|
||||
{ \
|
||||
_attr|SHELL_CMD_TYPE(SHELL_TYPE_KEY), \
|
||||
_value, \
|
||||
(void (*)(Shell *))_func, \
|
||||
|
@ -22,7 +22,7 @@
|
||||
const char shellCmdDefaultUser[] = SHELL_DEFAULT_USER;
|
||||
const char shellPasswordDefaultUser[] = SHELL_DEFAULT_USER_PASSWORD;
|
||||
const char shellDesDefaultUser[] = "default user";
|
||||
const ShellCommand shellUserDefault SECTION("shellCommand") =
|
||||
SHELL_USED const ShellCommand shellUserDefault SHELL_SECTION("shellCommand") =
|
||||
{
|
||||
.attr.value = SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_USER),
|
||||
.data.user.name = shellCmdDefaultUser,
|
||||
|
42
src/shell.h
42
src/shell.h
@ -75,15 +75,27 @@
|
||||
#define SHELL_CMD_PARAM_NUM(num) \
|
||||
((num & 0x0000000F)) << 16
|
||||
|
||||
#ifndef SECTION
|
||||
#if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && __ARMCC_VERSION >= 6000000)
|
||||
#define SECTION(x) __attribute__((used, section(x)))
|
||||
#elif defined(__ICCARM__) || defined(__ICCRX__)
|
||||
#define SECTION(x) @ x
|
||||
#ifndef SHELL_SECTION
|
||||
#if defined(__CC_ARM) || defined(__CLANG_ARM)
|
||||
#define SHELL_SECTION(x) __attribute__((section(x)))
|
||||
#elif defined (__IAR_SYSTEMS_ICC__)
|
||||
#define SHELL_SECTION(x) @ x
|
||||
#elif defined(__GNUC__)
|
||||
#define SECTION(x) __attribute__((section(x)))
|
||||
#define SHELL_SECTION(x) __attribute__((section(x)))
|
||||
#else
|
||||
#define SECTION(x)
|
||||
#define SHELL_SECTION(x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef SHELL_USED
|
||||
#if defined(__CC_ARM) || defined(__CLANG_ARM)
|
||||
#define SHELL_USED __attribute__((used))
|
||||
#elif defined (__IAR_SYSTEMS_ICC__)
|
||||
#define SHELL_USED __root
|
||||
#elif defined(__GNUC__)
|
||||
#define SHELL_USED __attribute__((used))
|
||||
#else
|
||||
#define SHELL_USED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -120,8 +132,8 @@
|
||||
#define SHELL_EXPORT_CMD(_attr, _name, _func, _desc) \
|
||||
const char shellCmd##_name[] = #_name; \
|
||||
const char shellDesc##_name[] = #_desc; \
|
||||
const ShellCommand \
|
||||
shellCommand##_name SECTION("shellCommand") = \
|
||||
SHELL_USED const ShellCommand \
|
||||
shellCommand##_name SHELL_SECTION("shellCommand") = \
|
||||
{ \
|
||||
.attr.value = _attr, \
|
||||
.data.cmd.name = shellCmd##_name, \
|
||||
@ -153,8 +165,8 @@
|
||||
#define SHELL_EXPORT_VAR(_attr, _name, _value, _desc) \
|
||||
const char shellCmd##_name[] = #_name; \
|
||||
const char shellDesc##_name[] = #_desc; \
|
||||
const ShellCommand \
|
||||
shellVar##_name SECTION("shellCommand") = \
|
||||
SHELL_USED const ShellCommand \
|
||||
shellVar##_name SHELL_SECTION("shellCommand") = \
|
||||
{ \
|
||||
.attr.value = _attr, \
|
||||
.data.var.name = shellCmd##_name, \
|
||||
@ -174,8 +186,8 @@
|
||||
const char shellCmd##_name[] = #_name; \
|
||||
const char shellPassword##_name[] = #_password; \
|
||||
const char shellDesc##_name[] = #_desc; \
|
||||
const ShellCommand \
|
||||
shellUser##_name SECTION("shellCommand") = \
|
||||
SHELL_USED const ShellCommand \
|
||||
shellUser##_name SHELL_SECTION("shellCommand") = \
|
||||
{ \
|
||||
.attr.value = _attr|SHELL_CMD_TYPE(SHELL_TYPE_USER), \
|
||||
.data.user.name = shellCmd##_name, \
|
||||
@ -193,8 +205,8 @@
|
||||
*/
|
||||
#define SHELL_EXPORT_KEY(_attr, _value, _func, _desc) \
|
||||
const char shellDesc##_value[] = #_desc; \
|
||||
const ShellCommand \
|
||||
shellKey##_value SECTION("shellCommand") = \
|
||||
SHELL_USED const ShellCommand \
|
||||
shellKey##_value SHELL_SECTION("shellCommand") = \
|
||||
{ \
|
||||
.attr.value = _attr|SHELL_CMD_TYPE(SHELL_TYPE_KEY), \
|
||||
.data.key.value = _value, \
|
||||
|
@ -125,6 +125,12 @@
|
||||
*/
|
||||
#define SHELL_GET_TICK() 0
|
||||
|
||||
/**
|
||||
* @brief 使用锁
|
||||
* @note 使用shell锁时,需要对加锁和解锁进行实现
|
||||
*/
|
||||
#define SHELL_USING_LOCK 0
|
||||
|
||||
/**
|
||||
* @brief shell内存分配
|
||||
* shell本身不需要此接口,若使用shell伴生对象,需要进行定义
|
||||
|
Loading…
x
Reference in New Issue
Block a user