OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [posix/] [inline/] [rtems/] [posix/] [mutex.inl] - Blame information for rev 1026

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*  rtems/posix/mutex.inl
2
 *
3
 *  This include file contains the static inline 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
 *  mutex.inl,v 1.10 2002/01/16 22:01:19 joel Exp
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
RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Allocate( void )
25
{
26
  return (POSIX_Mutex_Control *) _Objects_Allocate( &_POSIX_Mutex_Information );
27
}
28
 
29
/*PAGE
30
 *
31
 *  _POSIX_Mutex_Free
32
 */
33
 
34
RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Free (
35
  POSIX_Mutex_Control *the_mutex
36
)
37
{
38
  _Objects_Free( &_POSIX_Mutex_Information, &the_mutex->Object );
39
}
40
 
41
/*PAGE
42
 *
43
 *  _POSIX_Mutex_Get_support
44
 *
45
 *  NOTE: The support macro makes it possible for both to use exactly
46
 *        the same code to check for NULL id pointer and
47
 *        PTHREAD_MUTEX_INITIALIZER without adding overhead.
48
 */
49
 
50
#define ___POSIX_Mutex_Get_support( _id, _location ) \
51
  do { \
52
    int _status; \
53
    \
54
    if ( !_id ) { \
55
      *_location = OBJECTS_ERROR; \
56
      return (POSIX_Mutex_Control *) 0; \
57
    }  \
58
    \
59
    if ( *_id == PTHREAD_MUTEX_INITIALIZER ) { \
60
      /* \
61
       *  Do an "auto-create" here. \
62
       */ \
63
    \
64
      _status = pthread_mutex_init( _id, 0 ); \
65
      if ( _status ) { \
66
        *_location = OBJECTS_ERROR;  \
67
        return (POSIX_Mutex_Control *) 0; \
68
      } \
69
    } \
70
  } while (0)
71
 
72
RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Get (
73
  Objects_Id        *id,
74
  Objects_Locations *location
75
)
76
{
77
  ___POSIX_Mutex_Get_support( id, location );
78
 
79
  return (POSIX_Mutex_Control *)
80
    _Objects_Get( &_POSIX_Mutex_Information, *id, location );
81
}
82
 
83
RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable (
84
  Objects_Id        *id,
85
  Objects_Locations *location,
86
  ISR_Level         *level
87
)
88
{
89
  ___POSIX_Mutex_Get_support( id, location );
90
 
91
  return (POSIX_Mutex_Control *)
92
    _Objects_Get_isr_disable( &_POSIX_Mutex_Information, *id, location, level );
93
}
94
 
95
 
96
/*PAGE
97
 *
98
 *  _POSIX_Mutex_Is_null
99
 */
100
 
101
RTEMS_INLINE_ROUTINE boolean _POSIX_Mutex_Is_null (
102
  POSIX_Mutex_Control *the_mutex
103
)
104
{
105
  return !the_mutex;
106
}
107
 
108
#endif
109
/*  end of include file */
110
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.