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,7 +42,18 @@ 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("1."#module".VarExpTab."#identi) = \ + { \ + _vexp_##identi##_module, \ + _vexp_##identi##_identi, \ + value, \ + } +#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; \ @@ -65,17 +76,6 @@ typedef struct ve_iterator ve_iterator_t; _vexp_##identi##_identi, \ value, \ } -#else -#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) = \ - { \ - _vexp_##identi##_module, \ - _vexp_##identi##_identi, \ - value, \ - } #endif /* initialize var export */ 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 *