brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 2b9ecc0 Raw
43 lines · c
1//===-- Trivial builtin implementations  ----------------------------------===//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_GENERIC_BUILTIN_H10#define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_GENERIC_BUILTIN_H11 12#include "src/__support/macros/attributes.h" // LIBC_INLINE13#include "src/__support/macros/config.h"     // LIBC_NAMESPACE_DECL14#include "src/string/memory_utils/utils.h" // Ptr, CPtr15 16#include <stddef.h> // size_t17 18namespace LIBC_NAMESPACE_DECL {19 20#if !__has_builtin(__builtin_memcpy) || !__has_builtin(__builtin_memset) ||    \21    !__has_builtin(__builtin_memmove)22#error "Builtin not defined");23#endif24 25[[maybe_unused]] LIBC_INLINE void26inline_memcpy_builtin(Ptr dst, CPtr src, size_t count, size_t offset = 0) {27  __builtin_memcpy(dst + offset, src + offset, count);28}29 30[[maybe_unused]] LIBC_INLINE void inline_memmove_builtin(Ptr dst, CPtr src,31                                                         size_t count) {32  __builtin_memmove(dst, src, count);33}34 35[[maybe_unused]] LIBC_INLINE static void36inline_memset_builtin(Ptr dst, uint8_t value, size_t count, size_t offset = 0) {37  __builtin_memset(dst + offset, value, count);38}39 40} // namespace LIBC_NAMESPACE_DECL41 42#endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_GENERIC_BUILTIN_H43