]> git.corax.cc Git - corax/commitdiff
Add strlen() function to userspace libc
authorMatthias Kruk <m@m10k.eu>
Fri, 31 Jan 2020 11:24:53 +0000 (20:24 +0900)
committerMatthias Kruk <m@m10k.eu>
Fri, 31 Jan 2020 11:24:53 +0000 (20:24 +0900)
libc/Makefile
libc/string.c [new file with mode: 0644]

index 5029badee4ee55216d10d06efeeddced3ddccd57..f10ed46e6573f530f026f2c5d14e3be5fc63b147 100644 (file)
@@ -1,5 +1,5 @@
 OUTPUT = libc.a
-OBJECTS = syscall.o
+OBJECTS = syscall.o string.o
 PHONY = clean
 INCLUDES = -I../include
 CFLAGS = -m32 -Wall -nostdlib -nodefaultlibs -nostartfiles -ffreestanding $(INCLUDES)
diff --git a/libc/string.c b/libc/string.c
new file mode 100644 (file)
index 0000000..5ae3b1d
--- /dev/null
@@ -0,0 +1,10 @@
+#include <sys/types.h>
+
+size_t strlen(const char *s)
+{
+       size_t ret_val;
+
+       for(ret_val = 0; s[ret_val]; ret_val++);
+
+       return(ret_val);
+}