paw: spkg: Add support package groundwork
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# Copyright (c) 2026, Chloe M.
|
||||
# Provided under the BSD-3 clause
|
||||
#
|
||||
# Description: Support package build script
|
||||
# Author: Chloe M.
|
||||
#
|
||||
|
||||
.SILENT:
|
||||
include ../mk/stos.mk
|
||||
|
||||
CFILES = $(shell find . -name "*.c")
|
||||
OFILES = $(CFILES:.c=.o)
|
||||
|
||||
CFLAGS = \
|
||||
$(SYS_CFLAGS) \
|
||||
-Ihead \
|
||||
-I$(ST_PROJECT_ROOT)/sdk/head
|
||||
|
||||
.PHONY: all
|
||||
all: $(OFILES)
|
||||
|
||||
%.o: %.c
|
||||
$(PROMPT) "CC" $<
|
||||
$(SYS_CC) -c $(CFLAGS) $< -o $@
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2026, Chloe M.
|
||||
* Provided under the BSD-3 clause.
|
||||
*
|
||||
* Description: String helpers
|
||||
* Author: Chloe M.
|
||||
*/
|
||||
|
||||
#ifndef _SPKG_STRING_H_
|
||||
#define _SPKG_STRING_H_ 1
|
||||
|
||||
#include <stdef.h>
|
||||
|
||||
/*
|
||||
* Compare the differences between two strings
|
||||
*
|
||||
* @Buffer1: First buffer to compare
|
||||
* @Buffer2: Second buffer to compare
|
||||
* @Length: Number of bytes to compare
|
||||
*
|
||||
* Returns the differences
|
||||
*/
|
||||
LONG RtlMemCmp(const VOID *Buffer1, const VOID *Buffer2, USIZE Length);
|
||||
|
||||
#endif /* !_SPKG_STRING_H_ */
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2026, Chloe M.
|
||||
* Provided under the BSD-3 clause.
|
||||
*
|
||||
* Description: RtlMemCmp() implementation
|
||||
* Author: Chloe M.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
LONG
|
||||
RtlMemCmp(const VOID *Buffer1, const VOID *Buffer2, USIZE Length)
|
||||
{
|
||||
const UCHAR *Ptr1 = Buffer1;
|
||||
const UCHAR *Ptr2 = Buffer2;
|
||||
|
||||
if (Buffer1 == NULL || Buffer2 == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (Length == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
do {
|
||||
if (*Ptr1++ != *Ptr2++) {
|
||||
return (*--Ptr1 - *--Ptr2);
|
||||
}
|
||||
} while (--Length != 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user