WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
los_list.h
浏览该文件的文档.
1/* ----------------------------------------------------------------------------
2 * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
3 * Description: Doubly linked list
4 * Author: Huawei LiteOS Team
5 * Create: 2013-01-01
6 * Redistribution and use in source and binary forms, with or without modification,
7 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 * to endorse or promote products derived from this software without specific prior written
15 * permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * --------------------------------------------------------------------------- */
28
34#ifndef _LOS_LIST_H
35#define _LOS_LIST_H
36
37#include "los_typedef.h"
38
39#ifdef __cplusplus
40extern "C" {
41#endif /* __cplusplus */
42
51
71{
72 list->pstNext = list;
73 list->pstPrev = list;
74}
75
93#define LOS_DL_LIST_FIRST(object) ((object)->pstNext)
94
112#define LOS_DL_LIST_LAST(object) ((object)->pstPrev)
113
133{
134 node->pstNext = list->pstNext;
135 node->pstPrev = list;
136 list->pstNext->pstPrev = node;
137 list->pstNext = node;
138}
139
158LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListTailInsert(LOS_DL_LIST *list, LOS_DL_LIST *node)
159{
160 LOS_ListAdd(list->pstPrev, node);
161}
162
182LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListHeadInsert(LOS_DL_LIST *list, LOS_DL_LIST *node)
183{
184 LOS_ListAdd(list, node);
185}
186
205{
206 node->pstNext->pstPrev = node->pstPrev;
207 node->pstPrev->pstNext = node->pstNext;
208 node->pstNext = NULL;
209 node->pstPrev = NULL;
210}
211
231{
232 return (BOOL)(list->pstNext == list);
233}
234
253#define LOS_OFF_SET_OF(type, member) ((UINTPTR)&((type *)0)->member)
254
255/* Obsolete API, please use LOS_OFF_SET_OF instead */
256#define OFFSET_OF_FIELD(type, field) LOS_OFF_SET_OF(type, field)
257
279#define LOS_DL_LIST_ENTRY(item, type, member) \
280 ((type *)(VOID *)((CHAR *)(item) - LOS_OFF_SET_OF(type, member)))
281
306#define LOS_DL_LIST_FOR_EACH_ENTRY(item, list, type, member) \
307 for ((item) = LOS_DL_LIST_ENTRY((list)->pstNext, type, member); \
308 &(item)->member != (list); \
309 (item) = LOS_DL_LIST_ENTRY((item)->member.pstNext, type, member))
310
339#define LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, next, list, type, member) \
340 for ((item) = LOS_DL_LIST_ENTRY((list)->pstNext, type, member), \
341 (next) = LOS_DL_LIST_ENTRY((item)->member.pstNext, type, member); \
342 &(item)->member != (list); \
343 (item) = (next), (next) = LOS_DL_LIST_ENTRY((item)->member.pstNext, type, member))
344
367#define LOS_DL_LIST_FOR_EACH_ENTRY_HOOK(item, list, type, member, hook) \
368 for ((item) = LOS_DL_LIST_ENTRY((list)->pstNext, type, member), hook; \
369 &(item)->member != (list); \
370 (item) = LOS_DL_LIST_ENTRY((item)->member.pstNext, type, member), hook)
371
392{
393 list->pstNext->pstPrev = list->pstPrev;
394 list->pstPrev->pstNext = list->pstNext;
395 LOS_ListInit(list);
396}
397
420#define LOS_DL_LIST_FOR_EACH(item, list) \
421 for ((item) = (list)->pstNext; \
422 (item) != (list); \
423 (item) = (item)->pstNext)
424
451#define LOS_DL_LIST_FOR_EACH_SAFE(item, next, list) \
452 for ((item) = (list)->pstNext, (next) = (item)->pstNext; \
453 (item) != (list); \
454 (item) = (next), (next) = (item)->pstNext)
455
475#define LOS_DL_LIST_HEAD(list) LOS_DL_LIST list = { &(list), &(list) }
476
477#ifdef __cplusplus
478}
479#endif /* __cplusplus */
480
481#endif /* _LOS_LIST_H */
#define NULL
Definition common_def.h:21
#define STATIC
Definition common_def.h:57
#define INLINE
Definition common_def.h:65
#define LITE_OS_SEC_ALW_INLINE
Definition los_builddef.h:46
#define VOID
Definition los_typedef.h:88
size_t BOOL
Definition los_typedef.h:83
Definition los_list.h:47
struct LOS_DL_LIST * pstPrev
Definition los_list.h:48
struct LOS_DL_LIST * pstNext
Definition los_list.h:49