source: rtems/c/src/exec/posix/src/semunlink.c @ cb3c1718

4.104.114.84.95
Last change on this file since cb3c1718 was cb3c1718, checked in by Jennifer Averett <Jennifer.Averett@…>, on Nov 22, 1999 at 4:13:22 PM

+ Corrected enable/disable of dispatch.
+ Cleaned up code.

  • 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  Objects_Locations                 location;
37 
38  _Thread_Disable_dispatch();
39
40  status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id );
41  if ( status != 0 ) {
42    _Thread_Enable_dispatch();
43    set_errno_and_return_minus_one( status );
44  }
45
46  /*
47   *  Don't support unlinking a remote semaphore.
48   */
49
50  if ( !_Objects_Is_local_id(the_semaphore_id) ) {
51    _Thread_Enable_dispatch();
52    set_errno_and_return_minus_one( ENOSYS );
53  }
54
55  the_semaphore = _Objects_Get_local_object(
56    &_POSIX_Semaphore_Information,
57    _Objects_Get_index( the_semaphore_id )
58  );
59 
60#if defined(RTEMS_MULTIPROCESSING)
61  if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
62    _Objects_MP_Close( &_POSIX_Semaphore_Information, the_semaphore_id );
63  }
64#endif
65
66  the_semaphore->linked = FALSE;
67  _POSIX_Semaphore_Namespace_remove( the_semaphore );
68  _POSIX_Semaphore_Delete( the_semaphore );
69
70  _Thread_Enable_dispatch();
71  return 0;
72}
Note: See TracBrowser for help on using the repository browser.