From 5222488573e3ba8c2eceffe29f878a73a3a81694 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 26 Sep 2017 07:49:17 +0200 Subject: posix: Implement self-contained POSIX condvar POSIX condition variables are now available in all configurations and no longer depend on --enable-posix. Update #2514. Update #3113. --- cpukit/posix/src/condsignalsupp.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'cpukit/posix/src/condsignalsupp.c') diff --git a/cpukit/posix/src/condsignalsupp.c b/cpukit/posix/src/condsignalsupp.c index e42476e1c4..1d9d4fc1ad 100644 --- a/cpukit/posix/src/condsignalsupp.c +++ b/cpukit/posix/src/condsignalsupp.c @@ -32,29 +32,30 @@ int _POSIX_Condition_variables_Signal_support( bool is_broadcast ) { - Thread_Control *the_thread; + POSIX_Condition_variables_Control *the_cond; + unsigned long flags; + const Thread_queue_Operations *operations; + Thread_queue_Heads *heads; - do { - POSIX_Condition_variables_Control *the_cond; - Thread_queue_Context queue_context; + the_cond = _POSIX_Condition_variables_Get( cond ); + POSIX_CONDITION_VARIABLES_VALIDATE_OBJECT( the_cond, flags ); + operations = POSIX_CONDITION_VARIABLES_TQ_OPERATIONS; - the_cond = _POSIX_Condition_variables_Get( cond, &queue_context ); + do { + Thread_queue_Context queue_context; - if ( the_cond == NULL ) { - return EINVAL; - } + _Thread_queue_Context_initialize( &queue_context ); + _POSIX_Condition_variables_Acquire( the_cond, &queue_context ); - _POSIX_Condition_variables_Acquire_critical( the_cond, &queue_context ); + heads = the_cond->Queue.Queue.heads; - the_thread = _Thread_queue_First_locked( - &the_cond->Wait_queue, - POSIX_CONDITION_VARIABLES_TQ_OPERATIONS - ); + if ( heads != NULL ) { + Thread_Control *the_thread; - if ( the_thread != NULL ) { + the_thread = ( *operations->first )( heads ); _Thread_queue_Extract_critical( - &the_cond->Wait_queue.Queue, - POSIX_CONDITION_VARIABLES_TQ_OPERATIONS, + &the_cond->Queue.Queue, + operations, the_thread, &queue_context ); @@ -62,7 +63,7 @@ int _POSIX_Condition_variables_Signal_support( the_cond->mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX; _POSIX_Condition_variables_Release( the_cond, &queue_context ); } - } while ( is_broadcast && the_thread != NULL ); + } while ( is_broadcast && heads != NULL ); return 0; } -- cgit v1.2.3