OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems/] [c/] [src/] [exec/] [posix/] [src/] [semunlink.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 158 chris
/*
2 208 chris
 *  $Id: semunlink.c,v 1.2 2001-09-27 11:59:17 chris Exp $
3 158 chris
 */
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
 
29
int 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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.