summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mk/defaults.mk1
-rw-r--r--usr/.keep0
-rw-r--r--usr/sdk/Makefile21
-rw-r--r--usr/sdk/common/string/strlen.c20
-rw-r--r--usr/sdk/inc/sdk/string.h18
5 files changed, 60 insertions, 0 deletions
diff --git a/mk/defaults.mk b/mk/defaults.mk
index ae85cfd..2c06603 100644
--- a/mk/defaults.mk
+++ b/mk/defaults.mk
@@ -8,6 +8,7 @@ QEMU = qemu-system-$(ARCH)
CC = $(shell pwd)/var/cc/gcc/bin/$(ARCH)-pc-osmora-gcc
LD = $(shell pwd)/var/cc/toolchain/build-binutils/bin/$(ARCH)-pc-osmora-ld
+AR = $(shell pwd)/var/cc/toolchain/build-binutils/bin/$(ARCH)-pc-osmora-ar
SYS_CFLAGS = \
-nostdlib \
diff --git a/usr/.keep b/usr/.keep
deleted file mode 100644
index e69de29..0000000
--- a/usr/.keep
+++ /dev/null
diff --git a/usr/sdk/Makefile b/usr/sdk/Makefile
new file mode 100644
index 0000000..9a5cc73
--- /dev/null
+++ b/usr/sdk/Makefile
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2025, Ian Moffett.
+# Provided under the BSD-3 clause.
+#
+
+CFILES = $(shell find common/ -name "*.c")
+OFILES = $(CFILES:.c=.o)
+
+CC =
+LD =
+
+ARCH =
+SYS_CFLAGS =
+CFLAGS = $(SYS_CFLAGS) -Iinc/
+
+.PHONY: all
+all: $(OFILES)
+ $(AR) rcs libmos.a $(OFILES)
+
+%.o: %.c
+ $(CC) -c $(CFLAGS) $< -o $@
diff --git a/usr/sdk/common/string/strlen.c b/usr/sdk/common/string/strlen.c
new file mode 100644
index 0000000..4499512
--- /dev/null
+++ b/usr/sdk/common/string/strlen.c
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025, Ian Moffett.
+ * Provided under the BSD-3 clause.
+ */
+
+#include <sdk/string.h>
+#include <sdk/types.h>
+
+USIZE
+strlen(const char *str)
+{
+ USIZE len = 0;
+
+ if (str == NULL) {
+ return 0;
+ }
+
+ while (str[len++] != '\0');
+ return len - 1;
+}
diff --git a/usr/sdk/inc/sdk/string.h b/usr/sdk/inc/sdk/string.h
new file mode 100644
index 0000000..f7668fd
--- /dev/null
+++ b/usr/sdk/inc/sdk/string.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2025, Ian Moffett.
+ * Provided under the BSD-3 clause.
+ */
+
+#ifndef _SDK_STRING_H_
+#define _SDK_STRING_H_ 1
+
+ #include <sdk/types.h>
+
+/*
+ * Returns the length of a string
+ *
+ * @str: String to get length of
+ */
+USIZE strlen(const char *str);
+
+#endif /* !_SDK_STRING_H_ */