[ox/std] Add memmove

This commit is contained in:
Gary Talent 2021-05-09 22:42:28 -05:00
parent 2e71d288b4
commit 8dcd350671
2 changed files with 15 additions and 0 deletions

View File

@ -19,6 +19,10 @@ void *ox_inhibit_loop_to_libcall memcpy(void *dest, const void *src, std::size_t
return ox_memcpy(dest, src, size);
}
void *ox_inhibit_loop_to_libcall memmove(void *dest, const void *src, std::size_t size) {
return ox_memcpy(dest, src, size);
}
void *ox_inhibit_loop_to_libcall memset(void *ptr, int val, std::size_t size) {
return ox_memset(ptr, val, size);
}

View File

@ -17,6 +17,8 @@ extern "C" {
void *memcpy(void *dest, const void *src, std::size_t size);
void *memmove(void *dest, const void *src, std::size_t size);
void *memset(void *ptr, int val, std::size_t size);
}
@ -33,6 +35,15 @@ constexpr void *ox_memcpy(void *dest, const void *src, std::size_t size) noexcep
return dest;
}
constexpr void *ox_memmove(void *dest, const void *src, std::size_t size) noexcept {
auto srcBuf = static_cast<const char*>(src);
auto dstBuf = static_cast<char*>(dest);
for (std::size_t i = 0; i < size; i++) {
dstBuf[i] = static_cast<char>(srcBuf[i]);
}
return dest;
}
constexpr void *ox_memset(void *ptr, int val, std::size_t size) noexcept {
auto buf = static_cast<uint8_t*>(ptr);
for (std::size_t i = 0; i < size; i++) {