1 | /** |
---|
2 | * @file rtems/chain.h |
---|
3 | */ |
---|
4 | |
---|
5 | /* chain.h |
---|
6 | * |
---|
7 | * This include file contains all the constants and structures associated |
---|
8 | * with doubly linked chains. This file actually just provides an |
---|
9 | * interface to the chain object in rtems. |
---|
10 | * |
---|
11 | * COPYRIGHT (c) 1989-1997. |
---|
12 | * On-Line Applications Research Corporation (OAR). |
---|
13 | * |
---|
14 | * The license and distribution terms for this file may in |
---|
15 | * the file LICENSE in this distribution or at |
---|
16 | * http://www.rtems.com/license/LICENSE. |
---|
17 | * |
---|
18 | * $ld: |
---|
19 | */ |
---|
20 | |
---|
21 | #ifndef _RTEMS_CHAIN_H |
---|
22 | #define _RTEMS_CHAIN_H |
---|
23 | |
---|
24 | #include <rtems.h> |
---|
25 | |
---|
26 | /* |
---|
27 | * Chain_Initialize |
---|
28 | * |
---|
29 | * This routine initializes the_chain structure to manage the |
---|
30 | * contiguous array of number_nodes nodes which starts at |
---|
31 | * starting_address. Each node is of node_size bytes. |
---|
32 | * |
---|
33 | * Chain_Control *the_chain, * IN * |
---|
34 | * void *starting_address, * IN * |
---|
35 | * uint32_t number_nodes, * IN * |
---|
36 | * uint32_t node_size * IN * |
---|
37 | */ |
---|
38 | |
---|
39 | #define Chain_Initialize( the_chain, starting_address, \ |
---|
40 | number_nodes, node_size ) \ |
---|
41 | _Chain_Initialize( the_chain, starting_address, \ |
---|
42 | number_nodes, node_size ) \ |
---|
43 | |
---|
44 | |
---|
45 | /* |
---|
46 | * Chain_Initialize_empty |
---|
47 | * |
---|
48 | * This routine initializes the specified chain to contain zero nodes. |
---|
49 | * |
---|
50 | * Chain_Control *the_chain * IN * |
---|
51 | */ |
---|
52 | |
---|
53 | #define Chain_Initialize_empty( the_chain ) \ |
---|
54 | _Chain_Initialize_empty( the_chain ) |
---|
55 | |
---|
56 | |
---|
57 | /* |
---|
58 | * Chain_Are_nodes_equal |
---|
59 | * |
---|
60 | * This function returns TRUE if LEFT and RIGHT are equal, |
---|
61 | * and FALSE otherwise. |
---|
62 | * |
---|
63 | * Chain_Node *left, * IN * |
---|
64 | * Chain_Node *right * IN * |
---|
65 | */ |
---|
66 | |
---|
67 | #define Chain_Are_nodes_equal( left, right ) \ |
---|
68 | _Chain_Are_nodes_equal( left, right ) |
---|
69 | |
---|
70 | |
---|
71 | /* |
---|
72 | * Chain_Extract_unprotected |
---|
73 | * |
---|
74 | * This routine extracts the_node from the chain on which it resides. |
---|
75 | * It does NOT disable interrupts to insure the atomicity of the |
---|
76 | * extract operation. |
---|
77 | * |
---|
78 | * Chain_Node *the_node * IN * |
---|
79 | */ |
---|
80 | |
---|
81 | #define Chain_Extract_unprotected( the_node ) \ |
---|
82 | _Chain_Extract_unprotected( the_node ) |
---|
83 | |
---|
84 | |
---|
85 | /* |
---|
86 | * Chain_Extract |
---|
87 | * |
---|
88 | * This routine extracts the_node from the chain on which it resides. |
---|
89 | * It disables interrupts to insure the atomicity of the |
---|
90 | * extract operation. |
---|
91 | * |
---|
92 | * Chain_Node *the_node * IN * |
---|
93 | */ |
---|
94 | |
---|
95 | #define Chain_Extract( the_node ) \ |
---|
96 | _Chain_Extract( the_node ) |
---|
97 | |
---|
98 | |
---|
99 | /* |
---|
100 | * Chain_Get_unprotected |
---|
101 | * |
---|
102 | * This function removes the first node from the_chain and returns |
---|
103 | * a pointer to that node. If the_chain is empty, then NULL is returned. |
---|
104 | * It does NOT disable interrupts to insure the atomicity of the |
---|
105 | * get operation. |
---|
106 | * |
---|
107 | * Chain_Control *the_chain * IN * |
---|
108 | */ |
---|
109 | |
---|
110 | #define Chain_Get_unprotected( the_chain ) \ |
---|
111 | _Chain_Get_unprotected( the_chain ) |
---|
112 | |
---|
113 | |
---|
114 | /* |
---|
115 | * Chain_Get |
---|
116 | * |
---|
117 | * This function removes the first node from the_chain and returns |
---|
118 | * a pointer to that node. If the_chain is empty, then NULL is returned. |
---|
119 | * It disables interrupts to insure the atomicity of the |
---|
120 | * get operation. |
---|
121 | * |
---|
122 | * Chain_Control *the_chain * IN * |
---|
123 | */ |
---|
124 | |
---|
125 | #define Chain_Get( the_chain ) \ |
---|
126 | _Chain_Get( the_chain ) |
---|
127 | |
---|
128 | |
---|
129 | /* |
---|
130 | * Chain_Get_first_unprotected |
---|
131 | * |
---|
132 | * This function removes the first node from the_chain and returns |
---|
133 | * a pointer to that node. It does NOT disable interrupts to insure |
---|
134 | * the atomicity of the get operation. |
---|
135 | * |
---|
136 | * Chain_Control *the_chain * IN * |
---|
137 | */ |
---|
138 | |
---|
139 | #define Chain_Get_first_unprotected( the_chain ) \ |
---|
140 | _Chain_Get_first_unprotected( the_chain ) |
---|
141 | |
---|
142 | |
---|
143 | /* |
---|
144 | * Chain_Insert_unprotected |
---|
145 | * |
---|
146 | * This routine inserts the_node on a chain immediately following |
---|
147 | * after_node. It does NOT disable interrupts to insure the atomicity |
---|
148 | * of the extract operation. |
---|
149 | * |
---|
150 | * Chain_Node *after_node, * IN * |
---|
151 | * Chain_Node *the_node * IN * |
---|
152 | */ |
---|
153 | |
---|
154 | #define Chain_Insert_unprotected( after_node, the_node ) \ |
---|
155 | _Chain_Insert_unprotected( after_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 | * Chain_Node *after_node, * IN * |
---|
166 | * Chain_Node *the_node * IN * |
---|
167 | */ |
---|
168 | |
---|
169 | #define Chain_Insert( after_node, the_node ) \ |
---|
170 | _Chain_Insert( after_node, the_node ) |
---|
171 | |
---|
172 | |
---|
173 | /* |
---|
174 | * Chain_Append_unprotected |
---|
175 | * |
---|
176 | * This routine appends the_node onto the end of the_chain. |
---|
177 | * It does NOT disable interrupts to insure the atomicity of the |
---|
178 | * append operation. |
---|
179 | * |
---|
180 | * Chain_Control *the_chain, * IN * |
---|
181 | * Chain_Node *the_node * IN * |
---|
182 | */ |
---|
183 | |
---|
184 | #define Chain_Append_unprotected( the_chain, the_node ) \ |
---|
185 | _Chain_Append_unprotected( the_chain, the_node ) |
---|
186 | |
---|
187 | |
---|
188 | /* |
---|
189 | * Chain_Append |
---|
190 | * |
---|
191 | * This routine appends the_node onto the end of the_chain. |
---|
192 | * It disables interrupts to insure the atomicity of the |
---|
193 | * append operation. |
---|
194 | * |
---|
195 | * Chain_Control *the_chain, * IN * |
---|
196 | * Chain_Node *the_node * IN * |
---|
197 | */ |
---|
198 | |
---|
199 | #define Chain_Append( the_chain, the_node ) \ |
---|
200 | _Chain_Append( the_chain, the_node ) |
---|
201 | |
---|
202 | |
---|
203 | /* |
---|
204 | * Chain_Prepend_unprotected |
---|
205 | * |
---|
206 | * This routine prepends the_node onto the front of the_chain. |
---|
207 | * It does NOT disable interrupts to insure the atomicity of the |
---|
208 | * prepend operation. |
---|
209 | * |
---|
210 | * Chain_Control *the_chain, * IN * |
---|
211 | * Chain_Node *the_node * IN * |
---|
212 | */ |
---|
213 | |
---|
214 | #define Chain_Prepend_unprotected( the_chain, the_node ) \ |
---|
215 | _Chain_Prepend_unprotected( the_chain, the_node ) |
---|
216 | |
---|
217 | |
---|
218 | /* |
---|
219 | * Chain_Prepend |
---|
220 | * |
---|
221 | * This routine prepends the_node onto the front of the_chain. |
---|
222 | * It disables interrupts to insure the atomicity of the |
---|
223 | * prepend operation. |
---|
224 | * |
---|
225 | * Chain_Control *the_chain, * IN * |
---|
226 | * Chain_Node *the_node * IN * |
---|
227 | */ |
---|
228 | |
---|
229 | #define Chain_Prepend( the_chain, the_node ) \ |
---|
230 | _Chain_Prepend( the_chain, the_node ) |
---|
231 | |
---|
232 | |
---|
233 | /* |
---|
234 | * Chain_Head |
---|
235 | * |
---|
236 | * This function returns a pointer to the first node on the chain. |
---|
237 | * |
---|
238 | * Chain_Control *the_chain * IN * |
---|
239 | */ |
---|
240 | |
---|
241 | #define Chain_Head( the_chain ) \ |
---|
242 | _Chain_Head( the_chain ) |
---|
243 | |
---|
244 | |
---|
245 | /* |
---|
246 | * Chain_Tail |
---|
247 | * |
---|
248 | * This function returns a pointer to the last node on the chain. |
---|
249 | * |
---|
250 | * Chain_Control *the_chain * IN * |
---|
251 | */ |
---|
252 | |
---|
253 | #define Chain_Tail( the_chain ) \ |
---|
254 | _Chain_Tail( the_chain ) |
---|
255 | |
---|
256 | |
---|
257 | /* |
---|
258 | * Chain_Is_head |
---|
259 | * |
---|
260 | * This function returns TRUE if the_node is the head of the_chain and |
---|
261 | * FALSE otherwise. |
---|
262 | * |
---|
263 | * Chain_Control *the_chain, * IN * |
---|
264 | * Chain_Node *the_node * IN * |
---|
265 | */ |
---|
266 | |
---|
267 | #define Chain_Is_head( the_chain, the_node ) \ |
---|
268 | _Chain_Is_head( the_chain, the_node ) |
---|
269 | |
---|
270 | |
---|
271 | /* |
---|
272 | * Chain_Is_tail |
---|
273 | * |
---|
274 | * This function returns TRUE if the_node is the tail of the_chain and |
---|
275 | * FALSE otherwise. |
---|
276 | * |
---|
277 | * Chain_Control *the_chain, * IN * |
---|
278 | * Chain_Node *the_node * IN * |
---|
279 | */ |
---|
280 | |
---|
281 | #define Chain_Is_tail( the_chain, the_node ) \ |
---|
282 | _Chain_Is_tail( the_chain, the_node ) |
---|
283 | |
---|
284 | |
---|
285 | /* |
---|
286 | * Chain_Is_first |
---|
287 | * |
---|
288 | * This function returns TRUE if the_node is the first node on a chain and |
---|
289 | * FALSE otherwise. |
---|
290 | * |
---|
291 | * Chain_Node *the_node * IN * |
---|
292 | */ |
---|
293 | |
---|
294 | #define Chain_Is_first( the_node ) \ |
---|
295 | _Chain_Is_first( the_node ) |
---|
296 | |
---|
297 | |
---|
298 | /* |
---|
299 | * Chain_Is_last |
---|
300 | * |
---|
301 | * This function returns TRUE if the_node is the last node on a chain and |
---|
302 | * FALSE otherwise. |
---|
303 | * |
---|
304 | * Chain_Node *the_node * IN * |
---|
305 | */ |
---|
306 | |
---|
307 | #define Chain_Is_last( the_node ) \ |
---|
308 | _Chain_Is_last( the_node ) |
---|
309 | |
---|
310 | |
---|
311 | /* |
---|
312 | * Chain_Is_empty |
---|
313 | * |
---|
314 | * This function returns TRUE if there are no nodes on the_chain and |
---|
315 | * FALSE otherwise. |
---|
316 | * |
---|
317 | * Chain_Control *the_chain * IN * |
---|
318 | */ |
---|
319 | |
---|
320 | #define Chain_Is_empty( the_chain ) \ |
---|
321 | _Chain_Is_empty( the_chain ) |
---|
322 | |
---|
323 | |
---|
324 | /* |
---|
325 | * Chain_Has_only_one_node |
---|
326 | * |
---|
327 | * This function returns TRUE if there is only one node on the_chain and |
---|
328 | * FALSE otherwise. |
---|
329 | * |
---|
330 | * Chain_Control *the_chain * IN * |
---|
331 | */ |
---|
332 | |
---|
333 | #define Chain_Has_only_one_node( the_chain ) \ |
---|
334 | _Chain_Has_only_one_node( the_chain ) |
---|
335 | |
---|
336 | |
---|
337 | /* |
---|
338 | * Chain_Is_null |
---|
339 | * |
---|
340 | * This function returns TRUE if the_chain is NULL and FALSE otherwise. |
---|
341 | * |
---|
342 | * Chain_Control *the_chain * IN * |
---|
343 | */ |
---|
344 | |
---|
345 | #define Chain_Is_null( the_chain ) \ |
---|
346 | _Chain_Is_null( the_chain ) |
---|
347 | |
---|
348 | |
---|
349 | /* |
---|
350 | * Chain_Is_null_node |
---|
351 | * |
---|
352 | * This function returns TRUE if the_node is NULL and FALSE otherwise. |
---|
353 | * |
---|
354 | * Chain_Node *the_node * IN * |
---|
355 | */ |
---|
356 | |
---|
357 | #define Chain_Is_null_node( the_node ) \ |
---|
358 | _Chain_Is_null_node( the_node ) |
---|
359 | |
---|
360 | |
---|
361 | #undef __RTEMS_APPLICATION__ |
---|
362 | #include <rtems/score/chain.inl> |
---|
363 | #define __RTEMS_APPLICATION__ |
---|
364 | #endif |
---|
365 | /* end of include file */ |
---|