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

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-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_GENERIC_BUILTIN_H
10#define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_GENERIC_BUILTIN_H
11
12#include "src/__support/macros/attributes.h" // LIBC_INLINE
13#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL
14#include "src/string/memory_utils/utils.h" // Ptr, CPtr
15
16#include <stddef.h> // size_t
17
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#endif
24
25[[maybe_unused]] LIBC_INLINE void
26inline_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 void
36inline_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_DECL
41
42#endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_GENERIC_BUILTIN_H
43

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

source code of libc/src/string/memory_utils/generic/builtin.h