From aec908f9b248b27cb44217081c54e2c00604dff7 Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Mon, 26 Sep 2022 12:57:21 +0000 Subject: [PATCH] [libc][NFC] Move bzero_inline to separate file This allows for easier discovery. --- libc/src/string/CMakeLists.txt | 4 ++-- libc/src/string/bzero.cpp | 2 +- libc/src/string/memory_utils/CMakeLists.txt | 9 ++++++++ .../string/memory_utils/bzero_implementations.h | 24 ++++++++++++++++++++++ .../string/memory_utils/memset_implementations.h | 4 ---- libc/src/string/stpncpy.cpp | 2 +- libc/src/string/string_utils.h | 2 +- utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 1 + 8 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 libc/src/string/memory_utils/bzero_implementations.h diff --git a/libc/src/string/CMakeLists.txt b/libc/src/string/CMakeLists.txt index 4740c76..1b11d88 100644 --- a/libc/src/string/CMakeLists.txt +++ b/libc/src/string/CMakeLists.txt @@ -7,7 +7,7 @@ add_header_library( DEPENDS libc.src.__support.CPP.bitset .memory_utils.memcpy_implementation - .memory_utils.memset_implementation + .memory_utils.bzero_implementation ) add_entrypoint_object( @@ -65,7 +65,7 @@ add_entrypoint_object( HDRS stpncpy.h DEPENDS - .memory_utils.memset_implementation + .memory_utils.bzero_implementation ) add_entrypoint_object( diff --git a/libc/src/string/bzero.cpp b/libc/src/string/bzero.cpp index f852089..b04cca8 100644 --- a/libc/src/string/bzero.cpp +++ b/libc/src/string/bzero.cpp @@ -8,7 +8,7 @@ #include "src/string/bzero.h" #include "src/__support/common.h" -#include "src/string/memory_utils/memset_implementations.h" +#include "src/string/memory_utils/bzero_implementations.h" namespace __llvm_libc { diff --git a/libc/src/string/memory_utils/CMakeLists.txt b/libc/src/string/memory_utils/CMakeLists.txt index 6cd45dd..d735fcf 100644 --- a/libc/src/string/memory_utils/CMakeLists.txt +++ b/libc/src/string/memory_utils/CMakeLists.txt @@ -5,6 +5,7 @@ add_header_library( utils.h elements.h bcmp_implementations.h + bzero_implementations.h memcmp_implementations.h memcpy_implementations.h memset_implementations.h @@ -35,3 +36,11 @@ add_header_library( DEPS .memory_utils ) + +add_header_library( + bzero_implementation + HDRS + bzero_implementations.h + DEPS + .memset_implementation +) diff --git a/libc/src/string/memory_utils/bzero_implementations.h b/libc/src/string/memory_utils/bzero_implementations.h new file mode 100644 index 0000000..168fdd7 --- /dev/null +++ b/libc/src/string/memory_utils/bzero_implementations.h @@ -0,0 +1,24 @@ +//===-- Implementation of bzero -------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_BZERO_IMPLEMENTATIONS_H +#define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_BZERO_IMPLEMENTATIONS_H + +#include "src/string/memory_utils/memset_implementations.h" + +#include // size_t + +namespace __llvm_libc { + +inline static void inline_bzero(char *dst, size_t count) { + inline_memset(dst, 0, count); +} + +} // namespace __llvm_libc + +#endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_BZERO_IMPLEMENTATIONS_H diff --git a/libc/src/string/memory_utils/memset_implementations.h b/libc/src/string/memory_utils/memset_implementations.h index f63cb78..f1611a3 100644 --- a/libc/src/string/memory_utils/memset_implementations.h +++ b/libc/src/string/memory_utils/memset_implementations.h @@ -133,10 +133,6 @@ inline static void inline_memset(char *dst, unsigned char value, size_t count) { #endif } -inline static void inline_bzero(char *dst, size_t count) { - inline_memset(dst, 0, count); -} - } // namespace __llvm_libc #endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_MEMSET_IMPLEMENTATIONS_H diff --git a/libc/src/string/stpncpy.cpp b/libc/src/string/stpncpy.cpp index 127012c..cc4d89d 100644 --- a/libc/src/string/stpncpy.cpp +++ b/libc/src/string/stpncpy.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "src/string/stpncpy.h" -#include "src/string/memory_utils/memset_implementations.h" +#include "src/string/memory_utils/bzero_implementations.h" #include "src/__support/common.h" diff --git a/libc/src/string/string_utils.h b/libc/src/string/string_utils.h index e94c28b..b1b434d 100644 --- a/libc/src/string/string_utils.h +++ b/libc/src/string/string_utils.h @@ -12,7 +12,7 @@ #include "src/__support/CPP/bitset.h" #include "src/__support/common.h" #include "src/string/memory_utils/memcpy_implementations.h" -#include "src/string/memory_utils/memset_implementations.h" +#include "src/string/memory_utils/bzero_implementations.h" #include // size_t namespace __llvm_libc { diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel index d57eb3d..90aea2c 100644 --- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel @@ -980,6 +980,7 @@ cc_library( ], textual_hdrs = [ "src/string/memory_utils/bcmp_implementations.h", + "src/string/memory_utils/bzero_implementations.h", "src/string/memory_utils/memcmp_implementations.h", "src/string/memory_utils/memcpy_implementations.h", "src/string/memory_utils/memset_implementations.h", -- 2.7.4