Răsfoiți Sursa

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

* [fix][components][utilities]adjust the order of compiler macros

Signed-off-by: WillianChan <chentingwei@rt-thread.com>

* [modify][components][utilities]This PR complies with RT-Thread code specification

Signed-off-by: WillianChan <chentingwei@rt-thread.com>
WillianChan 陈威廉 3 ani în urmă
părinte
comite
49ccbdb851

+ 5 - 5
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;

+ 10 - 10
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,                                                \

+ 1 - 1
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
  *