score: Fix legacy RTEMS_STATIC_ASSERT()

In standard C pointer operands are not allowed in integer constant
expressions.  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.
This commit is contained in:
Sebastian Huber
2018-10-05 08:11:09 +02:00
parent 51b3cbca11
commit 1d39e96470
7 changed files with 25 additions and 11 deletions

View File

@@ -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]))

View File

@@ -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 ) \

View File

@@ -25,7 +25,8 @@
THREAD_QUEUE_OBJECT_ASSERT(
POSIX_Message_queue_Control,
Message_queue.Wait_queue
Message_queue.Wait_queue,
POSIX_MESSAGE_QUEUE_CONTROL
);
/*

View File

@@ -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(

View File

@@ -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,

View File

@@ -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,

View File

@@ -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