source: rtems/cpukit/posix/src/condinit.c @ c030edd

Last change on this file since c030edd was c030edd, checked in by Sebastian Huber <sebastian.huber@…>, on Sep 15, 2017 at 11:48:44 AM

posix: Allow PTHREAD_PROCESS_SHARED for condvar

Close #3137.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Initialize 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 <rtems/posix/condimpl.h>
22#include <rtems/posix/posixapi.h>
23
24/**
25 *  11.4.2 Initializing and Destroying a Condition Variable,
26 *         P1003.1c/Draft 10, p. 87
27 */
28int pthread_cond_init(
29  pthread_cond_t           *cond,
30  const pthread_condattr_t *attr
31)
32{
33  POSIX_Condition_variables_Control   *the_cond;
34  const pthread_condattr_t            *the_attr;
35
36  if ( attr ) the_attr = attr;
37  else        the_attr = &_POSIX_Condition_variables_Default_attributes;
38
39  /*
40   *  Be careful about attributes when global!!!
41   */
42
43  if ( !the_attr->is_initialized )
44    return EINVAL;
45
46  if ( !_POSIX_Is_valid_pshared( the_attr->process_shared ) ) {
47    return EINVAL;
48  }
49
50  the_cond = _POSIX_Condition_variables_Allocate();
51
52  if ( !the_cond ) {
53    _Objects_Allocator_unlock();
54    return ENOMEM;
55  }
56
57  _POSIX_Condition_variables_Initialize( the_cond, the_attr );
58
59  _Objects_Open_u32(
60    &_POSIX_Condition_variables_Information,
61    &the_cond->Object,
62    0
63  );
64
65  *cond = the_cond->Object.id;
66
67  _Objects_Allocator_unlock();
68
69  return 0;
70}
Note: See TracBrowser for help on using the repository browser.