[libc] refactor logic around embedded memcpy
authorGuillaume Chatelet <gchatelet@google.com>
Tue, 14 Feb 2023 15:11:47 +0000 (15:11 +0000)
committerGuillaume Chatelet <gchatelet@google.com>
Tue, 14 Feb 2023 15:58:08 +0000 (15:58 +0000)
libc/src/string/memory_utils/memcpy_implementations.h

index 9ff71ab1a54c537acbc866fab71bc262b0718cf2..850e0256c7b1d9713d8328c3fc0a6a7a144e9a77 100644 (file)
@@ -125,14 +125,13 @@ inline_memcpy_aarch64(Ptr __restrict dst, CPtr __restrict src, size_t count) {
 LIBC_INLINE void inline_memcpy(Ptr __restrict dst, CPtr __restrict src,
                                size_t count) {
   using namespace __llvm_libc::builtin;
-#if defined(LIBC_TARGET_ARCH_IS_X86)
+#if defined(LIBC_COPT_MEMCPY_USE_EMBEDDED_TINY) ||                             \
+    defined(LIBC_TARGET_ARCH_IS_ARM) || defined(LIBC_TARGET_ARCH_IS_GPU)
+  return inline_memcpy_embedded_tiny(dst, src, count);
+#elif defined(LIBC_TARGET_ARCH_IS_X86)
   return inline_memcpy_x86_maybe_interpose_repmovsb(dst, src, count);
 #elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
   return inline_memcpy_aarch64(dst, src, count);
-#elif defined(LIBC_TARGET_ARCH_IS_ARM)
-  return inline_memcpy_embedded_tiny(dst, src, count);
-#elif defined(LIBC_TARGET_ARCH_IS_GPU)
-  return inline_memcpy_embedded_tiny(dst, src, count);
 #else
 #error "Unsupported platform"
 #endif