Add a memcpy utility to libc
This commit is contained in:
parent
c35cef65fe
commit
f907c189bb
|
@ -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
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "stddef.h"
|
||||||
|
|
||||||
|
void* memcpy(void* dest, const void* src, size_t count);
|
|
@ -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;
|
||||||
|
}
|
Loading…
Reference in New Issue