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 631 : static inline void RS_INIT_LIST_HEAD(struct RsListHead *list)
20 : {
21 631 : list->next = list;
22 631 : list->prev = list;
23 631 : }
24 :
25 : #define RS_LIST_GET_HEAD_ENTRY(pos, n, head, member, type) do { \
26 : (pos) = list_entry((head)->next, type, member); \
27 : (n) = list_entry((pos)->member.next, type, member); \
28 : } while (0)
29 :
30 447 : static inline bool RsListEmpty(struct RsListHead *head)
31 : {
32 447 : return head->next == head;
33 : }
34 :
35 240 : static inline void __rs_list_add(struct RsListHead *xnew,
36 : struct RsListHead *prev,
37 : struct RsListHead *next)
38 : {
39 240 : next->prev = xnew;
40 240 : xnew->next = next;
41 240 : xnew->prev = prev;
42 240 : prev->next = xnew;
43 240 : }
44 :
45 240 : static inline void RsListAddTail(struct RsListHead *xnew, struct RsListHead *head)
46 : {
47 240 : __rs_list_add(xnew, head->prev, head);
48 240 : }
49 :
50 231 : static inline void __rs_list_del(struct RsListHead *prev, struct RsListHead *next)
51 : {
52 231 : next->prev = prev;
53 231 : prev->next = next;
54 231 : }
55 :
56 231 : static inline void RsListDel(struct RsListHead *entry)
57 : {
58 231 : __rs_list_del(entry->prev, entry->next);
59 231 : }
60 : #endif // RS_LIST_H
|