From f67bc808ccdf5b68a930d20007dae6df2c8a28a8 Mon Sep 17 00:00:00 2001 From: belliash Date: Sat, 13 Aug 2022 23:15:06 +0200 Subject: [PATCH] Basic support for double linked lists --- sdk/xtklib/CMakeLists.txt | 1 + sdk/xtklib/includes/librtl.h | 13 ++++++++ sdk/xtklib/rtl/plist.c | 63 ++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 sdk/xtklib/rtl/plist.c diff --git a/sdk/xtklib/CMakeLists.txt b/sdk/xtklib/CMakeLists.txt index 69e47de..e2fdf10 100644 --- a/sdk/xtklib/CMakeLists.txt +++ b/sdk/xtklib/CMakeLists.txt @@ -10,6 +10,7 @@ include_directories( list(APPEND XTKLIB_SOURCE ${XTKLIB_SOURCE_DIR}/hl/cport.c ${XTKLIB_SOURCE_DIR}/hl/${ARCH}/cpufunc.c + ${XTKLIB_SOURCE_DIR}/rtl/plist.c ${XTKLIB_SOURCE_DIR}/rtl/widestr.c) # Add library diff --git a/sdk/xtklib/includes/librtl.h b/sdk/xtklib/includes/librtl.h index 9e28cfe..c9218af 100644 --- a/sdk/xtklib/includes/librtl.h +++ b/sdk/xtklib/includes/librtl.h @@ -10,9 +10,22 @@ #define __XTKLIB_LIBRTL_H #include "xtdefs.h" +#include "xtstruct.h" #include "xttypes.h" +XTINLINE +VOID +RtlInitializeListHead(IN PLIST_ENTRY ListHead); + +XTINLINE +VOID +RtlInitializeListHead32(IN PLIST_ENTRY32 ListHead); + +XTINLINE +BOOLEAN +RtlListEmpty(PLIST_ENTRY ListHead); + INT RtlWideStringCompare(IN CONST PWCHAR String1, IN CONST PWCHAR String2, diff --git a/sdk/xtklib/rtl/plist.c b/sdk/xtklib/rtl/plist.c new file mode 100644 index 0000000..82892ff --- /dev/null +++ b/sdk/xtklib/rtl/plist.c @@ -0,0 +1,63 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: sdk/xtklib/rtl/plist.c + * DESCRIPTION: Linked list manipulation routines + * DEVELOPERS: Rafal Kupiec + */ + +#include + + +/** + * This routine initializes a structure representing the head of a double-linked list. + * + * @param ListHead + * Pointer to a structure that serves as the list header. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTINLINE +VOID +RtlInitializeListHead(IN PLIST_ENTRY ListHead) +{ + ListHead->Blink = ListHead; + ListHead->Flink = ListHead; +} + +/** + * This routine initializes a structure representing the head of a 32bit double-linked list. + * + * @param ListHead + * Pointer to a structure that serves as the list header. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTINLINE +VOID +RtlInitializeListHead32(IN PLIST_ENTRY32 ListHead) +{ + ListHead->Blink = PtrToUlong(ListHead); + ListHead->Flink = PtrToUlong(ListHead); +} + +/** + * Indicates whether a doubly linked list structure is empty. + * + * @param ListHead + * Pointer to a structure that represents the head of the list. + * + * @return TRUE if there are currently no entries in the list or FALSE otherwise. + * + * @since XT 1.0 + */ +XTINLINE +BOOLEAN +RtlListEmpty(PLIST_ENTRY ListHead) +{ + return (ListHead->Flink == ListHead); +}