summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/percpuasm.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-03-03 08:39:33 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-03-04 09:08:03 +0100
commit4a765b47a56cf9ba09c13381eb0cccd595e97cbd (patch)
treea41972abc8ee33b7d4b0e967f13d50282409fdd4 /cpukit/score/src/percpuasm.c
parentMAINTAINERS: Add myself to write after approval (diff)
downloadrtems-4a765b47a56cf9ba09c13381eb0cccd595e97cbd.tar.bz2
score: Enforce CPU_STACK_ALIGNMENT requirements
Clarify CPU_STACK_ALIGNMENT requirements in no_cpu port. Add static assertion to enforce CPU_STACK_ALIGNMENT requirements.
Diffstat (limited to 'cpukit/score/src/percpuasm.c')
-rw-r--r--cpukit/score/src/percpuasm.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/cpukit/score/src/percpuasm.c b/cpukit/score/src/percpuasm.c
index 9b0ce86c26..8414d3a7b4 100644
--- a/cpukit/score/src/percpuasm.c
+++ b/cpukit/score/src/percpuasm.c
@@ -30,29 +30,21 @@
#define _RTEMS_PERCPU_DEFINE_OFFSETS
#include <rtems/score/percpu.h>
+#define PER_CPU_IS_POWER_OF_TWO( value ) \
+ ( ( ( ( value ) - 1 ) & ( value ) ) == 0 )
+
/*
- * In case a CPU port needs another alignment, then add this here and make sure
- * it is a power of two greater than or equal to two.
+ * The minimum alignment of two is due to the Heap Handler which uses the
+ * HEAP_PREV_BLOCK_USED flag to indicate that the previous block is used.
*/
+
RTEMS_STATIC_ASSERT(
- CPU_ALIGNMENT == 2
- || CPU_ALIGNMENT == 4
- || CPU_ALIGNMENT == 8
- || CPU_ALIGNMENT == 16
- || CPU_ALIGNMENT == 32,
+ CPU_ALIGNMENT >= 2 && PER_CPU_IS_POWER_OF_TWO( CPU_ALIGNMENT ),
CPU_ALIGNMENT
);
-/*
- * In case a CPU port needs another heap alignment, then add this here and make
- * sure it is a power of two greater than or equal to two.
- */
RTEMS_STATIC_ASSERT(
- CPU_HEAP_ALIGNMENT == 2
- || CPU_HEAP_ALIGNMENT == 4
- || CPU_HEAP_ALIGNMENT == 8
- || CPU_HEAP_ALIGNMENT == 16
- || CPU_HEAP_ALIGNMENT == 32,
+ CPU_HEAP_ALIGNMENT >= 2 && PER_CPU_IS_POWER_OF_TWO( CPU_HEAP_ALIGNMENT ),
CPU_HEAP_ALIGNMENT_0
);
@@ -62,6 +54,12 @@ RTEMS_STATIC_ASSERT(
);
RTEMS_STATIC_ASSERT(
+ CPU_STACK_ALIGNMENT >= CPU_HEAP_ALIGNMENT &&
+ PER_CPU_IS_POWER_OF_TWO( CPU_STACK_ALIGNMENT ),
+ CPU_STACK_ALIGNMENT
+);
+
+RTEMS_STATIC_ASSERT(
sizeof(void *) == CPU_SIZEOF_POINTER,
CPU_SIZEOF_POINTER
);