From 182dbdf0f4b6e6484b0d4588aaefacc75862a99c Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Thu, 26 Mar 2020 10:59:46 +0100 Subject: util: Detect posix_fallocate() instead of assuming Don't assume that `posix_fallocate()` is available on Linux and not available on other operating systems. At least FreeBSD has it and we are not using it. Properly check whether `posix_fallocate()` is present and use it if it is. --- src/util/system.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/util/system.cpp') diff --git a/src/util/system.cpp b/src/util/system.cpp index b0a538b527..b4df0680af 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -17,7 +17,7 @@ #endif #ifndef WIN32 -// for posix_fallocate +// for posix_fallocate, in configure.ac we check if it is present after this #ifdef __linux__ #ifdef _POSIX_C_SOURCE @@ -1012,7 +1012,7 @@ void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length) { } ftruncate(fileno(file), static_cast(offset) + length); #else - #if defined(__linux__) + #if defined(HAVE_POSIX_FALLOCATE) // Version using posix_fallocate off_t nEndPos = (off_t)offset + length; if (0 == posix_fallocate(fileno(file), 0, nEndPos)) return; -- cgit v1.2.3