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