1 //===-- Dispatch logic for bcmp -------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_BCMP_H
10 #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_BCMP_H
12 #include "src/__support/common.h"
13 #include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_IS_
15 #include <stddef.h> // size_t
17 #if defined(LIBC_TARGET_ARCH_IS_X86)
18 #include "src/string/memory_utils/x86_64/inline_bcmp.h"
19 #define LIBC_SRC_STRING_MEMORY_UTILS_BCMP inline_bcmp_x86
20 #elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
21 #include "src/string/memory_utils/aarch64/inline_bcmp.h"
22 #define LIBC_SRC_STRING_MEMORY_UTILS_BCMP inline_bcmp_aarch64
23 #elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
24 #include "src/string/memory_utils/riscv/inline_bcmp.h"
25 #define LIBC_SRC_STRING_MEMORY_UTILS_BCMP inline_bcmp_riscv
26 #elif defined(LIBC_TARGET_ARCH_IS_ARM) || defined(LIBC_TARGET_ARCH_IS_GPU)
27 #include "src/string/memory_utils/generic/byte_per_byte.h"
28 #define LIBC_SRC_STRING_MEMORY_UTILS_BCMP inline_bcmp_byte_per_byte
30 #error "Unsupported architecture"
33 namespace LIBC_NAMESPACE
{
35 LIBC_INLINE
int inline_bcmp(const void *p1
, const void *p2
, size_t count
) {
36 return static_cast<int>(LIBC_SRC_STRING_MEMORY_UTILS_BCMP(
37 reinterpret_cast<CPtr
>(p1
), reinterpret_cast<CPtr
>(p2
), count
));
40 } // namespace LIBC_NAMESPACE
42 #undef LIBC_SRC_STRING_MEMORY_UTILS_BCMP
44 #endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_BCMP_H