Path: blob/main/system/lib/llvm-libc/src/string/memmove.cpp
6175 views
//===-- Implementation of memmove -----------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "src/string/memmove.h"9#include "src/__support/macros/config.h"10#include "src/__support/macros/null_check.h"11#include "src/string/memory_utils/inline_memcpy.h"12#include "src/string/memory_utils/inline_memmove.h"13#include <stddef.h> // size_t1415namespace LIBC_NAMESPACE_DECL {1617LLVM_LIBC_FUNCTION(void *, memmove,18(void *dst, const void *src, size_t count)) {19if (count) {20LIBC_CRASH_ON_NULLPTR(dst);21LIBC_CRASH_ON_NULLPTR(src);22}23// Memmove may handle some small sizes as efficiently as inline_memcpy.24// For these sizes we may not do is_disjoint check.25// This both avoids additional code for the most frequent smaller sizes26// and removes code bloat (we don't need the memcpy logic for small sizes).27if (inline_memmove_small_size(dst, src, count))28return dst;29if (is_disjoint(dst, src, count))30inline_memcpy(dst, src, count);31else32inline_memmove_follow_up(dst, src, count);33return dst;34}3536} // namespace LIBC_NAMESPACE_DECL373839