From 69f2a078c876de5eb13c2f2eb440160b849dff15 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 24 Aug 2010 14:29:55 +0000 Subject: 2010-08-24 Sebastian Huber 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(). --- cpukit/sapi/inline/rtems/chain.inl | 78 +++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 13 deletions(-) (limited to 'cpukit/sapi/inline/rtems') 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). * @@ -36,6 +28,12 @@ #include +/** + * @addtogroup ClassicChains + * + * @{ + */ + /** * @brief Initialize a Chain Header * @@ -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 */ -- cgit v1.2.3