source: rtems/cpukit/posix/src/semclose.c @ 2c3af4c5

4.104.114.84.95
Last change on this file since 2c3af4c5 was 2c3af4c5, checked in by Jennifer Averett <Jennifer.Averett@…>, on 11/22/99 at 16:10:25

+ Added description of routine to comment.

  • Property mode set to 100644
File size: 1.1 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
20/*PAGE
21 *
22 *  sem_close
23 * 
24 *  Routine to close a semaphore that has been opened or initialized.
25 * 
26 *  11.2.4 Close a Named Semaphore, P1003.1b-1993, p.224
27 */
28
29int sem_close(
30  sem_t *sem
31)
32{
33  register POSIX_Semaphore_Control *the_semaphore;
34  Objects_Locations                 location;
35 
36  the_semaphore = _POSIX_Semaphore_Get( sem, &location );
37  switch ( location ) {
38    case OBJECTS_ERROR:
39      set_errno_and_return_minus_one( EINVAL );
40    case OBJECTS_REMOTE:
41      _Thread_Dispatch();
42      return POSIX_MP_NOT_IMPLEMENTED();
43      set_errno_and_return_minus_one( EINVAL );
44    case OBJECTS_LOCAL:
45      the_semaphore->open_count -= 1;
46      _POSIX_Semaphore_Delete( the_semaphore );
47      _Thread_Enable_dispatch();
48      return 0;
49  }
50  return POSIX_BOTTOM_REACHED();
51}
Note: See TracBrowser for help on using the repository browser.