forked from Imagelibrary/rtems
score: Move thread queue object support
This commit is contained in:
@@ -22,12 +22,9 @@
|
|||||||
#include <rtems/posix/muteximpl.h>
|
#include <rtems/posix/muteximpl.h>
|
||||||
#include <rtems/score/assert.h>
|
#include <rtems/score/assert.h>
|
||||||
#include <rtems/score/statesimpl.h>
|
#include <rtems/score/statesimpl.h>
|
||||||
#include <rtems/score/threadimpl.h>
|
#include <rtems/score/threaddispatch.h>
|
||||||
|
|
||||||
THREAD_WAIT_QUEUE_OBJECT_ASSERT(
|
THREAD_QUEUE_OBJECT_ASSERT( POSIX_Condition_variables_Control, Wait_queue );
|
||||||
POSIX_Condition_variables_Control,
|
|
||||||
Wait_queue
|
|
||||||
);
|
|
||||||
|
|
||||||
int _POSIX_Condition_variables_Wait_support(
|
int _POSIX_Condition_variables_Wait_support(
|
||||||
pthread_cond_t *cond,
|
pthread_cond_t *cond,
|
||||||
|
|||||||
@@ -19,11 +19,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <rtems/posix/mqueueimpl.h>
|
#include <rtems/posix/mqueueimpl.h>
|
||||||
#include <rtems/score/threadimpl.h>
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
THREAD_WAIT_QUEUE_OBJECT_ASSERT(
|
THREAD_QUEUE_OBJECT_ASSERT(
|
||||||
POSIX_Message_queue_Control,
|
POSIX_Message_queue_Control,
|
||||||
Message_queue.Wait_queue
|
Message_queue.Wait_queue
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <rtems/posix/muteximpl.h>
|
#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(
|
int _POSIX_Mutex_Lock_support(
|
||||||
pthread_mutex_t *mutex,
|
pthread_mutex_t *mutex,
|
||||||
|
|||||||
@@ -19,9 +19,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <rtems/posix/barrierimpl.h>
|
#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.
|
* This directive allows a thread to wait at a barrier.
|
||||||
|
|||||||
@@ -24,9 +24,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <rtems/posix/rwlockimpl.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(
|
int pthread_rwlock_wrlock(
|
||||||
pthread_rwlock_t *rwlock
|
pthread_rwlock_t *rwlock
|
||||||
|
|||||||
@@ -21,12 +21,8 @@
|
|||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
|
||||||
#include <rtems/posix/semaphoreimpl.h>
|
#include <rtems/posix/semaphoreimpl.h>
|
||||||
#include <rtems/score/threadimpl.h>
|
|
||||||
|
|
||||||
THREAD_WAIT_QUEUE_OBJECT_ASSERT(
|
THREAD_QUEUE_OBJECT_ASSERT( POSIX_Semaphore_Control, Semaphore.Wait_queue );
|
||||||
POSIX_Semaphore_Control,
|
|
||||||
Semaphore.Wait_queue
|
|
||||||
);
|
|
||||||
|
|
||||||
int _POSIX_Semaphore_Wait_support(
|
int _POSIX_Semaphore_Wait_support(
|
||||||
sem_t *sem,
|
sem_t *sem,
|
||||||
|
|||||||
@@ -19,9 +19,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <rtems/rtems/barrierimpl.h>
|
#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_status_code rtems_barrier_wait(
|
||||||
rtems_id id,
|
rtems_id id,
|
||||||
|
|||||||
@@ -19,13 +19,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <rtems/rtems/messageimpl.h>
|
#include <rtems/rtems/messageimpl.h>
|
||||||
#include <rtems/score/threadimpl.h>
|
|
||||||
#include <rtems/rtems/optionsimpl.h>
|
#include <rtems/rtems/optionsimpl.h>
|
||||||
|
|
||||||
THREAD_WAIT_QUEUE_OBJECT_ASSERT(
|
THREAD_QUEUE_OBJECT_ASSERT( Message_queue_Control, message_queue.Wait_queue );
|
||||||
Message_queue_Control,
|
|
||||||
message_queue.Wait_queue
|
|
||||||
);
|
|
||||||
|
|
||||||
rtems_status_code rtems_message_queue_receive(
|
rtems_status_code rtems_message_queue_receive(
|
||||||
rtems_id id,
|
rtems_id id,
|
||||||
|
|||||||
@@ -19,16 +19,15 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <rtems/rtems/semimpl.h>
|
#include <rtems/rtems/semimpl.h>
|
||||||
#include <rtems/score/threadimpl.h>
|
|
||||||
#include <rtems/rtems/attrimpl.h>
|
#include <rtems/rtems/attrimpl.h>
|
||||||
#include <rtems/rtems/optionsimpl.h>
|
#include <rtems/rtems/optionsimpl.h>
|
||||||
|
|
||||||
THREAD_WAIT_QUEUE_OBJECT_ASSERT(
|
THREAD_QUEUE_OBJECT_ASSERT(
|
||||||
Semaphore_Control,
|
Semaphore_Control,
|
||||||
Core_control.mutex.Wait_queue
|
Core_control.mutex.Wait_queue
|
||||||
);
|
);
|
||||||
|
|
||||||
THREAD_WAIT_QUEUE_OBJECT_ASSERT(
|
THREAD_QUEUE_OBJECT_ASSERT(
|
||||||
Semaphore_Control,
|
Semaphore_Control,
|
||||||
Core_control.semaphore.Wait_queue
|
Core_control.semaphore.Wait_queue
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1463,26 +1463,6 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_set_timeout_code(
|
|||||||
the_thread->Wait.timeout_code = 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
|
* @brief Returns the object identifier of the object containing the current
|
||||||
* thread wait queue.
|
* thread wait queue.
|
||||||
|
|||||||
@@ -795,6 +795,33 @@ void _Thread_queue_Unblock_proxy(
|
|||||||
);
|
);
|
||||||
#endif
|
#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_default;
|
||||||
|
|
||||||
extern const Thread_queue_Operations _Thread_queue_Operations_FIFO;
|
extern const Thread_queue_Operations _Thread_queue_Operations_FIFO;
|
||||||
|
|||||||
@@ -39,13 +39,9 @@ Objects_Id _Thread_Wait_get_id( const Thread_Control *the_thread )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( ( current_state & THREAD_WAIT_QUEUE_OBJECT_STATES ) != 0 ) {
|
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(
|
queue_object = THREAD_QUEUE_QUEUE_TO_OBJECT( the_thread->Wait.queue );
|
||||||
the_thread->Wait.queue,
|
|
||||||
Thread_Wait_queue_object,
|
|
||||||
Wait_queue.Queue
|
|
||||||
);
|
|
||||||
|
|
||||||
return queue_object->Object.id;
|
return queue_object->Object.id;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user