|
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
|
* Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
|
|
|
|
|
* Description: Doubly linked list
|
|
|
|
|
* Author: Huawei LiteOS Team
|
|
|
|
|
* Create: 2013-01-01
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
|
* are permitted provided that the following conditions are met:
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
|
|
* conditions and the following disclaimer.
|
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
|
|
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
|
|
|
* provided with the distribution.
|
|
|
|
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
|
|
|
|
* to endorse or promote products derived from this software without specific prior written
|
|
|
|
|
* permission.
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
* --------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @defgroup los_list Doubly linked list
|
|
|
|
|
* @ingroup kernel
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef _LOS_LIST_H
|
|
|
|
|
#define _LOS_LIST_H
|
|
|
|
|
|
|
|
|
|
#include "los_typedef.h"
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
#if __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* Structure of a node in a doubly linked list.
|
|
|
|
|
*/
|
|
|
|
|
typedef struct LOS_DL_LIST {
|
|
|
|
|
struct LOS_DL_LIST *pstPrev; /**< Current node's pointer to the previous node */
|
|
|
|
|
struct LOS_DL_LIST *pstNext; /**< Current node's pointer to the next node */
|
|
|
|
|
} LOS_DL_LIST;
|
|
|
|
|
/*<2A><><EFBFBD>ֽṹ<D6BD><E1B9B9>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>˫<EFBFBD><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9>
|
|
|
|
|
ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD><EFBFBD>LOS_DL_LIST<EFBFBD>ṹ<EFBFBD>壬
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Initialize the input node to a doubly linked list.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to initialize the input node (the first parameter list) to
|
|
|
|
|
* a doubly linked list.
|
|
|
|
|
* @attention
|
|
|
|
|
* The parameter passed in should be a legal pointer.
|
|
|
|
|
*
|
|
|
|
|
* @param list [IN] A node in a doubly linked list.
|
|
|
|
|
*
|
|
|
|
|
* @retval None.
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @see LOS_DL_LIST_HEAD
|
|
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
|
|
*/
|
|
|
|
|
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListInit(LOS_DL_LIST *list)
|
|
|
|
|
{
|
|
|
|
|
list->pstNext = list;
|
|
|
|
|
list->pstPrev = list;
|
|
|
|
|
}
|
|
|
|
|
/*<2A><><EFBFBD>δ<EFBFBD><CEB4>붨<EFBFBD><EBB6A8><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>LOS_ListInit<69><74>
|
|
|
|
|
<EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>LOS_DL_LIST<EFBFBD>ṹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>list<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>з<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>pstNext<EFBFBD><EFBFBD>pstPrevָ
|
|
|
|
|
<EFBFBD>붼ָ<EFBFBD><EFBFBD>ͷ<EFBFBD>ڵ㱾<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ㡣*/
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Point to the next node of the current node.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to point to the next node of the current node.
|
|
|
|
|
* @attention
|
|
|
|
|
* None.
|
|
|
|
|
*
|
|
|
|
|
* @param object [IN] Type #LOS_DL_LIST * The node in the doubly linked list.
|
|
|
|
|
*
|
|
|
|
|
* @retval None.
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @see LOS_DL_LIST_LAST
|
|
|
|
|
* @since Huawei LiteOS V100R001C00
|
|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EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ڵ㡣*/
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Point to the previous node of the current node.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to point to the previous node of the current node.
|
|
|
|
|
* @attention
|
|
|
|
|
* None.
|
|
|
|
|
*
|
|
|
|
|
* @param object [IN] Type #LOS_DL_LIST * The node in the doubly linked list.
|
|
|
|
|
*
|
|
|
|
|
* @retval None.
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @see LOS_DL_LIST_FIRST
|
|
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
|
|
*/
|
|
|
|
|
#define LOS_DL_LIST_LAST(object) ((object)->pstPrev)
|
|
|
|
|
/*<2A><><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>궨<EFBFBD>壬<EFBFBD><E5A3AC><EFBFBD>ڻ<EFBFBD>ȡ˫<C8A1><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>ǰһ<C7B0><D2BB><EFBFBD>ڵ㡣
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD> object <EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>˫<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>룬
|
|
|
|
|
pstPrev <EFBFBD>Ǹýڵ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>ǰһ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>롣
|
|
|
|
|
<EFBFBD>ú<EFBFBD><EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>ǰһ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>롣*/
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Insert a new node to a doubly linked list.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to insert a new node after the list node to a doubly linked list.
|
|
|
|
|
* @attention
|
|
|
|
|
* The parameters passed in should be legal pointers.
|
|
|
|
|
*
|
|
|
|
|
* @param list [IN] Doubly linked list which the new node will be inserted in.
|
|
|
|
|
* @param node [IN] The new node to be inserted.
|
|
|
|
|
*
|
|
|
|
|
* @retval None
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @see LOS_ListDelete | LOS_ListTailInsert | LOS_ListHeadInsert
|
|
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
|
|
*/
|
|
|
|
|
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListAdd(LOS_DL_LIST *list, LOS_DL_LIST *node)
|
|
|
|
|
{
|
|
|
|
|
node->pstNext = list->pstNext;
|
|
|
|
|
node->pstPrev = list;
|
|
|
|
|
list->pstNext->pstPrev = node;
|
|
|
|
|
list->pstNext = node;
|
|
|
|
|
}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<EFBFBD><EFBFBD>ͱ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Insert a node to a doubly linked list.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to insert a new node before the list node to a doubly linked list.
|
|
|
|
|
* @attention
|
|
|
|
|
* The parameters passed in should be legal pointers.
|
|
|
|
|
*
|
|
|
|
|
* @param list [IN] Doubly linked list which the new node will be inserted in.
|
|
|
|
|
* @param node [IN] The new node to be inserted.
|
|
|
|
|
*
|
|
|
|
|
* @retval None.
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @see LOS_ListAdd | LOS_ListHeadInsert
|
|
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
|
|
*/
|
|
|
|
|
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListTailInsert(LOS_DL_LIST *list, LOS_DL_LIST *node)
|
|
|
|
|
{
|
|
|
|
|
LOS_ListAdd(list->pstPrev, node);
|
|
|
|
|
}
|
|
|
|
|
/*<2A>ڸú<DAB8><C3BA><EFBFBD><EFBFBD>У<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD>˺궨<CBBA><EAB6A8> LOS_DL_LIST <20><><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>ڵ㣬
|
|
|
|
|
ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> STATIC INLINE <EFBFBD>ؼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߴ<EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD>Ч<EFBFBD>ʡ<EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ַdz<EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˫<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LOS_ListAdd<EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>½ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰһ<EFBFBD><EFBFBD><EFBFBD>ڵ㼴<EFBFBD>ɡ<EFBFBD>*/
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Insert a node to a doubly linked list.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to insert a new node after the list node to a doubly linked list.
|
|
|
|
|
* It is same with #LOS_ListAdd.
|
|
|
|
|
* @attention
|
|
|
|
|
* The parameters passed in should be legal pointers.
|
|
|
|
|
*
|
|
|
|
|
* @param list [IN] Doubly linked list which the new node will be inserted in.
|
|
|
|
|
* @param node [IN] The new node to be inserted.
|
|
|
|
|
*
|
|
|
|
|
* @retval None.
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @see LOS_ListAdd | LOS_ListTailInsert
|
|
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
|
|
*/
|
|
|
|
|
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListHeadInsert(LOS_DL_LIST *list, LOS_DL_LIST *node)
|
|
|
|
|
{
|
|
|
|
|
LOS_ListAdd(list, node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Delete a specified node from a doubly linked list.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to delete a specified node from a doubly linked list.
|
|
|
|
|
* @attention
|
|
|
|
|
* The parameter passed in should be a legal pointer.
|
|
|
|
|
*
|
|
|
|
|
* @param node [IN] Node to be deleted.
|
|
|
|
|
*
|
|
|
|
|
* @retval None.
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @see LOS_ListAdd
|
|
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
|
|
*/
|
|
|
|
|
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListDelete(LOS_DL_LIST *node)
|
|
|
|
|
{
|
|
|
|
|
node->pstNext->pstPrev = node->pstPrev;
|
|
|
|
|
node->pstPrev->pstNext = node->pstNext;
|
|
|
|
|
node->pstNext = NULL;
|
|
|
|
|
node->pstPrev = NULL;
|
|
|
|
|
}
|
|
|
|
|
/*<2A>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ַdz<D6B7><C7B3><EFBFBD><F2B5A5A3><EFBFBD><EFBFBD>岽<EFBFBD><E5B2BD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|
|
|
|
|
|
|
|
|
<EFBFBD>ѱ<EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD> next <EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD> prev ָ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD> prev <EFBFBD>ڵ㡣
|
|
|
|
|
<EFBFBD>ѱ<EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD> prev <EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD> next ָ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD> next <EFBFBD>ڵ㡣
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>ձ<EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD> next ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> prev ָ<EFBFBD>롣
|
|
|
|
|
ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD>裬<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>Ľڵ<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD>ˡ<EFBFBD>*/
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Identify whether a specified doubly linked list is empty or not.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to judge whether a doubly linked list is empty or not. It
|
|
|
|
|
* returns a Boolean value.
|
|
|
|
|
* @attention
|
|
|
|
|
* The parameter passed in should be a legal pointer.
|
|
|
|
|
*
|
|
|
|
|
* @param list [IN] Doubly linked list.
|
|
|
|
|
*
|
|
|
|
|
* @retval #TRUE The doubly linked list is empty.
|
|
|
|
|
* @retval #FALSE The doubly linked list is not empty.
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
|
|
*/
|
|
|
|
|
LITE_OS_SEC_ALW_INLINE STATIC INLINE BOOL LOS_ListEmpty(LOS_DL_LIST *list)
|
|
|
|
|
{
|
|
|
|
|
return (BOOL)(list->pstNext == list);
|
|
|
|
|
}
|
|
|
|
|
/*<2A><><EFBFBD>岽<EFBFBD><E5B2BD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|
|
|
|
|
|
|
|
|
<EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> pstNext ָ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TRUE<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FALSE<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD>裬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD>ա<EFBFBD>*/
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Obtain the offset of a structure member relative to the structure start address.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to obtain the offset of the structure member (member) relative to
|
|
|
|
|
* the start address of the structure (type). And return the offset of #UINTPTR type.
|
|
|
|
|
* @attention
|
|
|
|
|
* None.
|
|
|
|
|
*
|
|
|
|
|
* @param type [IN] Structure name.
|
|
|
|
|
* @param member [IN] The structure member name which needs to measure the offset.
|
|
|
|
|
*
|
|
|
|
|
* @retval #UINTPTR Offset of the member relative to the structure start address.
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
|
|
*/
|
|
|
|
|
#define LOS_OFF_SET_OF(type, member) ((UINTPTR)&((type *)0)->member)
|
|
|
|
|
|
|
|
|
|
/* Obsolete API, please use LOS_OFF_SET_OF instead */
|
|
|
|
|
#define OFFSET_OF_FIELD(type, field) LOS_OFF_SET_OF(type, field)
|
|
|
|
|
/*<2A><>Щ<EFBFBD><D0A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>ڱ<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD>ػ<EFBFBD>ȡ<EFBFBD>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD><EFBFBD>ṹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>ƫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD>Ա<EFBFBD><EFBFBD>ƫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ó<EFBFBD>Ա<EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>ĸó<EFBFBD>Ա<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>*/
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Obtain the pointer to a structure that contains a doubly linked list.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to obtain the pointer to a structure that contains the doubly
|
|
|
|
|
* linked list which the first parameter item specified.
|
|
|
|
|
* @attention
|
|
|
|
|
* None.
|
|
|
|
|
*
|
|
|
|
|
* @param item [IN] Type #LOS_DL_LIST * The node of the doubly linked list.
|
|
|
|
|
* @param type [IN] Structure name.
|
|
|
|
|
* @param member [IN] The doubly linked list name in the structure.
|
|
|
|
|
*
|
|
|
|
|
* @retval The pointer to the structure that contains the doubly linked list. And
|
|
|
|
|
* the doubly linked list has the node of the first parameter item.
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @see LOS_DL_LIST_FOR_EACH_ENTRY | LOS_DL_LIST_FOR_EACH_ENTRY_SAFE
|
|
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
|
|
*/
|
|
|
|
|
#define LOS_DL_LIST_ENTRY(item, type, member) \
|
|
|
|
|
((type *)(VOID *)((CHAR *)(item) - LOS_OFF_SET_OF(type, member)))
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Traverse a doubly linked list which is included in a given type structure.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to traverse a doubly linked list which is included in a given type
|
|
|
|
|
* structure. The API is a loop. The start node of the doubly linked list is the second
|
|
|
|
|
* parameter list. And in each loop, the obtained pointer to a structure that contains
|
|
|
|
|
* the list is outputted in the first parameter item.
|
|
|
|
|
* @attention
|
|
|
|
|
* None.
|
|
|
|
|
*
|
|
|
|
|
* @param item [IN/OUT] The pointer to the structure that contains the doubly linked list.
|
|
|
|
|
* @param list [IN] Type #LOS_DL_LIST * The start node of the doubly linked list to
|
|
|
|
|
* be traversed.
|
|
|
|
|
* @param type [IN] Structure name.
|
|
|
|
|
* @param member [IN] The doubly linked list name in the structure.
|
|
|
|
|
*
|
|
|
|
|
* @retval None.
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @see LOS_DL_LIST_ENTRY | LOS_DL_LIST_FOR_EACH_ENTRY_SAFE | LOS_DL_LIST_FOR_EACH
|
|
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
|
|
*/
|
|
|
|
|
#define LOS_DL_LIST_FOR_EACH_ENTRY(item, list, type, member) \
|
|
|
|
|
for (item = LOS_DL_LIST_ENTRY((list)->pstNext, type, member); \
|
|
|
|
|
&(item)->member != (list); \
|
|
|
|
|
item = LOS_DL_LIST_ENTRY((item)->member.pstNext, type, member))
|
|
|
|
|
/*<2A><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>ͨ<EFBFBD><CDA8> for ѭ<><D1AD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>岽<EFBFBD><E5B2BD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> LOS_DL_LIST_ENTRY <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>룬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>丳ֵ<EFBFBD><EFBFBD> item <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼλ<EFBFBD>á<EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> &(item)->member != (list)<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFB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BD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Traverse a doubly linked list which is included in a given type structure. And
|
|
|
|
|
* it is safe against removal of list entry.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to traverse a doubly linked list which is included in a given type
|
|
|
|
|
* structure. The API is a loop. The start node of the doubly linked list is the third
|
|
|
|
|
* parameter list. And in each loop, the obtained pointer to a structure that contains
|
|
|
|
|
* the list is outputted in the first parameter item. And the next node is outputted in
|
|
|
|
|
* the second parameter next.
|
|
|
|
|
* @attention
|
|
|
|
|
* None.
|
|
|
|
|
*
|
|
|
|
|
* @param item [IN/OUT] The pointer to the structure that contains the doubly linked list.
|
|
|
|
|
* @param next [IN/OUT] The pointer to the structure that contains the next node of the
|
|
|
|
|
* doubly linked list.
|
|
|
|
|
* @param list [IN] Type #LOS_DL_LIST * The start node of the doubly linked list to
|
|
|
|
|
* be traversed.
|
|
|
|
|
* @param type [IN] Structure name.
|
|
|
|
|
* @param member [IN] The doubly linked list name in the structure.
|
|
|
|
|
*
|
|
|
|
|
* @retval None.
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @see LOS_DL_LIST_ENTRY | LOS_DL_LIST_FOR_EACH_ENTRY | LOS_DL_LIST_FOR_EACH_SAFE
|
|
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
|
|
*/
|
|
|
|
|
#define LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, next, list, type, member) \
|
|
|
|
|
for (item = LOS_DL_LIST_ENTRY((list)->pstNext, type, member), \
|
|
|
|
|
next = LOS_DL_LIST_ENTRY((item)->member.pstNext, type, member); \
|
|
|
|
|
&(item)->member != (list); \
|
|
|
|
|
item = next, next = LOS_DL_LIST_ENTRY((item)->member.pstNext, type, member))
|
|
|
|
|
/*<2A>ú<EFBFBD><C3BA>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD>ǰ<EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD>ڵ㣬<DAB5><E3A3AC><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD>ڵ<EFBFBD>ִ<EFBFBD><D6B4>ָ<EFBFBD><D6B8><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
item<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľڵ<EFBFBD>
|
|
|
|
|
next<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
list<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD>
|
|
|
|
|
type<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵĽṹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
member<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ڽṹ<EFBFBD><EFBFBD><EFBFBD>еij<EFBFBD>Ա<EFBFBD><EFBFBD>*/
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Iterate over a doubly linked list of given type, and call hook for any extra procedures every time.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to iterate over a doubly linked list of given type,
|
|
|
|
|
* and call hook for any extra procedures every time.
|
|
|
|
|
* @attention
|
|
|
|
|
* None.
|
|
|
|
|
*
|
|
|
|
|
* @param item [IN/OUT] Pointer to the structure that contains the doubly linked list that is to be traversed.
|
|
|
|
|
* @param list [IN] Pointer to the doubly linked list to be traversed.
|
|
|
|
|
* @param type [IN] Structure name.
|
|
|
|
|
* @param member [IN] Member name of the doubly linked list in the structure.
|
|
|
|
|
* @param hook [IN] Hook for extra procedures which will be called every time when dev is fetched.
|
|
|
|
|
*
|
|
|
|
|
* @retval None.
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @see LOS_DL_LIST_ENTRY | LOS_DL_LIST_FOR_EACH_ENTRY
|
|
|
|
|
* @since Huawei LiteOS V200R005C10
|
|
|
|
|
*/
|
|
|
|
|
#define LOS_DL_LIST_FOR_EACH_ENTRY_HOOK(item, list, type, member, hook) \
|
|
|
|
|
for (item = LOS_DL_LIST_ENTRY((list)->pstNext, type, member), hook; \
|
|
|
|
|
&(item)->member != (list); \
|
|
|
|
|
item = LOS_DL_LIST_ENTRY((item)->member.pstNext, type, member), hook)
|
|
|
|
|
/*<2A>ú<EFBFBD><C3BA>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD>ǰ<EFBFBD>˳<EFBFBD><CBB3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FBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Delete a specified node from a doubly linked list and reinitialize the node.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to delete a specified node (the first parameter list) from the doubly
|
|
|
|
|
* linked list. And reinitialize the deleted node to a doubly linked list.
|
|
|
|
|
*
|
|
|
|
|
* @attention
|
|
|
|
|
* The parameter passed in should be a legal pointer.
|
|
|
|
|
*
|
|
|
|
|
* @param list [IN] Node to be deleted and reinitialize to a doubly linked list.
|
|
|
|
|
*
|
|
|
|
|
* @retval None.
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @see LOS_ListInit | LOS_ListDelete
|
|
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
|
|
*/
|
|
|
|
|
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListDelInit(LOS_DL_LIST *list)
|
|
|
|
|
{
|
|
|
|
|
list->pstNext->pstPrev = list->pstPrev;
|
|
|
|
|
list->pstPrev->pstNext = list->pstNext;
|
|
|
|
|
LOS_ListInit(list);
|
|
|
|
|
}
|
|
|
|
|
/**/
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Traverse a doubly linked list.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to traverse a doubly linked list. The API is a loop. The start node of the
|
|
|
|
|
* doubly linked list is the second parameter list. And in each loop, the obtained pointer to
|
|
|
|
|
* the next node of the doubly linked list is outputted in the first parameter item.
|
|
|
|
|
* @attention
|
|
|
|
|
* None.
|
|
|
|
|
*
|
|
|
|
|
* @param item [IN/OUT] Type #LOS_DL_LIST * The pointer to the next node in the doubly
|
|
|
|
|
* linked list.
|
|
|
|
|
* @param list [IN] Type #LOS_DL_LIST * The pointer to the node of the doubly linked
|
|
|
|
|
* list to be traversed.
|
|
|
|
|
*
|
|
|
|
|
* @retval None.
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @see LOS_DL_LIST_FOR_EACH_SAFE | LOS_DL_LIST_FOR_EACH_ENTRY
|
|
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
|
|
*/
|
|
|
|
|
#define LOS_DL_LIST_FOR_EACH(item, list) \
|
|
|
|
|
for (item = (list)->pstNext; \
|
|
|
|
|
(item) != (list); \
|
|
|
|
|
item = (item)->pstNext)
|
|
|
|
|
/*<2A><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>ͨ<EFBFBD><CDA8> for ѭ<><D1AD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>岽<EFBFBD><E5B2BD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD><EFBFBD><EFBFBD> item <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ڵ㣬<EFBFBD><EFBFBD> (list)->pstNext<EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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<EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Traverse a doubly linked list safe against removal of list entry.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to traverse a doubly linked list safe against removal of list entry. The
|
|
|
|
|
* API is a loop. The start node of the doubly linked list is the third parameter list. And
|
|
|
|
|
* in each loop, the obtained pointer to the next node of the doubly linked list is outputted
|
|
|
|
|
* in the first parameter item. And the next node of the the node specified by first parameter
|
|
|
|
|
* item is outputted in the second parameter next.
|
|
|
|
|
* @attention
|
|
|
|
|
* None.
|
|
|
|
|
*
|
|
|
|
|
* @param item [IN/OUT] Type #LOS_DL_LIST * The pointer to the next node in the doubly
|
|
|
|
|
* linked list.
|
|
|
|
|
* @param next [IN/OUT] Type #LOS_DL_LIST * The pointer to the next node of the the node
|
|
|
|
|
* specified by first parameter item.
|
|
|
|
|
* @param list [IN] Type #LOS_DL_LIST * The pointer to the node of the doubly linked
|
|
|
|
|
* list to be traversed.
|
|
|
|
|
*
|
|
|
|
|
* @retval None.
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @see LOS_DL_LIST_FOR_EACH | LOS_DL_LIST_FOR_EACH_ENTRY_SAFE
|
|
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
|
|
*/
|
|
|
|
|
#define LOS_DL_LIST_FOR_EACH_SAFE(item, next, list) \
|
|
|
|
|
for (item = (list)->pstNext, next = (item)->pstNext; \
|
|
|
|
|
(item) != (list); \
|
|
|
|
|
item = next, next = (item)->pstNext)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup los_list
|
|
|
|
|
* @brief Initialize a double linked list.
|
|
|
|
|
*
|
|
|
|
|
* @par Description:
|
|
|
|
|
* This API is used to initialize the input node (the parameter list) to a double linked
|
|
|
|
|
* list. The difference with LOS_ListInit is that the parameter list is not a pointer while
|
|
|
|
|
* in LOS_ListInit it is a pointer.
|
|
|
|
|
* @attention
|
|
|
|
|
* None.
|
|
|
|
|
*
|
|
|
|
|
* @param list [IN] Type #LOS_DL_LIST A node to be initialized to a doubly linked list.
|
|
|
|
|
*
|
|
|
|
|
* @retval None.
|
|
|
|
|
* @par Dependency:
|
|
|
|
|
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
|
|
|
|
|
* @see LOS_ListInit
|
|
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
|
|
*/
|
|
|
|
|
#define LOS_DL_LIST_HEAD(list) LOS_DL_LIST list = { &(list), &(list) }
|
|
|
|
|
/*ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>꣬<EFBFBD><EAA3AC><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD>ͳ<EFBFBD>ʼ<EFBFBD><CABC>һ<EFBFBD><D2BB>˫<EFBFBD><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>ڵ㣬Ϊ<E3A3AC><CEAA><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṩ<EFBFBD>˱<EFBFBD><CBB1><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
#if __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
|
|
#endif /* _LOS_LIST_H */
|