[PATCH 3/5] score: Move thread queue object support

Sebastian Huber sebastian.huber at embedded-brains.de
Tue May 24 12:07:13 UTC 2016


---
 cpukit/posix/src/condwaitsupp.c                |  7 ++-----
 cpukit/posix/src/mqueuerecvsupp.c              |  3 +--
 cpukit/posix/src/mutexlocksupp.c               |  2 +-
 cpukit/posix/src/pbarrierwait.c                |  3 +--
 cpukit/posix/src/prwlockwrlock.c               |  3 +--
 cpukit/posix/src/semaphorewaitsupp.c           |  6 +-----
 cpukit/rtems/src/barrierwait.c                 |  3 +--
 cpukit/rtems/src/msgqreceive.c                 |  6 +-----
 cpukit/rtems/src/semobtain.c                   |  5 ++---
 cpukit/score/include/rtems/score/threadimpl.h  | 20 -------------------
 cpukit/score/include/rtems/score/threadqimpl.h | 27 ++++++++++++++++++++++++++
 cpukit/score/src/threadwaitgetid.c             |  8 ++------
 12 files changed, 40 insertions(+), 53 deletions(-)

diff --git a/cpukit/posix/src/condwaitsupp.c b/cpukit/posix/src/condwaitsupp.c
index b578a5f..4f0ac3c 100644
--- a/cpukit/posix/src/condwaitsupp.c
+++ b/cpukit/posix/src/condwaitsupp.c
@@ -22,12 +22,9 @@
 #include <rtems/posix/muteximpl.h>
 #include <rtems/score/assert.h>
 #include <rtems/score/statesimpl.h>
-#include <rtems/score/threadimpl.h>
+#include <rtems/score/threaddispatch.h>
 
-THREAD_WAIT_QUEUE_OBJECT_ASSERT(
-  POSIX_Condition_variables_Control,
-  Wait_queue
-);
+THREAD_QUEUE_OBJECT_ASSERT( POSIX_Condition_variables_Control, Wait_queue );
 
 int _POSIX_Condition_variables_Wait_support(
   pthread_cond_t            *cond,
diff --git a/cpukit/posix/src/mqueuerecvsupp.c b/cpukit/posix/src/mqueuerecvsupp.c
index 1d7d527..b5a790a 100644
--- a/cpukit/posix/src/mqueuerecvsupp.c
+++ b/cpukit/posix/src/mqueuerecvsupp.c
@@ -19,11 +19,10 @@
 #endif
 
 #include <rtems/posix/mqueueimpl.h>
-#include <rtems/score/threadimpl.h>
 
 #include <fcntl.h>
 
-THREAD_WAIT_QUEUE_OBJECT_ASSERT(
+THREAD_QUEUE_OBJECT_ASSERT(
   POSIX_Message_queue_Control,
   Message_queue.Wait_queue
 );
diff --git a/cpukit/posix/src/mutexlocksupp.c b/cpukit/posix/src/mutexlocksupp.c
index 5c70857..0c70cf0 100644
--- a/cpukit/posix/src/mutexlocksupp.c
+++ b/cpukit/posix/src/mutexlocksupp.c
@@ -20,7 +20,7 @@
 
 #include <rtems/posix/muteximpl.h>
 
-THREAD_WAIT_QUEUE_OBJECT_ASSERT( POSIX_Mutex_Control, Mutex.Wait_queue );
+THREAD_QUEUE_OBJECT_ASSERT( POSIX_Mutex_Control, Mutex.Wait_queue );
 
 int _POSIX_Mutex_Lock_support(
   pthread_mutex_t   *mutex,
diff --git a/cpukit/posix/src/pbarrierwait.c b/cpukit/posix/src/pbarrierwait.c
index 9200dc0..150ece7 100644
--- a/cpukit/posix/src/pbarrierwait.c
+++ b/cpukit/posix/src/pbarrierwait.c
@@ -19,9 +19,8 @@
 #endif
 
 #include <rtems/posix/barrierimpl.h>
-#include <rtems/score/threadimpl.h>
 
-THREAD_WAIT_QUEUE_OBJECT_ASSERT( POSIX_Barrier_Control, Barrier.Wait_queue );
+THREAD_QUEUE_OBJECT_ASSERT( POSIX_Barrier_Control, Barrier.Wait_queue );
 
 /**
  * This directive allows a thread to wait at a barrier.
diff --git a/cpukit/posix/src/prwlockwrlock.c b/cpukit/posix/src/prwlockwrlock.c
index 635f376..5683163 100644
--- a/cpukit/posix/src/prwlockwrlock.c
+++ b/cpukit/posix/src/prwlockwrlock.c
@@ -24,9 +24,8 @@
 #include <errno.h>
 
 #include <rtems/posix/rwlockimpl.h>
-#include <rtems/score/threadimpl.h>
 
-THREAD_WAIT_QUEUE_OBJECT_ASSERT( POSIX_RWLock_Control, RWLock.Wait_queue );
+THREAD_QUEUE_OBJECT_ASSERT( POSIX_RWLock_Control, RWLock.Wait_queue );
 
 int pthread_rwlock_wrlock(
   pthread_rwlock_t  *rwlock
diff --git a/cpukit/posix/src/semaphorewaitsupp.c b/cpukit/posix/src/semaphorewaitsupp.c
index 02a2ae1..f08efa8 100644
--- a/cpukit/posix/src/semaphorewaitsupp.c
+++ b/cpukit/posix/src/semaphorewaitsupp.c
@@ -21,12 +21,8 @@
 #include <semaphore.h>
 
 #include <rtems/posix/semaphoreimpl.h>
-#include <rtems/score/threadimpl.h>
 
-THREAD_WAIT_QUEUE_OBJECT_ASSERT(
-  POSIX_Semaphore_Control,
-  Semaphore.Wait_queue
-);
+THREAD_QUEUE_OBJECT_ASSERT( POSIX_Semaphore_Control, Semaphore.Wait_queue );
 
 int _POSIX_Semaphore_Wait_support(
   sem_t             *sem,
diff --git a/cpukit/rtems/src/barrierwait.c b/cpukit/rtems/src/barrierwait.c
index b5f23d7..d9d3869 100644
--- a/cpukit/rtems/src/barrierwait.c
+++ b/cpukit/rtems/src/barrierwait.c
@@ -19,9 +19,8 @@
 #endif
 
 #include <rtems/rtems/barrierimpl.h>
-#include <rtems/score/threadimpl.h>
 
-THREAD_WAIT_QUEUE_OBJECT_ASSERT( Barrier_Control, Barrier.Wait_queue );
+THREAD_QUEUE_OBJECT_ASSERT( Barrier_Control, Barrier.Wait_queue );
 
 rtems_status_code rtems_barrier_wait(
   rtems_id        id,
diff --git a/cpukit/rtems/src/msgqreceive.c b/cpukit/rtems/src/msgqreceive.c
index 578b280..dada8df 100644
--- a/cpukit/rtems/src/msgqreceive.c
+++ b/cpukit/rtems/src/msgqreceive.c
@@ -19,13 +19,9 @@
 #endif
 
 #include <rtems/rtems/messageimpl.h>
-#include <rtems/score/threadimpl.h>
 #include <rtems/rtems/optionsimpl.h>
 
-THREAD_WAIT_QUEUE_OBJECT_ASSERT(
-  Message_queue_Control,
-  message_queue.Wait_queue
-);
+THREAD_QUEUE_OBJECT_ASSERT( Message_queue_Control, message_queue.Wait_queue );
 
 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 4340815..3cf780a 100644
--- a/cpukit/rtems/src/semobtain.c
+++ b/cpukit/rtems/src/semobtain.c
@@ -19,16 +19,15 @@
 #endif
 
 #include <rtems/rtems/semimpl.h>
-#include <rtems/score/threadimpl.h>
 #include <rtems/rtems/attrimpl.h>
 #include <rtems/rtems/optionsimpl.h>
 
-THREAD_WAIT_QUEUE_OBJECT_ASSERT(
+THREAD_QUEUE_OBJECT_ASSERT(
   Semaphore_Control,
   Core_control.mutex.Wait_queue
 );
 
-THREAD_WAIT_QUEUE_OBJECT_ASSERT(
+THREAD_QUEUE_OBJECT_ASSERT(
   Semaphore_Control,
   Core_control.semaphore.Wait_queue
 );
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index 0802730..cef2786 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -1464,26 +1464,6 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_set_timeout_code(
 }
 
 /**
- * @brief Helper structure to ensure that all objects containing a thread queue
- * have the right layout.
- *
- * @see _Thread_Wait_get_id() and THREAD_WAIT_QUEUE_OBJECT_ASSERT().
- */
-typedef struct {
-  Objects_Control      Object;
-  Thread_queue_Control Wait_queue;
-} Thread_Wait_queue_object;
-
-#define THREAD_WAIT_QUEUE_OBJECT_ASSERT( object_type, wait_queue_member ) \
-  RTEMS_STATIC_ASSERT( \
-    offsetof( object_type, wait_queue_member ) \
-      == offsetof( Thread_Wait_queue_object, Wait_queue ) \
-    && ( &( ( (object_type *) 0 )->wait_queue_member ) \
-      == ( &( (Thread_Wait_queue_object *) 0 )->Wait_queue ) ), \
-    object_type \
-  )
-
-/**
  * @brief Returns the object identifier of the object containing the current
  * thread wait queue.
  *
diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h
index 0c4e979..f24e48c 100644
--- a/cpukit/score/include/rtems/score/threadqimpl.h
+++ b/cpukit/score/include/rtems/score/threadqimpl.h
@@ -795,6 +795,33 @@ void _Thread_queue_Unblock_proxy(
 );
 #endif
 
+/**
+ * @brief Helper structure to ensure that all objects containing a thread queue
+ * have the right layout.
+ *
+ * @see _Thread_Wait_get_id() and THREAD_QUEUE_OBJECT_ASSERT().
+ */
+typedef struct {
+  Objects_Control      Object;
+  Thread_queue_Control Wait_queue;
+} Thread_queue_Object;
+
+#define THREAD_QUEUE_OBJECT_ASSERT( object_type, wait_queue_member ) \
+  RTEMS_STATIC_ASSERT( \
+    offsetof( object_type, wait_queue_member ) \
+      == offsetof( Thread_queue_Object, Wait_queue ) \
+    && ( &( ( (object_type *) 0 )->wait_queue_member ) \
+      == ( &( (Thread_queue_Object *) 0 )->Wait_queue ) ), \
+    object_type \
+  )
+
+#define THREAD_QUEUE_QUEUE_TO_OBJECT( queue ) \
+  RTEMS_CONTAINER_OF( \
+    queue, \
+    Thread_queue_Object, \
+    Wait_queue.Queue \
+  )
+
 extern const Thread_queue_Operations _Thread_queue_Operations_default;
 
 extern const Thread_queue_Operations _Thread_queue_Operations_FIFO;
diff --git a/cpukit/score/src/threadwaitgetid.c b/cpukit/score/src/threadwaitgetid.c
index 0851e8f..6c12fd6 100644
--- a/cpukit/score/src/threadwaitgetid.c
+++ b/cpukit/score/src/threadwaitgetid.c
@@ -39,13 +39,9 @@ Objects_Id _Thread_Wait_get_id( const Thread_Control *the_thread )
 #endif
 
   if ( ( current_state & THREAD_WAIT_QUEUE_OBJECT_STATES ) != 0 ) {
-    const Thread_Wait_queue_object *queue_object;
+    const Thread_queue_Object *queue_object;
 
-    queue_object = RTEMS_CONTAINER_OF(
-      the_thread->Wait.queue,
-      Thread_Wait_queue_object,
-      Wait_queue.Queue
-    );
+    queue_object = THREAD_QUEUE_QUEUE_TO_OBJECT( the_thread->Wait.queue );
 
     return queue_object->Object.id;
   }
-- 
1.8.4.5




More information about the devel mailing list