HDFS-15977. Call explicit_bzero only if it is available. (#2914)

Reviewed-by: Masatake Iwasaki <iwasakims@apache.org>
Reviewed-by: Inigo Goiri <inigoiri@apache.org>
This commit is contained in:
Akira Ajisaka 2021-04-16 13:26:45 +09:00 committed by GitHub
parent 17be99f9f9
commit f0241ec216
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -51,6 +51,7 @@ find_package(GSasl)
find_package(Threads)
include(CheckCXXSourceCompiles)
include(CheckSymbolExists)
# Download and build gtest
configure_file(CMakeLists-gtest.txt.in googletest-download/CMakeLists.txt)
@ -168,6 +169,11 @@ else (NOT NO_SASL)
message(STATUS "Compiling with NO SASL SUPPORT")
endif (NOT NO_SASL)
check_symbol_exists(explicit_bzero "string.h" HAVE_EXPLICIT_BZERO)
if(HAVE_EXPLICIT_BZERO)
add_definitions(-DHAVE_EXPLICIT_BZERO)
endif()
add_definitions(-DASIO_STANDALONE -DASIO_CPP11_DATE_TIME)
# Disable optimizations if compiling debug

View File

@ -47,7 +47,12 @@ bool XPlatform::Syscall::WriteToStdoutImpl(const char* message) {
void XPlatform::Syscall::ClearBufferSafely(void* buffer,
const size_t sz_bytes) {
if (buffer != nullptr) {
#ifdef HAVE_EXPLICIT_BZERO
explicit_bzero(buffer, sz_bytes);
#else
// fallback to bzero
bzero(buffer, sz_bytes);
#endif
}
}