source: rtems/cpukit/score/src/chain.c

Last change on this file was 9278f3d, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 27, 2020 at 4:21:23 PM

score: Canonicalize Doxygen @file comments

Use common phrases for the file brief descriptions.

Update #3706.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup RTEMSScoreChain
5 *
6 * @brief This source file contains the implementation of
7 *   _Chain_Initialize().
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2007.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifdef HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include <rtems/score/chainimpl.h>
24#include <rtems/score/address.h>
25#include <rtems/score/assert.h>
26
27void _Chain_Initialize(
28  Chain_Control *the_chain,
29  void           *starting_address,
30  size_t         number_nodes,
31  size_t         node_size
32)
33{
34  size_t count = number_nodes;
35  Chain_Node *head = _Chain_Head( the_chain );
36  Chain_Node *tail = _Chain_Tail( the_chain );
37  Chain_Node *current = head;
38  Chain_Node *next = starting_address;
39
40  _Assert( node_size >= sizeof( *next ) );
41
42  head->previous = NULL;
43
44  while ( count-- ) {
45    current->next  = next;
46    next->previous = current;
47    current        = next;
48    next           = (Chain_Node *)
49                        _Addresses_Add_offset( (void *) next, node_size );
50  }
51
52  current->next = tail;
53  tail->previous = current;
54}
Note: See TracBrowser for help on using the repository browser.