summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorWillianChan 陈威廉 <[email protected]>2022-02-14 14:03:34 +0800
committerGitHub <[email protected]>2022-02-14 14:03:34 +0800
commit49ccbdb85199a6aa33b559856e6ed9e4328e62b9 (patch)
treeb6cc20f1ab835bd6521f1a5fdc634fd65b83a9f6 /components
parenta1d1f95338ee5972b674bb3a6827cdd07761a63f (diff)
[fix][components][utilities]adjust the order of compiler macros (#5593)
* [fix][components][utilities]adjust the order of compiler macros Signed-off-by: WillianChan <[email protected]> * [modify][components][utilities]This PR complies with RT-Thread code specification Signed-off-by: WillianChan <[email protected]>
Diffstat (limited to 'components')
-rw-r--r--components/utilities/var_export/var_export.c10
-rw-r--r--components/utilities/var_export/var_export.h20
-rw-r--r--components/utilities/var_export/var_export_cmd.c2
3 files changed, 16 insertions, 16 deletions
diff --git a/components/utilities/var_export/var_export.c b/components/utilities/var_export/var_export.c
index 1e54f39362..0a6275c180 100644
--- a/components/utilities/var_export/var_export.c
+++ b/components/utilities/var_export/var_export.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -43,17 +43,17 @@ RT_USED const struct ve_exporter __ve_table_end = { "ve_end", "ve_end", 2};
int var_export_init(void)
{
/* 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_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 */
extern const int __ve_table_start;
extern const int __ve_table_end;
ve_exporter_table = (const ve_exporter_t *)&__ve_table_start;
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 */
unsigned int *ptr_begin = (unsigned int *)&__ve_table_start;
unsigned int *ptr_end = (unsigned int *)&__ve_table_end;
diff --git a/components/utilities/var_export/var_export.h b/components/utilities/var_export/var_export.h
index 4bab33e957..6e147e8201 100644
--- a/components/utilities/var_export/var_export.h
+++ b/components/utilities/var_export/var_export.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -42,35 +42,35 @@ typedef struct ve_iterator ve_iterator_t;
#define VE_NOT_FOUND (0xFFFFFFFFu) /* not found */
/* exporter's export command */
-#if defined(__GNUC__)
+#if defined(__ARMCC_VERSION) || defined(__IAR_SYSTEMS_ICC__)
#define VAR_EXPORT(module, identi, value) \
const char _vexp_##identi##_module[] RT_SECTION(".rodata.vexp") = #module; \
const char _vexp_##identi##_identi[] RT_SECTION(".rodata.vexp") = #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##_identi, \
value, \
}
-#elif defined(_MSC_VER)
-#pragma section("VarExpTab$f",read)
+#elif defined(__GNUC__)
#define VAR_EXPORT(module, identi, value) \
const char _vexp_##identi##_module[] RT_SECTION(".rodata.vexp") = #module; \
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##_identi, \
value, \
}
-#else
+#elif defined(_MSC_VER)
+#pragma section("VarExpTab$f",read)
#define VAR_EXPORT(module, identi, value) \
const char _vexp_##identi##_module[] RT_SECTION(".rodata.vexp") = #module; \
const char _vexp_##identi##_identi[] RT_SECTION(".rodata.vexp") = #identi; \
- RT_USED const struct ve_exporter _vexp_##module##identi \
- RT_SECTION("1."#module".VarExpTab."#identi) = \
+ __declspec(allocate("VarExpTab$f")) \
+ RT_USED const struct ve_exporter _vexp_##module##identi = \
{ \
_vexp_##identi##_module, \
_vexp_##identi##_identi, \
diff --git a/components/utilities/var_export/var_export_cmd.c b/components/utilities/var_export/var_export_cmd.c
index fba3cc92bb..1d684c840e 100644
--- a/components/utilities/var_export/var_export_cmd.c
+++ b/components/utilities/var_export/var_export_cmd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*