[libc-commits] [libc] aec908f - [libc][NFC] Move bzero_inline to separate file

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Mon Sep 26 05:58:11 PDT 2022


Author: Guillaume Chatelet
Date: 2022-09-26T12:57:51Z
New Revision: aec908f9b248b27cb44217081c54e2c00604dff7

URL: https://github.com/llvm/llvm-project/commit/aec908f9b248b27cb44217081c54e2c00604dff7
DIFF: https://github.com/llvm/llvm-project/commit/aec908f9b248b27cb44217081c54e2c00604dff7.diff

LOG: [libc][NFC] Move bzero_inline to separate file
This allows for easier discovery.

Added: 
    libc/src/string/memory_utils/bzero_implementations.h

Modified: 
    libc/src/string/CMakeLists.txt
    libc/src/string/bzero.cpp
    libc/src/string/memory_utils/CMakeLists.txt
    libc/src/string/memory_utils/memset_implementations.h
    libc/src/string/stpncpy.cpp
    libc/src/string/string_utils.h
    utils/bazel/llvm-project-overlay/libc/BUILD.bazel

Removed: 
    


################################################################################
diff  --git a/libc/src/string/CMakeLists.txt b/libc/src/string/CMakeLists.txt
index 4740c761d1114..1b11d888bdc4f 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 f852089507ded..b04cca834f986 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 6cd45ddc42ace..d735fcfe54174 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 0000000000000..168fdd7e531d2
--- /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 <stddef.h> // 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 f63cb787267be..f1611a32807cb 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 127012c4c9efe..cc4d89d8e2bbc 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 e94c28b383077..b1b434dbf1723 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 <stddef.h> // 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 d57eb3df274d5..90aea2c75cc2e 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",


        


More information about the libc-commits mailing list