[PATCH v2] linker set: Allow adding any variable into content

Gedare Bloom gedare at rtems.org
Mon Aug 1 15:38:46 UTC 2016


The code looks fine, but I don't quite understand the
purpose/usefulness of the change.

On Mon, Aug 1, 2016 at 7:16 AM, Christian Mauderer
<christian.mauderer at embedded-brains.de> wrote:
> From: Christian Mauderer <Christian.Mauderer at embedded-brains.de>
>
> The newly created macro allows to add any kind of variable into the
> content of a linker set. This allows (for example) saving an execution
> state of a function using the following method:
>
> - put a group of different variables into one linker set
> - save the memory area containing the group of variables before the
>   execution of a function
> - restore the memory area after the function has been executed
> ---
>  cpukit/score/include/rtems/linkersets.h            |  8 ++++++++
>  testsuites/sptests/splinkersets01/init.c           | 24 ++++++++++++++++++++++
>  testsuites/sptests/splinkersets01/items.c          |  8 ++++++++
>  testsuites/sptests/splinkersets01/sets.c           |  4 ++++
>  testsuites/sptests/splinkersets01/splinkersets01.h | 12 +++++++++++
>  5 files changed, 56 insertions(+)
>
> diff --git a/cpukit/score/include/rtems/linkersets.h b/cpukit/score/include/rtems/linkersets.h
> index e40be66..47c210d 100644
> --- a/cpukit/score/include/rtems/linkersets.h
> +++ b/cpukit/score/include/rtems/linkersets.h
> @@ -57,6 +57,10 @@ extern "C" {
>    type volatile const _Linker_set_##set##_##item \
>    RTEMS_SECTION( ".rtemsroset." #set ".content.1" ) RTEMS_USED
>
> +#define RTEMS_LINKER_ROSET_CONTENT( set, decl ) \
> +  decl \
> +  RTEMS_SECTION( ".rtemsroset." #set ".content" )
> +
>  #define RTEMS_LINKER_RWSET_DECLARE( set, type ) \
>    extern type volatile RTEMS_LINKER_SET_BEGIN( set )[0]; \
>    extern type volatile RTEMS_LINKER_SET_END( set )[0]
> @@ -89,6 +93,10 @@ extern "C" {
>    type volatile _Linker_set_##set##_##item \
>    RTEMS_SECTION( ".rtemsrwset." #set ".content.1" ) RTEMS_USED
>
> +#define RTEMS_LINKER_RWSET_CONTENT( set, decl ) \
> +  decl \
> +  RTEMS_SECTION( ".rtemsrwset." #set ".content" )
> +
>  #ifdef __cplusplus
>  }
>  #endif /* __cplusplus */
> diff --git a/testsuites/sptests/splinkersets01/init.c b/testsuites/sptests/splinkersets01/init.c
> index 3d35a4e..28c6384 100644
> --- a/testsuites/sptests/splinkersets01/init.c
> +++ b/testsuites/sptests/splinkersets01/init.c
> @@ -130,11 +130,35 @@ static void test(void)
>    rtems_test_assert(&s2 == sb[2]);
>  }
>
> +static void test_content(void)
> +{
> +  void volatile *b_rw = RTEMS_LINKER_SET_BEGIN(test_content_rw);
> +  void volatile *e_rw = RTEMS_LINKER_SET_END(test_content_rw);
> +
> +  void volatile const *b_ro = RTEMS_LINKER_SET_BEGIN(test_content_ro);
> +  void volatile const *e_ro = RTEMS_LINKER_SET_END(test_content_ro);
> +
> +  rtems_test_assert(&content_rw_1 >= b_rw);
> +  rtems_test_assert(&content_rw_2 >= b_rw);
> +  rtems_test_assert(&content_rw_3 >= b_rw);
> +  rtems_test_assert(&content_rw_1 <= e_rw);
> +  rtems_test_assert(&content_rw_2 <= e_rw);
> +  rtems_test_assert(&content_rw_3 <= e_rw);
> +
> +  rtems_test_assert(&content_ro_1 >= b_ro);
> +  rtems_test_assert(&content_ro_2 >= b_ro);
> +  rtems_test_assert(&content_ro_3 >= b_ro);
> +  rtems_test_assert(&content_ro_1 <= e_ro);
> +  rtems_test_assert(&content_ro_2 <= e_ro);
> +  rtems_test_assert(&content_ro_3 <= e_ro);
> +}
> +
>  static void Init(rtems_task_argument arg)
>  {
>    TEST_BEGIN();
>
>    test();
> +  test_content();
>
>    TEST_END();
>    rtems_test_exit(0);
> diff --git a/testsuites/sptests/splinkersets01/items.c b/testsuites/sptests/splinkersets01/items.c
> index 7ca6f53..fde102a 100644
> --- a/testsuites/sptests/splinkersets01/items.c
> +++ b/testsuites/sptests/splinkersets01/items.c
> @@ -21,3 +21,11 @@
>  RTEMS_LINKER_RWSET_ITEM_ORDERED(test_rw, const int *, a1, 1) = &a[1];
>
>  RTEMS_LINKER_ROSET_ITEM_ORDERED(test_ro, const int *, ca2, OC) = &ca[2];
> +
> +int content_rw_1;
> +char content_rw_2;
> +char content_rw_3;
> +
> +const int content_ro_1;
> +const char content_ro_2;
> +const char content_ro_3;
> diff --git a/testsuites/sptests/splinkersets01/sets.c b/testsuites/sptests/splinkersets01/sets.c
> index 0cc1993..1061379 100644
> --- a/testsuites/sptests/splinkersets01/sets.c
> +++ b/testsuites/sptests/splinkersets01/sets.c
> @@ -21,3 +21,7 @@
>  RTEMS_LINKER_RWSET(test_rw, const int *);
>
>  RTEMS_LINKER_ROSET(test_ro, const int *);
> +
> +RTEMS_LINKER_RWSET(test_content_rw, char);
> +
> +RTEMS_LINKER_ROSET(test_content_ro, char);
> diff --git a/testsuites/sptests/splinkersets01/splinkersets01.h b/testsuites/sptests/splinkersets01/splinkersets01.h
> index 5da8ec6..0339154 100644
> --- a/testsuites/sptests/splinkersets01/splinkersets01.h
> +++ b/testsuites/sptests/splinkersets01/splinkersets01.h
> @@ -29,10 +29,22 @@ RTEMS_LINKER_RWSET_DECLARE(test_rw, const int *);
>
>  RTEMS_LINKER_ROSET_DECLARE(test_ro, const int *);
>
> +RTEMS_LINKER_RWSET_DECLARE(test_content_rw, char);
> +
> +RTEMS_LINKER_ROSET_DECLARE(test_content_ro, char);
> +
>  RTEMS_LINKER_RWSET_ITEM_DECLARE(test_rw, const int *, a1);
>
>  RTEMS_LINKER_ROSET_ITEM_DECLARE(test_ro, const int *, ca2);
>
> +RTEMS_LINKER_RWSET_CONTENT(test_content_rw, extern int content_rw_1);
> +RTEMS_LINKER_RWSET_CONTENT(test_content_rw, extern char content_rw_2);
> +RTEMS_LINKER_RWSET_CONTENT(test_content_rw, extern char content_rw_3);
> +
> +RTEMS_LINKER_ROSET_CONTENT(test_content_ro, extern const int content_ro_1);
> +RTEMS_LINKER_ROSET_CONTENT(test_content_ro, extern const char content_ro_2);
> +RTEMS_LINKER_ROSET_CONTENT(test_content_ro, extern const char content_ro_3);
> +
>  #ifdef __cplusplus
>  }
>  #endif /* __cplusplus */
> --
> 2.9.2
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list