Mercurial > dovecot > core-2.2
changeset 19750:ac29347cf81e
lib: Ignore ENOSYS errors from madvise() calls.
For example Raspberry Pi kernels have removed this. We'll wrap all the
madvise() calls with my_madvise() to avoid extra checks all over the place.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Wed, 10 Feb 2016 19:30:42 +0200 |
parents | cea1e2bccd1c |
children | 1e0cfc3dc89a |
files | src/lib/mmap-util.c src/lib/mmap-util.h |
diffstat | 2 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/mmap-util.c Wed Feb 10 23:39:25 2016 +0100 +++ b/src/lib/mmap-util.c Wed Feb 10 19:30:42 2016 +0200 @@ -37,13 +37,18 @@ return mmap_file(fd, length, PROT_READ | PROT_WRITE); } -#ifndef HAVE_MADVISE +#undef madvise int my_madvise(void *start ATTR_UNUSED, size_t length ATTR_UNUSED, int advice ATTR_UNUSED) { +#ifdef HAVE_MADVISE + /* Ignore ENOSYS errors, which happen if the kernel hasn't implemented + the syscall even if libc has. */ + if (madvise(start, length, advice) < 0 && errno != ENOSYS) + return -1; +#endif return 0; } -#endif size_t mmap_get_page_size(void) {
--- a/src/lib/mmap-util.h Wed Feb 10 23:39:25 2016 +0100 +++ b/src/lib/mmap-util.h Wed Feb 10 19:30:42 2016 +0200 @@ -14,9 +14,9 @@ # define MREMAP_MAYMOVE 1 #endif +#define madvise my_madvise +int my_madvise(void *start, size_t length, int advice); #ifndef HAVE_MADVISE -# define madvise my_madvise -int my_madvise(void *start, size_t length, int advice); # ifndef MADV_NORMAL # define MADV_NORMAL 0 # define MADV_RANDOM 0