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
This commit is contained in:
Christian Mauderer
2016-08-02 07:47:04 +02:00
committed by Sebastian Huber
parent 501b11baab
commit 5fe6d07ad5
5 changed files with 56 additions and 0 deletions
+8
View File
@@ -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 */
+24
View File
@@ -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);
@@ -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;
+4
View File
@@ -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);
@@ -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 */