12423ec58SCheng Wang //===-- Implementation of memmove -----------------------------------------===// 22423ec58SCheng Wang // 32423ec58SCheng Wang // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42423ec58SCheng Wang // See https://llvm.org/LICENSE.txt for license information. 52423ec58SCheng Wang // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 62423ec58SCheng Wang // 72423ec58SCheng Wang //===----------------------------------------------------------------------===// 82423ec58SCheng Wang 92423ec58SCheng Wang #include "src/string/memmove.h" 10*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 111f578347SGuillaume Chatelet #include "src/string/memory_utils/inline_memcpy.h" 121f578347SGuillaume Chatelet #include "src/string/memory_utils/inline_memmove.h" 13a5f4f12bSGuillaume Chatelet #include <stddef.h> // size_t 1467437dd0SGuillaume Chatelet 15*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 162423ec58SCheng Wang 172423ec58SCheng Wang LLVM_LIBC_FUNCTION(void *, memmove, 1835828287SCheng Wang (void *dst, const void *src, size_t count)) { 190e110fb4SDmitry Vyukov // Memmove may handle some small sizes as efficiently as inline_memcpy. 200e110fb4SDmitry Vyukov // For these sizes we may not do is_disjoint check. 210e110fb4SDmitry Vyukov // This both avoids additional code for the most frequent smaller sizes 220e110fb4SDmitry Vyukov // and removes code bloat (we don't need the memcpy logic for small sizes). 230e110fb4SDmitry Vyukov if (inline_memmove_small_size(dst, src, count)) 240e110fb4SDmitry Vyukov return dst; 252cfae7cdSGuillaume Chatelet if (is_disjoint(dst, src, count)) 262cfae7cdSGuillaume Chatelet inline_memcpy(dst, src, count); 272cfae7cdSGuillaume Chatelet else 280e110fb4SDmitry Vyukov inline_memmove_follow_up(dst, src, count); 2935828287SCheng Wang return dst; 302423ec58SCheng Wang } 312423ec58SCheng Wang 32*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 33