diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-18 07:25:23 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-18 15:36:58 +0100 |
commit | c904df573396d95957dc79b242b3a76911063089 (patch) | |
tree | be6406676689018e8af8a929b6a4ef5284f94c70 /cpukit/posix/src/semunlink.c | |
parent | sptests/sptls02: Use GNU++11 (diff) | |
download | rtems-c904df573396d95957dc79b242b3a76911063089.tar.bz2 |
score: Add _Objects_Get_by_name()
Replace _Objects_Name_to_id_string() with _Objects_Get_by_name() since
all users of this function are interested in the object itself and not
the identifier.
Use the object allocator lock to protect the search.
Update #2555.
Diffstat (limited to 'cpukit/posix/src/semunlink.c')
-rw-r--r-- | cpukit/posix/src/semunlink.c | 28 |
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; } |