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

4.104.115
Last change on this file since 8f6b7b51 was ce19f1fa, checked in by Joel Sherrill <joel.sherrill@…>, on 01/23/08 at 22:57:43

2008-01-23 Joel Sherrill <joel.sherrill@…>

  • itron/include/rtems/itron/object.h, itron/src/cre_tsk.c, libblock/src/show_bdbuf.c, libmisc/capture/capture-cli.c, libmisc/capture/capture.c, libmisc/monitor/mon-manager.c, libmisc/stackchk/check.c, posix/src/condinit.c, posix/src/keycreate.c, posix/src/mqueuecreatesupp.c, posix/src/mqueuedeletesupp.c, posix/src/mqueuenametoid.c, posix/src/mqueueopen.c, posix/src/mqueueunlink.c, posix/src/mutexinit.c, posix/src/pbarrierinit.c, posix/src/prwlockinit.c, posix/src/pspininit.c, posix/src/pthreadcreate.c, posix/src/pthreadexit.c, posix/src/semaphorecreatesupp.c, posix/src/semaphorenametoid.c, posix/src/timercreate.c, rtems/src/barrierident.c, rtems/src/dpmemident.c, rtems/src/msgqident.c, rtems/src/partident.c, rtems/src/ratemonident.c, rtems/src/regionident.c, rtems/src/semident.c, rtems/src/taskident.c, rtems/src/timerident.c, sapi/src/extensionident.c, score/Makefile.am, score/include/rtems/score/object.h, score/inline/rtems/score/object.inl, score/src/apimutexallocate.c, score/src/objectextendinformation.c, score/src/objectgetnameasstring.c, score/src/objectmp.c, score/src/objectnametoid.c: Convert the Objects_Name type from a simple type to a union of an unsigned 32 bit integer and a pointer. This should help eliminate weird casts between u32 and pointers in various places. The APIs now have to explicitly call _u32 or _string versions of helper routines. This should also simplify things and eliminate the need for ugly casts in some cases.
  • score/src/objectclearname.c, score/src/objectcomparenameraw.c, score/src/objectcomparenamestring.c, score/src/objectcopynameraw.c, score/src/objectcopynamestring.c: Removed.
  • Property mode set to 100644
File size: 1.8 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 <pthread.h>
17#include <errno.h>
18
19#include <rtems/system.h>
20#include <rtems/score/object.h>
21#include <rtems/score/states.h>
22#include <rtems/score/watchdog.h>
23#include <rtems/posix/cond.h>
24#include <rtems/posix/time.h>
25#include <rtems/posix/mutex.h>
26
27/*PAGE
28 *
29 *  11.4.2 Initializing and Destroying a Condition Variable,
30 *         P1003.1c/Draft 10, p. 87
31 */
32
33int pthread_cond_init(
34  pthread_cond_t           *cond,
35  const pthread_condattr_t *attr
36)
37{
38  POSIX_Condition_variables_Control   *the_cond;
39  const pthread_condattr_t            *the_attr;
40
41  if ( attr ) the_attr = attr;
42  else        the_attr = &_POSIX_Condition_variables_Default_attributes;
43
44  /*
45   *  Be careful about attributes when global!!!
46   */
47
48  if ( the_attr->process_shared == PTHREAD_PROCESS_SHARED )
49    return EINVAL;
50
51  if ( !the_attr->is_initialized )
52    return EINVAL;
53
54  _Thread_Disable_dispatch();
55
56  the_cond = _POSIX_Condition_variables_Allocate();
57
58  if ( !the_cond ) {
59    _Thread_Enable_dispatch();
60    return ENOMEM;
61  }
62
63  the_cond->process_shared  = the_attr->process_shared;
64
65  the_cond->Mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX;
66
67/* XXX some more initialization might need to go here */
68  _Thread_queue_Initialize(
69    &the_cond->Wait_queue,
70    THREAD_QUEUE_DISCIPLINE_FIFO,
71    STATES_WAITING_FOR_CONDITION_VARIABLE,
72    ETIMEDOUT
73  );
74
75  _Objects_Open_u32(
76    &_POSIX_Condition_variables_Information,
77    &the_cond->Object,
78    0
79  );
80
81  *cond = the_cond->Object.id;
82
83  _Thread_Enable_dispatch();
84
85  return 0;
86}
Note: See TracBrowser for help on using the repository browser.