forked from Imagelibrary/rtems
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:
@@ -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]))
|
||||
|
||||
@@ -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 ) \
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
|
||||
THREAD_QUEUE_OBJECT_ASSERT(
|
||||
POSIX_Message_queue_Control,
|
||||
Message_queue.Wait_queue
|
||||
Message_queue.Wait_queue,
|
||||
POSIX_MESSAGE_QUEUE_CONTROL
|
||||
);
|
||||
|
||||
/*
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user