[rtems commit] linker set: Allow adding any variable into content

Sebastian Huber sebh at rtems.org
Tue Aug 2 05:52:08 UTC 2016


Module:    rtems
Branch:    master
Commit:    5fe6d07ad5690e3d9c6445ca3a465a700a5a5015
Changeset: http://git.rtems.org/rtems/commit/?id=5fe6d07ad5690e3d9c6445ca3a465a700a5a5015

Author:    Christian Mauderer <Christian.Mauderer at embedded-brains.de>
Date:      Mon Aug  1 13:16:57 2016 +0200

linker set: Allow adding any variable into content

The newly created macro adds any kind of variable into a linker set. It
allows (for example) the 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 */




More information about the vc mailing list