From d0eab9323f083303a55298183451ac5eff7f0507 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sat, 22 Nov 2014 13:32:54 -0800 Subject: [PATCH] Don't assume that madvise() is available even if related macros are defined. --- configure.ac | 2 +- src/libsodium/sodium/utils.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 2b9633a6..3a908468 100644 --- a/configure.ac +++ b/configure.ac @@ -407,7 +407,7 @@ dnl Checks for functions and headers AS_IF([test "x$EMSCRIPTEN" = "x"],[ 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]) diff --git a/src/libsodium/sodium/utils.c b/src/libsodium/sodium/utils.c index a1ebe9ba..c8fc206d 100644 --- a/src/libsodium/sodium/utils.c +++ b/src/libsodium/sodium/utils.c @@ -175,7 +175,7 @@ sodium_hex2bin(unsigned char * const bin, const size_t bin_maxlen, int 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); #endif #ifdef HAVE_MLOCK @@ -192,7 +192,7 @@ int sodium_munlock(void * const addr, const size_t len) { sodium_memzero(addr, len); -#ifdef MADV_DODUMP +#if defined(MADV_DODUMP) && defined(HAVE_MADVISE) (void) madvise(addr, len, MADV_DODUMP); #endif #ifdef HAVE_MLOCK