diff --git a/lib/libc/CMakeLists.txt b/lib/libc/CMakeLists.txt index 1f85c1f..e9e5148 100644 --- a/lib/libc/CMakeLists.txt +++ b/lib/libc/CMakeLists.txt @@ -2,6 +2,7 @@ add_library(c STATIC src/malloc.cpp src/stdio.cpp + src/string.cpp ) target_include_directories(c diff --git a/lib/libc/include/string.h b/lib/libc/include/string.h new file mode 100644 index 0000000..bb4f5bc --- /dev/null +++ b/lib/libc/include/string.h @@ -0,0 +1,5 @@ +#pragma once + +#include "stddef.h" + +void* memcpy(void* dest, const void* src, size_t count); diff --git a/lib/libc/src/string.cpp b/lib/libc/src/string.cpp new file mode 100644 index 0000000..da0261a --- /dev/null +++ b/lib/libc/src/string.cpp @@ -0,0 +1,10 @@ +#include "string.h" + +void* memcpy(void* dest, const void* src, size_t count) { + uint8_t* d = (uint8_t*)dest; + const uint8_t* s = (uint8_t*)src; + for (size_t i = 0; i < count; i++) { + d[i] = s[i]; + } + return dest; +}