Don't assume that madvise() is available even if related macros are defined.

This commit is contained in:
Frank Denis 2014-11-22 13:32:54 -08:00
parent 133118ca4d
commit d0eab9323f
2 changed files with 3 additions and 3 deletions

View File

@ -407,7 +407,7 @@ dnl Checks for functions and headers
AS_IF([test "x$EMSCRIPTEN" = "x"],[ AS_IF([test "x$EMSCRIPTEN" = "x"],[
AC_CHECK_FUNCS([arc4random arc4random_buf]) AC_CHECK_FUNCS([arc4random arc4random_buf])
AC_CHECK_FUNCS([mlock mprotect explicit_bzero]) AC_CHECK_FUNCS([mlock madvise mprotect explicit_bzero])
]) ])
AC_CHECK_FUNCS([posix_memalign]) AC_CHECK_FUNCS([posix_memalign])

View File

@ -175,7 +175,7 @@ sodium_hex2bin(unsigned char * const bin, const size_t bin_maxlen,
int int
sodium_mlock(void * const addr, const size_t len) sodium_mlock(void * const addr, const size_t len)
{ {
#ifdef MADV_DONTDUMP #if defined(MADV_DONTDUMP) && defined(HAVE_MADVISE)
(void) madvise(addr, len, MADV_DONTDUMP); (void) madvise(addr, len, MADV_DONTDUMP);
#endif #endif
#ifdef HAVE_MLOCK #ifdef HAVE_MLOCK
@ -192,7 +192,7 @@ int
sodium_munlock(void * const addr, const size_t len) sodium_munlock(void * const addr, const size_t len)
{ {
sodium_memzero(addr, len); sodium_memzero(addr, len);
#ifdef MADV_DODUMP #if defined(MADV_DODUMP) && defined(HAVE_MADVISE)
(void) madvise(addr, len, MADV_DODUMP); (void) madvise(addr, len, MADV_DODUMP);
#endif #endif
#ifdef HAVE_MLOCK #ifdef HAVE_MLOCK