source: rtems/cpukit/posix/src/pbarrierdestroy.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Destroy a Barrier Object
5 *  @ingroup POSIXAPI
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <pthread.h>
22#include <errno.h>
23
24#include <rtems/system.h>
25#include <rtems/posix/barrierimpl.h>
26
27/**
28 *  This directive allows a thread to delete a barrier specified by
29 *  the barrier id.  The barrier is freed back to the inactive
30 *  barrier chain.
31 *
32 *  @param[in] barrier is the barrier id
33 *
34 *  @return This method returns 0 if there was not an
35 *  error. Otherwise, a status code is returned indicating the
36 *  source of the error.
37 */
38int pthread_barrier_destroy(
39  pthread_barrier_t *barrier
40)
41{
42  POSIX_Barrier_Control *the_barrier = NULL;
43  Objects_Locations      location;
44
45  if ( !barrier )
46    return EINVAL;
47
48  the_barrier = _POSIX_Barrier_Get( barrier, &location );
49  switch ( location ) {
50
51    case OBJECTS_LOCAL:
52      if ( the_barrier->Barrier.number_of_waiting_threads != 0 ) {
53        _Objects_Put( &the_barrier->Object );
54        return EBUSY;
55      }
56
57      _Objects_Close( &_POSIX_Barrier_Information, &the_barrier->Object );
58
59      _POSIX_Barrier_Free( the_barrier );
60
61      _Objects_Put( &the_barrier->Object );
62      return 0;
63
64#if defined(RTEMS_MULTIPROCESSING)
65    case OBJECTS_REMOTE:
66#endif
67    case OBJECTS_ERROR:
68      break;
69  }
70
71  return EINVAL;
72}
Note: See TracBrowser for help on using the repository browser.