Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #ifndef RS_LIST_H
12 : #define RS_LIST_H
13 : #include <ccan/list.h>
14 :
15 : struct RsListHead {
16 : struct RsListHead *next, *prev;
17 : };
18 :
19 645 : static inline void RS_INIT_LIST_HEAD(struct RsListHead *list)
20 : {
21 645 : list->next = list;
22 645 : list->prev = list;
23 645 : }
24 :
25 : #define RS_LIST_GET_HEAD_ENTRY(pos, n, head, member, type) \
26 : do { \
27 : (pos) = list_entry((head)->next, type, member); \
28 : (n) = list_entry((pos)->member.next, type, member); \
29 : } while (0)
30 :
31 457 : static inline bool RsListEmpty(struct RsListHead *head)
32 : {
33 457 : return head->next == head;
34 : }
35 :
36 246 : static inline void __rs_list_add(struct RsListHead *xnew, struct RsListHead *prev, struct RsListHead *next)
37 : {
38 246 : next->prev = xnew;
39 246 : xnew->next = next;
40 246 : xnew->prev = prev;
41 246 : prev->next = xnew;
42 246 : }
43 :
44 246 : static inline void RsListAddTail(struct RsListHead *xnew, struct RsListHead *head)
45 : {
46 246 : __rs_list_add(xnew, head->prev, head);
47 246 : }
48 :
49 237 : static inline void __rs_list_del(struct RsListHead *prev, struct RsListHead *next)
50 : {
51 237 : next->prev = prev;
52 237 : prev->next = next;
53 237 : }
54 :
55 237 : static inline void RsListDel(struct RsListHead *entry)
56 : {
57 237 : __rs_list_del(entry->prev, entry->next);
58 237 : }
59 : #endif // RS_LIST_H
|