source: rtems/cpukit/posix/src/semunlink.c @ 3bacb250

4.104.115
Last change on this file since 3bacb250 was b1dbfd7, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/03/09 at 10:10:57

Eliminate TRUE/FALSE.

  • 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/*PAGE
31 *
32 *  sem_unlink
33 *
34 *  Unlinks a named semaphore, sem_close must also be called to remove
35 *  the semaphore.
36 *
37 *  11.2.5 Remove a Named Semaphore, P1003.1b-1993, p.225
38 */
39
40int sem_unlink(
41  const char *name
42)
43{
44  int  status;
45  register POSIX_Semaphore_Control *the_semaphore;
46  sem_t                        the_semaphore_id;
47
48  _Thread_Disable_dispatch();
49
50  status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id );
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.