wm: teppich

Download patch

ref: b4587b6d4f1c365c7ecfe653264046bb49ca7478
parent: 086331e6bf7b682b12ca392130160a1afb371f12
author: mkf <mkf@cloud9p.org>
date: Mon Nov 13 12:29:19 EST 2023

memcpy, memset: import

--- /dev/null
+++ b/libc/memcpy.c
@@ -1,0 +1,24 @@
+void*
+memcpy(void *a1, void *a2, unsigned int len)
+{
+	char *s1, *s2;
+
+	s1 = a1;
+	s2 = a2;
+	if((s2 < s1) && (s2 + len > s1))
+		goto back;
+	while(len > 0) {
+		*s1++ = *s2++;
+		len--;
+	}
+	return a1;
+
+back:
+	s1 += len;
+	s2 += len;
+	while(len > 0) {
+		*--s1 = *--s2;
+		len--;
+	}
+	return a1;
+}
--- /dev/null
+++ b/libc/memset.c
@@ -1,0 +1,9 @@
+void*
+memset(void* src, char c, unsigned int len)
+{
+	for (unsigned int i = 0; i < len; i++)
+	{
+		*(char*)(src++) = c;
+	}
+	return src;
+}