[4d3017a] | 1 | /** |
---|
| 2 | * @file rtems/chain.h |
---|
| 3 | */ |
---|
| 4 | |
---|
[ecc9737f] | 5 | /* chain.h |
---|
[50f32b11] | 6 | * |
---|
[ecc9737f] | 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 |
---|
[0eae36c7] | 16 | * http://www.rtems.com/license/LICENSE. |
---|
[ecc9737f] | 17 | * |
---|
| 18 | * $ld: |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | #ifndef __CHAIN_h |
---|
| 22 | #define __CHAIN_h |
---|
| 23 | |
---|
| 24 | #include <rtems.h> |
---|
| 25 | |
---|
[50f32b11] | 26 | /* |
---|
[ecc9737f] | 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 | * |
---|
[50f32b11] | 33 | * Chain_Control *the_chain, * IN * |
---|
| 34 | * void *starting_address, * IN * |
---|
| 35 | * uint32_t number_nodes, * IN * |
---|
| 36 | * uint32_t node_size * IN * |
---|
[ecc9737f] | 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 | |
---|
[50f32b11] | 45 | /* |
---|
[ecc9737f] | 46 | * Chain_Initialize_empty |
---|
| 47 | * |
---|
| 48 | * This routine initializes the specified chain to contain zero nodes. |
---|
| 49 | * |
---|
[50f32b11] | 50 | * Chain_Control *the_chain * IN * |
---|
[ecc9737f] | 51 | */ |
---|
| 52 | |
---|
| 53 | #define Chain_Initialize_empty( the_chain ) \ |
---|
| 54 | _Chain_Initialize_empty( the_chain ) |
---|
[50f32b11] | 55 | |
---|
[ecc9737f] | 56 | |
---|
| 57 | /* |
---|
| 58 | * Chain_Are_nodes_equal |
---|
| 59 | * |
---|
| 60 | * This function returns TRUE if LEFT and RIGHT are equal, |
---|
| 61 | * and FALSE otherwise. |
---|
| 62 | * |
---|
[50f32b11] | 63 | * Chain_Node *left, * IN * |
---|
| 64 | * Chain_Node *right * IN * |
---|
[ecc9737f] | 65 | */ |
---|
[50f32b11] | 66 | |
---|
[ecc9737f] | 67 | #define Chain_Are_nodes_equal( left, right ) \ |
---|
| 68 | _Chain_Are_nodes_equal( left, right ) |
---|
| 69 | |
---|
| 70 | |
---|
[50f32b11] | 71 | /* |
---|
[ecc9737f] | 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 | * |
---|
[50f32b11] | 78 | * Chain_Node *the_node * IN * |
---|
[ecc9737f] | 79 | */ |
---|
| 80 | |
---|
| 81 | #define Chain_Extract_unprotected( the_node ) \ |
---|
| 82 | _Chain_Extract_unprotected( the_node ) |
---|
| 83 | |
---|
| 84 | |
---|
[50f32b11] | 85 | /* |
---|
[ecc9737f] | 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 | * |
---|
[50f32b11] | 92 | * Chain_Node *the_node * IN * |
---|
[ecc9737f] | 93 | */ |
---|
| 94 | |
---|
| 95 | #define Chain_Extract( the_node ) \ |
---|
| 96 | _Chain_Extract( the_node ) |
---|
| 97 | |
---|
| 98 | |
---|
[50f32b11] | 99 | /* |
---|
[ecc9737f] | 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 | * |
---|
[50f32b11] | 107 | * Chain_Control *the_chain * IN * |
---|
[ecc9737f] | 108 | */ |
---|
| 109 | |
---|
| 110 | #define Chain_Get_unprotected( the_chain ) \ |
---|
| 111 | _Chain_Get_unprotected( the_chain ) |
---|
| 112 | |
---|
| 113 | |
---|
[50f32b11] | 114 | /* |
---|
[ecc9737f] | 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 | * |
---|
[50f32b11] | 122 | * Chain_Control *the_chain * IN * |
---|
[ecc9737f] | 123 | */ |
---|
| 124 | |
---|
| 125 | #define Chain_Get( the_chain ) \ |
---|
| 126 | _Chain_Get( the_chain ) |
---|
| 127 | |
---|
| 128 | |
---|
[50f32b11] | 129 | /* |
---|
[ecc9737f] | 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 | * |
---|
[50f32b11] | 136 | * Chain_Control *the_chain * IN * |
---|
[ecc9737f] | 137 | */ |
---|
| 138 | |
---|
| 139 | #define Chain_Get_first_unprotected( the_chain ) \ |
---|
| 140 | _Chain_Get_first_unprotected( the_chain ) |
---|
| 141 | |
---|
| 142 | |
---|
[50f32b11] | 143 | /* |
---|
[ecc9737f] | 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 | * |
---|
[50f32b11] | 150 | * Chain_Node *after_node, * IN * |
---|
| 151 | * Chain_Node *the_node * IN * |
---|
[ecc9737f] | 152 | */ |
---|
| 153 | |
---|
| 154 | #define Chain_Insert_unprotected( after_node, the_node ) \ |
---|
| 155 | _Chain_Insert_unprotected( after_node, the_node ) |
---|
| 156 | |
---|
| 157 | |
---|
[50f32b11] | 158 | /* |
---|
[ecc9737f] | 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 | * |
---|
[50f32b11] | 165 | * Chain_Node *after_node, * IN * |
---|
| 166 | * Chain_Node *the_node * IN * |
---|
[ecc9737f] | 167 | */ |
---|
| 168 | |
---|
| 169 | #define Chain_Insert( after_node, the_node ) \ |
---|
| 170 | _Chain_Insert( after_node, the_node ) |
---|
| 171 | |
---|
| 172 | |
---|
[50f32b11] | 173 | /* |
---|
[ecc9737f] | 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 | * |
---|
[50f32b11] | 180 | * Chain_Control *the_chain, * IN * |
---|
| 181 | * Chain_Node *the_node * IN * |
---|
[ecc9737f] | 182 | */ |
---|
| 183 | |
---|
| 184 | #define Chain_Append_unprotected( the_chain, the_node ) \ |
---|
| 185 | _Chain_Append_unprotected( the_chain, the_node ) |
---|
| 186 | |
---|
| 187 | |
---|
[50f32b11] | 188 | /* |
---|
[ecc9737f] | 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 | * |
---|
[50f32b11] | 195 | * Chain_Control *the_chain, * IN * |
---|
| 196 | * Chain_Node *the_node * IN * |
---|
[ecc9737f] | 197 | */ |
---|
| 198 | |
---|
| 199 | #define Chain_Append( the_chain, the_node ) \ |
---|
| 200 | _Chain_Append( the_chain, the_node ) |
---|
| 201 | |
---|
| 202 | |
---|
[50f32b11] | 203 | /* |
---|
[ecc9737f] | 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 | * |
---|
[50f32b11] | 210 | * Chain_Control *the_chain, * IN * |
---|
| 211 | * Chain_Node *the_node * IN * |
---|
[ecc9737f] | 212 | */ |
---|
| 213 | |
---|
| 214 | #define Chain_Prepend_unprotected( the_chain, the_node ) \ |
---|
| 215 | _Chain_Prepend_unprotected( the_chain, the_node ) |
---|
| 216 | |
---|
| 217 | |
---|
[50f32b11] | 218 | /* |
---|
[ecc9737f] | 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 | * |
---|
[50f32b11] | 225 | * Chain_Control *the_chain, * IN * |
---|
| 226 | * Chain_Node *the_node * IN * |
---|
[ecc9737f] | 227 | */ |
---|
| 228 | |
---|
| 229 | #define Chain_Prepend( the_chain, the_node ) \ |
---|
| 230 | _Chain_Prepend( the_chain, the_node ) |
---|
| 231 | |
---|
| 232 | |
---|
[50f32b11] | 233 | /* |
---|
[ecc9737f] | 234 | * Chain_Head |
---|
| 235 | * |
---|
| 236 | * This function returns a pointer to the first node on the chain. |
---|
| 237 | * |
---|
[50f32b11] | 238 | * Chain_Control *the_chain * IN * |
---|
[ecc9737f] | 239 | */ |
---|
| 240 | |
---|
| 241 | #define Chain_Head( the_chain ) \ |
---|
| 242 | _Chain_Head( the_chain ) |
---|
| 243 | |
---|
| 244 | |
---|
[50f32b11] | 245 | /* |
---|
[ecc9737f] | 246 | * Chain_Tail |
---|
| 247 | * |
---|
| 248 | * This function returns a pointer to the last node on the chain. |
---|
| 249 | * |
---|
[50f32b11] | 250 | * Chain_Control *the_chain * IN * |
---|
[ecc9737f] | 251 | */ |
---|
| 252 | |
---|
| 253 | #define Chain_Tail( the_chain ) \ |
---|
| 254 | _Chain_Tail( the_chain ) |
---|
| 255 | |
---|
| 256 | |
---|
[50f32b11] | 257 | /* |
---|
[ecc9737f] | 258 | * Chain_Is_head |
---|
| 259 | * |
---|
| 260 | * This function returns TRUE if the_node is the head of the_chain and |
---|
| 261 | * FALSE otherwise. |
---|
| 262 | * |
---|
[50f32b11] | 263 | * Chain_Control *the_chain, * IN * |
---|
| 264 | * Chain_Node *the_node * IN * |
---|
[ecc9737f] | 265 | */ |
---|
| 266 | |
---|
| 267 | #define Chain_Is_head( the_chain, the_node ) \ |
---|
| 268 | _Chain_Is_head( the_chain, the_node ) |
---|
| 269 | |
---|
| 270 | |
---|
[50f32b11] | 271 | /* |
---|
[ecc9737f] | 272 | * Chain_Is_tail |
---|
| 273 | * |
---|
| 274 | * This function returns TRUE if the_node is the tail of the_chain and |
---|
| 275 | * FALSE otherwise. |
---|
| 276 | * |
---|
[50f32b11] | 277 | * Chain_Control *the_chain, * IN * |
---|
| 278 | * Chain_Node *the_node * IN * |
---|
[ecc9737f] | 279 | */ |
---|
| 280 | |
---|
| 281 | #define Chain_Is_tail( the_chain, the_node ) \ |
---|
| 282 | _Chain_Is_tail( the_chain, the_node ) |
---|
| 283 | |
---|
| 284 | |
---|
[50f32b11] | 285 | /* |
---|
[ecc9737f] | 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 | * |
---|
[50f32b11] | 291 | * Chain_Node *the_node * IN * |
---|
[ecc9737f] | 292 | */ |
---|
| 293 | |
---|
| 294 | #define Chain_Is_first( the_node ) \ |
---|
| 295 | _Chain_Is_first( the_node ) |
---|
| 296 | |
---|
| 297 | |
---|
[50f32b11] | 298 | /* |
---|
[ecc9737f] | 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 | * |
---|
[50f32b11] | 304 | * Chain_Node *the_node * IN * |
---|
[ecc9737f] | 305 | */ |
---|
| 306 | |
---|
| 307 | #define Chain_Is_last( the_node ) \ |
---|
| 308 | _Chain_Is_last( the_node ) |
---|
| 309 | |
---|
| 310 | |
---|
[50f32b11] | 311 | /* |
---|
[ecc9737f] | 312 | * Chain_Is_empty |
---|
| 313 | * |
---|
| 314 | * This function returns TRUE if there are no nodes on the_chain and |
---|
| 315 | * FALSE otherwise. |
---|
| 316 | * |
---|
[50f32b11] | 317 | * Chain_Control *the_chain * IN * |
---|
[ecc9737f] | 318 | */ |
---|
| 319 | |
---|
| 320 | #define Chain_Is_empty( the_chain ) \ |
---|
| 321 | _Chain_Is_empty( the_chain ) |
---|
| 322 | |
---|
| 323 | |
---|
[50f32b11] | 324 | /* |
---|
[ecc9737f] | 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 | * |
---|
[50f32b11] | 330 | * Chain_Control *the_chain * IN * |
---|
[ecc9737f] | 331 | */ |
---|
| 332 | |
---|
| 333 | #define Chain_Has_only_one_node( the_chain ) \ |
---|
| 334 | _Chain_Has_only_one_node( the_chain ) |
---|
| 335 | |
---|
| 336 | |
---|
[50f32b11] | 337 | /* |
---|
[ecc9737f] | 338 | * Chain_Is_null |
---|
| 339 | * |
---|
| 340 | * This function returns TRUE if the_chain is NULL and FALSE otherwise. |
---|
| 341 | * |
---|
[50f32b11] | 342 | * Chain_Control *the_chain * IN * |
---|
[ecc9737f] | 343 | */ |
---|
| 344 | |
---|
| 345 | #define Chain_Is_null( the_chain ) \ |
---|
| 346 | _Chain_Is_null( the_chain ) |
---|
| 347 | |
---|
| 348 | |
---|
[50f32b11] | 349 | /* |
---|
[ecc9737f] | 350 | * Chain_Is_null_node |
---|
| 351 | * |
---|
| 352 | * This function returns TRUE if the_node is NULL and FALSE otherwise. |
---|
| 353 | * |
---|
[50f32b11] | 354 | * Chain_Node *the_node * IN * |
---|
[ecc9737f] | 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 */ |
---|