Dokan 3.0.0
User mode file system library for windows with FUSE Wrapper
Loading...
Searching...
No Matches
list.h
1/*
2 Dokan : user-mode file system library for Windows
3
4 Copyright (C) 2020 - 2025 Google, Inc.
5 Copyright (C) 2015 - 2019 Adrien J. <liryna.stark@gmail.com> and Maxime C. <maxime@islog.com>
6 Copyright (C) 2007 - 2011 Hiroki Asakawa <info@dokan-dev.net>
7
8 http://dokan-dev.github.io
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free
12Software Foundation; either version 3 of the License, or (at your option) any
13later version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT ANY
16WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#ifndef LIST_H_
24#define LIST_H_
25
26#include <windows.h>
27
28FORCEINLINE
29VOID InitializeListHead(PLIST_ENTRY ListHead) {
30 ListHead->Flink = ListHead->Blink = ListHead;
31}
32
33FORCEINLINE
34BOOLEAN
35IsListEmpty(const LIST_ENTRY *ListHead) {
36 return (BOOLEAN)(ListHead == NULL || ListHead->Flink == ListHead);
37}
38
39FORCEINLINE
40BOOLEAN
41RemoveEntryList(PLIST_ENTRY Entry) {
42 PLIST_ENTRY Blink;
43 PLIST_ENTRY Flink;
44
45 if (Entry != NULL) {
46 Flink = Entry->Flink;
47 Blink = Entry->Blink;
48 Blink->Flink = Flink;
49 Flink->Blink = Blink;
50 return (BOOLEAN)(Flink == Blink);
51 }
52 /* Assumes the list is empty */
53 return TRUE;
54}
55
56FORCEINLINE
57PLIST_ENTRY
58RemoveHeadList(PLIST_ENTRY ListHead) {
59 PLIST_ENTRY Flink;
60 PLIST_ENTRY Entry;
61
62 Entry = ListHead->Flink;
63 Flink = Entry->Flink;
64 ListHead->Flink = Flink;
65 Flink->Blink = ListHead;
66 return Entry;
67}
68
69FORCEINLINE
70PLIST_ENTRY
71RemoveTailList(PLIST_ENTRY ListHead) {
72 PLIST_ENTRY Blink;
73 PLIST_ENTRY Entry;
74
75 Entry = ListHead->Blink;
76 Blink = Entry->Blink;
77 ListHead->Blink = Blink;
78 Blink->Flink = ListHead;
79 return Entry;
80}
81
82FORCEINLINE
83VOID InsertTailList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry) {
84 PLIST_ENTRY Blink;
85
86 Blink = ListHead->Blink;
87 Entry->Flink = ListHead;
88 Entry->Blink = Blink;
89 Blink->Flink = Entry;
90 ListHead->Blink = Entry;
91}
92
93FORCEINLINE
94VOID InsertHeadList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry) {
95 PLIST_ENTRY Flink;
96
97 Flink = ListHead->Flink;
98 Entry->Flink = Flink;
99 Entry->Blink = ListHead;
100 Flink->Blink = Entry;
101 ListHead->Flink = Entry;
102}
103
104FORCEINLINE
105VOID AppendTailList(PLIST_ENTRY ListHead, PLIST_ENTRY ListToAppend) {
106 PLIST_ENTRY ListEnd = ListHead->Blink;
107
108 ListHead->Blink->Flink = ListToAppend;
109 ListHead->Blink = ListToAppend->Blink;
110 ListToAppend->Blink->Flink = ListHead;
111 ListToAppend->Blink = ListEnd;
112}
113
114FORCEINLINE
115PSINGLE_LIST_ENTRY
116PopEntryList(PSINGLE_LIST_ENTRY ListHead) {
117 PSINGLE_LIST_ENTRY FirstEntry;
118 FirstEntry = ListHead->Next;
119 if (FirstEntry != NULL) {
120 ListHead->Next = FirstEntry->Next;
121 }
122
123 return FirstEntry;
124}
125
126FORCEINLINE
127VOID PushEntryList(PSINGLE_LIST_ENTRY ListHead, PSINGLE_LIST_ENTRY Entry) {
128 Entry->Next = ListHead->Next;
129 ListHead->Next = Entry;
130}
131
132#endif // LIST_H_