source: rtems/cpukit/posix/src/semdestroy.c @ 8f6b7b51

4.104.115
Last change on this file since 8f6b7b51 was b1dbfd7, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/03/09 at 10:10:57

Eliminate TRUE/FALSE.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2007.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <stdarg.h>
17
18#include <errno.h>
19#include <fcntl.h>
20#include <pthread.h>
21#include <semaphore.h>
22#include <limits.h>
23
24#include <rtems/system.h>
25#include <rtems/score/object.h>
26#include <rtems/posix/semaphore.h>
27#include <rtems/posix/time.h>
28#include <rtems/seterr.h>
29
30/*PAGE
31 *
32 *  11.2.2 Destroy an Unnamed Semaphore, P1003.1b-1993, p.220
33 */
34
35int sem_destroy(
36  sem_t *sem
37)
38{
39  register POSIX_Semaphore_Control *the_semaphore;
40  Objects_Locations                 location;
41
42  the_semaphore = _POSIX_Semaphore_Get( sem, &location );
43  switch ( location ) {
44
45    case OBJECTS_LOCAL:
46      /*
47       *  Undefined operation on a named semaphore.
48       */
49
50      if ( the_semaphore->named == true ) {
51        _Thread_Enable_dispatch();
52        rtems_set_errno_and_return_minus_one( EINVAL );
53      }
54
55      _POSIX_Semaphore_Delete( the_semaphore );
56      _Thread_Enable_dispatch();
57      return 0;
58
59#if defined(RTEMS_MULTIPROCESSING)
60    case OBJECTS_REMOTE:
61#endif
62    case OBJECTS_ERROR:
63      break;
64  }
65
66  rtems_set_errno_and_return_minus_one( EINVAL );
67}
Note: See TracBrowser for help on using the repository browser.