summaryrefslogtreecommitdiffstats
path: root/cpukit/sapi/inline/rtems
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2010-08-24 14:29:55 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2010-08-24 14:29:55 +0000
commit69f2a078c876de5eb13c2f2eb440160b849dff15 (patch)
tree570055f609424cf8574ce9807328d28b7416d0d8 /cpukit/sapi/inline/rtems
parent2010-08-24 Ralf Corsépius <ralf.corsepius@rtems.org> (diff)
downloadrtems-69f2a078c876de5eb13c2f2eb440160b849dff15.tar.bz2
2010-08-24 Sebastian Huber <sebastian.huber@embedded-brains.de>
PR 1673/cpukit * sapi/src/chainappendnotify.c, sapi/src/chaingetnotify.c, sapi/src/chaingetwait.c, sapi/src/chainprependnotify.c: New files. * sapi/Makefile.am: Reflect changes above. * sapi/include/rtems/chain.h: Declare rtems_chain_append_with_notification(), rtems_chain_prepend_with_notification(), rtems_chain_get_with_notification(), and rtems_chain_get_with_wait(). * sapi/inline/rtems/chain.inl: Define rtems_chain_append_with_empty_check(), rtems_chain_prepend_with_empty_check(), and rtems_chain_get_with_empty_check().
Diffstat (limited to 'cpukit/sapi/inline/rtems')
-rw-r--r--cpukit/sapi/inline/rtems/chain.inl78
1 files changed, 65 insertions, 13 deletions
diff --git a/cpukit/sapi/inline/rtems/chain.inl b/cpukit/sapi/inline/rtems/chain.inl
index 58b6770525..2816e81b41 100644
--- a/cpukit/sapi/inline/rtems/chain.inl
+++ b/cpukit/sapi/inline/rtems/chain.inl
@@ -1,22 +1,14 @@
/**
- * @file rtems/chain.inl
+ * @file
*
- * This include file contains all the constants and structures associated
- * with the Chain API in RTEMS. The chain is a double linked list that
- * is part of the Super Core. This is the published interface to that
- * code.
+ * @ingroup ClassicChains
*
- * Iterate the node of a chain can be performed with the following code:
- *
- * rtems_chain_control* cc = &object->pending;
- * rtems_chain_node* cn = cc->first;
- * while (!rtems_chain_is_tail (cc, cn))
- * {
- * cn = cn->next;
- * }
+ * @brief Chain API.
*/
/*
+ * Copyright (c) 2010 embedded brains GmbH.
+ *
* COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
*
@@ -37,6 +29,12 @@
#include <rtems/score/chain.inl>
/**
+ * @addtogroup ClassicChains
+ *
+ * @{
+ */
+
+/**
* @brief Initialize a Chain Header
*
* This routine initializes @a the_chain structure to manage the
@@ -505,5 +503,59 @@ RTEMS_INLINE_ROUTINE void rtems_chain_prepend_unprotected(
_Chain_Prepend_unprotected( the_chain, the_node );
}
+/**
+ * @brief Checks if the @a chain is empty and appends the @a node.
+ *
+ * Interrupts are disabled to ensure the atomicity of the operation.
+ *
+ * @retval true The chain was empty before the append.
+ * @retval false The chain contained at least one node before the append.
+ */
+RTEMS_INLINE_ROUTINE bool rtems_chain_append_with_empty_check(
+ rtems_chain_control *chain,
+ rtems_chain_node *node
+)
+{
+ return _Chain_Append_with_empty_check( chain, node );
+}
+
+/**
+ * @brief Checks if the @a chain is empty and prepends the @a node.
+ *
+ * Interrupts are disabled to ensure the atomicity of the operation.
+ *
+ * @retval true The chain was empty before the prepend.
+ * @retval false The chain contained at least one node before the prepend.
+ */
+RTEMS_INLINE_ROUTINE bool rtems_chain_prepend_with_empty_check(
+ rtems_chain_control *chain,
+ rtems_chain_node *node
+)
+{
+ return _Chain_Prepend_with_empty_check( chain, node );
+}
+
+/**
+ * @brief Tries to get the first @a node and check if the @a chain is empty
+ * afterwards.
+ *
+ * This function removes the first node from the @a chain and returns a pointer
+ * to that node in @a node. If the @a chain is empty, then @c NULL is returned.
+ *
+ * Interrupts are disabled to ensure the atomicity of the operation.
+ *
+ * @retval true The chain is empty after the node removal.
+ * @retval false The chain contained at least one node after the node removal.
+ */
+RTEMS_INLINE_ROUTINE bool rtems_chain_get_with_empty_check(
+ rtems_chain_control *chain,
+ rtems_chain_node **node
+)
+{
+ return _Chain_Get_with_empty_check( chain, node );
+}
+
+/** @} */
+
#endif
/* end of include file */