brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 85a614b Raw
45 lines · c
1//===-- Implementation of memcmp ------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMCMP_H10#define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMCMP_H11 12#include "src/__support/macros/attributes.h"               // LIBC_INLINE13#include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_IS_14#include "src/string/memory_utils/utils.h"                 // Ptr, CPtr15 16#include <stddef.h> // size_t17 18#if defined(LIBC_TARGET_ARCH_IS_X86)19#include "src/string/memory_utils/x86_64/inline_memcmp.h"20#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCMP inline_memcmp_x8621#elif defined(LIBC_TARGET_ARCH_IS_AARCH64)22#include "src/string/memory_utils/aarch64/inline_memcmp.h"23#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCMP inline_memcmp_aarch64_dispatch24#elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)25#include "src/string/memory_utils/riscv/inline_memcmp.h"26#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCMP inline_memcmp_riscv27#else28#include "src/string/memory_utils/generic/byte_per_byte.h"29#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCMP inline_memcmp_byte_per_byte30#endif31 32namespace LIBC_NAMESPACE_DECL {33 34[[gnu::flatten]] LIBC_INLINE int inline_memcmp(const void *p1, const void *p2,35                                               size_t count) {36  return static_cast<int>(LIBC_SRC_STRING_MEMORY_UTILS_MEMCMP(37      reinterpret_cast<CPtr>(p1), reinterpret_cast<CPtr>(p2), count));38}39 40} // namespace LIBC_NAMESPACE_DECL41 42#undef LIBC_SRC_STRING_MEMORY_UTILS_MEMCMP43 44#endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMCMP_H45