source: rtems/cpukit/posix/src/semunlink.c @ b98d399f

4.115
Last change on this file since b98d399f was b98d399f, checked in by Sebastian Huber <sebastian.huber@…>, on 12/13/11 at 12:56:53

2011-12-13 Sebastian Huber <sebastian.huber@…>

  • posix/src/mqueuenametoid.c, posix/src/semaphorenametoid.c: Removed files.
  • posix/src/psxnametoid.c: New file.
  • posix/Makefile.am: Reflect changes above.
  • posix/include/rtems/posix/config.h: Fixed integer types.
  • posix/include/rtems/posix/posixapi.h: Declare _POSIX_Name_to_id().
  • posix/include/rtems/posix/mqueue.h, posix/inline/rtems/posix/mqueue.inl: Changed parameter of _POSIX_Message_queue_Create_support(). _POSIX_Message_queue_Name_to_id() is now inline.
  • posix/include/rtems/posix/semaphore.h, posix/inline/rtems/posix/semaphore.inl: Changed parameter of _POSIX_Semaphore_Create_support(). _POSIX_Semaphore_Name_to_id() is now inline.
  • posix/src/mqueuecreatesupp.c, posix/src/semaphorecreatesupp.c: Use _Workspace_String_duplicate().
  • posix/src/mqueuesendsupp.c, posix/src/mqueueopen.c, posix/src/mqueueunlink.c, posix/src/seminit.c, posix/src/semopen.c, posix/src/semunlink.c: Update due to API changes.
  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2007.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <stdarg.h>
17
18#include <errno.h>
19#include <fcntl.h>
20#include <pthread.h>
21#include <semaphore.h>
22#include <limits.h>
23
24#include <rtems/system.h>
25#include <rtems/score/object.h>
26#include <rtems/posix/semaphore.h>
27#include <rtems/posix/time.h>
28#include <rtems/seterr.h>
29
30/*
31 *  sem_unlink
32 *
33 *  Unlinks a named semaphore, sem_close must also be called to remove
34 *  the semaphore.
35 *
36 *  11.2.5 Remove a Named Semaphore, P1003.1b-1993, p.225
37 */
38
39int sem_unlink(
40  const char *name
41)
42{
43  int  status;
44  register POSIX_Semaphore_Control *the_semaphore;
45  Objects_Id the_semaphore_id;
46  size_t name_len;
47
48  _Thread_Disable_dispatch();
49
50  status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id, &name_len );
51  if ( status != 0 ) {
52    _Thread_Enable_dispatch();
53    rtems_set_errno_and_return_minus_one( status );
54  }
55
56  the_semaphore = (POSIX_Semaphore_Control *) _Objects_Get_local_object(
57    &_POSIX_Semaphore_Information,
58    _Objects_Get_index( the_semaphore_id )
59  );
60
61  the_semaphore->linked = false;
62  _POSIX_Semaphore_Namespace_remove( the_semaphore );
63  _POSIX_Semaphore_Delete( the_semaphore );
64
65  _Thread_Enable_dispatch();
66  return 0;
67}
Note: See TracBrowser for help on using the repository browser.