Revert RTL::LinkedList::RemoveEntryList() routine signature and extend RTL::LinkedList API
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 38s
Builds / ExectOS (i686, debug) (push) Successful in 37s
Builds / ExectOS (amd64, release) (push) Successful in 1m17s
Builds / ExectOS (i686, release) (push) Successful in 1m14s

This commit is contained in:
2026-02-16 15:43:00 +01:00
parent 2af94a1c3b
commit 94a8917c5c
6 changed files with 130 additions and 12 deletions

View File

@@ -9,6 +9,32 @@
#include <xtos.hh>
/**
* Retrieves the first entry from a double-linked list without removing it from the list.
*
* @param ListHead
* Pointer to a structure that serves as the list header.
*
* @return This routine returns a pointer to the first entry in the list.
* If the list is empty, the return value points to the list head.
*
* @since XT 1.0
*/
XTCDECL
PLIST_ENTRY
RTL::LinkedList::GetFirstEntry(IN PLIST_ENTRY ListHead)
{
/* Check if the list is empty */
if(ListEmpty(ListHead))
{
/* Empty list, return NULLPTR */
return NULLPTR;
}
/* Return first entry in the list */
return ListHead->Flink;
}
/**
* This routine initializes a structure representing the head of a double-linked list.
*
@@ -23,6 +49,7 @@ XTCDECL
VOID
RTL::LinkedList::InitializeListHead(IN PLIST_ENTRY ListHead)
{
/* Initialize list head */
ListHead->Blink = ListHead;
ListHead->Flink = ListHead;
}
@@ -41,6 +68,7 @@ XTCDECL
VOID
RTL::LinkedList::InitializeListHead32(IN PLIST_ENTRY32 ListHead)
{
/* Initialize list head */
ListHead->Blink = PtrToUlong(ListHead);
ListHead->Flink = PtrToUlong(ListHead);
}
@@ -63,6 +91,7 @@ VOID
RTL::LinkedList::InsertHeadList(IN OUT PLIST_ENTRY ListHead,
IN PLIST_ENTRY Entry)
{
/* Insert entry at the head of the list */
Entry->Flink = ListHead->Flink;
Entry->Blink = ListHead;
ListHead->Flink->Blink = Entry;
@@ -87,6 +116,7 @@ VOID
RTL::LinkedList::InsertTailList(IN OUT PLIST_ENTRY ListHead,
IN PLIST_ENTRY Entry)
{
/* Insert entry at the tail of the list */
Entry->Flink = ListHead;
Entry->Blink = ListHead->Blink;
ListHead->Blink->Flink = Entry;
@@ -107,6 +137,7 @@ XTCDECL
BOOLEAN
RTL::LinkedList::ListEmpty(IN PLIST_ENTRY ListHead)
{
/* Check if the list is empty */
return (((ListHead->Flink == NULLPTR) && (ListHead->Blink == NULLPTR)) || (ListHead->Flink == ListHead));
}
@@ -162,18 +193,99 @@ RTL::LinkedList::ListLoop(IN PLIST_ENTRY ListHead)
* @param Entry
* Pointer to the entry that will be removed from the list.
*
* @return This routine returns TRUE if the list is empty after removal, or FALSE otherwise.
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
BOOLEAN
VOID
RTL::LinkedList::RemoveEntryList(IN PLIST_ENTRY Entry)
{
/* Remove entry from the list */
Entry->Flink->Blink = Entry->Blink;
Entry->Blink->Flink = Entry->Flink;
/* Return TRUE if list is empty, or FALSE otherwise */
return ListEmpty(Entry);
}
/**
* Splices a doubly linked list at the head of another list. The source list is reinitialized to empty.
*
* @param ListHead
* Pointer to a structure that represents the head of the list.
*
* @param SpliceList
* Pointer to a structure that represents the head of the list that will be spliced.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
RTL::LinkedList::SpliceHeadList(IN OUT PLIST_ENTRY ListHead,
IN OUT PLIST_ENTRY SpliceList)
{
PLIST_ENTRY FirstEntry, LastEntry;
/* Check if the list to splice is empty */
if(SpliceList->Flink == SpliceList)
{
/* Nothing to splice, return */
return;
}
/* Get first and last entries of the list to splice */
FirstEntry = SpliceList->Flink;
LastEntry = SpliceList->Blink;
/* Splice the list at the head of destination */
FirstEntry->Blink = ListHead;
LastEntry->Flink = ListHead->Flink;
ListHead->Flink->Blink = LastEntry;
ListHead->Flink = FirstEntry;
/* Reinitialize the source list to empty */
SpliceList->Blink = SpliceList;
SpliceList->Flink = SpliceList;
}
/**
* Splices a doubly linked list at the tail of another list. The source list is reinitialized to empty.
*
* @param ListHead
* Pointer to the head of the destination list.
*
* @param SpliceList
* Pointer to the head of the list that will be spliced.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
RTL::LinkedList::SpliceTailList(IN OUT PLIST_ENTRY ListHead,
IN OUT PLIST_ENTRY SpliceList)
{
PLIST_ENTRY FirstEntry, LastEntry;
/* Check if the list to splice is empty */
if(SpliceList->Flink == SpliceList)
{
/* Nothing to splice, return */
return;
}
/* Get first and last entries of the list to splice */
FirstEntry = SpliceList->Flink;
LastEntry = SpliceList->Blink;
/* Splice the list at the tail of destination */
FirstEntry->Blink = ListHead->Blink;
LastEntry->Flink = ListHead;
ListHead->Blink->Flink = FirstEntry;
ListHead->Blink = LastEntry;
/* Reinitialize the source list to empty */
SpliceList->Blink = SpliceList;
SpliceList->Flink = SpliceList;
}