#ifndef __LIST_H__
#define __LIST_H__
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _in
#define _in
#endif
#ifndef _out
#define _out
#endif
#ifndef _inout
#define _inout
#endif
#ifndef FORCEINLINE
#if (_MSC_VER >= 1200)
#define FORCEINLINE __forceinline
#else
#define FORCEINLINE _inline
#endif
#endif
struct list_entry {
struct list_entry *next;
struct list_entry *prev;
};
//#ifndef _SINGLE_struct list_entry
// typedef struct _SINGLE_struct list_entry {
// struct _SINGLE_struct list_entry* Next;
// } SINGLE_struct list_entry, * PSINGLE_struct list_entry;
//#endif
FORCEINLINE
void
initialize_list_head(
_out struct list_entry* list_head
)
{
list_head->next = list_head->prev = list_head;
}
int
FORCEINLINE
is_list_empty(
_in const struct list_entry * list_head
)
{
return (int)(list_head->next == list_head);
}
FORCEINLINE
int
remove_entry_list(
_in struct list_entry* entry
)
{
struct list_entry* prev;
struct list_entry* next;
next = entry->next;
prev = entry->prev;
prev->next = next;
next->prev = prev;
return (int)(next == prev);
}
FORCEINLINE
struct list_entry*
remove_head_list(
_inout struct list_entry* list_head
)
{
struct list_entry* next;
struct list_entry* entry;
entry = list_head->next;
next = entry->next;
list_head->next = next;
next->prev = list_head;
return entry;
}
FORCEINLINE
struct list_entry*
remove_tail_list(
_inout struct list_entry* list_head
)
{
struct list_entry* prev;
struct list_entry* entry;
entry = list_head->prev;
prev = entry->prev;
list_head->prev = prev;
prev->next = list_head;
return entry;
}
FORCEINLINE
void
insert_tail_list(
_inout struct list_entry* list_head,
_inout struct list_entry* entry
)
{
struct list_entry* prev;
prev = list_head->prev;
entry->next = list_head;
entry->prev = prev;
prev->next = entry;
list_head->prev = entry;
}
FORCEINLINE
void
insert_head_list(
_inout struct list_entry* list_head,
_inout struct list_entry* entry
)
{
struct list_entry* next;
next = list_head->next;
entry->next = next;
entry->prev = list_head;
next->prev = entry;
list_head->next = entry;
}
FORCEINLINE
void
append_tail_list(
_inout struct list_entry* list_head,
_inout struct list_entry* list_to_append
)
{
struct list_entry* list_end = list_head->prev;
list_head->prev->next = list_to_append;
list_head->prev = list_to_append->prev;
list_to_append->prev->next = list_head;
list_to_append->prev = list_end;
}
//FORCEINLINE
//PSINGLE_struct list_entry
//Popentry_list(
// _inout PSINGLE_struct list_entry list_head
//)
//{
// PSINGLE_struct list_entry Firstentry;
// Firstentry = list_head->Next;
// if (Firstentry != 0) {
// list_head->Next = Firstentry->Next;
// }
//
// return Firstentry;
//}
//
//
//FORCEINLINE
//void
//Pushentry_list(
// _inout PSINGLE_struct list_entry list_head,
// _inout PSINGLE_struct list_entry entry
//)
//{
// entry->Next = list_head->Next;
// list_head->Next = entry;
//}
#ifdef __cplusplus
}
#endif
#endif
#ifndef __LIST_H__
#define __LIST_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <Windows.h>
FORCEINLINE
VOID
InitializeListHead(
__out PLIST_ENTRY ListHead
)
{
ListHead->Flink = ListHead->Blink = ListHead;
}
__checkReturn
BOOLEAN
FORCEINLINE
IsListEmpty(
__in const LIST_ENTRY * ListHead
)
{
return (BOOLEAN)(ListHead->Flink == ListHead);
}
FORCEINLINE
BOOLEAN
RemoveEntryList(
__in PLIST_ENTRY Entry
)
{
PLIST_ENTRY Blink;
PLIST_ENTRY Flink;
Flink = Entry->Flink;
Blink = Entry->Blink;
Blink->Flink = Flink;
Flink->Blink = Blink;
return (BOOLEAN)(Flink == Blink);
}
FORCEINLINE
PLIST_ENTRY
RemoveHeadList(
__inout PLIST_ENTRY ListHead
)
{
PLIST_ENTRY Flink;
PLIST_ENTRY Entry;
Entry = ListHead->Flink;
Flink = Entry->Flink;
ListHead->Flink = Flink;
Flink->Blink = ListHead;
return Entry;
}
FORCEINLINE
PLIST_ENTRY
RemoveTailList(
__inout PLIST_ENTRY ListHead
)
{
PLIST_ENTRY Blink;
PLIST_ENTRY Entry;
Entry = ListHead->Blink;
Blink = Entry->Blink;
ListHead->Blink = Blink;
Blink->Flink = ListHead;
return Entry;
}
FORCEINLINE
VOID
InsertTailList(
__inout PLIST_ENTRY ListHead,
__inout __drv_aliasesMem PLIST_ENTRY Entry
)
{
PLIST_ENTRY Blink;
Blink = ListHead->Blink;
Entry->Flink = ListHead;
Entry->Blink = Blink;
Blink->Flink = Entry;
ListHead->Blink = Entry;
}
FORCEINLINE
VOID
InsertHeadList(
__inout PLIST_ENTRY ListHead,
__inout __drv_aliasesMem PLIST_ENTRY Entry
)
{
PLIST_ENTRY Flink;
Flink = ListHead->Flink;
Entry->Flink = Flink;
Entry->Blink = ListHead;
Flink->Blink = Entry;
ListHead->Flink = Entry;
}
FORCEINLINE
VOID
AppendTailList(
__inout PLIST_ENTRY ListHead,
__inout PLIST_ENTRY ListToAppend
)
{
PLIST_ENTRY ListEnd = ListHead->Blink;
ListHead->Blink->Flink = ListToAppend;
ListHead->Blink = ListToAppend->Blink;
ListToAppend->Blink->Flink = ListHead;
ListToAppend->Blink = ListEnd;
}
FORCEINLINE
PSINGLE_LIST_ENTRY
PopEntryList(
__inout PSINGLE_LIST_ENTRY ListHead
)
{
PSINGLE_LIST_ENTRY FirstEntry;
FirstEntry = ListHead->Next;
if (FirstEntry != NULL) {
ListHead->Next = FirstEntry->Next;
}
return FirstEntry;
}
FORCEINLINE
VOID
PushEntryList(
__inout PSINGLE_LIST_ENTRY ListHead,
__inout __drv_aliasesMem PSINGLE_LIST_ENTRY Entry
)
{
Entry->Next = ListHead->Next;
ListHead->Next = Entry;
}
#ifdef __cplusplus
}
#endif
#endif
#ifndef __LIST_H__
#define __LIST_H__
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _in
#define _in
#endif
#ifndef _out
#define _out
#endif
#ifndef _inout
#define _inout
#endif
#ifndef FORCEINLINE
#if (_MSC_VER >= 1200)
#define FORCEINLINE __forceinline
#else
#define FORCEINLINE _inline
#endif
#endif
struct list_entry {
struct list_entry *next;
struct list_entry *prev;
};
//#ifndef _SINGLE_struct list_entry
// typedef struct _SINGLE_struct list_entry {
// struct _SINGLE_struct list_entry* Next;
// } SINGLE_struct list_entry, * PSINGLE_struct list_entry;
//#endif
FORCEINLINE
void
InitializeListHead(
_out struct list_entry *list_head
) {
list_head->next = list_head->prev = list_head;
}
int
FORCEINLINE
IsListEmpty(
_in const struct list_entry *list_head
) {
return (int)(list_head->next == list_head);
}
FORCEINLINE
int
RemoveEntryList(
_in struct list_entry *entry
) {
struct list_entry *prev;
struct list_entry *next;
next = entry->next;
prev = entry->prev;
prev->next = next;
next->prev = prev;
return (int)(next == prev);
}
FORCEINLINE
struct list_entry *
RemoveHeadList(
_inout struct list_entry *list_head
) {
struct list_entry *next;
struct list_entry *entry;
entry = list_head->next;
next = entry->next;
list_head->next = next;
next->prev = list_head;
return entry;
}
FORCEINLINE
struct list_entry *
RemoveTailList(
_inout struct list_entry *list_head
) {
struct list_entry *prev;
struct list_entry *entry;
entry = list_head->prev;
prev = entry->prev;
list_head->prev = prev;
prev->next = list_head;
return entry;
}
FORCEINLINE
void
InsertTailList(
_inout struct list_entry *list_head,
_inout struct list_entry *entry
) {
struct list_entry *prev;
prev = list_head->prev;
entry->next = list_head;
entry->prev = prev;
prev->next = entry;
list_head->prev = entry;
}
FORCEINLINE
void
InsertHeadList(
_inout struct list_entry *list_head,
_inout struct list_entry *entry
) {
struct list_entry *next;
next = list_head->next;
entry->next = next;
entry->prev = list_head;
next->prev = entry;
list_head->next = entry;
}
FORCEINLINE
void
AppendTailList(
_inout struct list_entry *list_head,
_inout struct list_entry *list_to_append
) {
struct list_entry *list_end = list_head->prev;
list_head->prev->next = list_to_append;
list_head->prev = list_to_append->prev;
list_to_append->prev->next = list_head;
list_to_append->prev = list_end;
}
//FORCEINLINE
//PSINGLE_struct list_entry
//Popentry_list(
// _inout PSINGLE_struct list_entry list_head
//)
//{
// PSINGLE_struct list_entry Firstentry;
// Firstentry = list_head->Next;
// if (Firstentry != 0) {
// list_head->Next = Firstentry->Next;
// }
//
// return Firstentry;
//}
//
//
//FORCEINLINE
//void
//Pushentry_list(
// _inout PSINGLE_struct list_entry list_head,
// _inout PSINGLE_struct list_entry entry
//)
//{
// entry->Next = list_head->Next;
// list_head->Next = entry;
//}
#ifdef __cplusplus
}
#endif
#endif
发表回复