source: rtems/cpukit/posix/macros/rtems/posix/mutex.inl @ ce92867b

4.104.114.84.95
Last change on this file since ce92867b was ce92867b, checked in by Joel Sherrill <joel.sherrill@…>, on Feb 2, 2005 at 12:06:18 AM

2005-02-01 Joel Sherrill <joel@…>

  • libblock/include/rtems/bdbuf.h, libblock/include/rtems/ide_part_table.h, libblock/src/blkdev.c, libcsupport/include/rtems/termiostypes.h, libcsupport/src/termios.c, posix/macros/rtems/posix/cond.inl, posix/macros/rtems/posix/mutex.inl : Remove 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 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 
70/* If we find a compiler that doesn't accept static inline functions,
71 * then this will have to move to a .c file.  Until then, we will use this.
72 */
73static inline POSIX_Mutex_Control * _POSIX_Mutex_Get(
74  Objects_Id        *id,
75  Objects_Locations *location
76)
77{
78  ___POSIX_Mutex_Get_support( id, location );
79
80  return (POSIX_Mutex_Control *)
81    _Objects_Get( &_POSIX_Mutex_Information, *id, location );
82}
83
84/* If we find a compiler that doesn't accept static inline functions,
85 * then this will have to move to a .c file.  Until then, we will use this.
86 */
87static inline POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable(
88  Objects_Id        *id,
89  Objects_Locations *location,
90  ISR_Level         *level
91)
92{
93  ___POSIX_Mutex_Get_support( id, location );
94
95  return (POSIX_Mutex_Control *)
96    _Objects_Get_isr_disable( &_POSIX_Mutex_Information, *id, location, level );
97}
98
99 
100/*PAGE
101 *
102 *  _POSIX_Mutex_Is_null
103 */
104 
105#define _POSIX_Mutex_Is_null( _the_mutex ) \
106  (!(_the_mutex))
107
108#endif
109/*  end of include file */
110
Note: See TracBrowser for help on using the repository browser.