source: rtems/cpukit/posix/src/condinit.c @ 8230a329

5
Last change on this file since 8230a329 was b5bfaaf9, checked in by Gedare Bloom <gedare@…>, on 06/23/16 at 20:55:38

posix: cond_timedwait remember and use clock from condattr

updates #2745

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[e49a36cb]1/**
2 *  @file
3 *
4 *  @brief Initialize a Condition Variable
[5cb175bb]5 *  @ingroup POSIXAPI
[e49a36cb]6 */
7
[43ed935]8/*
[feaa007]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
[c499856]14 *  http://www.rtems.org/license/LICENSE.
[43ed935]15 */
16
[f42b726]17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
[35210b12]21#include <rtems/posix/condimpl.h>
[43ed935]22
[e49a36cb]23/**
[874297f3]24 *  11.4.2 Initializing and Destroying a Condition Variable,
[43ed935]25 *         P1003.1c/Draft 10, p. 87
26 */
27int pthread_cond_init(
28  pthread_cond_t           *cond,
29  const pthread_condattr_t *attr
30)
31{
32  POSIX_Condition_variables_Control   *the_cond;
33  const pthread_condattr_t            *the_attr;
[874297f3]34
[43ed935]35  if ( attr ) the_attr = attr;
36  else        the_attr = &_POSIX_Condition_variables_Default_attributes;
[874297f3]37
[43ed935]38  /*
[b8596d8]39   *  Be careful about attributes when global!!!
[43ed935]40   */
41  if ( the_attr->process_shared == PTHREAD_PROCESS_SHARED )
[0e87deaa]42    return EINVAL;
[874297f3]43
[43ed935]44  if ( !the_attr->is_initialized )
45    return EINVAL;
[874297f3]46
[43ed935]47  the_cond = _POSIX_Condition_variables_Allocate();
[874297f3]48
[43ed935]49  if ( !the_cond ) {
[23fec9f0]50    _Objects_Allocator_unlock();
[43ed935]51    return ENOMEM;
52  }
[874297f3]53
[b5bfaaf9]54  _POSIX_Condition_variables_Initialize( the_cond, the_attr );
[43ed935]55
[ce19f1fa]56  _Objects_Open_u32(
[43ed935]57    &_POSIX_Condition_variables_Information,
58    &the_cond->Object,
59    0
60  );
[874297f3]61
[43ed935]62  *cond = the_cond->Object.id;
[874297f3]63
[23fec9f0]64  _Objects_Allocator_unlock();
[43ed935]65
66  return 0;
67}
Note: See TracBrowser for help on using the repository browser.