summaryrefslogtreecommitdiff
path: root/src/config.h
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2012-10-25 16:15:55 +0200
committerantirez <antirez@gmail.com>2012-10-25 22:01:20 +0200
commitd2f83d4a764fc155dbe07f5badecd9b65af699a5 (patch)
treef2d5bd25266cd8d3647bd756feb01ad69467d0e7 /src/config.h
parent68fc64afd46acef8109a388311730a4712a23e6d (diff)
downloadredis-d2f83d4a764fc155dbe07f5badecd9b65af699a5.tar.gz
Fix compilation on Linux kernels or glibc versions lacking sync_file_range().
This fixes issue #667. Many thanks to Didier Spezia for the fix.
Diffstat (limited to 'src/config.h')
-rw-r--r--src/config.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/config.h b/src/config.h
index 617682fcf..ce7e53b02 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 <linux/version.h>
+#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)