Add a memcpy utility to libc

This commit is contained in:
Drew Galbraith 2023-06-12 19:13:16 -07:00
parent c35cef65fe
commit f907c189bb
3 changed files with 16 additions and 0 deletions

View File

@ -2,6 +2,7 @@
add_library(c STATIC add_library(c STATIC
src/malloc.cpp src/malloc.cpp
src/stdio.cpp src/stdio.cpp
src/string.cpp
) )
target_include_directories(c target_include_directories(c

View File

@ -0,0 +1,5 @@
#pragma once
#include "stddef.h"
void* memcpy(void* dest, const void* src, size_t count);

10
lib/libc/src/string.cpp Normal file
View File

@ -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;
}