RTEMS
chainnodecount.c
1 /*
2  * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
3  *
4  * embedded brains GmbH
5  * Obere Lagerstr. 30
6  * 82178 Puchheim
7  * Germany
8  * <rtems@embedded-brains.de>
9  *
10  * The license and distribution terms for this file may be
11  * found in the file LICENSE in this distribution or at
12  * http://www.rtems.org/license/LICENSE.
13  */
14 
15 #ifdef HAVE_CONFIG_H
16 #include "config.h"
17 #endif
18 
19 #include <rtems/score/chainimpl.h>
20 
22 {
23  size_t count = 0;
24  const Chain_Node *tail = _Chain_Immutable_tail( chain );
25  const Chain_Node *node = _Chain_Immutable_first( chain );
26 
27  while ( node != tail ) {
28  ++count;
29 
30  node = _Chain_Immutable_next( node );
31  }
32 
33  return count;
34 }
size_t _Chain_Node_count_unprotected(const Chain_Control *chain)
Returns the node count of the chain.
static __inline__ const Chain_Node * _Chain_Immutable_next(const Chain_Node *the_node)
Returns pointer to the immutable next node from this node.
Definition: chainimpl.h:343
Chain Handler API.
static __inline__ const Chain_Node * _Chain_Immutable_first(const Chain_Control *the_chain)
Returns pointer to immutable chain&#39;s first node.
Definition: chainimpl.h:277
static __inline__ const Chain_Node * _Chain_Immutable_tail(const Chain_Control *the_chain)
Returns pointer to immutable chain tail.
Definition: chainimpl.h:243