diff --git a/include/sys/string.h b/include/sys/string.h index c056406..c0463cc 100644 --- a/include/sys/string.h +++ b/include/sys/string.h @@ -16,6 +16,8 @@ #define MAX(x, y) ((x) > (y) ? (x) : (y)) #define MIN(x, y) ((x) < (y) ? (x) : (y)) +int atoi(const char *str); + void *memcpy(void *restrict dst, const void *restrict src, size_t cnt); uint64_t *memcpyq(uint64_t *restrict dst, const uint64_t *restrict src, size_t cnt); void *memmove(void *dst, const void *src, size_t cnt); diff --git a/sys/string.c b/sys/string.c index 1e26af7..778562d 100644 --- a/sys/string.c +++ b/sys/string.c @@ -1,4 +1,14 @@ #include "sys/string.h" +#include "sys/ctype.h" + +int atoi(const char *str) { + int res = 0; + while (isdigit(*str)) { + res *= 10; + res += (*str++) - '0'; + } + return res; +} char *strcat(char *dst, const char *src) { size_t l = strlen(dst);