From 8a9208612eec8ddae4c418485d848ecfa0613699 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Mon, 30 Oct 2023 22:12:14 +0100 Subject: Meta: Move kernel and userland to their own folders. This is to allow both the kernel and the userland to share certain header files and to make the folder structure a bit more clear. --- libc/string/copy.c | 26 -------------------------- libc/string/isequal.c | 15 --------------- libc/string/memcmp.c | 12 ------------ libc/string/memcpy.c | 20 -------------------- libc/string/memset.c | 9 --------- libc/string/strcat.c | 6 ------ libc/string/strcmp.c | 8 -------- libc/string/strcpy.c | 8 -------- libc/string/strlcpy.c | 21 --------------------- libc/string/strlen.c | 8 -------- libc/string/strncpy.c | 11 ----------- 11 files changed, 144 deletions(-) delete mode 100644 libc/string/copy.c delete mode 100644 libc/string/isequal.c delete mode 100644 libc/string/memcmp.c delete mode 100644 libc/string/memcpy.c delete mode 100644 libc/string/memset.c delete mode 100644 libc/string/strcat.c delete mode 100644 libc/string/strcmp.c delete mode 100644 libc/string/strcpy.c delete mode 100644 libc/string/strlcpy.c delete mode 100644 libc/string/strlen.c delete mode 100644 libc/string/strncpy.c (limited to 'libc/string') diff --git a/libc/string/copy.c b/libc/string/copy.c deleted file mode 100644 index 277c808..0000000 --- a/libc/string/copy.c +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include -#include - -char *copy_and_allocate_string(const char *s) { - size_t l = strlen(s); - char *r = kmalloc(l + 1); - if (!r) - return NULL; - return strncpy(r, s, l); -} - -char *copy_and_allocate_user_string(const char *s) { - size_t len; - if (!is_valid_user_c_string(s, &len)) - return NULL; - size_t real_len = strlen(s); - assert(real_len == len); - len = real_len; - char *r = kmalloc(len + 1); - if (!r) - return NULL; - strlcpy(r, s, len); - return r; -} diff --git a/libc/string/isequal.c b/libc/string/isequal.c deleted file mode 100644 index cdbd3cc..0000000 --- a/libc/string/isequal.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "../include/string.h" - -int isequal(const char *s1, const char *s2) { - for(;*s1;s1++,s2++) - if(*s1 != *s2) - return 0; - return 1; -} - -int isequal_n(const char *s1, const char *s2, uint32_t n) { - for(;*s1 && n;s1++,s2++,n--) - if(*s1 != *s2) - return 0; - return 1; -} diff --git a/libc/string/memcmp.c b/libc/string/memcmp.c deleted file mode 100644 index 72c680a..0000000 --- a/libc/string/memcmp.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "../include/string.h" - -int memcmp(const void *s1, const void *s2, uint32_t n) -{ - int return_value = 0; - - for(uint32_t i = 0;i < n;i++) - if(((unsigned char *)(s1))[i] != ((unsigned char *)(s2))[i]) - return_value++; - - return return_value; -} diff --git a/libc/string/memcpy.c b/libc/string/memcpy.c deleted file mode 100644 index 5c04407..0000000 --- a/libc/string/memcpy.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "../include/string.h" - -void * -memcpy(void *dest, const void *src, uint32_t n) { - unsigned char *d = dest; - const unsigned char *s = src; - - for (; n >= 8; n -= 8, d += 8, s += 8) - *(uint64_t *)d = *(uint64_t *)s; - - for (; n >= 4; n -= 4, d += 4, s += 4) - *(uint32_t *)d = *(uint32_t *)s; - - for (; n >= 2; n -= 2, d += 2, s += 2) - *(uint16_t *)d = *(uint16_t *)s; - - for (; n; n--) - *d++ = *s++; - return dest; -} diff --git a/libc/string/memset.c b/libc/string/memset.c deleted file mode 100644 index a446eb4..0000000 --- a/libc/string/memset.c +++ /dev/null @@ -1,9 +0,0 @@ -#include - -void *memset(void *dst, const unsigned char c, uint32_t n) { - uintptr_t d = (uintptr_t)dst; - for (uint32_t i = 0; i < n; i++, d++) - *(unsigned char *)d = c; - - return (void *)d; -} diff --git a/libc/string/strcat.c b/libc/string/strcat.c deleted file mode 100644 index 78a9ec6..0000000 --- a/libc/string/strcat.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -char *strcat(char *s1, const char *s2) { - strcpy(s1 + strlen(s1), s2); - return s1; -} diff --git a/libc/string/strcmp.c b/libc/string/strcmp.c deleted file mode 100644 index d7039e2..0000000 --- a/libc/string/strcmp.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "../include/string.h" - -int strcmp(const char *s1, const char *s2) -{ - for(;*s1 == *s2 && *s1; s1++, s2++) - ; - return *s1 - *s2; -} diff --git a/libc/string/strcpy.c b/libc/string/strcpy.c deleted file mode 100644 index fa1e336..0000000 --- a/libc/string/strcpy.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -char *strcpy(char *d, const char *s) { - char *s1 = d; - for (; (*d++ = *s++);) - ; - return s1; -} diff --git a/libc/string/strlcpy.c b/libc/string/strlcpy.c deleted file mode 100644 index 43d0e58..0000000 --- a/libc/string/strlcpy.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -// Copy string src to buffer dst of size dsize. At most dsize-1 -// chars will be copied. Always NUL terminates (unless dsize == 0). -// Returns strlen(src); if retval >= dsize, truncation occurred. -size_t strlcpy(char *dst, const char *src, size_t dsize) { - size_t n = dsize; - const char *osrc = src; - for (; n; n--) { - if ((*dst++ = *src++) == '\0') - break; - } - if (n == 0) { - if (dsize != 0) - *dst = '\0'; /* NUL-terminate dst */ - while (*src++) - ; - } - return src - osrc - 1; -} diff --git a/libc/string/strlen.c b/libc/string/strlen.c deleted file mode 100644 index 4346383..0000000 --- a/libc/string/strlen.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "../include/string.h" - -unsigned long strlen(const char *s) -{ - const char * tmp = s; - for(;*tmp++;); - return (tmp - s)-1; -} diff --git a/libc/string/strncpy.c b/libc/string/strncpy.c deleted file mode 100644 index a886895..0000000 --- a/libc/string/strncpy.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -// FIXME: Something is weird with this function -char *strncpy(char *dest, const char *src, size_t n) { - char *r = dest; - for (; n && (*dest = *src); n--, src++, dest++) - ; - *dest = '\0'; - return r; -} -- cgit v1.2.3