summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/pbarrierdestroy.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cpukit/posix/src/pbarrierdestroy.c45
1 files changed, 18 insertions, 27 deletions
diff --git a/cpukit/posix/src/pbarrierdestroy.c b/cpukit/posix/src/pbarrierdestroy.c
index 4b9a0fdca9..709644bf4e 100644
--- a/cpukit/posix/src/pbarrierdestroy.c
+++ b/cpukit/posix/src/pbarrierdestroy.c
@@ -18,10 +18,6 @@
#include "config.h"
#endif
-#include <pthread.h>
-#include <errno.h>
-
-#include <rtems/system.h>
#include <rtems/posix/barrierimpl.h>
/**
@@ -39,37 +35,32 @@ int pthread_barrier_destroy(
pthread_barrier_t *barrier
)
{
- POSIX_Barrier_Control *the_barrier = NULL;
- Objects_Locations location;
+ POSIX_Barrier_Control *the_barrier;
+ ISR_lock_Context lock_context;
- if ( !barrier )
+ if ( barrier == NULL ) {
return EINVAL;
+ }
_Objects_Allocator_lock();
- the_barrier = _POSIX_Barrier_Get( barrier, &location );
- switch ( location ) {
+ the_barrier = _POSIX_Barrier_Get( barrier, &lock_context );
- case OBJECTS_LOCAL:
- if ( the_barrier->Barrier.number_of_waiting_threads != 0 ) {
- _Objects_Put( &the_barrier->Object );
- return EBUSY;
- }
-
- _Objects_Close( &_POSIX_Barrier_Information, &the_barrier->Object );
- _Objects_Put( &the_barrier->Object );
+ if ( the_barrier == NULL ) {
+ _Objects_Allocator_unlock();
+ return EINVAL;
+ }
- _POSIX_Barrier_Free( the_barrier );
- _Objects_Allocator_unlock();
- return 0;
+ _CORE_barrier_Acquire_critical( &the_barrier->Barrier, &lock_context );
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE:
-#endif
- case OBJECTS_ERROR:
- break;
+ if ( the_barrier->Barrier.number_of_waiting_threads != 0 ) {
+ _CORE_barrier_Release( &the_barrier->Barrier, &lock_context );
+ _Objects_Allocator_unlock();
+ return EBUSY;
}
+ _Objects_Close( &_POSIX_Barrier_Information, &the_barrier->Object );
+ _CORE_barrier_Release( &the_barrier->Barrier, &lock_context );
+ _POSIX_Barrier_Free( the_barrier );
_Objects_Allocator_unlock();
-
- return EINVAL;
+ return 0;
}