source: rtems/c/src/exec/score/inline/chain.inl @ 45819022

4.104.114.84.95
Last change on this file since 45819022 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 4.8 KB
Line 
1/*  inline/chain.inl
2 *
3 *  This include file contains the bodies of the routines which are
4 *  associated with doubly linked chains and inlined.
5 *
6 *  NOTE:  The routines in this file are ordered from simple
7 *         to complex.  No other Chain Handler routine is referenced
8 *         unless it has already been defined.
9 *
10 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
11 *  On-Line Applications Research Corporation (OAR).
12 *  All rights assigned to U.S. Government, 1994.
13 *
14 *  This material may be reproduced by or for the U.S. Government pursuant
15 *  to the copyright license under the clause at DFARS 252.227-7013.  This
16 *  notice must appear in all copies of this file and its derivatives.
17 *
18 *  $Id$
19 */
20
21#ifndef __INLINE_CHAIN_inl
22#define __INLINE_CHAIN_inl
23
24/*PAGE
25 *
26 *  _Chain_Are_nodes_equal
27 */
28
29STATIC INLINE boolean _Chain_Are_nodes_equal(
30  Chain_Node *left,
31  Chain_Node *right
32)
33{
34  return left == right;
35}
36
37/*PAGE
38 *
39 *  _Chain_Is_null
40 */
41
42STATIC INLINE boolean _Chain_Is_null(
43  Chain_Control *the_chain
44)
45{
46  return ( the_chain == NULL );
47}
48
49/*PAGE
50 *
51 *  _Chain_Is_null_node
52 */
53
54STATIC INLINE boolean _Chain_Is_null_node(
55  Chain_Node *the_node
56)
57{
58  return ( the_node == NULL );
59}
60
61/*PAGE
62 *
63 *  _Chain_Head
64 */
65
66STATIC INLINE Chain_Node *_Chain_Head(
67  Chain_Control *the_chain
68)
69{
70   return (Chain_Node *) the_chain;
71}
72
73/*PAGE
74 *
75 *  _Chain_Tail
76 */
77
78STATIC INLINE Chain_Node *_Chain_Tail(
79  Chain_Control *the_chain
80)
81{
82   return (Chain_Node *) &the_chain->permanent_null;
83}
84
85/*PAGE
86 *
87 *  _Chain_Is_empty
88 */
89
90STATIC INLINE boolean _Chain_Is_empty(
91  Chain_Control *the_chain
92)
93{
94  return ( the_chain->first == _Chain_Tail( the_chain ) );
95}
96
97/*PAGE
98 *
99 *  _Chain_Is_first
100 */
101
102STATIC INLINE boolean _Chain_Is_first(
103  Chain_Node *the_node
104)
105{
106  return ( the_node->previous == NULL );
107}
108
109/*PAGE
110 *
111 *  _Chain_Is_last
112 */
113
114STATIC INLINE boolean _Chain_Is_last(
115  Chain_Node *the_node
116)
117{
118  return ( the_node->next == NULL );
119}
120
121/*PAGE
122 *
123 *  _Chain_Has_only_one_node
124 */
125
126STATIC INLINE boolean _Chain_Has_only_one_node(
127  Chain_Control *the_chain
128)
129{
130  return ( the_chain->first == the_chain->last );
131}
132
133/*PAGE
134 *
135 *  _Chain_Is_head
136 */
137
138STATIC INLINE boolean _Chain_Is_head(
139  Chain_Control *the_chain,
140  Chain_Node    *the_node
141)
142{
143   return ( the_node == _Chain_Head( the_chain ) );
144}
145
146/*PAGE
147 *
148 *  _Chain_Is_tail
149 */
150
151STATIC INLINE boolean _Chain_Is_tail(
152  Chain_Control *the_chain,
153  Chain_Node    *the_node
154)
155{
156   return ( the_node == _Chain_Tail( the_chain ) );
157}
158
159/*PAGE
160 *
161 *  Chain_Initialize_empty
162 */
163
164STATIC INLINE void _Chain_Initialize_empty(
165  Chain_Control *the_chain
166)
167{
168  the_chain->first          = _Chain_Tail( the_chain );
169  the_chain->permanent_null = NULL;
170  the_chain->last           = _Chain_Head( the_chain );
171}
172
173/*PAGE
174 *
175 *  _Chain_Extract_unprotected
176 */
177
178STATIC INLINE void _Chain_Extract_unprotected(
179  Chain_Node *the_node
180)
181{
182  Chain_Node *next;
183  Chain_Node *previous;
184
185  next           = the_node->next;
186  previous       = the_node->previous;
187  next->previous = previous;
188  previous->next = next;
189}
190
191/*PAGE
192 *
193 *  _Chain_Get_first_unprotected
194 */
195
196STATIC INLINE Chain_Node *_Chain_Get_first_unprotected(
197  Chain_Control *the_chain
198)
199{
200  Chain_Node  *return_node;
201  Chain_Node  *new_first;
202
203  return_node         = the_chain->first;
204  new_first           = return_node->next;
205  the_chain->first    = new_first;
206  new_first->previous = _Chain_Head( the_chain );
207
208  return return_node;
209}
210
211/*PAGE
212 *
213 *  Chain_Get_unprotected
214 */
215
216STATIC INLINE Chain_Node *_Chain_Get_unprotected(
217  Chain_Control *the_chain
218)
219{
220  if ( !_Chain_Is_empty( the_chain ) )
221    return _Chain_Get_first_unprotected( the_chain );
222  else
223    return NULL;
224}
225
226/*PAGE
227 *
228 *  _Chain_Insert_unprotected
229 */
230
231STATIC INLINE void _Chain_Insert_unprotected(
232  Chain_Node *after_node,
233  Chain_Node *the_node
234)
235{
236  Chain_Node *before_node;
237
238  the_node->previous    = after_node;
239  before_node           = after_node->next;
240  after_node->next      = the_node;
241  the_node->next        = before_node;
242  before_node->previous = the_node;
243}
244
245/*PAGE
246 *
247 *  _Chain_Append_unprotected
248 */
249
250STATIC INLINE void _Chain_Append_unprotected(
251  Chain_Control *the_chain,
252  Chain_Node    *the_node
253)
254{
255  Chain_Node *old_last_node;
256
257  the_node->next      = _Chain_Tail( the_chain );
258  old_last_node       = the_chain->last;
259  the_chain->last     = the_node;
260  old_last_node->next = the_node;
261  the_node->previous  = old_last_node;
262}
263
264/*PAGE
265 *
266 *  _Chain_Prepend_unprotected
267 */
268
269STATIC INLINE void _Chain_Prepend_unprotected(
270  Chain_Control *the_chain,
271  Chain_Node    *the_node
272)
273{
274  _Chain_Insert_unprotected( _Chain_Head( the_chain ), the_node );
275
276}
277
278/*PAGE
279 *
280 *  _Chain_Prepend
281 */
282
283STATIC INLINE void _Chain_Prepend(
284  Chain_Control *the_chain,
285  Chain_Node    *the_node
286)
287{
288  _Chain_Insert( _Chain_Head( the_chain ), the_node );
289}
290
291#endif
292/* end of include file */
Note: See TracBrowser for help on using the repository browser.