more robust this way.
Signed-off-by: Kefu Chai <kchai@redhat.com>
include(CheckIncludeFileCXX)
include(CheckFunctionExists)
+check_function_exists(memset_s HAVE_MEMSET_S)
check_function_exists(fallocate CEPH_HAVE_FALLOCATE)
check_function_exists(posix_fadvise HAVE_POSIX_FADVISE)
check_function_exists(posix_fallocate HAVE_POSIX_FALLOCATE)
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
+#include "acconfig.h"
+#ifdef HAVE_MEMSET_S
+# define __STDC_WANT_LIB_EXT1__ 1
+#endif
#include <string.h>
#include <thread>
#ifndef _WIN32
}
int ceph_memzero_s(void *dest, size_t destsz, size_t count) {
-#ifdef __STDC_LIB_EXT1__
+#ifdef HAVE_MEMSET_S
return memset_s(dest, destsz, 0, count);
#elif defined(_WIN32)
SecureZeroMemory(dest, count);
#ifndef CONFIG_H
#define CONFIG_H
+/* Define to 1 if you have the `memset_s()` function. */
+#cmakedefine HAVE_MEMSET_S
+
/* fallocate(2) is supported */
#cmakedefine CEPH_HAVE_FALLOCATE