mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
xz: Use posix_fadvise() if it is available.
This commit is contained in:
parent
1ef3cf44a8
commit
1039bfcfc0
2 changed files with 18 additions and 0 deletions
|
@ -517,6 +517,9 @@ gl_GETOPT
|
||||||
# Find the best function to set timestamps.
|
# Find the best function to set timestamps.
|
||||||
AC_CHECK_FUNCS([futimens futimes futimesat utimes utime], [break])
|
AC_CHECK_FUNCS([futimens futimes futimesat utimes utime], [break])
|
||||||
|
|
||||||
|
# This is nice to have but not mandatory.
|
||||||
|
AC_CHECK_FUNCS([posix_fadvise])
|
||||||
|
|
||||||
TUKLIB_PROGNAME
|
TUKLIB_PROGNAME
|
||||||
TUKLIB_INTEGER
|
TUKLIB_INTEGER
|
||||||
TUKLIB_PHYSMEM
|
TUKLIB_PHYSMEM
|
||||||
|
|
|
@ -293,6 +293,10 @@ io_open_src_real(file_pair *pair)
|
||||||
pair->src_fd = STDIN_FILENO;
|
pair->src_fd = STDIN_FILENO;
|
||||||
#ifdef TUKLIB_DOSLIKE
|
#ifdef TUKLIB_DOSLIKE
|
||||||
setmode(STDIN_FILENO, O_BINARY);
|
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
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -497,6 +501,17 @@ io_open_src_real(file_pair *pair)
|
||||||
}
|
}
|
||||||
#endif
|
#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;
|
return false;
|
||||||
|
|
||||||
error_msg:
|
error_msg:
|
||||||
|
|
Loading…
Reference in a new issue