source: rtems/c/src/exec/posix/src/semunlink.c @ 105d7872

4.104.114.84.95
Last change on this file since 105d7872 was 17879f4, checked in by Jennifer Averett <Jennifer.Averett@…>, on 11/18/99 at 19:43:13

+ Debuged to the point that you could open, unlink and close a semaphore.

but all paths have not been checked, yet.

  • 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 *  11.2.5 Remove a Named Semaphore, P1003.1b-1993, p.225
22 */
23
24int sem_unlink(
25  const char *name
26)
27{
28  int  status;
29  register POSIX_Semaphore_Control *the_semaphore;
30  Objects_Id                        the_semaphore_id;
31  Objects_Locations                 location;
32 
33  status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id );
34  if ( status != 0 )
35    set_errno_and_return_minus_one( status );
36
37  the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
38  switch ( location ) {
39    case OBJECTS_ERROR:
40      set_errno_and_return_minus_one( EINVAL );
41    case OBJECTS_REMOTE:
42      _Thread_Dispatch();
43      return POSIX_MP_NOT_IMPLEMENTED();
44      set_errno_and_return_minus_one( EINVAL );
45    case OBJECTS_LOCAL:
46
47#if defined(RTEMS_MULTIPROCESSING)
48      if ( the_semaphore->process_shared == PTHREAD_PROCESS_SHARED ) {
49        _Objects_MP_Close(
50          &_POSIX_Semaphore_Information,
51          the_semaphore->Object.id
52        );
53      }
54#endif
55
56      the_semaphore->linked = FALSE;
57      _POSIX_Semaphore_Namespace_remove( the_semaphore );
58      _POSIX_Semaphore_Delete( the_semaphore );
59
60      _Thread_Enable_dispatch();
61      return 0;
62  }
63  return POSIX_BOTTOM_REACHED();
64}
Note: See TracBrowser for help on using the repository browser.