lib: Add libstr library

Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
2026-04-16 22:19:20 -04:00
parent 67688b60bc
commit 95031d592a
7 changed files with 129 additions and 3 deletions
+5 -1
View File
@@ -12,7 +12,11 @@
include mk/sys.mk
.PHONY: all
all: sp1 boot
all: lib sp1 boot
.PHONY: lib
lib:
cd lib/; $(MAKE)
.PHONY: boot
boot:
+19
View File
@@ -0,0 +1,19 @@
#
# Copyright (c) 2026, Mirocom Laboratories
# All rights reserved.
#
# The following sources are CONFIDENTIAL and PROPRIETARY
# property of Mirocom Laboratories. Unauthorized copying,
# use, distrubution or modification of this file, in whole
# and in part, is strictly prohibited without the prior written
# consent from Mirocom Laboratories.
#
include ../mk/sys.mk
.PHONY: all
all: libstr
.PHONY: libstr
libstr:
cd libstr/; $(MAKE) $(PASSDOWN_ARGS)
+22
View File
@@ -0,0 +1,22 @@
#
# Copyright (c) 2026, Mirocom Laboratories
# All rights reserved.
#
# The following sources are CONFIDENTIAL and PROPRIETARY
# property of Mirocom Laboratories. Unauthorized copying,
# use, distrubution or modification of this file, in whole
# and in part, is strictly prohibited without the prior written
# consent from Mirocom Laboratories.
#
CFILES = $(shell find . -name "*.c")
OFILES = $(CFILES:.c=.o)
CC = ../../../../$(SYS_CC)
CFLAGS = $(SYS_CFLAGS) -I../../head -D_SP1_SOURCE
.PHONY: all
all: $(OFILES)
%.o: %.c
$(CC) -c $< $(CFLAGS) -o $@
+27
View File
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2026, Mirocom Laboratories
* All rights reserved.
*
* The following sources are CONFIDENTIAL and PROPRIETARY
* property of Mirocom Laboratories. Unauthorized copying,
* use, distribution or modification of this file, in whole
* and in part, is strictly prohibited without the prior written
* consent from Mirocom Laboratories.
*/
#include <string.h>
int
memcmp(const void *s1, const void *s2, __size_t n)
{
if (n != 0) {
const unsigned char *p1 = s1, *p2 = s2;
do {
if (*p1++ != *p2++) {
return (*--p1 - *--p2);
}
} while (--n != 0);
}
return 0;
}
+26
View File
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2026, Mirocom Laboratories
* All rights reserved.
*
* The following sources are CONFIDENTIAL and PROPRIETARY
* property of Mirocom Laboratories. Unauthorized copying,
* use, distribution or modification of this file, in whole
* and in part, is strictly prohibited without the prior written
* consent from Mirocom Laboratories.
*/
#include <string.h>
void *
memcpy(void *dest, const void *src, size_t count)
{
if (dest == NULL || src == NULL) {
return NULL;
}
for (size_t i = 0; i < count; ++i) {
((char *)dest)[i] = ((char *)src)[i];
}
return dest;
}
+26
View File
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2026, Mirocom Laboratories
* All rights reserved.
*
* The following sources are CONFIDENTIAL and PROPRIETARY
* property of Mirocom Laboratories. Unauthorized copying,
* use, distribution or modification of this file, in whole
* and in part, is strictly prohibited without the prior written
* consent from Mirocom Laboratories.
*/
#include <string.h>
void *
memset(void *s, int c, size_t n)
{
if (s == NULL) {
return NULL;
}
for (size_t i = 0; i < n; ++i) {
((uint8_t *)s)[i] = c;
}
return s;
}
+4 -2
View File
@@ -11,7 +11,9 @@
ASMFILES = $(shell find . -name "*.S")
ASMOFILES = $(ASMFILES:.S=.S.o)
MISC_OFILES = $(shell find ../common -name "*.o")
MISC_OFILES = $(shell find ../ -name "*.o")
LIB_OFILES = $(shell find ../../lib/ -name "*.o")
CC = \
../../../../$(SYS_CC)
@@ -27,7 +29,7 @@ all: $(ASMOFILES)
$(LD) \
-Tconf/link.ld \
$(MISC_OFILES) \
$(ASMOFILES) \
$(LIB_OFILES) \
-o ../../../../sp1.sys
%.S.o: %.S