1 //===-- Implementation of memmove -----------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "src/string/memmove.h" 10 #include "src/__support/macros/config.h" 11 #include "src/string/memory_utils/inline_memcpy.h" 12 #include "src/string/memory_utils/inline_memmove.h" 13 #include <stddef.h> // size_t 14 15 namespace LIBC_NAMESPACE_DECL { 16 17 LLVM_LIBC_FUNCTION(void *, memmove, 18 (void *dst, const void *src, size_t count)) { 19 // Memmove may handle some small sizes as efficiently as inline_memcpy. 20 // For these sizes we may not do is_disjoint check. 21 // This both avoids additional code for the most frequent smaller sizes 22 // and removes code bloat (we don't need the memcpy logic for small sizes). 23 if (inline_memmove_small_size(dst, src, count)) 24 return dst; 25 if (is_disjoint(dst, src, count)) 26 inline_memcpy(dst, src, count); 27 else 28 inline_memmove_follow_up(dst, src, count); 29 return dst; 30 } 31 32 } // namespace LIBC_NAMESPACE_DECL 33