source: rtems/c/src/exec/posix/macros/rtems/posix/mutex.inl @ 2b2bda4

4.104.114.84.95
Last change on this file since 2b2bda4 was 2b2bda4, checked in by Joel Sherrill <joel.sherrill@…>, on 12/01/00 at 18:57:36

2000-12-01 Joel Sherrill <joel@…>

  • Added macro support to POSIX API. This is known to compile.
  • macros/rtems/posix/cond.inl, macros/rtems/posix/intr.inl, macros/rtems/posix/key.inl, macros/rtems/posix/mqueue.inl, macros/rtems/posix/mutex.inl, macros/rtems/posix/priority.inl, macros/rtems/posix/pthread.inl, macros/rtems/posix/semaphore.inl, macros/rtems/posix/timer.inl: New files.
  • configure.in: Removed error check for enabling macros.
  • rtems/posix/mutex.h: #if 0'ed out prototypes for inlined routines since you cannot have prototypes for macros.
  • macros/rtems/posix/Makefile.am: Added files.
  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*  rtems/posix/mutex.inl
2 *
3 *  This include file contains the macro implementation of the private
4 *  inlined routines for POSIX mutex's.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15 
16#ifndef __RTEMS_POSIX_MUTEX_inl
17#define __RTEMS_POSIX_MUTEX_inl
18 
19/*PAGE
20 *
21 *  _POSIX_Mutex_Allocate
22 */
23 
24#define _POSIX_Mutex_Allocate() \
25  (POSIX_Mutex_Control *) _Objects_Allocate( &_POSIX_Mutex_Information )
26 
27/*PAGE
28 *
29 *  _POSIX_Mutex_Free
30 */
31 
32#define _POSIX_Mutex_Free( _the_mutex ) \
33  _Objects_Free( &_POSIX_Mutex_Information, &(_the_mutex)->Object )
34 
35/*PAGE
36 *
37 *  _POSIX_Mutex_Get
38 *
39 *  NOTE: The support macro makes it possible for both to use exactly
40 *        the same code to check for NULL id pointer and
41 *        PTHREAD_MUTEX_INITIALIZER without adding overhead.
42 */
43
44#define ___POSIX_Mutex_Get_support( _id, _location ) \
45  do { \
46    int _status; \
47    \
48    if ( !_id ) { \
49      *_location = OBJECTS_ERROR; \
50      return (POSIX_Mutex_Control *) 0; \
51    }  \
52    \
53    if ( *_id == PTHREAD_MUTEX_INITIALIZER ) { \
54      /* \
55       *  Do an "auto-create" here. \
56       */ \
57    \
58      _status = pthread_mutex_init( _id, 0 ); \
59      if ( _status ) { \
60        *_location = OBJECTS_ERROR;  \
61        return (POSIX_Mutex_Control *) 0; \
62      } \
63    } \
64  } while (0)
65 
66static POSIX_Mutex_Control * _POSIX_Mutex_Get(
67  Objects_Id        *id,
68  Objects_Locations *location
69)
70{
71  ___POSIX_Mutex_Get_support( id, location );
72
73  return (POSIX_Mutex_Control *)
74    _Objects_Get( &_POSIX_Mutex_Information, *id, location );
75}
76
77static POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable(
78  Objects_Id        *id,
79  Objects_Locations *location,
80  ISR_Level         *level
81)
82{
83  ___POSIX_Mutex_Get_support( id, location );
84
85  return (POSIX_Mutex_Control *)
86    _Objects_Get_isr_disable( &_POSIX_Mutex_Information, *id, location, level );
87}
88
89 
90/*PAGE
91 *
92 *  _POSIX_Mutex_Is_null
93 */
94 
95#define _POSIX_Mutex_Is_null( _the_mutex ) \
96  (!(_the_mutex))
97
98#endif
99/*  end of include file */
100
Note: See TracBrowser for help on using the repository browser.