1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-20 02:25:14 -07:00

Support memset_explicit() if available

NetBSD has explicit_memset(), but C23 decided to implement the
same thing but call it memset_explicit() instead. Go figure.
This commit is contained in:
Frank Denis 2022-11-21 15:26:18 +01:00
parent d0c73fcefc
commit 1cfba584db
3 changed files with 9 additions and 1 deletions

6
configure vendored
View File

@ -20935,6 +20935,12 @@ if test "x$ac_cv_func_explicit_bzero" = xyes
then :
printf "%s\n" "#define HAVE_EXPLICIT_BZERO 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "memset_explicit" "ac_cv_func_memset_explicit"
if test "x$ac_cv_func_memset_explicit" = xyes
then :
printf "%s\n" "#define HAVE_MEMSET_EXPLICIT 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "explicit_memset" "ac_cv_func_explicit_memset"
if test "x$ac_cv_func_explicit_memset" = xyes

View File

@ -884,7 +884,7 @@ AS_IF([test "x$WASI" = "x"],[
AC_CHECK_FUNCS([posix_memalign nanosleep])
AS_IF([test "x$WASI" = "x"],[
AC_CHECK_FUNCS([memset_s explicit_bzero explicit_memset])
AC_CHECK_FUNCS([memset_s explicit_bzero memset_explicit explicit_memset])
])
AC_SUBST([LIBTOOL_EXTRA_FLAGS])

View File

@ -129,6 +129,8 @@ sodium_memzero(void * const pnt, const size_t len)
}
#elif defined(HAVE_EXPLICIT_BZERO)
explicit_bzero(pnt, len);
#elif defined(HAVE_MEMSET_EXPLICIT)
memset_explicit(pnt, 0, len);
#elif defined(HAVE_EXPLICIT_MEMSET)
explicit_memset(pnt, 0, len);
#elif HAVE_WEAK_SYMBOLS