Skip to content

Commit b316e64

Browse files
committed
HDFS-15977. Call explicit_bzero only if it is available.
1 parent 7d6f0ca commit b316e64

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ find_package(GSasl)
5151
find_package(Threads)
5252

5353
include(CheckCXXSourceCompiles)
54+
include(CheckSymbolExists)
5455

5556
# Download and build gtest
5657
configure_file(CMakeLists-gtest.txt.in googletest-download/CMakeLists.txt)
@@ -168,6 +169,11 @@ else (NOT NO_SASL)
168169
message(STATUS "Compiling with NO SASL SUPPORT")
169170
endif (NOT NO_SASL)
170171

172+
check_symbol_exists(explicit_bzero "string.h" HAVE_EXPLICIT_BZERO)
173+
if(HAVE_EXPLICIT_BZERO)
174+
add_definitions(-DHAVE_EXPLICIT_BZERO)
175+
endif()
176+
171177
add_definitions(-DASIO_STANDALONE -DASIO_CPP11_DATE_TIME)
172178

173179
# Disable optimizations if compiling debug

hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/x-platform/syscall_linux.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ bool XPlatform::Syscall::WriteToStdoutImpl(const char* message) {
4747
void XPlatform::Syscall::ClearBufferSafely(void* buffer,
4848
const size_t sz_bytes) {
4949
if (buffer != nullptr) {
50+
#ifdef HAVE_EXPLICIT_BZERO
5051
explicit_bzero(buffer, sz_bytes);
52+
#else
53+
// fallback to bzero
54+
bzero(buffer, sz_bytes);
55+
#endif
5156
}
5257
}
5358

0 commit comments

Comments
 (0)