Implement RtlCopyMemory() and RtlSameMemory(), no inline functions in static library
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
This commit is contained in:
parent
18d5a6d794
commit
e61108d9b5
@ -10,6 +10,7 @@ include_directories(
|
|||||||
list(APPEND XTKLIB_SOURCE
|
list(APPEND XTKLIB_SOURCE
|
||||||
${XTKLIB_SOURCE_DIR}/hl/cport.c
|
${XTKLIB_SOURCE_DIR}/hl/cport.c
|
||||||
${XTKLIB_SOURCE_DIR}/hl/${ARCH}/cpufunc.c
|
${XTKLIB_SOURCE_DIR}/hl/${ARCH}/cpufunc.c
|
||||||
|
${XTKLIB_SOURCE_DIR}/rtl/memory.c
|
||||||
${XTKLIB_SOURCE_DIR}/rtl/plist.c
|
${XTKLIB_SOURCE_DIR}/rtl/plist.c
|
||||||
${XTKLIB_SOURCE_DIR}/rtl/widestr.c)
|
${XTKLIB_SOURCE_DIR}/rtl/widestr.c)
|
||||||
|
|
||||||
|
@ -14,28 +14,35 @@
|
|||||||
#include "xttypes.h"
|
#include "xttypes.h"
|
||||||
|
|
||||||
|
|
||||||
XTINLINE
|
XTAPI
|
||||||
|
PVOID
|
||||||
|
RtlCopyMemory(IN PVOID Destination,
|
||||||
|
IN PCVOID Source,
|
||||||
|
IN SIZE_T Length);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
RtlInitializeListHead(IN PLIST_ENTRY ListHead);
|
RtlInitializeListHead(IN PLIST_ENTRY ListHead);
|
||||||
|
|
||||||
XTINLINE
|
|
||||||
VOID
|
VOID
|
||||||
RtlInitializeListHead32(IN PLIST_ENTRY32 ListHead);
|
RtlInitializeListHead32(IN PLIST_ENTRY32 ListHead);
|
||||||
|
|
||||||
XTINLINE
|
|
||||||
VOID
|
VOID
|
||||||
RtlInsertHeadList(IN OUT PLIST_ENTRY ListHead,
|
RtlInsertHeadList(IN OUT PLIST_ENTRY ListHead,
|
||||||
IN OUT PLIST_ENTRY Entry);
|
IN OUT PLIST_ENTRY Entry);
|
||||||
|
|
||||||
XTINLINE
|
|
||||||
VOID
|
VOID
|
||||||
RtlInsertTailList(IN OUT PLIST_ENTRY ListHead,
|
RtlInsertTailList(IN OUT PLIST_ENTRY ListHead,
|
||||||
IN OUT PLIST_ENTRY Entry);
|
IN OUT PLIST_ENTRY Entry);
|
||||||
|
|
||||||
XTINLINE
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
RtlListEmpty(PLIST_ENTRY ListHead);
|
RtlListEmpty(PLIST_ENTRY ListHead);
|
||||||
|
|
||||||
|
XTAPI
|
||||||
|
SIZE_T
|
||||||
|
RtlSameMemory(IN PCVOID LeftBuffer,
|
||||||
|
IN PCVOID RightBuffer,
|
||||||
|
IN SIZE_T Length);
|
||||||
|
|
||||||
INT
|
INT
|
||||||
RtlWideStringCompare(IN CONST PWCHAR String1,
|
RtlWideStringCompare(IN CONST PWCHAR String1,
|
||||||
IN CONST PWCHAR String2,
|
IN CONST PWCHAR String2,
|
||||||
|
95
sdk/xtklib/rtl/memory.c
Normal file
95
sdk/xtklib/rtl/memory.c
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/**
|
||||||
|
* PROJECT: ExectOS
|
||||||
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
|
* FILE: sdk/xtklib/rtl/memory.c
|
||||||
|
* DESCRIPTION: Memory related routines
|
||||||
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <xtkmapi.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This routine copies a block of memory.
|
||||||
|
*
|
||||||
|
* @param Destination
|
||||||
|
* Supplies a pointer to the buffer where data will be copied to.
|
||||||
|
*
|
||||||
|
* @param Source
|
||||||
|
* Supplies a pointer to the source buffer that will be copied.
|
||||||
|
*
|
||||||
|
* @param Length
|
||||||
|
* Specifies the number of bytes to copy.
|
||||||
|
*
|
||||||
|
* @return Returns the destination pointer.
|
||||||
|
*
|
||||||
|
* @since NT 3.5
|
||||||
|
*/
|
||||||
|
XTAPI
|
||||||
|
PVOID
|
||||||
|
RtlCopyMemory(IN PVOID Destination,
|
||||||
|
IN PCVOID Source,
|
||||||
|
IN SIZE_T Length)
|
||||||
|
{
|
||||||
|
PCHAR DestinationBytes = (PCHAR)Destination;
|
||||||
|
PCHAR SourceBytes = (PCHAR)Source;
|
||||||
|
|
||||||
|
/* Forward buffer copy */
|
||||||
|
while(Length--)
|
||||||
|
{
|
||||||
|
*DestinationBytes++ = *SourceBytes++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return pointer to destination buffer */
|
||||||
|
return Destination;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This routine compares the first bytes of the specified memory buffers.
|
||||||
|
*
|
||||||
|
* @param LeftBuffer
|
||||||
|
* Supplies a pointer to the first block of memory to compare.
|
||||||
|
*
|
||||||
|
* @param RightBuffer
|
||||||
|
* Supplies a pointer to the second block of memory to compare.
|
||||||
|
*
|
||||||
|
* @param Length
|
||||||
|
* Specifies a number of bytes to compare.
|
||||||
|
*
|
||||||
|
* @return A value indicating the relationship between the content of the memory blocks.
|
||||||
|
* It returns zero (0) if both memory blocks are equal or a value different than
|
||||||
|
* zero representing which is greater if they do not match.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTAPI
|
||||||
|
SIZE_T
|
||||||
|
RtlSameMemory(IN PCVOID LeftBuffer,
|
||||||
|
IN PCVOID RightBuffer,
|
||||||
|
IN SIZE_T Length)
|
||||||
|
{
|
||||||
|
CONST UCHAR *Left = (PUCHAR)LeftBuffer;
|
||||||
|
CONST UCHAR *Right = (PUCHAR)RightBuffer;
|
||||||
|
|
||||||
|
/* Check if there is anything to compare */
|
||||||
|
if(Length)
|
||||||
|
{
|
||||||
|
/* Iterate through whole buffer length */
|
||||||
|
while(Length--)
|
||||||
|
{
|
||||||
|
/* Compare bytes from both bufers */
|
||||||
|
if(*Left != *Right)
|
||||||
|
{
|
||||||
|
/* Buffers differ */
|
||||||
|
return (*Left - *Right);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Advance to next byte */
|
||||||
|
Left++;
|
||||||
|
Right++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Buffers equal */
|
||||||
|
return 0;
|
||||||
|
}
|
@ -19,7 +19,6 @@
|
|||||||
*
|
*
|
||||||
* @since XT 1.0
|
* @since XT 1.0
|
||||||
*/
|
*/
|
||||||
XTINLINE
|
|
||||||
VOID
|
VOID
|
||||||
RtlInitializeListHead(IN PLIST_ENTRY ListHead)
|
RtlInitializeListHead(IN PLIST_ENTRY ListHead)
|
||||||
{
|
{
|
||||||
@ -37,7 +36,6 @@ RtlInitializeListHead(IN PLIST_ENTRY ListHead)
|
|||||||
*
|
*
|
||||||
* @since XT 1.0
|
* @since XT 1.0
|
||||||
*/
|
*/
|
||||||
XTINLINE
|
|
||||||
VOID
|
VOID
|
||||||
RtlInitializeListHead32(IN PLIST_ENTRY32 ListHead)
|
RtlInitializeListHead32(IN PLIST_ENTRY32 ListHead)
|
||||||
{
|
{
|
||||||
@ -58,7 +56,6 @@ RtlInitializeListHead32(IN PLIST_ENTRY32 ListHead)
|
|||||||
*
|
*
|
||||||
* @since XT 1.0
|
* @since XT 1.0
|
||||||
*/
|
*/
|
||||||
XTINLINE
|
|
||||||
VOID
|
VOID
|
||||||
RtlInsertHeadList(IN OUT PLIST_ENTRY ListHead,
|
RtlInsertHeadList(IN OUT PLIST_ENTRY ListHead,
|
||||||
IN OUT PLIST_ENTRY Entry)
|
IN OUT PLIST_ENTRY Entry)
|
||||||
@ -82,7 +79,6 @@ RtlInsertHeadList(IN OUT PLIST_ENTRY ListHead,
|
|||||||
*
|
*
|
||||||
* @since XT 1.0
|
* @since XT 1.0
|
||||||
*/
|
*/
|
||||||
XTINLINE
|
|
||||||
VOID
|
VOID
|
||||||
RtlInsertTailList(IN OUT PLIST_ENTRY ListHead,
|
RtlInsertTailList(IN OUT PLIST_ENTRY ListHead,
|
||||||
IN OUT PLIST_ENTRY Entry)
|
IN OUT PLIST_ENTRY Entry)
|
||||||
@ -103,7 +99,6 @@ RtlInsertTailList(IN OUT PLIST_ENTRY ListHead,
|
|||||||
*
|
*
|
||||||
* @since XT 1.0
|
* @since XT 1.0
|
||||||
*/
|
*/
|
||||||
XTINLINE
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
RtlListEmpty(PLIST_ENTRY ListHead)
|
RtlListEmpty(PLIST_ENTRY ListHead)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user