Warning: This file is not a C or C++ file. It does not have highlighting.

1//===-- Memcpy implementation -----------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMCPY_H
10#define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMCPY_H
11
12#include "src/__support/macros/attributes.h" // LIBC_INLINE
13#include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_IS_
14#include "src/string/memory_utils/utils.h" // Ptr, CPtr
15
16#include <stddef.h> // size_t
17
18#if defined(LIBC_COPT_MEMCPY_USE_EMBEDDED_TINY)
19#include "src/string/memory_utils/generic/byte_per_byte.h"
20#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_byte_per_byte
21#elif defined(LIBC_TARGET_ARCH_IS_X86)
22#include "src/string/memory_utils/x86_64/inline_memcpy.h"
23#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY \
24 inline_memcpy_x86_maybe_interpose_repmovsb
25#elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
26#include "src/string/memory_utils/aarch64/inline_memcpy.h"
27#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_aarch64
28#elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
29#include "src/string/memory_utils/riscv/inline_memcpy.h"
30#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_riscv
31#elif defined(LIBC_TARGET_ARCH_IS_GPU)
32#include "src/string/memory_utils/generic/builtin.h"
33#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_builtin
34#else
35#include "src/string/memory_utils/generic/byte_per_byte.h"
36#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_byte_per_byte
37#endif
38
39namespace LIBC_NAMESPACE_DECL {
40
41[[gnu::flatten]] LIBC_INLINE void
42inline_memcpy(void *__restrict dst, const void *__restrict src, size_t count) {
43 LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY(reinterpret_cast<Ptr>(dst),
44 reinterpret_cast<CPtr>(src), count);
45}
46
47} // namespace LIBC_NAMESPACE_DECL
48
49#endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMCPY_H
50

Warning: This file is not a C or C++ file. It does not have highlighting.

Provided by KDAB

Privacy Policy
Update your C++ knowledge – Modern C++11/14/17 Training
Find out more

source code of libc/src/string/memory_utils/inline_memcpy.h