Skip to content

Commit

Permalink
[libc][NFC] Move bzero_inline to separate file
Browse files Browse the repository at this point in the history
This allows for easier discovery.
  • Loading branch information
gchatelet committed Sep 26, 2022
1 parent 2188cf9 commit aec908f
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 9 deletions.
4 changes: 2 additions & 2 deletions libc/src/string/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -65,7 +65,7 @@ add_entrypoint_object(
HDRS
stpncpy.h
DEPENDS
.memory_utils.memset_implementation
.memory_utils.bzero_implementation
)

add_entrypoint_object(
Expand Down
2 changes: 1 addition & 1 deletion libc/src/string/bzero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
9 changes: 9 additions & 0 deletions libc/src/string/memory_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -35,3 +36,11 @@ add_header_library(
DEPS
.memory_utils
)

add_header_library(
bzero_implementation
HDRS
bzero_implementations.h
DEPS
.memset_implementation
)
24 changes: 24 additions & 0 deletions libc/src/string/memory_utils/bzero_implementations.h
Original file line number Diff line number Diff line change
@@ -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
4 changes: 0 additions & 4 deletions libc/src/string/memory_utils/memset_implementations.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion libc/src/string/stpncpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion libc/src/string/string_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions utils/bazel/llvm-project-overlay/libc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit aec908f

Please sign in to comment.