source: rtems/cpukit/posix/src/conddestroy.c @ 1e1a91ed

5
Last change on this file since 1e1a91ed was 1e1a91ed, checked in by Sebastian Huber <sebastian.huber@…>, on 03/23/16 at 09:01:31

score: Remove Thread_queue_Queue::operations field

Remove the Thread_queue_Queue::operations field to reduce the size of
this structure. Add a thread queue operations parameter to the
_Thread_queue_First(), _Thread_queue_First_locked(),
_Thread_queue_Enqueue(), _Thread_queue_Dequeue() and
_Thread_queue_Flush() functions. This is a preparation patch to reduce
the size of several synchronization objects.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Destroy a Condition Variable
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/score/watchdog.h>
26#include <rtems/posix/condimpl.h>
27#include <rtems/posix/muteximpl.h>
28
29/**
30 *  11.4.2 Initializing and Destroying a Condition Variable,
31 *         P1003.1c/Draft 10, p. 87
32 */
33int pthread_cond_destroy(
34  pthread_cond_t           *cond
35)
36{
37  POSIX_Condition_variables_Control *the_cond;
38  Objects_Locations                  location;
39
40  _Objects_Allocator_lock();
41  the_cond = _POSIX_Condition_variables_Get( cond, &location );
42  switch ( location ) {
43
44    case OBJECTS_LOCAL:
45
46      if (
47        _Thread_queue_First(
48          &the_cond->Wait_queue,
49          POSIX_CONDITION_VARIABLES_TQ_OPERATIONS
50        )
51      ) {
52        _Objects_Put( &the_cond->Object );
53        _Objects_Allocator_unlock();
54        return EBUSY;
55      }
56
57      _Objects_Close(
58        &_POSIX_Condition_variables_Information,
59        &the_cond->Object
60      );
61      _Objects_Put( &the_cond->Object );
62      _POSIX_Condition_variables_Free( the_cond );
63      _Objects_Allocator_unlock();
64      return 0;
65
66#if defined(RTEMS_MULTIPROCESSING)
67    case OBJECTS_REMOTE:
68#endif
69    case OBJECTS_ERROR:
70      break;
71  }
72
73  _Objects_Allocator_unlock();
74
75  return EINVAL;
76}
Note: See TracBrowser for help on using the repository browser.