diff options
Diffstat (limited to 'cpukit/posix/src/pbarrierdestroy.c')
-rw-r--r-- | cpukit/posix/src/pbarrierdestroy.c | 44 |
1 files changed, 11 insertions, 33 deletions
diff --git a/cpukit/posix/src/pbarrierdestroy.c b/cpukit/posix/src/pbarrierdestroy.c index 8f85762211..83d06318b5 100644 --- a/cpukit/posix/src/pbarrierdestroy.c +++ b/cpukit/posix/src/pbarrierdestroy.c @@ -9,6 +9,8 @@ * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * + * Copyright (c) 2017 embedded brains GmbH + * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rtems.org/license/LICENSE. @@ -20,47 +22,23 @@ #include <rtems/posix/barrierimpl.h> -/** - * This directive allows a thread to delete a barrier specified by - * the barrier id. The barrier is freed back to the inactive - * barrier chain. - * - * @param[in] barrier is the barrier id - * - * @return This method returns 0 if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -int pthread_barrier_destroy( - pthread_barrier_t *barrier -) +int pthread_barrier_destroy( pthread_barrier_t *_barrier ) { - POSIX_Barrier_Control *the_barrier; + POSIX_Barrier_Control *barrier; Thread_queue_Context queue_context; - if ( barrier == NULL ) { - return EINVAL; - } - - _Objects_Allocator_lock(); - the_barrier = _POSIX_Barrier_Get( barrier, &queue_context ); + POSIX_BARRIER_VALIDATE_OBJECT( _barrier ); - if ( the_barrier == NULL ) { - _Objects_Allocator_unlock(); - return EINVAL; - } + barrier = _POSIX_Barrier_Get( _barrier ); - _CORE_barrier_Acquire_critical( &the_barrier->Barrier, &queue_context ); + _POSIX_Barrier_Queue_acquire( barrier, &queue_context ); - if ( the_barrier->Barrier.number_of_waiting_threads != 0 ) { - _CORE_barrier_Release( &the_barrier->Barrier, &queue_context ); - _Objects_Allocator_unlock(); + if ( barrier->waiting_threads != 0 ) { + _POSIX_Barrier_Queue_release( barrier, &queue_context ); return EBUSY; } - _Objects_Close( &_POSIX_Barrier_Information, &the_barrier->Object ); - _CORE_barrier_Release( &the_barrier->Barrier, &queue_context ); - _POSIX_Barrier_Free( the_barrier ); - _Objects_Allocator_unlock(); + barrier->flags = 0; + _POSIX_Barrier_Queue_release( barrier, &queue_context ); return 0; } |