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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [doc/] [tools/] [bmenu/] [chain.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
/*  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
 *  COPYRIGHT (c) 1988-2002.
7
 *  On-Line Applications Research Corporation (OAR).
8
 *  All rights reserved.
9
 *
10
 *  chain.inl,v 1.5 2002/01/17 21:47:47 joel Exp
11
 */
12
 
13
#ifndef __INLINE_CHAIN_inl
14
#define __INLINE_CHAIN_inl
15
 
16
/*PAGE
17
 *
18
 *  _Chain_Is_null
19
 */
20
 
21
STATIC INLINE boolean _Chain_Is_null(
22
  Chain_Control *the_chain
23
)
24
{
25
  return ( the_chain == NULL );
26
}
27
 
28
/*PAGE
29
 *
30
 *  _Chain_Is_null_node
31
 */
32
 
33
STATIC INLINE boolean _Chain_Is_null_node(
34
  Chain_Node *the_node
35
)
36
{
37
  return ( the_node == NULL );
38
}
39
 
40
/*PAGE
41
 *
42
 *  _Chain_Head
43
 */
44
 
45
STATIC INLINE Chain_Node *_Chain_Head(
46
  Chain_Control *the_chain
47
)
48
{
49
   return (Chain_Node *) the_chain;
50
}
51
 
52
/*PAGE
53
 *
54
 *  _Chain_Tail
55
 */
56
 
57
STATIC INLINE Chain_Node *_Chain_Tail(
58
  Chain_Control *the_chain
59
)
60
{
61
   return (Chain_Node *) &the_chain->permanent_null;
62
}
63
 
64
/*PAGE
65
 *
66
 *  _Chain_Is_empty
67
 */
68
 
69
STATIC INLINE boolean _Chain_Is_empty(
70
  Chain_Control *the_chain
71
)
72
{
73
  return ( the_chain->first == _Chain_Tail( the_chain ) );
74
}
75
 
76
/*PAGE
77
 *
78
 *  _Chain_Is_first
79
 */
80
 
81
STATIC INLINE boolean _Chain_Is_first(
82
  Chain_Node *the_node
83
)
84
{
85
  return ( the_node->previous == NULL );
86
}
87
 
88
/*PAGE
89
 *
90
 *  _Chain_Is_last
91
 */
92
 
93
STATIC INLINE boolean _Chain_Is_last(
94
  Chain_Node *the_node
95
)
96
{
97
  return ( the_node->next == NULL );
98
}
99
 
100
/*PAGE
101
 *
102
 *  _Chain_Has_only_one_node
103
 */
104
 
105
STATIC INLINE boolean _Chain_Has_only_one_node(
106
  Chain_Control *the_chain
107
)
108
{
109
  return ( the_chain->first == the_chain->last );
110
}
111
 
112
/*PAGE
113
 *
114
 *  _Chain_Is_head
115
 */
116
 
117
STATIC INLINE boolean _Chain_Is_head(
118
  Chain_Control *the_chain,
119
  Chain_Node    *the_node
120
)
121
{
122
   return ( the_node == _Chain_Head( the_chain ) );
123
}
124
 
125
/*PAGE
126
 *
127
 *  _Chain_Is_tail
128
 */
129
 
130
STATIC INLINE boolean _Chain_Is_tail(
131
  Chain_Control *the_chain,
132
  Chain_Node    *the_node
133
)
134
{
135
   return ( the_node == _Chain_Tail( the_chain ) );
136
}
137
 
138
/*PAGE
139
 *
140
 *  Chain_Initialize_empty
141
 */
142
 
143
STATIC INLINE void _Chain_Initialize_empty(
144
  Chain_Control *the_chain
145
)
146
{
147
  the_chain->first          = _Chain_Tail( the_chain );
148
  the_chain->permanent_null = NULL;
149
  the_chain->last           = _Chain_Head( the_chain );
150
}
151
 
152
/*PAGE
153
 *
154
 *  _Chain_Extract_unprotected
155
 */
156
 
157
STATIC INLINE void _Chain_Extract_unprotected(
158
  Chain_Node *the_node
159
)
160
{
161
  Chain_Node *next;
162
  Chain_Node *previous;
163
 
164
  next           = the_node->next;
165
  previous       = the_node->previous;
166
  next->previous = previous;
167
  previous->next = next;
168
}
169
 
170
/*PAGE
171
 *
172
 *  _Chain_Get_first_unprotected
173
 */
174
 
175
STATIC INLINE Chain_Node *_Chain_Get_first_unprotected(
176
  Chain_Control *the_chain
177
)
178
{
179
  Chain_Node  *return_node;
180
  Chain_Node  *new_first;
181
 
182
  return_node         = the_chain->first;
183
  new_first           = return_node->next;
184
  the_chain->first    = new_first;
185
  new_first->previous = _Chain_Head( the_chain );
186
 
187
  return return_node;
188
}
189
 
190
/*PAGE
191
 *
192
 *  Chain_Get_unprotected
193
 */
194
 
195
STATIC INLINE Chain_Node *_Chain_Get_unprotected(
196
  Chain_Control *the_chain
197
)
198
{
199
  if ( !_Chain_Is_empty( the_chain ) )
200
    return _Chain_Get_first_unprotected( the_chain );
201
  else
202
    return NULL;
203
}
204
 
205
/*PAGE
206
 *
207
 *  _Chain_Insert_unprotected
208
 */
209
 
210
STATIC INLINE void _Chain_Insert_unprotected(
211
  Chain_Node *after_node,
212
  Chain_Node *the_node
213
)
214
{
215
  Chain_Node *before_node;
216
 
217
  the_node->previous    = after_node;
218
  before_node           = after_node->next;
219
  after_node->next      = the_node;
220
  the_node->next        = before_node;
221
  before_node->previous = the_node;
222
}
223
 
224
/*PAGE
225
 *
226
 *  _Chain_Append_unprotected
227
 */
228
 
229
STATIC INLINE void _Chain_Append_unprotected(
230
  Chain_Control *the_chain,
231
  Chain_Node    *the_node
232
)
233
{
234
  Chain_Node *old_last_node;
235
 
236
  the_node->next      = _Chain_Tail( the_chain );
237
  old_last_node       = the_chain->last;
238
  the_chain->last     = the_node;
239
  old_last_node->next = the_node;
240
  the_node->previous  = old_last_node;
241
}
242
 
243
/*PAGE
244
 *
245
 *  _Chain_Prepend_unprotected
246
 */
247
 
248
STATIC INLINE void _Chain_Prepend_unprotected(
249
  Chain_Control *the_chain,
250
  Chain_Node    *the_node
251
)
252
{
253
  _Chain_Insert_unprotected( _Chain_Head( the_chain ), the_node );
254
 
255
}
256
 
257
/*PAGE
258
 *
259
 *  _Chain_Prepend
260
 */
261
 
262
STATIC INLINE void _Chain_Prepend(
263
  Chain_Control *the_chain,
264
  Chain_Node    *the_node
265
)
266
{
267
  _Chain_Insert( _Chain_Head( the_chain ), the_node );
268
}
269
 
270
#endif
271
/* end of include file */

powered by: WebSVN 2.1.0

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