diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/init/stdlib.c | 17 | ||||
-rw-r--r-- | src/init/stdlib.h | 2 | ||||
-rw-r--r-- | src/shared/mem.c | 17 | ||||
-rw-r--r-- | src/shared/mem.h | 3 |
4 files changed, 20 insertions, 19 deletions
diff --git a/src/init/stdlib.c b/src/init/stdlib.c index c83440f..18da3da 100644 --- a/src/init/stdlib.c +++ b/src/init/stdlib.c @@ -5,23 +5,6 @@ int __tty_fd; -int strcmp(const char *s1, const char *s2) { - while (*s1) { - if (*s1 != *s2) { - if (*s1 < *s2) return -1; - else return 1; - } - s1++; s2++; - } - return 0; -} - -size_t strlen(const char *s) { - size_t c = 0; - while (*s++) c++; - return c; -} - int printf(const char *fmt, ...) { const char *seg = fmt; // beginning of the current segment int total = 0; diff --git a/src/init/stdlib.h b/src/init/stdlib.h index af0788b..17ec0b9 100644 --- a/src/init/stdlib.h +++ b/src/init/stdlib.h @@ -4,6 +4,4 @@ extern int __tty_fd; -int strcmp(const char *s1, const char *s2); -size_t strlen(const char *s); int printf(const char *fmt, ...); diff --git a/src/shared/mem.c b/src/shared/mem.c index 1b483fe..9185c9e 100644 --- a/src/shared/mem.c +++ b/src/shared/mem.c @@ -26,3 +26,20 @@ void *memset(void *s, int c, size_t n) { s2[i] = c; return s; } + +int strcmp(const char *s1, const char *s2) { + while (*s1) { + if (*s1 != *s2) { + if (*s1 < *s2) return -1; + else return 1; + } + s1++; s2++; + } + return 0; +} + +size_t strlen(const char *s) { + size_t c = 0; + while (*s++) c++; + return c; +} diff --git a/src/shared/mem.h b/src/shared/mem.h index 682c184..7036381 100644 --- a/src/shared/mem.h +++ b/src/shared/mem.h @@ -5,3 +5,6 @@ int memcmp(const void *s1, const void *s2, size_t n); void *memcpy(void *dest, const void *src, size_t n); void *memset(void *s, int c, size_t n); + +int strcmp(const char *s1, const char *s2); +size_t strlen(const char *s); |