]> git.saurik.com Git - redis.git/blobdiff - src/config.h
Marginally more robust glibc version test for sync_file_range detection.
[redis.git] / src / config.h
index 617682fcf45247d07ae734f3724cc0a4fde600a5..5e6d2807271cd04266522fcfd8f0f665b61670f2 100644 (file)
 /* Define rdb_fsync_range to sync_file_range() on Linux, otherwise we use
  * the plain fsync() call. */
 #ifdef __linux__
 /* Define rdb_fsync_range to sync_file_range() on Linux, otherwise we use
  * the plain fsync() call. */
 #ifdef __linux__
+#include <linux/version.h>
+#include <features.h>
+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
+#if (LINUX_VERSION_CODE >= 0x020611 && __GLIBC_PREREQ(2, 6))
+#define HAVE_SYNC_FILE_RANGE 1
+#endif
+#else
+#if (LINUX_VERSION_CODE >= 0x020611)
+#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)
 #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)