summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-09-10 11:47:24 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-09-10 12:01:50 +0200
commit1fe1b820de02c274c2b2b3431340152734ee9fb6 (patch)
tree27100a93af1ce3764ffd9178ede2bcafd842b77a
parente58f1cd381edf890c8021f7a7bd2a3428d4da30d (diff)
downloadrtems-1fe1b820de02c274c2b2b3431340152734ee9fb6.tar.bz2
score: Fix PER_CPU_DATA_GET_BY_OFFSET()
Add uniprocessor version for PER_CPU_DATA_GET_BY_OFFSET(). Fix warnings in uniprocessor configurations. Update #3507.
-rw-r--r--cpukit/include/rtems/score/percpudata.h8
-rw-r--r--testsuites/sptests/sppercpudata01/init.c10
2 files changed, 17 insertions, 1 deletions
diff --git a/cpukit/include/rtems/score/percpudata.h b/cpukit/include/rtems/score/percpudata.h
index 3de99566ad..fe29fd9fba 100644
--- a/cpukit/include/rtems/score/percpudata.h
+++ b/cpukit/include/rtems/score/percpudata.h
@@ -76,8 +76,14 @@ RTEMS_LINKER_RWSET_DECLARE( _Per_CPU_Data, char );
* @param type The type of the item.
* @param offset The offset of the item.
*/
+#ifdef RTEMS_SMP
#define PER_CPU_DATA_GET_BY_OFFSET( cpu, type, offset ) \
(type *) ( cpu->data + offset )
+#else
+#define PER_CPU_DATA_GET_BY_OFFSET( cpu, type, offset ) \
+ (type *) ( (uintptr_t) RTEMS_LINKER_SET_BEGIN( _Per_CPU_Data ) + offset ), \
+ (void) cpu
+#endif
/**
* @brief Returns a pointer of the specified type to the specified per-CPU item
@@ -92,7 +98,7 @@ RTEMS_LINKER_RWSET_DECLARE( _Per_CPU_Data, char );
PER_CPU_DATA_GET_BY_OFFSET( cpu, type, PER_CPU_DATA_OFFSET( item ) )
#else
#define PER_CPU_DATA_GET( cpu, type, item ) \
- &_Linker_set__Per_CPU_Data_##item
+ &_Linker_set__Per_CPU_Data_##item, (void) cpu
#endif
/** @} */
diff --git a/testsuites/sptests/sppercpudata01/init.c b/testsuites/sptests/sppercpudata01/init.c
index 4c20ea7e2b..94f5185d4e 100644
--- a/testsuites/sptests/sppercpudata01/init.c
+++ b/testsuites/sptests/sppercpudata01/init.c
@@ -74,11 +74,16 @@ static void test_initial_values(void)
unsigned short *s;
unsigned int *i;
unsigned long *l;
+ uintptr_t off;
t *pt;
set_affinity(cpu_index);
cpu = _Per_CPU_Get_by_index(cpu_index);
+ off = PER_CPU_DATA_OFFSET(c);
+ c = PER_CPU_DATA_GET_BY_OFFSET(cpu, unsigned char, off);
+ rtems_test_assert(*c == 1);
+
c = PER_CPU_DATA_GET(cpu, unsigned char, c);
rtems_test_assert(*c == 1);
@@ -197,6 +202,7 @@ static void test_unique_values(unsigned int v)
unsigned short *s;
unsigned int *i;
unsigned long *l;
+ uintptr_t off;
t *pt;
set_affinity(cpu_index);
@@ -206,6 +212,10 @@ static void test_unique_values(unsigned int v)
++v;
rtems_test_assert(*c == (unsigned char) v);
+ off = PER_CPU_DATA_OFFSET(c);
+ c = PER_CPU_DATA_GET_BY_OFFSET(cpu, unsigned char, off);
+ rtems_test_assert(*c == (unsigned char) v);
+
c = PER_CPU_DATA_GET(cpu, unsigned char, cz);
++v;
rtems_test_assert(*c == (unsigned char) v);