summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-12-21 09:50:15 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-12-21 15:40:27 +0100
commitcbd07e4ce0ede36bacf6920bd594579e931b1bdd (patch)
tree716aba4b883d92fe7a8aab8338dc783ba04d812d /cpukit
parentbsp/gen83xx: Add GPR_1 to register map (diff)
downloadrtems-cbd07e4ce0ede36bacf6920bd594579e931b1bdd.tar.bz2
score: Add rtems_chain_node_count_unprotected()
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/sapi/inline/rtems/chain.inl17
-rw-r--r--cpukit/score/Makefile.am1
-rw-r--r--cpukit/score/include/rtems/score/chain.h12
-rw-r--r--cpukit/score/src/chainnodecount.c34
4 files changed, 64 insertions, 0 deletions
diff --git a/cpukit/sapi/inline/rtems/chain.inl b/cpukit/sapi/inline/rtems/chain.inl
index d7f7f7152d..a1bfc2f32e 100644
--- a/cpukit/sapi/inline/rtems/chain.inl
+++ b/cpukit/sapi/inline/rtems/chain.inl
@@ -645,6 +645,23 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_get_with_empty_check(
return _Chain_Get_with_empty_check( chain, node );
}
+/**
+ * @brief Returns the node count of the chain.
+ *
+ * @param[in] chain The chain.
+ *
+ * @note It does NOT disable interrupts to ensure the atomicity of the
+ * operation.
+ *
+ * @return The node count of the chain.
+ */
+RTEMS_INLINE_ROUTINE size_t rtems_chain_node_count_unprotected(
+ const rtems_chain_control *chain
+)
+{
+ return _Chain_Node_count_unprotected( chain );
+}
+
/** @} */
#endif
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index cc252db0b9..cc0cbd5c35 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -326,6 +326,7 @@ libscore_a_SOURCES += src/userextaddset.c \
libscore_a_SOURCES += src/apiext.c src/chain.c src/chainappend.c \
src/chainextract.c src/chainget.c src/chaininsert.c \
src/chainappendempty.c src/chainprependempty.c src/chaingetempty.c \
+ src/chainnodecount.c \
src/interr.c src/isr.c src/wkspace.c src/wkstringduplicate.c
EXTRA_DIST = src/Unlimited.txt
diff --git a/cpukit/score/include/rtems/score/chain.h b/cpukit/score/include/rtems/score/chain.h
index ebb0f24e8c..f0a837f379 100644
--- a/cpukit/score/include/rtems/score/chain.h
+++ b/cpukit/score/include/rtems/score/chain.h
@@ -254,6 +254,18 @@ bool _Chain_Get_with_empty_check(
Chain_Node **the_node
);
+/**
+ * @brief Returns the node count of the chain.
+ *
+ * @param[in] chain The chain.
+ *
+ * @note It does NOT disable interrupts to ensure the atomicity of the
+ * operation.
+ *
+ * @return The node count of the chain.
+ */
+size_t _Chain_Node_count_unprotected( const Chain_Control *chain );
+
#ifndef __RTEMS_APPLICATION__
#include <rtems/score/chain.inl>
#endif
diff --git a/cpukit/score/src/chainnodecount.c b/cpukit/score/src/chainnodecount.c
new file mode 100644
index 0000000000..3b54d93468
--- /dev/null
+++ b/cpukit/score/src/chainnodecount.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <rtems/score/chain.h>
+
+size_t _Chain_Node_count_unprotected( const Chain_Control *chain )
+{
+ size_t count = 0;
+ const Chain_Node *tail = _Chain_Immutable_tail( chain );
+ const Chain_Node *node = _Chain_Immutable_first( chain );
+
+ while ( node != tail ) {
+ ++count;
+
+ node = _Chain_Immutable_next( node );
+ }
+
+ return count;
+}