Warning: This file is not a C or C++ file. It does not have highlighting.
1 | //===-- Memmove 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_MEMMOVE_H |
10 | #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMMOVE_H |
11 | |
12 | #include "src/__support/macros/attributes.h" // LIBC_INLINE |
13 | #include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL |
14 | #include <stddef.h> // size_t, ptrdiff_t |
15 | |
16 | #if defined(LIBC_TARGET_ARCH_IS_X86) |
17 | #include "src/string/memory_utils/x86_64/inline_memmove.h" |
18 | #define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_SMALL_SIZE \ |
19 | inline_memmove_small_size_x86 |
20 | #define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_FOLLOW_UP \ |
21 | inline_memmove_follow_up_x86 |
22 | #elif defined(LIBC_TARGET_ARCH_IS_AARCH64) |
23 | #include "src/string/memory_utils/aarch64/inline_memmove.h" |
24 | #define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_SMALL_SIZE \ |
25 | inline_memmove_no_small_size |
26 | #define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_FOLLOW_UP inline_memmove_aarch64 |
27 | #elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) |
28 | #include "src/string/memory_utils/riscv/inline_memmove.h" |
29 | #define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_SMALL_SIZE \ |
30 | inline_memmove_no_small_size |
31 | #define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_FOLLOW_UP inline_memmove_riscv |
32 | #elif defined(LIBC_TARGET_ARCH_IS_GPU) |
33 | #include "src/string/memory_utils/generic/builtin.h" |
34 | #define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_SMALL_SIZE \ |
35 | inline_memmove_no_small_size |
36 | #define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_FOLLOW_UP inline_memmove_builtin |
37 | #else |
38 | #include "src/string/memory_utils/generic/byte_per_byte.h" |
39 | #define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_SMALL_SIZE \ |
40 | inline_memmove_no_small_size |
41 | #define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_FOLLOW_UP \ |
42 | inline_memmove_byte_per_byte |
43 | #endif |
44 | |
45 | namespace LIBC_NAMESPACE_DECL { |
46 | |
47 | LIBC_INLINE constexpr bool inline_memmove_no_small_size(void *, const void *, |
48 | size_t) { |
49 | return false; |
50 | } |
51 | |
52 | [[gnu::flatten]] LIBC_INLINE bool |
53 | inline_memmove_small_size(void *dst, const void *src, size_t count) { |
54 | return LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_SMALL_SIZE( |
55 | reinterpret_cast<Ptr>(dst), reinterpret_cast<CPtr>(src), count); |
56 | } |
57 | |
58 | [[gnu::flatten]] LIBC_INLINE void |
59 | inline_memmove_follow_up(void *dst, const void *src, size_t count) { |
60 | LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_FOLLOW_UP( |
61 | reinterpret_cast<Ptr>(dst), reinterpret_cast<CPtr>(src), count); |
62 | } |
63 | |
64 | LIBC_INLINE void inline_memmove(void *dst, const void *src, size_t count) { |
65 | if (inline_memmove_small_size(dst, src, count)) |
66 | return; |
67 | inline_memmove_follow_up(dst, src, count); |
68 | } |
69 | |
70 | } // namespace LIBC_NAMESPACE_DECL |
71 | |
72 | #endif /* LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMMOVE_H */ |
73 |
Warning: This file is not a C or C++ file. It does not have highlighting.