summaryrefslogtreecommitdiffstats
path: root/cpukit/score/macros/rtems/score/object.inl
blob: 62994ee4e59fada1dd52634fc4409aab12389c25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*  object.inl
 *
 *  This include file contains the macro implementation of all
 *  of the inlined routines in the Object Handler.
 *
 *  COPYRIGHT (c) 1989-1998.
 *  On-Line Applications Research Corporation (OAR).
 *  Copyright assigned to U.S. Government, 1994.
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.OARcorp.com/rtems/license.html.
 *
 *  $Id$
 */

#ifndef __OBJECTS_inl
#define __OBJECTS_inl

/*PAGE
 *
 *  _Objects_Build_id
 *
 */

#define _Objects_Build_id( _the_class, _node, _index ) \
  ( ((_the_class) << OBJECTS_CLASS_START_BIT) | \
    ((_node) << OBJECTS_NODE_START_BIT)       | \
    ((_index) << OBJECTS_INDEX_START_BIT) )

/*PAGE
 *
 *  _Objects_Get_class
 */
 
#define _Objects_Get_class( _id ) \
  (Objects_Classes) \
    (((_id) >> OBJECTS_CLASS_START_BIT) & OBJECTS_CLASS_VALID_BITS)

/*PAGE
 *
 *  _Objects_Get_node
 *
 */

#define _Objects_Get_node( _id ) \
  (((_id) >> OBJECTS_NODE_START_BIT) & OBJECTS_NODE_VALID_BITS)

/*PAGE
 *
 *  _Objects_Get_index
 *
 */

#define _Objects_Get_index( _id ) \
  (((_id) >> OBJECTS_INDEX_START_BIT) & OBJECTS_INDEX_VALID_BITS)

/*PAGE
 *
 *  _Objects_Is_class_valid
 *
 */
 
#define _Objects_Is_class_valid( _the_class ) \
  ( (_the_class) && (_the_class) <= OBJECTS_CLASSES_LAST )

/*PAGE
 *
 *  _Objects_Is_local_node
 *
 */

#define _Objects_Is_local_node( _node ) \
  ( (_node) == _Objects_Local_node )

/*PAGE
 *
 *  _Objects_Is_local_id
 *
 */

#define _Objects_Is_local_id( _id ) \
  _Objects_Is_local_node( _Objects_Get_node(_id) )

/*PAGE
 *
 *  _Objects_Are_ids_equal
 *
 */

#define _Objects_Are_ids_equal( _left, _right ) \
  ( (_left) == (_right) )

/*PAGE
 *
 *  _Objects_Get_local_object
 *
 */

#define _Objects_Get_local_object( information, index ) \
  ( ( index > information->maximum) ?  NULL : \
                       information->local_table[ index ] )

/*PAGE
 *
 *  _Objects_Set_local_object
 *
 */

#define _Objects_Set_local_object( information, index, the_object ) \
  { \
    if ( index <= information->maximum) \
      information->local_table[ index ] = the_object; \
  }


/*PAGE
 *
 *  _Objects_Get_information
 *
 */
 
#define _Objects_Get_information( id ) \
 ( \
   ( !_Objects_Is_class_valid( _Objects_Get_class( id ) ) ) ? \
     NULL : \
     _Objects_Information_table[ _Objects_Get_class( id ) ] \
 )

/*PAGE
 *
 *  _Objects_Open
 *
 */

#define _Objects_Open( _information, _the_object, _name ) \
  { \
    unsigned32 _index; \
    \
    _index = _Objects_Get_index( (_the_object)->id ); \
    (_information)->local_table[ _index ] = (_the_object); \
    \
    if ( (_information)->is_string ) \
      _Objects_Copy_name_string( (_name), (_the_object)->name ); \
    else \
      _Objects_Copy_name_raw( \
        (_name), (_the_object)->name, (_information)->name_length ); \
  }

/*PAGE
 *
 *  _Objects_Close
 *
 */

#define _Objects_Close( _information, _the_object ) \
  { \
    unsigned32 _index; \
    \
    _index = _Objects_Get_index( (_the_object)->id ); \
    (_information)->local_table[ _index ] = (Objects_Control *) NULL; \
    _Objects_Clear_name( (_the_object)->name, (_information)->name_length ); \
  }

#endif
/* end of include file */