aboutsummaryrefslogtreecommitdiff
path: root/src/xz
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2011-04-05 15:27:26 +0300
committerLasse Collin <lasse.collin@tukaani.org>2011-04-05 15:27:26 +0300
commit1039bfcfc098b69d56ecb39d198a092552eacf6d (patch)
treefe82bb00cf81625f215497d5f2732fa10377f764 /src/xz
parentxz: Call lzma_end(&strm) before exiting if debugging is enabled. (diff)
downloadxz-1039bfcfc098b69d56ecb39d198a092552eacf6d.tar.xz
xz: Use posix_fadvise() if it is available.
Diffstat (limited to 'src/xz')
-rw-r--r--src/xz/file_io.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/xz/file_io.c b/src/xz/file_io.c
index 09edcca6..56acf3bd 100644
--- a/src/xz/file_io.c
+++ b/src/xz/file_io.c
@@ -294,6 +294,10 @@ io_open_src_real(file_pair *pair)
#ifdef TUKLIB_DOSLIKE
setmode(STDIN_FILENO, O_BINARY);
#endif
+#ifdef HAVE_POSIX_FADVISE
+ // It will fail if stdin is a pipe and that's fine.
+ (void)posix_fadvise(STDIN_FILENO, 0, 0, POSIX_FADV_SEQUENTIAL);
+#endif
return false;
}
@@ -497,6 +501,17 @@ io_open_src_real(file_pair *pair)
}
#endif
+#ifdef HAVE_POSIX_FADVISE
+ const int fadvise_ret = posix_fadvise(
+ pair->src_fd, 0, 0, POSIX_FADV_SEQUENTIAL);
+
+ // It shouldn't fail, but if it does anyway, it doesn't matter.
+ // Check it with an assertion so that if something gets messed
+ // up in the future, it will get caught when debugging is enabled.
+ assert(fadvise_ret == 0);
+ (void)fadvise_ret;
+#endif
+
return false;
error_msg: