source: rtems/c/src/exec/posix/src/semunlink.c @ 64f55e7

4.104.114.84.95
Last change on this file since 64f55e7 was 64f55e7, checked in by Joel Sherrill <joel.sherrill@…>, on 11/29/99 at 15:40:38

Made sure POSIX would build with MP enabled.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 *  $Id$
3 */
4
5#include <stdarg.h>
6
7#include <errno.h>
8#include <fcntl.h>
9#include <pthread.h>
10#include <semaphore.h>
11#include <limits.h>
12
13#include <rtems/system.h>
14#include <rtems/score/object.h>
15#include <rtems/posix/semaphore.h>
16#include <rtems/posix/time.h>
17#include <rtems/posix/seterr.h>
18
19/*PAGE
20 *
21 *  sem_unlink
22 * 
23 *  Unlinks a named semaphore, sem_close must also be called to remove
24 *  the semaphore.
25 *
26 *  11.2.5 Remove a Named Semaphore, P1003.1b-1993, p.225
27 */
28
29int sem_unlink(
30  const char *name
31)
32{
33  int  status;
34  register POSIX_Semaphore_Control *the_semaphore;
35  Objects_Id                        the_semaphore_id;
36 
37  _Thread_Disable_dispatch();
38
39  status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id );
40  if ( status != 0 ) {
41    _Thread_Enable_dispatch();
42    set_errno_and_return_minus_one( status );
43  }
44
45  /*
46   *  Don't support unlinking a remote semaphore.
47   */
48
49  if ( !_Objects_Is_local_id(the_semaphore_id) ) {
50    _Thread_Enable_dispatch();
51    set_errno_and_return_minus_one( ENOSYS );
52  }
53
54  the_semaphore = (POSIX_Semaphore_Control *) _Objects_Get_local_object(
55    &_POSIX_Semaphore_Information,
56    _Objects_Get_index( the_semaphore_id )
57  );
58 
59#if defined(RTEMS_MULTIPROCESSING)
60  if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
61    _Objects_MP_Close( &_POSIX_Semaphore_Information, the_semaphore_id );
62  }
63#endif
64
65  the_semaphore->linked = FALSE;
66  _POSIX_Semaphore_Namespace_remove( the_semaphore );
67  _POSIX_Semaphore_Delete( the_semaphore );
68
69  _Thread_Enable_dispatch();
70  return 0;
71}
Note: See TracBrowser for help on using the repository browser.