diff options
| author | Guillaume Chatelet <gchatelet@google.com> | 2025-07-17 10:15:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-17 10:15:43 +0200 |
| commit | e0cce5cdcb8a7829389d910a9204447646e69407 (patch) | |
| tree | bb42153f2d05c3f65a770b558bc001e49202c6b6 /libc/src/string/memory_utils/inline_memset.h | |
| parent | 8b553c495155a024d22871f22f05187fb785c4fc (diff) | |
[libc] Improve Cortex `memset` and `memcpy` functions (#149044)
The code for `memcpy` is the same as in #148204 but it fixes the build
bot error by using `static_assert(cpp::always_false<decltype(access)>)`
instead of `static_assert(false)` (older compilers fails on
`static_assert(false)` in `constexpr` `else` bodies).
The code for `memset` is new and vastly improves performance over the
current byte per byte implementation.
Both `memset` and `memcpy` implementations use prefetching for sizes >=
64. This lowers a bit the performance for sizes between 64 and 256 but
improves throughput for greater sizes.
Diffstat (limited to 'libc/src/string/memory_utils/inline_memset.h')
| -rw-r--r-- | libc/src/string/memory_utils/inline_memset.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libc/src/string/memory_utils/inline_memset.h b/libc/src/string/memory_utils/inline_memset.h index fd9c29ea4410..e41bdb626d60 100644 --- a/libc/src/string/memory_utils/inline_memset.h +++ b/libc/src/string/memory_utils/inline_memset.h @@ -18,6 +18,9 @@ #if defined(LIBC_TARGET_ARCH_IS_X86) #include "src/string/memory_utils/x86_64/inline_memset.h" #define LIBC_SRC_STRING_MEMORY_UTILS_MEMSET inline_memset_x86 +#elif defined(LIBC_TARGET_ARCH_IS_ARM) +#include "src/string/memory_utils/arm/inline_memset.h" +#define LIBC_SRC_STRING_MEMORY_UTILS_MEMSET inline_memset_arm_dispatch #elif defined(LIBC_TARGET_ARCH_IS_AARCH64) #include "src/string/memory_utils/aarch64/inline_memset.h" #define LIBC_SRC_STRING_MEMORY_UTILS_MEMSET inline_memset_aarch64_dispatch @@ -34,7 +37,8 @@ namespace LIBC_NAMESPACE_DECL { -LIBC_INLINE static void inline_memset(void *dst, uint8_t value, size_t count) { +[[gnu::flatten]] LIBC_INLINE void inline_memset(void *dst, uint8_t value, + size_t count) { LIBC_SRC_STRING_MEMORY_UTILS_MEMSET(reinterpret_cast<Ptr>(dst), value, count); } |
