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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [doc/] [tools/] [bmenu/] [chain.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*  chain.h
2
 *
3
 *  This include file contains all the constants and structures associated
4
 *  with the Doubly Linked Chain Handler.
5
 *
6
 *  COPYRIGHT (c) 1988-2002.
7
 *  On-Line Applications Research Corporation (OAR).
8
 *  All rights reserved.
9
 *
10
 *  chain.h,v 1.5 2002/01/17 21:47:47 joel Exp
11
 */
12
 
13
#ifndef __CHAIN_h
14
#define __CHAIN_h
15
 
16
#include "address.h"
17
 
18
/*
19
 *  This is used to manage each element (node) which is placed
20
 *  on a chain.
21
 *
22
 *  NOTE:  Typically, a more complicated structure will use the
23
 *         chain package.  The more complicated structure will
24
 *         include a chain node as the first element in its
25
 *         control structure.  It will then call the chain package
26
 *         with a pointer to that node element.  The node pointer
27
 *         and the higher level structure start at the same address
28
 *         so the user can cast the pointers back and forth.
29
 */
30
 
31
typedef struct Chain_Node_struct Chain_Node;
32
 
33
struct Chain_Node_struct {
34
  Chain_Node *next;
35
  Chain_Node *previous;
36
};
37
 
38
/*
39
 *  This is used to manage a chain.  A chain consists of a doubly
40
 *  linked list of zero or more nodes.
41
 *
42
 *  NOTE:  This implementation does not require special checks for
43
 *         manipulating the first and last elements on the chain.
44
 *         To accomplish this the chain control structure is
45
 *         treated as two overlapping chain nodes.  The permanent
46
 *         head of the chain overlays a node structure on the
47
 *         first and permanent_null fields.  The permanent tail
48
 *         of the chain overlays a node structure on the
49
 *         permanent_null and last elements of the structure.
50
 */
51
 
52
typedef struct {
53
  Chain_Node *first;
54
  Chain_Node *permanent_null;
55
  Chain_Node *last;
56
} Chain_Control;
57
 
58
/*
59
 *  _Chain_Initialize
60
 *
61
 *  This routine initializes the_chain structure to manage the
62
 *  contiguous array of number_nodes nodes which starts at
63
 *  starting_address.  Each node is of node_size bytes.
64
 */
65
 
66
void _Chain_Initialize(
67
  Chain_Control *the_chain,
68
  void          *starting_address,
69
  unsigned32     number_nodes,
70
  unsigned32     node_size
71
);
72
 
73
/*
74
 *  _Chain_Initialize_empty
75
 *
76
 *  This routine initializes the specified chain to contain zero nodes.
77
 */
78
 
79
STATIC INLINE void _Chain_Initialize_empty(
80
  Chain_Control *the_chain
81
);
82
 
83
/*
84
 *  _Chain_Extract_unprotected
85
 *
86
 *  This routine extracts the_node from the chain on which it resides.
87
 *  It does NOT disable interrupts to insure the atomicity of the
88
 *  extract operation.
89
 */
90
 
91
STATIC INLINE void _Chain_Extract_unprotected(
92
  Chain_Node *the_node
93
);
94
 
95
/*
96
 *  _Chain_Extract
97
 *
98
 *  This routine extracts the_node from the chain on which it resides.
99
 *  It disables interrupts to insure the atomicity of the
100
 *  extract operation.
101
 */
102
 
103
void _Chain_Extract(
104
  Chain_Node *the_node
105
);
106
 
107
/*
108
 *  _Chain_Get_unprotected
109
 *
110
 *  This function removes the first node from the_chain and returns
111
 *  a pointer to that node.  If the_chain is empty, then NULL is returned.
112
 *  It does NOT disable interrupts to insure the atomicity of the
113
 *  get operation.
114
 */
115
 
116
STATIC INLINE Chain_Node *_Chain_Get_unprotected(
117
  Chain_Control *the_chain
118
);
119
 
120
/*
121
 *  _Chain_Get
122
 *
123
 *  This function removes the first node from the_chain and returns
124
 *  a pointer to that node.  If the_chain is empty, then NULL is returned.
125
 *  It disables interrupts to insure the atomicity of the
126
 *  get operation.
127
 */
128
 
129
Chain_Node *_Chain_Get(
130
  Chain_Control *the_chain
131
);
132
 
133
/*
134
 *  _Chain_Get_first_unprotected
135
 *
136
 *  This function removes the first node from the_chain and returns
137
 *  a pointer to that node.  It does NOT disable interrupts to insure
138
 *  the atomicity of the get operation.
139
 */
140
 
141
STATIC INLINE Chain_Node *_Chain_Get_first_unprotected(
142
  Chain_Control *the_chain
143
);
144
 
145
/*
146
 *  _Chain_Insert_unprotected
147
 *
148
 *  This routine inserts the_node on a chain immediately following
149
 *  after_node.  It does NOT disable interrupts to insure the atomicity
150
 *  of the extract operation.
151
 */
152
 
153
STATIC INLINE void _Chain_Insert_unprotected(
154
  Chain_Node *after_node,
155
  Chain_Node *the_node
156
);
157
 
158
/*
159
 *  _Chain_Insert
160
 *
161
 *  This routine inserts the_node on a chain immediately following
162
 *  after_node.  It disables interrupts to insure the atomicity
163
 *  of the extract operation.
164
 */
165
 
166
void _Chain_Insert(
167
  Chain_Node *after_node,
168
  Chain_Node *the_node
169
);
170
 
171
/*
172
 *  _Chain_Append_unprotected
173
 *
174
 *  This routine appends the_node onto the end of the_chain.
175
 *  It does NOT disable interrupts to insure the atomicity of the
176
 *  append operation.
177
 */
178
 
179
STATIC INLINE void _Chain_Append_unprotected(
180
  Chain_Control *the_chain,
181
  Chain_Node    *the_node
182
);
183
 
184
/*
185
 *  _Chain_Append
186
 *
187
 *  This routine appends the_node onto the end of the_chain.
188
 *  It disables interrupts to insure the atomicity of the
189
 *  append operation.
190
 */
191
 
192
void _Chain_Append(
193
  Chain_Control *the_chain,
194
  Chain_Node    *the_node
195
);
196
 
197
/*
198
 *  _Chain_Prepend_unprotected
199
 *
200
 *  This routine prepends the_node onto the front of the_chain.
201
 *  It does NOT disable interrupts to insure the atomicity of the
202
 *  prepend operation.
203
 */
204
 
205
STATIC INLINE void _Chain_Prepend_unprotected(
206
  Chain_Control *the_chain,
207
  Chain_Node    *the_node
208
);
209
 
210
/*
211
 *  _Chain_Prepend
212
 *
213
 *  This routine prepends the_node onto the front of the_chain.
214
 *  It disables interrupts to insure the atomicity of the
215
 *  prepend operation.
216
 */
217
 
218
STATIC INLINE void _Chain_Prepend(
219
  Chain_Control *the_chain,
220
  Chain_Node    *the_node
221
);
222
 
223
/*
224
 *  _Chain_Insert_chain
225
 *
226
 *  This routine inserts a chain after the specified node in another
227
 *  chain. It is assumed that the insert after node is not on the
228
 *  second chain.
229
 */
230
 
231
void _Chain_Insert_chain(
232
  Chain_Node    *insert_after,
233
  Chain_Control *to_insert
234
);
235
 
236
/*
237
 *  _Chain_Head
238
 *
239
 *  This function returns a pointer to the first node on the chain.
240
 */
241
 
242
STATIC INLINE Chain_Node *_Chain_Head(
243
  Chain_Control *the_chain
244
);
245
 
246
/*
247
 *  _Chain_Tail
248
 *
249
 *  This function returns a pointer to the last node on the chain.
250
 */
251
 
252
STATIC INLINE Chain_Node *_Chain_Tail(
253
  Chain_Control *the_chain
254
);
255
 
256
/*
257
 *  _Chain_Is_head
258
 *
259
 *  This function returns TRUE if the_node is the head of the_chain and
260
 *  FALSE otherwise.
261
 */
262
 
263
STATIC INLINE boolean _Chain_Is_head(
264
  Chain_Control *the_chain,
265
  Chain_Node    *the_node
266
);
267
 
268
/*
269
 *  _Chain_Is_tail
270
 *
271
 *  This function returns TRUE if the_node is the tail of the_chain and
272
 *  FALSE otherwise.
273
 */
274
 
275
STATIC INLINE boolean _Chain_Is_tail(
276
  Chain_Control *the_chain,
277
  Chain_Node    *the_node
278
);
279
 
280
/*
281
 *  _Chain_Is_first
282
 *
283
 *  This function returns TRUE if the_node is the first node on a chain and
284
 *  FALSE otherwise.
285
 */
286
 
287
STATIC INLINE boolean _Chain_Is_first(
288
  Chain_Node *the_node
289
);
290
 
291
/*
292
 *  _Chain_Is_last
293
 *
294
 *  This function returns TRUE if the_node is the last node on a chain and
295
 *  FALSE otherwise.
296
 */
297
 
298
STATIC INLINE boolean _Chain_Is_last(
299
  Chain_Node *the_node
300
);
301
 
302
/*
303
 *  _Chain_Is_empty
304
 *
305
 *  This function returns TRUE if there a no nodes on the_chain and
306
 *  FALSE otherwise.
307
 */
308
 
309
STATIC INLINE boolean _Chain_Is_empty(
310
  Chain_Control *the_chain
311
);
312
 
313
/*
314
 *  _Chain_Has_only_one_node
315
 *
316
 *  This function returns TRUE if there is only one node on the_chain and
317
 *  FALSE otherwise.
318
 */
319
 
320
STATIC INLINE boolean _Chain_Has_only_one_node(
321
  Chain_Control *the_chain
322
);
323
 
324
/*
325
 *  _Chain_Is_null
326
 *
327
 *  This function returns TRUE if the_chain is NULL and FALSE otherwise.
328
 */
329
 
330
STATIC INLINE boolean _Chain_Is_null(
331
  Chain_Control *the_chain
332
);
333
 
334
/*
335
 *  _Chain_Is_null_node
336
 *
337
 *  This function returns TRUE if the_node is NULL and FALSE otherwise.
338
 */
339
 
340
STATIC INLINE boolean _Chain_Is_null_node(
341
  Chain_Node *the_node
342
);
343
 
344
#include "chain.inl"
345
 
346
#endif
347
/* end of include file */

powered by: WebSVN 2.1.0

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