mtl/include/mtl/utility.hpp
Madeline Busig 1159162e50 Change armv4t integer to string conversion to use an unrolled loop
This implementation also writes the digits from left to right instead of
right to left. Using this method we can write the string to the
beginning of the buffer and still avoid reversing the string. It also
has the benefit of being slightly slower than the previous
implementation. The function's signature changed as well because there
is no longer a reason to pass the buffer size or a pointer to output the
start of the string.
2024-03-25 17:13:29 -06:00

37 lines
1.1 KiB
C++

#pragma once
#include <cstring>
#include <cstddef>
extern "C" {
#ifdef __ARM_ARCH_4T__
void mtl_memcpy32(void* dst, const void* src, size_t num8);
void mtl_dumbcpy16(void* dst, const void* src, size_t num8);
void mtl_dumbcpy(void* dst, const void* src, size_t num8);
void mtl_hybridcpy(void* dst, const void* src, size_t num8);
void mtl_rmemcpy32(void* dst, const void* src, size_t num8);
void mtl_rdumbcpy16(void* dst, const void* src, size_t num8);
void mtl_rdumbcpy(void* dst, const void* src, size_t num8);
void mtl_rhybridcpy(void* dst, const void* src, size_t num8);
void mtl_hybridmove(void* dst, const void* src, size_t num8);
uint32_t mtl_udiv10(uint32_t x);
uint32_t mtl_umod10(uint32_t x);
uint32_t mtl_utostr(uint32_t x, char* buf);
uint32_t mtl_utostrx(uint32_t x, char* buf);
uint32_t mtl_itostr(int32_t x, char* buf);
uint32_t mtl_itostrx(int32_t x, char* buf);
#endif
}
namespace mtl {
#ifdef __ARM_ARCH_4T__
constexpr auto memcpy = mtl_hybridcpy;
constexpr auto memmove = mtl_hybridmove;
#else
constexpr auto memcpy = std::memcpy;
constexpr auto memmove = std::memmove;
#endif
}