From df0c783f4bcbeb93bccd24c33160863563e2f3dc Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Thu, 28 Apr 2022 21:06:51 -0700 Subject: 50133: use read-ahead and lseek-rewind for efficient line-buffered input --- configure.ac | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 8bba78c56..c72148d06 100644 --- a/configure.ac +++ b/configure.ac @@ -2209,6 +2209,65 @@ if test x$zsh_cv_sys_fifo = xyes; then AC_DEFINE(HAVE_FIFOS) fi +dnl ----------- +dnl check that lseek() correctly reports seekability. +dnl ----------- +AC_CACHE_CHECK(if lseek() correctly reports seekability, +zsh_cv_sys_lseek, +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include +#include +#include +#include +#include +int main() { + int pipefd[2], fd; + off_t ret; + char* tmpfile = "seekfiletest.tmp"; + if ((fd = open(tmpfile, O_CREAT, S_IRUSR)) < 0) { + fprintf(stderr, "creating file failed\n"); + return 1; + } + ret = lseek(fd, 0, SEEK_CUR); + close(fd); + unlink(tmpfile); + if (ret == (off_t)-1) { + fprintf(stderr, "lseek on regular file failed\n"); + return 1; + } + if (pipe(pipefd) < 0) { + fprintf(stderr, "creating pipe failed\n"); + return 1; + } + write(pipefd[1], "abcdefgh", 8); + ret = lseek(pipefd[0], 0, SEEK_CUR); + close(pipefd[0]); + close(pipefd[1]); + if (ret != (off_t)-1) { + fprintf(stderr, "lseek on pipe succeeded\n"); + return 1; + } + if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { + fprintf(stderr, "creating UNIX domain socket failed\n"); + return 1; + } + ret = lseek(fd, 0, SEEK_CUR); + close(fd); + if (ret != (off_t)-1) { + fprintf(stderr, "lseek on UNIX domain socket succeeded\n"); + return 1; + } + return 0; +} +]])],[zsh_cv_sys_lseek=yes],[zsh_cv_sys_lseek=no],[zsh_cv_sys_lseek=yes]) +]) +AH_TEMPLATE([USE_LSEEK], +[Define to 1 if lseek() can be used for SHIN.]) +if test x$zsh_cv_sys_lseek = xyes; then + AC_DEFINE(USE_LSEEK) +fi + dnl ----------- dnl test for whether link() works dnl for instance, BeOS R4.51 doesn't support hard links yet -- cgit 1.4.1