-
Notifications
You must be signed in to change notification settings - Fork 0
/
ListOp.h
86 lines (67 loc) · 1.17 KB
/
ListOp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#pragma once
#include "WdmDriver.h"
typedef struct _LIST_T
{
LIST_ENTRY Head; // List Head entry
PKSPIN_LOCK SpinLock; // Pointer to a Lock for sync op
}LIST_T, *PLIST_T;
//
// Calls init on list head and list spin lock
//
FORCEINLINE
VOID
LopInit(
_Inout_ PLIST_T List
)
{
ASSERT(List != NULL);
InitializeListHead(&List->Head);
KeInitializeSpinLock(List->SpinLock);
return;
}
//
// Syncronised insert of Elem (PROCESS_T->ListEntry) in List after the head sentinel (List->Head), using spin lock (List->SpinLock)
//
VOID
FASTCALL
LopInsertHeadSync(
_Inout_ PLIST_T List,
_Inout_ PLIST_ENTRY Elem
);
/* List traverse */
PLIST_ENTRY
FORCEINLINE
LopListBegin(
_In_ PLIST_T List
)
{
ASSERT(List != NULL);
return List->Head.Flink;
}
PLIST_ENTRY
FORCEINLINE
LopListEnd(
_In_ PLIST_T List
)
{
ASSERT(List != NULL);
return List->Head.Blink;
}
PLIST_ENTRY
FORCEINLINE
LopEntryNext(
_In_ PLIST_ENTRY Elem
)
{
ASSERT(Elem != NULL);
return Elem->Flink;
}
BOOLEAN
FORCEINLINE
LopIsListEmpty(
_In_ PLIST_T List
)
{
ASSERT(List != NULL);
return (BOOLEAN)(List->Head.Flink == &List->Head);
}