source: rtems/cpukit/posix/macros/rtems/posix/mutex.inl @ 6c2675d

4.104.114.84.95
Last change on this file since 6c2675d was 6c2675d, checked in by Ralf Corsepius <ralf.corsepius@…>, on Nov 21, 2004 at 6:27:15 AM

Add doxygen preamble.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/**
2 * @file rtems/posix/mutex.inl
3 */
4
5/*  rtems/posix/mutex.inl
6 *
7 *  This include file contains the macro 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 
28#define _POSIX_Mutex_Allocate() \
29  (POSIX_Mutex_Control *) _Objects_Allocate( &_POSIX_Mutex_Information )
30 
31/*PAGE
32 *
33 *  _POSIX_Mutex_Free
34 */
35 
36#define _POSIX_Mutex_Free( _the_mutex ) \
37  _Objects_Free( &_POSIX_Mutex_Information, &(_the_mutex)->Object )
38 
39/*PAGE
40 *
41 *  _POSIX_Mutex_Get
42 *
43 *  NOTE: The support macro makes it possible for both to use exactly
44 *        the same code to check for NULL id pointer and
45 *        PTHREAD_MUTEX_INITIALIZER without adding overhead.
46 */
47
48#define ___POSIX_Mutex_Get_support( _id, _location ) \
49  do { \
50    int _status; \
51    \
52    if ( !_id ) { \
53      *_location = OBJECTS_ERROR; \
54      return (POSIX_Mutex_Control *) 0; \
55    }  \
56    \
57    if ( *_id == PTHREAD_MUTEX_INITIALIZER ) { \
58      /* \
59       *  Do an "auto-create" here. \
60       */ \
61    \
62      _status = pthread_mutex_init( _id, 0 ); \
63      if ( _status ) { \
64        *_location = OBJECTS_ERROR;  \
65        return (POSIX_Mutex_Control *) 0; \
66      } \
67    } \
68  } while (0)
69 
70static POSIX_Mutex_Control * _POSIX_Mutex_Get(
71  Objects_Id        *id,
72  Objects_Locations *location
73)
74{
75  ___POSIX_Mutex_Get_support( id, location );
76
77  return (POSIX_Mutex_Control *)
78    _Objects_Get( &_POSIX_Mutex_Information, *id, location );
79}
80
81static POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable(
82  Objects_Id        *id,
83  Objects_Locations *location,
84  ISR_Level         *level
85)
86{
87  ___POSIX_Mutex_Get_support( id, location );
88
89  return (POSIX_Mutex_Control *)
90    _Objects_Get_isr_disable( &_POSIX_Mutex_Information, *id, location, level );
91}
92
93 
94/*PAGE
95 *
96 *  _POSIX_Mutex_Is_null
97 */
98 
99#define _POSIX_Mutex_Is_null( _the_mutex ) \
100  (!(_the_mutex))
101
102#endif
103/*  end of include file */
104
Note: See TracBrowser for help on using the repository browser.