summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/pbarrierdestroy.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-21 14:13:16 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-05 14:29:01 +0200
commite67929c4c0025ef46053523be4c8736dd178cbec (patch)
tree09fca2c6ff8369031b9e76d97872da12236e155a /cpukit/posix/src/pbarrierdestroy.c
parentposix: Implement self-contained POSIX semaphores (diff)
downloadrtems-e67929c4c0025ef46053523be4c8736dd178cbec.tar.bz2
posix: Implement self-contained POSIX barriers
POSIX barriers are now available in all configurations and no longer depend on --enable-posix. Update #2514. Update #3114.
Diffstat (limited to 'cpukit/posix/src/pbarrierdestroy.c')
-rw-r--r--cpukit/posix/src/pbarrierdestroy.c44
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;
}