//===-- Implementation of memmove -----------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "src/string/memmove.h" #include "src/__support/common.h" #include "src/__support/integer_operations.h" #include "src/string/memory_utils/elements.h" #include // size_t, ptrdiff_t namespace __llvm_libc { static inline void inline_memmove(char *dst, const char *src, size_t count) { using namespace __llvm_libc::scalar; if (count == 0) return; if (count == 1) return move<_1>(dst, src); if (count <= 4) return move>(dst, src, count); if (count <= 8) return move>(dst, src, count); if (count <= 16) return move>(dst, src, count); if (count <= 32) return move>(dst, src, count); if (count <= 64) return move>(dst, src, count); if (count <= 128) return move>(dst, src, count); using AlignedMoveLoop = Align<_16, Arg::Src>::Then>; if (dst < src) return move(dst, src, count); else if (dst > src) return move_backward(dst, src, count); } LLVM_LIBC_FUNCTION(void *, memmove, (void *dst, const void *src, size_t count)) { inline_memmove(reinterpret_cast(dst), reinterpret_cast(src), count); return dst; } } // namespace __llvm_libc