[ox/std] Add ox_inhibit_loop_to_libcall for memset and memcpy

This commit is contained in:
Gary Talent 2019-11-09 00:06:05 -06:00
parent ddb158e433
commit e470a1da09
2 changed files with 8 additions and 4 deletions

View File

@ -11,18 +11,22 @@
#ifndef OX_USE_STDLIB
#define ox_inhibit_loop_to_libcall __attribute__((__optimize__ ("-fno-tree-loop-distribute-patterns")))
extern "C" {
void *memcpy(void *dest, const void *src, std::size_t size) {
void *ox_inhibit_loop_to_libcall memcpy(void *dest, const void *src, std::size_t size) {
return ox_memcpy(dest, src, size);
}
void *memset(void *ptr, int val, std::size_t size) {
void *ox_inhibit_loop_to_libcall memset(void *ptr, int val, std::size_t size) {
return ox_memset(ptr, val, size);
}
}
#undef ox_inhibit_loop_to_libcall
#endif
int ox_memcmp(const void *ptr1, const void *ptr2, std::size_t size) noexcept {

View File

@ -28,9 +28,9 @@ constexpr void *ox_memcpy(void *dest, const void *src, std::size_t size) noexcep
}
constexpr void *ox_memset(void *ptr, int val, std::size_t size) noexcept {
auto buf = static_cast<char*>(ptr);
auto buf = reinterpret_cast<uint8_t*>(ptr);
for (std::size_t i = 0; i < size; i++) {
buf[i] = val;
buf[i] = static_cast<uint8_t>(val);
}
return ptr;
}