summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/semunlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/posix/src/semunlink.c')
-rw-r--r--cpukit/posix/src/semunlink.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/cpukit/posix/src/semunlink.c b/cpukit/posix/src/semunlink.c
index 863d25801d..b8406185d4 100644
--- a/cpukit/posix/src/semunlink.c
+++ b/cpukit/posix/src/semunlink.c
@@ -18,15 +18,8 @@
#include "config.h"
#endif
-#include <stdarg.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
#include <semaphore.h>
-#include <limits.h>
-#include <rtems/system.h>
#include <rtems/posix/semaphoreimpl.h>
#include <rtems/seterr.h>
@@ -34,32 +27,21 @@ int sem_unlink(
const char *name
)
{
- int status;
- POSIX_Semaphore_Control *the_semaphore;
- Objects_Id the_semaphore_id;
- size_t name_len;
+ POSIX_Semaphore_Control *the_semaphore;
+ Objects_Get_by_name_error error;
_Objects_Allocator_lock();
- _Thread_Disable_dispatch();
- status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id, &name_len );
- if ( status != 0 ) {
- _Thread_Enable_dispatch();
+ the_semaphore = _POSIX_Semaphore_Get_by_name( name, NULL, &error );
+ if ( the_semaphore == NULL ) {
_Objects_Allocator_unlock();
- rtems_set_errno_and_return_minus_one( status );
+ rtems_set_errno_and_return_minus_one( _POSIX_Get_by_name_error( error ) );
}
- the_semaphore = (POSIX_Semaphore_Control *) _Objects_Get_local_object(
- &_POSIX_Semaphore_Information,
- _Objects_Get_index( the_semaphore_id )
- );
-
the_semaphore->linked = false;
_POSIX_Semaphore_Namespace_remove( the_semaphore );
_POSIX_Semaphore_Delete( the_semaphore );
- _Thread_Enable_dispatch();
_Objects_Allocator_unlock();
-
return 0;
}