RTEMS
chain.c
Go to the documentation of this file.
1 
9 /*
10  * COPYRIGHT (c) 1989-2007.
11  * On-Line Applications Research Corporation (OAR).
12  *
13  * The license and distribution terms for this file may be
14  * found in the file LICENSE in this distribution or at
15  * http://www.rtems.org/license/LICENSE.
16  */
17 
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21 
22 #include <rtems/score/chainimpl.h>
23 #include <rtems/score/address.h>
24 #include <rtems/score/assert.h>
25 
27  Chain_Control *the_chain,
28  void *starting_address,
29  size_t number_nodes,
30  size_t node_size
31 )
32 {
33  size_t count = number_nodes;
34  Chain_Node *head = _Chain_Head( the_chain );
35  Chain_Node *tail = _Chain_Tail( the_chain );
36  Chain_Node *current = head;
37  Chain_Node *next = starting_address;
38 
39  _Assert( node_size >= sizeof( *next ) );
40 
41  head->previous = NULL;
42 
43  while ( count-- ) {
44  current->next = next;
45  next->previous = current;
46  current = next;
47  next = (Chain_Node *)
48  _Addresses_Add_offset( (void *) next, node_size );
49  }
50 
51  current->next = tail;
52  tail->previous = current;
53 }
Chain_Node * previous
Definition: chain.h:72
void _Chain_Initialize(Chain_Control *the_chain, void *starting_address, size_t number_nodes, size_t node_size)
Initializes a chain header.
Definition: chain.c:26
Information for the Assert Handler.
Chain_Node * next
Definition: chain.h:70
Information Required to Manipulate Physical Addresses.
static __inline__ Chain_Node * _Chain_Head(Chain_Control *the_chain)
Returns pointer to chain head.
Definition: chainimpl.h:195
Chain Handler API.
static __inline__ Chain_Node * _Chain_Tail(Chain_Control *the_chain)
Returns pointer to chain tail.
Definition: chainimpl.h:227
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:100
RTEMS_INLINE_ROUTINE void * _Addresses_Add_offset(const void *base, uintptr_t offset)
Adds offset to an address.
Definition: address.h:55