From 14fafa25170ca3d3ae2713ccead25d80502c2b61 Mon Sep 17 00:00:00 2001 From: belliash Date: Tue, 16 Aug 2022 19:01:23 +0200 Subject: [PATCH] Implement RtlInsertHeadList() and RtlInsertTailList() --- sdk/xtklib/includes/librtl.h | 10 ++++++++ sdk/xtklib/rtl/plist.c | 48 ++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/sdk/xtklib/includes/librtl.h b/sdk/xtklib/includes/librtl.h index c9218af..d49f0cd 100644 --- a/sdk/xtklib/includes/librtl.h +++ b/sdk/xtklib/includes/librtl.h @@ -22,6 +22,16 @@ XTINLINE VOID RtlInitializeListHead32(IN PLIST_ENTRY32 ListHead); +XTINLINE +VOID +RtlInsertHeadList(IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY Entry); + +XTINLINE +VOID +RtlInsertTailList(IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY Entry); + XTINLINE BOOLEAN RtlListEmpty(PLIST_ENTRY ListHead); diff --git a/sdk/xtklib/rtl/plist.c b/sdk/xtklib/rtl/plist.c index 9250ad3..2c3a315 100644 --- a/sdk/xtklib/rtl/plist.c +++ b/sdk/xtklib/rtl/plist.c @@ -45,6 +45,54 @@ RtlInitializeListHead32(IN PLIST_ENTRY32 ListHead) ListHead->Flink = PtrToUlong(ListHead); } +/** + * This routine inserts an entry at the head of a double linked list. + * + * @param ListHead + * Pointer to the head of the list. + * + * @param Entry + * Pointer to the entry that will be inserted in the list. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTINLINE +VOID +RtlInsertHeadList(IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY Entry) +{ + Entry->Flink = ListHead->Flink; + Entry->Blink = ListHead; + ListHead->Flink->Blink = Entry; + ListHead->Flink = Entry; +} + +/** + * This routine inserts an entry at the tail of a double linked list. + * + * @param ListHead + * Pointer to the head of the list. + * + * @param Entry + * Pointer to the entry that will be inserted in the list. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTINLINE +VOID +RtlInsertTailList(IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY Entry) +{ + Entry->Flink = ListHead; + Entry->Blink = ListHead->Blink; + ListHead->Blink->Flink = Entry; + ListHead->Blink = Entry; +} + /** * Indicates whether a double linked list structure is empty. *