[PATCH] score: Fix legacy RTEMS_STATIC_ASSERT()
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Oct 5 06:31:31 UTC 2018
In standard C pointer operands are not allowed in integer constant
expression. Avoid a static assertion based on an array typedef since
this could lead to warnings ("variably modified 'x' at file scope" and
"typedef 'x' locally defined but not used");
This implementation requires unique messages.
---
cpukit/include/rtems/score/basedefs.h | 3 ++-
cpukit/include/rtems/score/threadqimpl.h | 4 ++--
cpukit/posix/src/mqueuerecvsupp.c | 3 ++-
cpukit/posix/src/mutexinit.c | 2 +-
cpukit/rtems/src/barrierwait.c | 6 +++++-
cpukit/rtems/src/msgqreceive.c | 6 +++++-
cpukit/rtems/src/semobtain.c | 12 ++++++++----
7 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/cpukit/include/rtems/score/basedefs.h b/cpukit/include/rtems/score/basedefs.h
index fd803e1b45..0a2bf8dd17 100644
--- a/cpukit/include/rtems/score/basedefs.h
+++ b/cpukit/include/rtems/score/basedefs.h
@@ -317,7 +317,8 @@
_Static_assert(cond, # msg)
#else
#define RTEMS_STATIC_ASSERT(cond, msg) \
- typedef int rtems_static_assert_ ## msg [(cond) ? 1 : -1]
+ struct rtems_static_assert_ ## msg \
+ { int rtems_static_assert_ ## msg : (cond) ? 1 : -1; }
#endif
#define RTEMS_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
diff --git a/cpukit/include/rtems/score/threadqimpl.h b/cpukit/include/rtems/score/threadqimpl.h
index ecbd8fd42f..8d537cc9e3 100644
--- a/cpukit/include/rtems/score/threadqimpl.h
+++ b/cpukit/include/rtems/score/threadqimpl.h
@@ -1207,7 +1207,7 @@ typedef struct {
Thread_queue_Control Wait_queue;
} Thread_queue_Object;
-#define THREAD_QUEUE_OBJECT_ASSERT( object_type, wait_queue_member ) \
+#define THREAD_QUEUE_OBJECT_ASSERT( object_type, wait_queue_member, msg ) \
RTEMS_STATIC_ASSERT( \
offsetof( object_type, wait_queue_member ) \
== offsetof( Thread_queue_Object, Wait_queue ) \
@@ -1217,7 +1217,7 @@ typedef struct {
Thread_queue_Object, \
Wait_queue \
), \
- object_type \
+ msg \
)
#define THREAD_QUEUE_QUEUE_TO_OBJECT( queue ) \
diff --git a/cpukit/posix/src/mqueuerecvsupp.c b/cpukit/posix/src/mqueuerecvsupp.c
index c6d1805214..062bd50dbf 100644
--- a/cpukit/posix/src/mqueuerecvsupp.c
+++ b/cpukit/posix/src/mqueuerecvsupp.c
@@ -25,7 +25,8 @@
THREAD_QUEUE_OBJECT_ASSERT(
POSIX_Message_queue_Control,
- Message_queue.Wait_queue
+ Message_queue.Wait_queue,
+ POSIX_MESSAGE_QUEUE_CONTROL
);
/*
diff --git a/cpukit/posix/src/mutexinit.c b/cpukit/posix/src/mutexinit.c
index 2d3857da75..45688eec1a 100644
--- a/cpukit/posix/src/mutexinit.c
+++ b/cpukit/posix/src/mutexinit.c
@@ -40,7 +40,7 @@ RTEMS_STATIC_ASSERT(
RTEMS_STATIC_ASSERT(
offsetof( POSIX_Mutex_Control, Priority_ceiling )
== offsetof( pthread_mutex_t, _Priority_ceiling ),
- POSIX_MUTEX_CONTROL_SCHEDULER
+ POSIX_MUTEX_CONTROL_PRIORITY_CEILING
);
RTEMS_STATIC_ASSERT(
diff --git a/cpukit/rtems/src/barrierwait.c b/cpukit/rtems/src/barrierwait.c
index 4811c218b8..f30f152abe 100644
--- a/cpukit/rtems/src/barrierwait.c
+++ b/cpukit/rtems/src/barrierwait.c
@@ -21,7 +21,11 @@
#include <rtems/rtems/barrierimpl.h>
#include <rtems/rtems/statusimpl.h>
-THREAD_QUEUE_OBJECT_ASSERT( Barrier_Control, Barrier.Wait_queue );
+THREAD_QUEUE_OBJECT_ASSERT(
+ Barrier_Control,
+ Barrier.Wait_queue,
+ BARRIER_CONTROL
+);
rtems_status_code rtems_barrier_wait(
rtems_id id,
diff --git a/cpukit/rtems/src/msgqreceive.c b/cpukit/rtems/src/msgqreceive.c
index 2304be735a..606454d7c4 100644
--- a/cpukit/rtems/src/msgqreceive.c
+++ b/cpukit/rtems/src/msgqreceive.c
@@ -22,7 +22,11 @@
#include <rtems/rtems/optionsimpl.h>
#include <rtems/rtems/statusimpl.h>
-THREAD_QUEUE_OBJECT_ASSERT( Message_queue_Control, message_queue.Wait_queue );
+THREAD_QUEUE_OBJECT_ASSERT(
+ Message_queue_Control,
+ message_queue.Wait_queue,
+ MESSAGE_QUEUE_CONTROL
+);
rtems_status_code rtems_message_queue_receive(
rtems_id id,
diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c
index db0c3f2e0c..2f73166df0 100644
--- a/cpukit/rtems/src/semobtain.c
+++ b/cpukit/rtems/src/semobtain.c
@@ -24,23 +24,27 @@
THREAD_QUEUE_OBJECT_ASSERT(
Semaphore_Control,
- Core_control.Wait_queue
+ Core_control.Wait_queue,
+ SEMAPHORE_CONTROL_GENERIC
);
THREAD_QUEUE_OBJECT_ASSERT(
Semaphore_Control,
- Core_control.Mutex.Recursive.Mutex.Wait_queue
+ Core_control.Mutex.Recursive.Mutex.Wait_queue,
+ SEMAPHORE_CONTROL_MUTEX
);
THREAD_QUEUE_OBJECT_ASSERT(
Semaphore_Control,
- Core_control.Semaphore.Wait_queue
+ Core_control.Semaphore.Wait_queue,
+ SEMAPHORE_CONTROL_SEMAPHORE
);
#if defined(RTEMS_SMP)
THREAD_QUEUE_OBJECT_ASSERT(
Semaphore_Control,
- Core_control.MRSP.Wait_queue
+ Core_control.MRSP.Wait_queue,
+ SEMAPHORE_CONTROL_MRSP
);
#endif
--
2.16.4
More information about the devel
mailing list