source: rtems/cpukit/posix/inline/rtems/posix/mutex.inl @ 5287d3e

4.104.114.84.95
Last change on this file since 5287d3e was 5287d3e, checked in by Joel Sherrill <joel.sherrill@…>, on 04/07/06 at 01:16:55

2006-04-06 Joel Sherrill <joel@…>

  • posix/inline/rtems/posix/mutex.inl, posix/inline/rtems/posix/timer.inl, posix/macros/rtems/posix/cond.inl, posix/macros/rtems/posix/mutex.inl, posix/macros/rtems/posix/timer.inl: Fix warnings.
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/**
2 * @file rtems/posix/mutex.inl
3 */
4
5/*  rtems/posix/mutex.inl
6 *
7 *  This include file contains the static inline implementation of the private
8 *  inlined routines for POSIX mutex's.
9 *
10 *  COPYRIGHT (c) 1989-1999.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19 
20#ifndef _RTEMS_POSIX_MUTEX_INL
21#define _RTEMS_POSIX_MUTEX_INL
22 
23/*PAGE
24 *
25 *  _POSIX_Mutex_Allocate
26 */
27 
28RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Allocate( void )
29{
30  return (POSIX_Mutex_Control *) _Objects_Allocate( &_POSIX_Mutex_Information );
31}
32 
33/*PAGE
34 *
35 *  _POSIX_Mutex_Free
36 */
37 
38RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Free (
39  POSIX_Mutex_Control *the_mutex
40)
41{
42  _Objects_Free( &_POSIX_Mutex_Information, &the_mutex->Object );
43}
44 
45/*PAGE
46 *
47 *  _POSIX_Mutex_Get_support
48 *
49 *  NOTE: The support macro makes it possible for both to use exactly
50 *        the same code to check for NULL id pointer and
51 *        PTHREAD_MUTEX_INITIALIZER without adding overhead.
52 */
53
54#define ___POSIX_Mutex_Get_support( _id, _location ) \
55  do { \
56    int _status; \
57    \
58    if ( !_id ) { \
59      *_location = OBJECTS_ERROR; \
60      return (POSIX_Mutex_Control *) 0; \
61    }  \
62    \
63    if ( *_id == PTHREAD_MUTEX_INITIALIZER ) { \
64      /* \
65       *  Do an "auto-create" here. \
66       */ \
67    \
68      _status = pthread_mutex_init( (pthread_mutex_t *)_id, 0 ); \
69      if ( _status ) { \
70        *_location = OBJECTS_ERROR;  \
71        return (POSIX_Mutex_Control *) 0; \
72      } \
73    } \
74  } while (0)
75 
76RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Get (
77  pthread_mutex_t   *mutex,
78  Objects_Locations *location
79)
80{
81  Objects_Id *id = (Objects_Id *)mutex;
82
83  ___POSIX_Mutex_Get_support( id, location );
84
85  return (POSIX_Mutex_Control *)
86    _Objects_Get( &_POSIX_Mutex_Information, *id, location );
87}
88
89RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable (
90  pthread_mutex_t   *mutex,
91  Objects_Locations *location,
92  ISR_Level         *level
93)
94{
95  Objects_Id *id = (Objects_Id *)mutex;
96
97  ___POSIX_Mutex_Get_support( id, location );
98
99  return (POSIX_Mutex_Control *)
100    _Objects_Get_isr_disable( &_POSIX_Mutex_Information, *id, location, level );
101}
102
103 
104/*PAGE
105 *
106 *  _POSIX_Mutex_Is_null
107 */
108 
109RTEMS_INLINE_ROUTINE boolean _POSIX_Mutex_Is_null (
110  POSIX_Mutex_Control *the_mutex
111)
112{
113  return !the_mutex;
114}
115
116#endif
117/*  end of include file */
118
Note: See TracBrowser for help on using the repository browser.