未验证 提交 49ccbdb8 编写于 作者: W WillianChan 陈威廉 提交者: GitHub

[fix][components][utilities]adjust the order of compiler macros (#5593)

* [fix][components][utilities]adjust the order of compiler macros
Signed-off-by: NWillianChan <chentingwei@rt-thread.com>

* [modify][components][utilities]This PR complies with RT-Thread code specification
Signed-off-by: NWillianChan <chentingwei@rt-thread.com>
上级 a1d1f953
/* /*
* Copyright (c) 2006-2021, RT-Thread Development Team * Copyright (c) 2006-2022, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
...@@ -43,17 +43,17 @@ RT_USED const struct ve_exporter __ve_table_end = { "ve_end", "ve_end", 2}; ...@@ -43,17 +43,17 @@ RT_USED const struct ve_exporter __ve_table_end = { "ve_end", "ve_end", 2};
int var_export_init(void) int var_export_init(void)
{ {
/* initialize the var export table.*/ /* initialize the var export table.*/
#if defined(__ARMCC_VERSION) /* for ARM C Compiler */ #if defined(__ARMCC_VERSION) /* for ARM C Compiler */
ve_exporter_table = &__ve_table_start + 1; ve_exporter_table = &__ve_table_start + 1;
ve_exporter_num = &__ve_table_end - &__ve_table_start; ve_exporter_num = &__ve_table_end - &__ve_table_start;
#elif defined (__IAR_SYSTEMS_ICC__) /* for IAR Compiler */
ve_exporter_table = &__ve_table_start + 1;
ve_exporter_num = &__ve_table_end - &__ve_table_start - 1;
#elif defined (__GNUC__) /* for GCC Compiler */ #elif defined (__GNUC__) /* for GCC Compiler */
extern const int __ve_table_start; extern const int __ve_table_start;
extern const int __ve_table_end; extern const int __ve_table_end;
ve_exporter_table = (const ve_exporter_t *)&__ve_table_start; ve_exporter_table = (const ve_exporter_t *)&__ve_table_start;
ve_exporter_num = (const ve_exporter_t *)&__ve_table_end - ve_exporter_table; ve_exporter_num = (const ve_exporter_t *)&__ve_table_end - ve_exporter_table;
#elif defined (__ICCARM__) || defined(__ICCRX__) /* for IAR Compiler */
ve_exporter_table = &__ve_table_start + 1;
ve_exporter_num = &__ve_table_end - &__ve_table_start - 1;
#elif defined (_MSC_VER) /* for MS VC++ compiler */ #elif defined (_MSC_VER) /* for MS VC++ compiler */
unsigned int *ptr_begin = (unsigned int *)&__ve_table_start; unsigned int *ptr_begin = (unsigned int *)&__ve_table_start;
unsigned int *ptr_end = (unsigned int *)&__ve_table_end; unsigned int *ptr_end = (unsigned int *)&__ve_table_end;
......
/* /*
* Copyright (c) 2006-2021, RT-Thread Development Team * Copyright (c) 2006-2022, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
...@@ -42,35 +42,35 @@ typedef struct ve_iterator ve_iterator_t; ...@@ -42,35 +42,35 @@ typedef struct ve_iterator ve_iterator_t;
#define VE_NOT_FOUND (0xFFFFFFFFu) /* not found */ #define VE_NOT_FOUND (0xFFFFFFFFu) /* not found */
/* exporter's export command */ /* exporter's export command */
#if defined(__GNUC__) #if defined(__ARMCC_VERSION) || defined(__IAR_SYSTEMS_ICC__)
#define VAR_EXPORT(module, identi, value) \ #define VAR_EXPORT(module, identi, value) \
const char _vexp_##identi##_module[] RT_SECTION(".rodata.vexp") = #module; \ const char _vexp_##identi##_module[] RT_SECTION(".rodata.vexp") = #module; \
const char _vexp_##identi##_identi[] RT_SECTION(".rodata.vexp") = #identi; \ const char _vexp_##identi##_identi[] RT_SECTION(".rodata.vexp") = #identi; \
RT_USED const struct ve_exporter _vexp_##module##identi \ RT_USED const struct ve_exporter _vexp_##module##identi \
RT_SECTION(#module".VarExpTab."#identi) = \ RT_SECTION("1."#module".VarExpTab."#identi) = \
{ \ { \
_vexp_##identi##_module, \ _vexp_##identi##_module, \
_vexp_##identi##_identi, \ _vexp_##identi##_identi, \
value, \ value, \
} }
#elif defined(_MSC_VER) #elif defined(__GNUC__)
#pragma section("VarExpTab$f",read)
#define VAR_EXPORT(module, identi, value) \ #define VAR_EXPORT(module, identi, value) \
const char _vexp_##identi##_module[] RT_SECTION(".rodata.vexp") = #module; \ const char _vexp_##identi##_module[] RT_SECTION(".rodata.vexp") = #module; \
const char _vexp_##identi##_identi[] RT_SECTION(".rodata.vexp") = #identi; \ const char _vexp_##identi##_identi[] RT_SECTION(".rodata.vexp") = #identi; \
__declspec(allocate("VarExpTab$f")) \ RT_USED const struct ve_exporter _vexp_##module##identi \
RT_USED const struct ve_exporter _vexp_##module##identi = \ RT_SECTION(#module".VarExpTab."#identi) = \
{ \ { \
_vexp_##identi##_module, \ _vexp_##identi##_module, \
_vexp_##identi##_identi, \ _vexp_##identi##_identi, \
value, \ value, \
} }
#else #elif defined(_MSC_VER)
#pragma section("VarExpTab$f",read)
#define VAR_EXPORT(module, identi, value) \ #define VAR_EXPORT(module, identi, value) \
const char _vexp_##identi##_module[] RT_SECTION(".rodata.vexp") = #module; \ const char _vexp_##identi##_module[] RT_SECTION(".rodata.vexp") = #module; \
const char _vexp_##identi##_identi[] RT_SECTION(".rodata.vexp") = #identi; \ const char _vexp_##identi##_identi[] RT_SECTION(".rodata.vexp") = #identi; \
RT_USED const struct ve_exporter _vexp_##module##identi \ __declspec(allocate("VarExpTab$f")) \
RT_SECTION("1."#module".VarExpTab."#identi) = \ RT_USED const struct ve_exporter _vexp_##module##identi = \
{ \ { \
_vexp_##identi##_module, \ _vexp_##identi##_module, \
_vexp_##identi##_identi, \ _vexp_##identi##_identi, \
......
/* /*
* Copyright (c) 2006-2021, RT-Thread Development Team * Copyright (c) 2006-2022, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册