score: Move thread queue object support

This commit is contained in:
Sebastian Huber
2016-05-23 06:26:58 +02:00
parent 0e9d5b69cc
commit 8866e6222f
12 changed files with 40 additions and 53 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1463,26 +1463,6 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_set_timeout_code(
the_thread->Wait.timeout_code = 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.

View File

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

View File

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