From be407c015c1848b145ad57edc023a1a810f8c6a9 Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 25 Oct 2012 16:15:55 +0200 Subject: [PATCH 1/1] Fix compilation on Linux kernels or glibc versions lacking sync_file_range(). This fixes issue #667. Many thanks to Didier Spezia for the fix. --- src/config.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/config.h b/src/config.h index 617682fc..ce7e53b0 100644 --- a/src/config.h +++ b/src/config.h @@ -55,6 +55,19 @@ /* Define rdb_fsync_range to sync_file_range() on Linux, otherwise we use * the plain fsync() call. */ #ifdef __linux__ +#include +#ifdef __GLIBC__ +#if (LINUX_VERSION_CODE >= 0x020617 && GLIBC_VERSION_AT_LEAST(2, 6)) +#define HAVE_SYNC_FILE_RANGE 1 +#endif +#else +#if (LINUX_VERSION_CODE >= 0x020617) +#define HAVE_SYNC_FILE_RANGE 1 +#endif +#endif +#endif + +#ifdef HAVE_SYNC_FILE_RANGE #define rdb_fsync_range(fd,off,size) sync_file_range(fd,off,size,SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE) #else #define rdb_fsync_range(fd,off,size) fsync(fd) -- 2.47.2